I’m using ffmpeg to convert videos on the fly, as they say, and I’m facing with a very annoying, unsolvable and unreferenced problem (as of yet 😉 ), when I run my php script, it basically works – takes the file, uses ffmpeg, starts converting it, but halway through it’s finished, the browser hangs, I don’t understand why or how to resolve it:
(even with set_time_limit the bastard won’t work).
function convertToMp4(){
/*
* Converts a file to mp4, returns the new file name
*/
set_time_limit(0);
$tmpFile = $this->fileName;
$newFile = uniqid();
$outputFile = "output/$justFile.mp4";
exec("ffmpeg -i " . $tmpFile . " -acodec copy -ar 44100 -ab 96k " . $outputFile. " &");
unlink($tmpFile);
return $outputFile;
}
Ideas?
Well, after much frustration, I realized that because ffmpeg takes a while to process, it’s a regular browser time out…
if you really need to encode large files, you should use cron jobs to start the encoding, but don’t expect to finish it in due time…