Skip to content

Instantly share code, notes, and snippets.

@HarveyChang
HarveyChang / batch_mp4_to_h264
Created November 1, 2025 03:55
batch convert all .mp4 files to H.264
@echo off
REM Script purpose: batch convert all .mp4 files to H.264 (libx264) and save to output\ with suffix _h264
REM Create output directory (safe if it already exists)
mkdir output
REM Loop over all mp4 files in the current directory
for %%a in (*.mp4) do (
REM Re-encode video to H.264 with CRF 23 and medium preset; copy audio stream unchanged
REM Input: "%%a" Output: "output\%%~na_h264.mp4"
ffmpeg -i "%%a" -c:v libx264 -crf 23 -preset medium -c:a copy "output\%%~na_h264.mp4"
)