1

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.

2
  • 1
    don't post screenshots. copy and paste the text. of the output. Commented Nov 26, 2015 at 21:49
  • Don't run it via PHP. Just run the 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 your ffmpeg commands. Commented Dec 5, 2015 at 0:39

1 Answer 1

1

When you see a problem with software you try to launch with php, take your command and launch it directly in a console/terminal and don't forget to replace all variables by the good information. Now watch what happening and if you can't fix the error just copy past the log and someone can help you

For ffmpeg I recommend removing this part 2>&1", $output to see what is happening in the console

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.