Search code examples
videoffmpeg

ffmpeg convert multiple files from avi dv video (dvsd) to avi h.264 + mp3(mp4)


I have a bunch of avi files inside a folder (on Windows 7) with Codec DV Video (dvds). These are copied directly from my Sony DCR-PC120E Pal camera with the included software from Sony.

The problem is that the old video files get so big when they are copied to the hard drive. So I've used the VLC Convert/Save function which reduced the size of the videos to 1/10 of the filesize without noticing any big signal loss. Another problem is that with VLC I have to convert one file at a time, and I have probably over 100 files.

I've configured ffmpeg to work on my Windows 7 pc but can't find a batch script that converts multiple files from avi dv video (dvsd) to avi h.264 + mp3(mp4).

Any help is greatly appreciated.


Solution

  • Try this code (save as convertall.bat). I've tested it with the newest version of the ffmpeg.exe binary installed from the Zeranoe daily builds on Windows 7. Adjust the -q:a and crf values to your video and audio quality/size preference.

    echo off
    echo *
    echo **********************************************
    echo *                                            *
    echo *  USE TO BATCH CONVERT ALL AVIS IN FOLDER   *
    echo *                                            *
    echo *   1) place videos in a folder              *
    echo *   2) copy convertall.bat to your folder    *
    echo *   3) double click convertall.bat           *
    echo *                                            *
    echo *                                            *
    echo **********************************************
    
    
    FOR /f "delims=" %%G IN ('dir /b *.AVI') DO (
    ffmpeg.exe -i "%%G" -y -c:v libx264  -c:a libmp3lame -q:a 2 -crf 22 -pix_fmt yuv420p "%%~nG".mp4
    )
    
    echo                  ************
    echo        ********                **********
    echo      ********                    **********
    echo    ****** DONE WITH BATCH CONVERTING ********
    echo      ********                    **********
    echo        ********                **********
    echo                  ************
    pause