Search code examples
ffmpeg

How can I convert any video to h264 format?


I have a video with a specific name which is the date when it is written. I don't really care about the name I want to convert it to this format then delete it. So one video gets in the file I convert it then remove the old one and move the new one to different file. The folder will always be empty or only contains 1 video. I'm using Windows 10.

For example,

ffmpeg -i *.mp4 -an -vcodec libx264 -crf 23 Todifferentfile/output.mp4 

Solution

  • My answer is based on FFMPEG and your input files being in the same folder.

    • Within that folder make a new folder converted
    • Paste the below text into a bat file. (save into FFMPEG folder)
      (Basically open notepad and paste - Change save filter to 'all files' and give it a bat extension)

    BAT file script:

    for %%a in ("*.mp4") do ffmpeg -i "%%a" -c:v libx264 -crf 23 -an "converted\%%~na.mp4"
    pause
    

    Make sure you save the output files into a different path to prevent overwrite (in above example 'converted' folder).

    Basically it will process all *.mp4 files within that folder (using %%a for filename).