0

I'm totally a newbie to FFmpeg and programming stuff, so the question might be too stupid... I have a video and want to crop it into small pieces and render out each one, so I'm trying to use a FOR loop:

FOR /l %x IN (0,40,1000) DO ffmpeg -i sample.avi -filter:v "crop=20:20:x:x" outx.avi; done

What I got is: [NULL @ 0000000002624220] Unable to find a suitable output format for 'outx.avi;' outx.avi;: Invalid argument

Anyone can help this out?

1 Answer 1

2

You're apparently using Windows batch files. Here, FOR loops do not have a trailing ; done, as Bash loops have.

Under Windows:

FOR ... IN ... DO ...

Under Bash:

for ... in ...; do ...; done

So, make sure you use the proper syntax for your shell.


Note that simply specifying out.avi will make ffmpeg choose MPEG-4 and MP3 as video and audio codecs, respectively, and your quality might be quite bad. Ideally, specify the video and audio encoders, e.g.:

ffmpeg -i <input> -c:v libx264 -crf 23 -c:a aac -b:a 192k out.mp4

Read the H.264 encoding guide for more info.

3
  • Thanks for the answering first! I removed the trailing, then the error gone! But seems like all the file will save as a same name"outx.avi", I tried "outx.avi" because I thought it will be save as out1.avi and then out2.avi ... but actually it doen't work... is there anyway I can make them save in different name in the for loop?
    – Link
    Commented Sep 28, 2017 at 15:22
  • I change the file name to out%x.avi and fixed!
    – Link
    Commented Sep 28, 2017 at 15:29
  • Glad you got it working. If this answer solved your question, please mark it as accepted using the green checkmark next to it. Thanks.
    – slhck
    Commented Sep 28, 2017 at 17:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .