Hardsub Guide


1. Download the latest version of ffmpeg (Static) and copy ffmpeg.exe from the “bin” folder to your desktop or prefered folder

2. Open an editor (like notepad.exe) and insert the following content:

pushd %~dp0

echo Encoding 720p ...
ffmpeg.exe -i "%~1" -vf scale=1280x720:flags=spline,format=yuv420p,"subtitles='%~n1'%~x1" -map_metadata -1 -movflags faststart -c:v libx264 -profile:v main -level:v 4.0 -preset veryfast -crf 16 -maxrate 20M -bufsize 25M -x264-params colormatrix=bt709 -c:a aac -b:a 224k "%~n1_720p.mp4"

echo Encoding 1080p ...
ffmpeg.exe -i "%~1" -vf format=yuv420p,"subtitles='%~n1'%~x1" -map_metadata -1 -movflags faststart -c:v libx264 -profile:v main -level:v 4.0 -preset veryfast -crf 17 -maxrate 20M -bufsize 25M -x264-params colormatrix=bt709 -c:a aac -b:a 224k "%~n1_1080p.mp4"

popd
echo Done.
PAUSE

Save it as a batch file (.bat instead of .txt) on your desktop or prefered folder (same as ffmpeg.exe)

A short explanation for the parameters:
-vf scale=1280x720:flags=spline => output resolution with downscale method. You can look HERE for more information
-vf format=yuv420p => chroma subsampling. Forcing for compatibility reasons
-vf subtitles="%~n1%~x1" => subtitles. We assume it's included in the .mkv
-profile:v main => h264 profile. "Main" for compatibility reasons. You can look HERE for more information
-level 4.0 => h264 level. Forcing "4.0" for compatibility reasons. You can look HERE for more information
-preset veryfast => compression algorithm/speed. Better preset means better compression but slower encode time. You can look HERE for more information
-crf 18 => compression quality. Lower value means better video quality (less compression) but bigger file size. You can look HERE for more information
-maxrate 20M -bufsize 25M => limiting the max. bitrate and buffer size. 
Forcing a limit for compatibility reasons. You can look HERE for more information
-x264-params colormatrix=bt709 => forcing the right colour matrix
-c:a aac => audio codec. You can look HERE for more information
-b:a 224k => audio bitrate. You can look HERE for more information
(Use "-c:a copy" instead of "-c:a aac" and "-b:a 224k" if you don't want to convert the audio)

Keep in mind that everything with "Forcing for compatibility reasons" doesn't mean it has to be forced with these settings or at all for you. The defaults here are aiming for the best compatibility (e.g. watching on a PS3).

3. Have your softsubbed video (.mkv) without any special characters (for avoiding error messages like “Error initializing filter ‘subtitles’ with args”) on your desktop or prefered folder (same as ffmpeg.exe and the batch file)

4. Drag & Drop your softsubbed video (.mkv) onto the batch file (.bat)