Skip to content

Instantly share code, notes, and snippets.

@mclang
Created April 25, 2017 07:37
Show Gist options
  • Save mclang/f04e916c8acfd09215150d3020d39149 to your computer and use it in GitHub Desktop.
Save mclang/f04e916c8acfd09215150d3020d39149 to your computer and use it in GitHub Desktop.
Converts given mkv files with embedded subtitle _streams_ into _harsub_ mp4 files using ffmpeg. Uses hardlinking to overcome problem with spaces in filename of the source subtitle file.
#!/bin/bash
set -u
set -e
shopt -s nullglob
for MKV in "$@"; do
out="$(basename "$MKV" .mkv).mp4"
echo "CONVERTING '$MKV''"
cp -l "$MKV" input.mkv
ffmpeg -i input.mkv -c:a copy -c:v libx264 -preset veryslow -crf 23 -vf subtitles=input.mkv "$out"
rm -f input.mkv
echo "==> $out"
echo ""
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment