jbonnett Posted February 22, 2012 Share Posted February 22, 2012 Anyone know of a script that will allow you to upload a file and converts it to a specified file format? Folder layout: script/ script/videos/mp4/ } script/videos/ogg/ } folders for converted files from uploaded files script/videos/webm/ } script/videos/swf/ } Video player: <video width="320" height="240" controls="controls"> <source src="script/videos/mp4/<? echo $movie; ?>.mp4" type="video/mp4" /> <source src="script/videos/ogg/ <? echo $movie; ?> .ogg" type="video/ogg" /> <source src="script/videos/webm/ <? echo $movie; ?> .webm" type="video/webm" /> <object data="script/videos/mp4/ <? echo $movie; ?> .mp4" width="320" height="240"> <embed src="script/videos/swf/ <? echo $movie; ?> .swf" width="320" height="240"> Your browser does not support video </embed> </object> </video> I have searched and searched the web for an answer and cannot find one pleas help? Link to comment https://forums.phpfreaks.com/topic/257571-video-uploading-script-with-conversion-to-multiple-file-types/ Share on other sites More sharing options...
xyph Posted February 22, 2012 Share Posted February 22, 2012 You'd need to use a command-line based tool. PHP has no ability to encode video. Link to comment https://forums.phpfreaks.com/topic/257571-video-uploading-script-with-conversion-to-multiple-file-types/#findComment-1320208 Share on other sites More sharing options...
PaulRyan Posted February 22, 2012 Share Posted February 22, 2012 FFMPEG Link to comment https://forums.phpfreaks.com/topic/257571-video-uploading-script-with-conversion-to-multiple-file-types/#findComment-1320247 Share on other sites More sharing options...
scootstah Posted February 23, 2012 Share Posted February 23, 2012 Keep in mind that doing this is pretty resource intensive. So if you are trying to encode multiple files at once you are going to hog a lot of resources. If you're on a shared host, they are going to get mad very quickly. For anything that has anywhere near decent traffic and lots of uploaded videos, you're going to need some serious resources to keep up with demand. Link to comment https://forums.phpfreaks.com/topic/257571-video-uploading-script-with-conversion-to-multiple-file-types/#findComment-1320253 Share on other sites More sharing options...
jbonnett Posted February 23, 2012 Author Share Posted February 23, 2012 Any code examples of FFMPEG i have tried FFMPEG and find it complicated to use cant get my head around it? Link to comment https://forums.phpfreaks.com/topic/257571-video-uploading-script-with-conversion-to-multiple-file-types/#findComment-1320317 Share on other sites More sharing options...
trq Posted February 23, 2012 Share Posted February 23, 2012 i have tried FFMPEG and find it complicated to use cant get my head around it? Post your code. Link to comment https://forums.phpfreaks.com/topic/257571-video-uploading-script-with-conversion-to-multiple-file-types/#findComment-1320318 Share on other sites More sharing options...
jbonnett Posted February 23, 2012 Author Share Posted February 23, 2012 I deleted it because it did not work Link to comment https://forums.phpfreaks.com/topic/257571-video-uploading-script-with-conversion-to-multiple-file-types/#findComment-1320322 Share on other sites More sharing options...
trq Posted February 23, 2012 Share Posted February 23, 2012 Well why not try again and come back when you have a specific problem? Link to comment https://forums.phpfreaks.com/topic/257571-video-uploading-script-with-conversion-to-multiple-file-types/#findComment-1320325 Share on other sites More sharing options...
jbonnett Posted February 23, 2012 Author Share Posted February 23, 2012 Heres a quick attempt <? $folderName = $_POST["album_name"]; $end = '/'; //Path to where the users are $path = "video/"; //Complete path to new folder $dir = $path . $folderName . $end; if ((($_FILES["file"]["type"] == "mp3") || ($_FILES["file"]["type"] == "video/mp4") && ($_FILES["file"]["size"] < 20000000000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Uploaded: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; if (file_exists("$dir" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "$dir" . $_FILES["file"]["name"]); echo "Stored in: $folderName's User Folder"; } } } else { echo "Invalid file"; } // ffmpeg // Set our source file $file = $dir . $_FILES["file"]["name"]; $srcFile = $file; $destFile = "/path/to/file.flv"; $ffmpegPath = "/path/to/ffmpeg"; $flvtool2Path = "/path/to/flvtool2"; // Create our FFMPEG-PHP class $ffmpegObj = new ffmpeg_movie($srcFile); // Save our needed variables $srcWidth = makeMultipleTwo($ffmpegObj->getFrameWidth()); $srcHeight = makeMultipleTwo($ffmpegObj->getFrameHeight()); $srcFPS = $ffmpegObj->getFrameRate(); $srcAB = intval($ffmpegObj->getAudioBitRate()/1000); $srcAR = $ffmpegObj->getAudioSampleRate(); // Call our convert using exec() exec($ffmpegPath . " -i " . $srcFile . " -ar " . $srcAR . " -ab " . $srcAB . " -f flv -s " . $srcWidth . "x" . $srcHeight . " " . $destFile . " | " . $flvtool2Path . " -U stdin " . $destFile); // Make multiples function function makeMultipleTwo ($value) { $sType = gettype($value/2); if($sType == "integer") { return $value; } else { return ($value-1); } } ?> would i just repeat the FFMPEG process? Link to comment https://forums.phpfreaks.com/topic/257571-video-uploading-script-with-conversion-to-multiple-file-types/#findComment-1320329 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.