Skip to content

Instantly share code, notes, and snippets.

@whs
Created February 9, 2012 11:43
Show Gist options
  • Save whs/1779474 to your computer and use it in GitHub Desktop.
Save whs/1779474 to your computer and use it in GitHub Desktop.
Hardsub a mkv
#!/bin/bash
if [ "$1" = "" -o "$2" = "" ]; then
echo "mkhardsub file.mkv out.mkv"
exit 1
fi
# -ass-force-style FontName=supermarket,Default
mplayer -nosound -benchmark "$1" -ass -fontconfig -ass-font-scale 1.2 -vf scale=854:480 -sid 0 -vo yuv4mpeg:file=>(x264 --crf 20 --preset ultrafast --level 30 --vbv-bufsize 10000 --vbv-maxrate 16000 --threads auto --output /tmp/mkhardsub.mkv --demuxer y4m -)
ffmpeg -i /tmp/mkhardsub.mkv -i "$1" -vcodec copy -map 0:0 -map 1:a:0 $2
#rm /tmp/mkhardsub.mkv
#!/bin/bash
# mplayer doesn't support 10bit
# use this
# ffmpeg -i in.mkv -acodec none -vcodec libx264 -threads 8 out.avi
# then use this to hardsub and manually merge the hardsub
# and the original file's sound using the command in this file.
if [ "$1" = "" -o "$2" = "" ]; then
echo "mkhardsubpro file.mkv out.mkv file.ass"
exit 1
fi
mplayer -nosound -benchmark "$1" -ass -sub "$3" -vo yuv4mpeg:file=>(x264 --crf 20 --profile Main --vbv-bufsize 10000 --vbv-maxrate 18000 --threads auto --demuxer y4m --output /tmp/mkhardsub.mkv -)
ffmpeg -i /tmp/mkhardsub.mkv -i "$1" -vcodec copy -acodec copy -map 0:0 -map 1:a:0 "$2"
#rm /tmp/mkhardsub.mkv
#!/bin/bash
# mplayer doesn't support 10bit
# use this
# ffmpeg -i in.mkv -acodec none -vcodec libx264 -threads 8 out.avi
# then use this to hardsub and manually merge the hardsub
# and the original file's sound using the command in this file.
if [ "$1" = "" ]; then
echo "mkhardsubraw file.mkv out.mkv"
exit 1
fi
mplayer -nosound -benchmark "$1" -ass -vo yuv4mpeg:file=>(x264 --crf 20 --profile Main --vbv-bufsize 10000 --vbv-maxrate 18000 --threads auto --demuxer y4m --output /tmp/mkhardsub.mkv -)
ffmpeg -i /tmp/mkhardsub.mkv -i "$1" -vcodec copy -acodec copy -map 0:0 -map 1:a:0 "$2"
#rm /tmp/mkhardsub.mkv
@whs
Copy link
Author

whs commented Mar 20, 2012

mkvmerge -S [Underwater]\ Another\ -\ 11\ (720p)\ [7ECAE7E8].mkv --language 0:th anotherthai.ass --language 0:en anotherorig.ass --attach-file /System/Library/Fonts/Thonburi.ttf -o another11subs.mkv

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