13
5
I am trying to convert 20+ .avi files in a batch using ffmpeg.
I've got the following
@echo off.
for file in *.avi
do
ffmpeg -i "$file" -s 640x480 -vcodec msmpeg4v2 "'basename "$file" .avi'.mpg';
done
in my .bat file but it does not work. How can I make it work under Windows OS. Oh, and yes all the files are in the same folder.
The error message I get:
File was unexpected at this time
And what exactly does not work about it? – slhck – 2012-09-05T19:32:51.183
If you can point me how to get the error message since the cmd disappears very fast, I will be able to tell you what I'm having problem with. – Darius – 2012-09-05T19:37:06.753
You should be able to just open a command window before (Start » Run… »
cmd) and then run the batch file using its full path from there. What do you actually want to do with the videos? What kind of videos are these? Do you just need to move them to an MPG container? Or do you need to resize them? Or do you specifically need themsmpeg4v2codec? – slhck – 2012-09-05T19:42:37.413The files are taken off a DVR and are over 1GB 5 minutes clips. Yes the DVR software is pathetic at compression. The codec works since it takes 1GB files to roughly 7MB files which are more manageable. And when trying to run that batch I get "File was unexpected at this time" message. – Darius – 2012-09-05T19:50:46.630
I see. If you don't care about the resulting video codec and container, I'd suggest to use x264 as an encoder instead, which results in much better quality than MPEG-4. The command would be something like
– slhck – 2012-09-05T19:55:58.603ffmpeg -i input.avi -c:v libx264 -crf 23 -s 640x480 output.mp4where the CRF value sets the quality (less is better, more is worse, sane values from 19 to 24). See also: Convert old videos to have smaller sizes and What parameters should I be looking at to reduce the size of a .MOV file?