Why not crop/remove the file extension in your output file?
@echo off
for file in *.avi
do
ffmpeg -i "$file" -s 640x480 -vcodec msmpeg4v2 "'basename "$file" .avi'.mpg';
done
@echo off
for %%i in (*.avi)do ffmpeg -i "%%~fi" -s 640x480 -vcodec msmpeg4v2 "%%~dpni.mpg"
rem :: "%%~fi" == Full Path == Drive + Path + Name + Extension %%i:
rem :: "%%~fi" == C:\Path\FileName.AVI
rem :: "%%~dpni.mpg" == Drive + Path + Name + .mpg %%i:
rem :: "%%~dpni.mpg" == C:\Path\FileName.mpeg
- To have the Name.eXtension (
%%~nxi
) of the input and output file on the screen, and to reduce the ffmeg output information, limiting only the conversion in progress (-hide_banner -v error -stats
):
@echo off
for %%i in (*.avi)do echo\Enconding: "%%~nxi" "%%~ni.mpg" && (
ffmpeg -i "%%~fi" -s 640x480 -vcodec msmpeg4v2 "%%~dpni.mpg" -hide_banner -v error -stats
)
Enconding: "bird_test.avi" "bird_test.mpg"
frame= 355 fps=0.0 q=31.0 Lsize= 680kB time=00:00:11.80 bitrate= 472.1kbits/s speed= 22x
Enconding: "file_input.avi" "file_input.mpg"
frame= 903 fps=248 q=11.3 Lsize= 2440kB time=00:00:30.56 bitrate= 653.9kbits/s dup=2 drop=0 speed= 8.4x
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 themsmpeg4v2
codec?ffmpeg -i input.avi -c:v libx264 -crf 23 -s 640x480 output.mp4
where 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?