Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jessielw/2f1b89b852b200ab7f0864299588640a to your computer and use it in GitHub Desktop.
Save jessielw/2f1b89b852b200ab7f0864299588640a to your computer and use it in GitHub Desktop.
@echo off
setlocal EnableDelayedExpansion
REM ##########################################################
REM ## Path's to executable files MUST BE QUOTED! ##
REM ## To get path's easily, hold "Left Shift" and "Right Click" on the exe, and select "Copy as Path"
REM ## Then you can paste after the = (no spaces)
REM ##
set dovi_tool_path="D:\Python Stuff\HDR10Plus-Parser-Tool\Apps\dovi_tool\dovi_tool.exe"
set mkvmerge_path="C:\Users\jlw_4\Desktop\mkvtoolnix\mkvmerge.exe"
set mkvextract_path="C:\Users\jlw_4\Desktop\mkvtoolnix\mkvextract.exe"
REM ##
REM DO NOT QUOTE TEMPORARY_WORKING_DIR!!
set temporary_working_dir=!cd!\temp_dir
REM DO NOT QUOTE TEMPORARY_WORKING_DIR!!
REM ##
REM ##########################################################
REM ############ Check for tools ############
set /a exe_count=0
if exist !dovi_tool_path! (
echo dovi_tool.exe found!
set /a exe_count=!exe_count!+1
) else (
set error_message=dovi_tool.exe
)
if exist !mkvmerge_path! (
echo mkvmerge.exe found!
set /a exe_count=!exe_count!+1
) else (
set error_message=!error_message!, mkvmerge.exe
)
if exist !mkvextract_path! (
echo mkvextract.exe found!
set /a exe_count=!exe_count!+1
) else (
set error_message=!error_message!, mkvextract.exe
)
REM ############ Check for tools ############
REM ############ Error handling ############
if "!exe_count!" == "3" goto startjob
if not "!exe_count!" == "3" goto printerror
REM ############ Error handling ############
:startjob
REM ######### Job Code ################
for %%1 in ("%~n1.*") do (
echo.
echo ########## Creating temporary directory ##########
mkdir "!temporary_working_dir!"
echo Created temporary working directory at:
echo !temporary_working_dir!
echo ########## Creating temporary directory ##########
echo.
echo.
echo ########## Demux Source HEVC File ##########
!mkvextract_path! "%%1" tracks 0:"!temporary_working_dir!\source_%%~n1.hevc"
echo.
echo Saving source HEVC to:
echo "!temporary_working_dir!\source_%%~n1.hevc"
echo ########## Demux Source HEVC File ##########
echo.
echo.
echo ########## Extract RPU to profile 8.1 ##########
!dovi_tool_path! -m 2 extract-rpu --input "!temporary_working_dir!\source_%%~n1.hevc" -o "!temporary_working_dir!\profile_8_RPU_%%~n1.bin"
echo.
echo Saving rpu bin to:
echo "!temporary_working_dir!\profile_8_RPU_%%~n1.bin"
echo ########## Extract RPU to profile 8.1 ##########
echo.
echo.
echo ########## Injecting RPU into source HEVC ##########
!dovi_tool_path! inject-rpu -i "!temporary_working_dir!\source_%%~n1.hevc" --rpu-in "!temporary_working_dir!\profile_8_RPU_%%~n1.bin" -o "!temporary_working_dir!\CONVERTED_%%~n1.hevc"
echo.
echo Saving converted HEVC to:
echo "!temporary_working_dir!\CONVERTED_%%~n1.hevc"
echo.
echo Deleting source:
echo "!temporary_working_dir!\source_%%~n1.hevc"
del /f "!temporary_working_dir!\source_%%~n1.hevc"
echo.
echo ########## Injecting RPU into source HEVC ##########
echo.
echo.
echo ########## Muxing converted HEVC into source via mkvmerge ##########
!mkvmerge_path! -o "%%~n1_CONVERTED.mkv" "!temporary_working_dir!\CONVERTED_%%~n1.hevc" -D "%%1"
echo ########## Muxing converted HEVC into source via mkvmerge ##########
echo.
echo.
echo ########## Cleaning Up Working Directory ##########
echo deleting "!temporary_working_dir!"
RMDIR /S /Q "!temporary_working_dir!"
echo ########## Cleaning Up Working Directory ##########
echo.
echo.
echo.
)
goto start_pause
:printerror
echo.
echo 1 or more executables are not set properly
echo missing tools:
echo !error_message!
echo please set paths correctly and try again...
echo.
goto start_pause
:start_pause
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment