Skip to content

Instantly share code, notes, and snippets.

@nateify
Created May 2, 2023 02:05
Show Gist options
  • Save nateify/b134efedc839e19175a9f38a28a0435c to your computer and use it in GitHub Desktop.
Save nateify/b134efedc839e19175a9f38a28a0435c to your computer and use it in GitHub Desktop.
Simplified method of remuxing MKV with Dolby Vision P7 FEL to P8.1 with EL discarded
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Usage: $0 input_file" >&2
exit 1
fi
input_file="$1"
input_dir=$(dirname "$input_file")
input_base=$(basename "${input_file%.*}")
# Extract and convert the BL+EL to BL only
ffmpeg -v quiet -stats -i "$input_file" -c:v copy -vbsf hevc_mp4toannexb -f hevc - | dovi_tool -m 2 convert --discard -i - -o "$input_dir/BL_RPU.hevc"
# Merge new HEVC and all non-video tracks from the original MKV
mkvmerge -o "$input_dir/$input_base.P8.mkv" \
"$input_dir/BL_RPU.hevc" \
--compression -1:none \
-d !0 \
"$input_file"
# Delete BL file from earlier
rm "$input_dir/BL_RPU.hevc"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment