I have a video upload script in php where I exec the following command:
exec("/usr/bin/ffmpeg -i ".$folder."/".$filenameIn.".mp4 ".$folder."/".$filenameOut.".flv 2>&1", $output);
And the result flv is correct.
But when I execute the same command with mp4 output
exec("/usr/bin/ffmpeg -i ".$folder."/".$filenameIn.".mp4 ".$folder."/".$filenameOut.".mp4 2>&1", $output);
the output has 0 bytes.
I also tried
exec("/usr/bin/ffmpeg -i ".$folder."/".$filenameIn.".mp4 -vcodec libx264 -crf 20 ".$folder."/".$filenameOut.".mp4");
but the output video still have 0 bytes.
I don't know why. Any help?
EDIT:
If I convert from mp4 to mkv, the mkv is fine. If I get that mkv and reconvert to mp4, the final mp4 is 0 bytes.
For example:
exec("/usr/bin/ffmpeg -i ".$folder."/".$filename." ".$folder."/".$filenameOut.".mkv 2>&1", $output);
exec("/usr/bin/ffmpeg -i ".$folder."/".$filenameOut.".mkv ".$folder."/".$filename.".mp4 2>&1", $output);
In this case, first mp4 has 1210409 bytes, the resultant mkv has 816018 bytes, and the final mp4 has 0 bytes. The same thing with mp4 -> flv -> mp4.
ffmpeg
command in cli. Once you get it working then integrate it in your PHP scripts. We can't give any answers without the complete console output from yourffmpeg
commands. – llogan Dec 5 '15 at 0:39