Guest User

Fix for HEVC rec.709 MKV files for streaming on Roku via Plex

a guest
Jan 26th, 2024
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.28 KB | Movies | 0 0
  1. @echo on
  2. setlocal enabledelayedexpansion
  3.  
  4. rem Set the directory containing the files
  5. set "input_directory=C:\Video"
  6.  
  7. rem Loop through each file in the directory
  8. for %%F in ("%input_directory%\*.mkv") do (
  9.    rem Extract file name and extension
  10.     set "filename=%%~nF"
  11.     set "extension=%%~xF"
  12.    
  13.     rem Check if the file name already contains "-ac3" at the end
  14.     set "excludeFile="
  15.     echo !filename! | find /i "-ac3" > nul && set excludeFile=1
  16.    
  17.     if not defined excludeFile (
  18.         rem Copy over all video (c:v copy) and subtitles (-scodec copy), and copy over all audio streams (-map 0), converting from AAC to AC3 (-c:a ac3)
  19.         rem Plex will attempt to reencode AAC to AC3 and will add back in header color info that will cause the oversaturation issue
  20.         ffmpeg -i "!input_directory!\!filename!!extension!" -flags +global_header -movflags faststart -c:v copy -c:a ac3 -map 0 -scodec copy "!input_directory!\!filename!-ac3!extension!"
  21.  
  22.         rem Strip header color information
  23.         mkvpropedit "!input_directory!\!filename!-ac3!extension!" --edit track:v1 --delete colour-primaries --delete colour-range --delete colour-matrix-coefficients --delete colour-transfer-characteristics --delete chroma-siting-horizontal --delete chroma-siting-vertical
  24.     )
  25. )
  26.  
  27. echo All operations completed.
  28. pause
Advertisement
Add Comment
Please, Sign In to add comment