Skip to content

Instantly share code, notes, and snippets.

@that4chanwolf
Forked from whs/mkhardsub.sh
Created July 26, 2012 11:08
Show Gist options
  • Save that4chanwolf/3181523 to your computer and use it in GitHub Desktop.
Save that4chanwolf/3181523 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment