1

I want to convert video files into different resolution using ffmpeg. Right now i can run only 1 ffmpeg command the 2nd ffmpeg command does not get execute.

shell_exec("C:\\ffmpeg\\bin\\ffmpeg.exe -y -i \"$target_file\" -c:v libx264 -s:v 854x480 -c:a copy \"{$newFileName}\" > logfile.txt 2>&1");
shell_exec("C:\\ffmpeg\\bin\\ffmpeg.exe -y -i \"$target_file\" -c:v libx264 -s:v 480x360 -c:a copy \"{$360FileName}\" > logfile.txt 2>&1");

how can i code the script so that it can compress the video into various different resolution such as 240p, 360p, 480p?

Edited code to output 3 video files?

shell_exec("C:\\ffmpeg\\bin\\ffmpeg.exe -y -i \"$target_file\" -map 0 -c:v libx264 -s:v 854x480 -c:a copy \"{$newFileName}\" -map 0 -c:v libx264 -s:v 480x360 -c:a copy \"{$new360pFileName}\" -map 0 -c:v libx264 -s:v 854x480 -c:a copy \"{$240pFileName}\"   > logfile.txt 2>&1");

1 Answer 1

1

You can outputs together, like this

shell_exec("C:\\ffmpeg\\bin\\ffmpeg.exe -y -i \"$target_file\" -map 0 -c:v libx264 -s:v 854x480 -c:a copy \"{$newFileName}\" -map 0 -c:v libx264 -s:v 480x360 -c:a copy \"{$360FileName}\" > logfile.txt 2>&1");
Sign up to request clarification or add additional context in comments.

2 Comments

what does -map 0 mean? if i wish to add more video resolution i need to add the command after -map 0? refer to my updated code above.
-map 0 means process all streams in input. Not strictly necessary, but safer to put it. For each new resolution, start with -map 0.Check your scale values. For the 240p outout, you have scaled to 854x480.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.