Added remuxing for mkv videos. Potential for future options too.
This commit is contained in:
parent
35402f3906
commit
c4ba8ab715
@ -14,7 +14,7 @@ const getFavesList = () => {
|
|||||||
doAjax("resources/php/dbController.php", "getTabs=true");
|
doAjax("resources/php/dbController.php", "getTabs=true");
|
||||||
}
|
}
|
||||||
|
|
||||||
const doAjax = (actionPath, data) => {
|
const doAjax = async (actionPath, data) => {
|
||||||
let xhttp = new XMLHttpRequest();
|
let xhttp = new XMLHttpRequest();
|
||||||
|
|
||||||
xhttp.onreadystatechange = function() {
|
xhttp.onreadystatechange = function() {
|
||||||
|
@ -48,7 +48,7 @@ const disableEdits = () => {
|
|||||||
this.readOnly = "true";
|
this.readOnly = "true";
|
||||||
}
|
}
|
||||||
|
|
||||||
const showMedia = (mediaLoc, type) => {
|
const showMedia = async (mediaLoc, type) => {
|
||||||
let path = document.getElementById("path").innerHTML;
|
let path = document.getElementById("path").innerHTML;
|
||||||
let tempRef = mediaLoc.toLowerCase();
|
let tempRef = mediaLoc.toLowerCase();
|
||||||
let fullMedia = path + mediaLoc;
|
let fullMedia = path + mediaLoc;
|
||||||
@ -86,17 +86,37 @@ const showMedia = (mediaLoc, type) => {
|
|||||||
imgTag.src = fullMedia;
|
imgTag.src = fullMedia;
|
||||||
imgDiv.appendChild(imgTag);
|
imgDiv.appendChild(imgTag);
|
||||||
|
|
||||||
if (tempRef.includes(".mp4") || tempRef.includes(".webm") ||
|
|
||||||
tempRef.includes(".mp3") || tempRef.includes(".ogg") ||
|
|
||||||
tempRef.includes(".pdf") || tempRef.includes(".flac") ||
|
if ((/\.(mkv|avi|flv|mov|m4v|mpg|wmv|mpeg|mp4|mp3|webm|flac|ogg|pdf)$/i).test(tempRef)) {
|
||||||
tempRef.includes(".mkv") || tempRef.includes(".avi")) {
|
if ((/\.(mkv)$/i).test(tempRef)) {
|
||||||
if (tempRef.includes(".mkv") || tempRef.includes(".avi")) {
|
let data = "remuxVideo=true&mediaPth=" + fullMedia;
|
||||||
|
|
||||||
|
// This kinda sucks but calling doAjax wont return data for some reason
|
||||||
|
let xhttp = new XMLHttpRequest();
|
||||||
|
xhttp.onreadystatechange = function() {
|
||||||
|
if (this.readyState === 4 && this.status === 200) {
|
||||||
|
// Send the returned data to further process
|
||||||
|
if (this.responseXML != null) {
|
||||||
|
data = this.responseXML;
|
||||||
|
fullMedia = data.getElementsByTagName("REMUX_PATH")[0].innerHTML;
|
||||||
|
} else {
|
||||||
|
document.getElementById('dynDiv').innerHTML =
|
||||||
|
"<p class=\"error\" style=\"width:100%;text-align:center;\"> "
|
||||||
|
+ "No content returned. Check the folder path.</p>";
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhttp.open("POST", "resources/php/filesystemActions.php", false);
|
||||||
|
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||||
|
xhttp.overrideMimeType('application/xml'); // Force return to be XML
|
||||||
|
xhttp.send(data);
|
||||||
|
} else if ((/\.(avi|flv|mov|m4v|mpg|wmv)$/i).test(tempRef)) {
|
||||||
openInLocalProg(fullMedia);
|
openInLocalProg(fullMedia);
|
||||||
return;
|
return ;
|
||||||
// Future option to convert container and view certain media.
|
|
||||||
// fullMedia = quickRemux(fullMedia);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
iframe.id = "fileViewInner";
|
iframe.id = "fileViewInner";
|
||||||
iframe.src = fullMedia;
|
iframe.src = fullMedia;
|
||||||
|
@ -38,7 +38,7 @@ document.ondblclick = (event) => {
|
|||||||
// If clicking on dir icon
|
// If clicking on dir icon
|
||||||
} else if (callingID == "dirID") {
|
} else if (callingID == "dirID") {
|
||||||
let node = obj.parentNode;
|
let node = obj.parentNode;
|
||||||
getDir(node.children[1].value, "dir");
|
getDir(node.children[1].value);
|
||||||
// If clicking on movie thumbnail
|
// If clicking on movie thumbnail
|
||||||
} else if (callingID == "movieID") {
|
} else if (callingID == "movieID") {
|
||||||
let node = obj.parentNode;
|
let node = obj.parentNode;
|
||||||
|
@ -135,9 +135,29 @@ function openFile($FILE) {
|
|||||||
serverMessage("success", $message);
|
serverMessage("success", $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function remuxVideo($FILE) {
|
||||||
|
$FILE = trim($FILE);
|
||||||
|
$PTH = "resources/tmp/";
|
||||||
|
$HASHED_NAME = hash('sha256', $FILE) . '.mp4';
|
||||||
|
$EXTNSN = strtolower(pathinfo($FILE, PATHINFO_EXTENSION));
|
||||||
|
|
||||||
|
if (!file_exists($PTH . $HASHED_NAME)) {
|
||||||
|
if (preg_match('(mp4)', $EXTNSN) === 1) {
|
||||||
|
$COMMAND = 'ffmpeg -i "' . $FILE . '" -movflags +faststart -codec copy ' . $PTH . $HASHED_NAME;
|
||||||
|
shell_exec($COMMAND . " > /dev/null &");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$GeneratedXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
|
||||||
|
$GeneratedXML .= "<REMUX_PATH>" . $PTH . $HASHED_NAME ."</REMUX_PATH>";
|
||||||
|
echo $GeneratedXML;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
chdir("../../");
|
chdir("../../");
|
||||||
if (isset($_POST["createItem"],
|
if (isset($_POST["remuxVideo"], $_POST["mediaPth"])) {
|
||||||
|
remuxVideo($_POST["mediaPth"]);
|
||||||
|
} else if (isset($_POST["createItem"],
|
||||||
$_POST["item"],
|
$_POST["item"],
|
||||||
$_POST["type"])) {
|
$_POST["type"])) {
|
||||||
createItem($_POST["item"], $_POST["type"]);
|
createItem($_POST["item"], $_POST["type"]);
|
||||||
|
1
resources/tmp/PLACE_HOLDERtxt
Normal file
1
resources/tmp/PLACE_HOLDERtxt
Normal file
@ -0,0 +1 @@
|
|||||||
|
Place Holder....
|
Loading…
Reference in New Issue
Block a user