Skip to content

Instantly share code, notes, and snippets.

@lovmoon3k
Forked from shinchiro/HardsubWithFFmpeg.txt
Created June 5, 2023 14:13
Show Gist options
  • Save lovmoon3k/3a61aaf3a19f3725cd25396805222371 to your computer and use it in GitHub Desktop.
Save lovmoon3k/3a61aaf3a19f3725cd25396805222371 to your computer and use it in GitHub Desktop.
How to hardsub subtitle with FFmpeg
::
:: This demonstrate on how to hardsub embeded subtitle and downscale video to 360p with only FFmpeg. Ensure FFmpeg is compiled with --enable-libass
ffmpeg -hide_banner -i "D:\oh\test\input.mkv" -vf "subtitles='D\:\\oh\\test\\input.mkv'",scale=-1:360:flags=spline -c:v libx264 -preset ultrafast output.mp4
::Character ':', '\' need to be escaped if present in input's path
:: Escape both characters with sed.
echo "D\:\\oh\\test\\input.mkv" | sed "s,\\,\\\\,g;s,:,\\:,g" >>name
set /p modified=< name
del name
echo %modified%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment