1

I have to issue a series of commands, all in the form as shown below:

ffmpeg -i 1.mp4 -s 640x480 -c:a copy 2.mp4
ffmpeg -i 2.mp4 -s 640x480 -c:a copy 2_2.mp4
ffmpeg -i 3.mp4 -s 640x480 -c:a copy 3_2.mp4
ffmpeg -i 4.mp4 -s 640x480 -c:a copy 4_2.mp4

Please show me how can I issue all commands automatically or do it with one command.

1 Answer 1

2

use a loop

If you're a Linux or OS X user then you can use a Bash for loop:

mkdir outputdir
for f in *.mp4; do ffmpeg -i "$f" -c:v libx264 -vf scale=640:-2 -c:a copy "outputdir/${f%.*}.mp4"; done

Maybe a Windows user can add a similar example that works for that OS.

or simply cram it all in one command

ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -i 4.mp4 \
-map 0 -s 640x480 -c:a copy 1_2.mp4 \
-map 1 -s 640x480 -c:a copy 2_2.mp4 \
-map 2 -s 640x480 -c:a copy 3_2.mp4 \
-map 3 -s 640x480 -c:a copy 4_2.mp4

You have to use -map otherwise the default stream selection will choose the same input for each output.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.