Skip to content

Instantly share code, notes, and snippets.

@rspurrell
Created October 17, 2022 09:00
Show Gist options
  • Save rspurrell/8cec0b18a4abf9b06447f46d77327cdc to your computer and use it in GitHub Desktop.
Save rspurrell/8cec0b18a4abf9b06447f46d77327cdc to your computer and use it in GitHub Desktop.
Converts DoVi MKV files to MP4 files
@ECHO OFF
REM Download and extract win64-gpl-5.1 (or similar) from https://github.com/yt-dlp/FFmpeg-Builds/wiki/Latest#latest-autobuilds
REM Download mp4muxer.exe from https://github.com/DolbyLaboratories/dlb_mp4base/tree/master/bin
REM In the same directory, put this batch, the win64-gpl-5.1 files, and mp4muxer.exe
REM Example: mkv2mp4.bat C:\path\to\file\video.mkv
SET fp=%~dp1
SET fn=%~n1
IF NOT EXIST "%fp%%fn%.mkv" (
ECHO Source MKV does not exist: "%fp%%fn%.mkv"
EXIT /b 2
)
IF EXIST "%fp%%fn%.mp4" (
ECHO Target MP4 already exists: "%fp%%fn%.mp4"
EXIT /b 2
)
IF EXIST "%fp%video.hevc" del "%fp%video.hevc"
IF EXIST "%fp%audio.eac3" del "%fp%audio.eac3"
IF EXIST "%fp%audio.ec3" del "%fp%audio.ec3"
ECHO.
ECHO ---- EXTRACTING VIDEO ----
ffmpeg -i "%fp%%fn%.mkv" -c copy "%fp%video.hevc"
IF %errorlevel% NEQ 0 EXIT /b %errorlevel%
ECHO.
ECHO ---- EXTRACTING AUDIO ----
ffmpeg -i "%fp%%fn%.mkv" -c copy "%fp%audio.eac3"
IF %errorlevel% NEQ 0 EXIT /b %errorlevel%
ren "%fp%audio.eac3" audio.ec3
IF %errorlevel% NEQ 0 EXIT /b %errorlevel%
ECHO.
ECHO ---- MUXING ----
mp4muxer --dv-profile 5 -i "%fp%video.hevc" -i "%fp%audio.ec3" --media-lang eng -o "%fp%%fn%.mp4"
IF %errorlevel% NEQ 0 EXIT /b %errorlevel%
ECHO Ouput: "%fp%%fn%.mp4"
del "%fp%video.hevc"
del "%fp%audio.ec3"
@GingerAdonis
Copy link

Thanks for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment