How can I embed subtitles into videos with ffmpeg?

39,318

Solution 1

From man ffmpeg:

Subtitle options:

-scodec codec Force subtitle codec ('copy' to copy stream).

-newsubtitle Add a new subtitle stream to the current output stream.

-slang code Set the ISO 639 language code (3 letters) of the current subtitle stream.

So: ffmpeg -newsubtitle subtitles.srv -i video.avi ...

Solution 2

From Pier's link, specifically:

ffmpeg -i video.avi -vf subtitles=subtitle.srt out.avi

This creates a hard-sub ("burns" the subtitles into the video images) so you can't hide the subtitles and the change is irreversible!

I've used this successfully with the current static git ffmpeg release.

Solution 3

ffmpeg developers are working with subtitle support, but as far as I know it's only working in the latest ffmpeg. mencoder will burn subtitles instantly, if you want to try that instead.

Share:
39,318

Related videos on Youtube

xralf
Author by

xralf

Updated on September 18, 2022

Comments

  • xralf
    xralf over 1 year

    I'm told it's possible to embed subtitles (.srt) into video files (.avi) using ffmpeg, but I can't find any mention of it in the man page. Is this possible? What command do I use?

  • xralf
    xralf over 12 years
    If I use instead of ... result.avi this command does not work At least one output file must be specified
  • Shawn J. Goff
    Shawn J. Goff over 12 years
    Of course, ... means "and whatever other options you need".
  • xralf
    xralf over 12 years
    Sufficient is ffmpeg -newsubtitle subtitles.srt -i video.avi result.avi but this ends with the message above. I hoped that result.avi is output file. I tried it with -o result.avi too but without success.
  • xralf
    xralf over 12 years
    I don't know why this didn't work for me (maybe wrong file or problem with ffmpeg). I tried this command instead mencoder movie.avi -sub movie.srt -o movie.hardsubs.avi -oac copy -ovc lavc -lavcopts vbitrate=1200
  • Alen Milakovic
    Alen Milakovic about 12 years
    @ShawnJ.Goff: This did not work for me either. What version of ffmpeg are you using, and what OS?
  • Alen Milakovic
    Alen Milakovic about 12 years
    For anyone else looking at this, check whether your ffmpeg is from libav-tools or similar, or actually from the ffmpeg project, since there has been a fork.
  • Rubi Shnol
    Rubi Shnol about 6 years
    Doesn't work. "Output file #0 does not contain any stream"
  • Nakamoto
    Nakamoto about 3 years
    This filter requires ffmpeg to be compiled with --enable-libass, according documentation.
  • 16851556
    16851556 over 2 years
    Thx, resulting subtitles was smaller than i am used to, i would increase 50%. Someone mention: subtitles=subtitle.srt:force_style='Fontsize=20' ffmpeg.org/ffmpeg-all.html