Extract Subtitles with FFmpeg
45sShows a quick, practical trick to extract subtitles from any video file using FFmpeg.
▶ Play Clip"The title accurately promises FFmpeg subtitle management, and the video delivers exactly that."
This video tutorial demonstrates how to manage subtitles using FFmpeg, covering extraction, conversion, embedding, and hard-burning subtitles into video files. The presenter uses the open movie Sintel as an example to show practical commands for handling subtitle tracks.
Use 'ffprobe' to list all tracks in a video, including subtitle streams. The command 'ffprobe -show_streams -show_format' reveals codec types and stream indices.
Run 'ffmpeg -codecs | grep subtitle' to see all supported subtitle codecs. Subrip (SRT) is a common format.
Use 'ffmpeg -i input.mp4 -vn -an -map 0:s:0 -c copy output.srt' to extract the first subtitle track without re-encoding.
SRT files are plain text with sequential numbers, timecodes (start --> end), and subtitle text. Entries are separated by blank lines.
Change the output extension to convert formats, e.g., 'output.ass' for ASS subtitles. The syntax differs: ASS uses a CSV-like structure with formatting codes.
Use 'ffprobe' to find stream indices for each language. Then extract each with 'ffmpeg -i input -vn -an -map 0:s:index -c copy lang.srt'.
Combine video, audio, and subtitle files using 'ffmpeg -i video -i sub1 -i sub2 -map 0:v -map 0:a -map 1 -map 2 -c copy output.mkv'.
Use '-metadata:s:s:0 language=eng' and '-metadata:s:s:1 language=ita' to label subtitle streams. Verify with 'ffprobe'.
Apply the subtitles filter: 'ffmpeg -i input -vf "subtitles=subs.srt" -c:v libx264 -crf 0 -preset slow -c:a copy output.mkv'. This re-encodes the video.
FFmpeg provides powerful tools for subtitle management, from extraction and conversion to embedding and hard-burning. Mastering these commands enables precise control over subtitle tracks in multimedia files.
What command lists all subtitle codecs supported by FFmpeg?
ffmpeg -codecs | grep subtitle
03:13
How do you extract the first subtitle track from a video without re-encoding?
ffmpeg -i input.mp4 -vn -an -map 0:s:0 -c copy output.srt
05:08
What is the structure of an SRT subtitle file?
Sequential number, timecode (start --> end), subtitle text, blank line between entries.
07:05
How do you convert an SRT subtitle to ASS format?
Change the output file extension to .ass; FFmpeg handles the conversion automatically.
09:21
How do you set the language metadata for the first subtitle stream to English?
-metadata:s:s:0 language=eng
18:49
What filter is used to hard-burn subtitles into a video?
The 'subtitles' filter: -vf "subtitles=subs.srt"
24:30
Why must the video be re-encoded when hard-burning subtitles?
Because the subtitles are merged into the video frames, requiring a new video stream.
25:46
What command shows all streams in a video file?
ffprobe -show_streams input.mp4
01:37
Extracting subtitles with FFmpeg
Core technique for isolating subtitle tracks from video files.
05:08SRT file format explained
Understanding the plain-text structure enables manual editing and troubleshooting.
07:05Combining multiple subtitle tracks
Demonstrates how to create multi-language video files.
14:42Setting language metadata
Proper metadata ensures subtitle tracks are correctly labeled in players.
18:49Hard-burning subtitles
Essential for creating videos with permanent, non-removable subtitles.
24:30[00:00] Hello this is Stef! Welcome back to
[00:04] share and subscribe if you like
[00:08] Now, today we're going to see something a
[00:14] we dealt with what to do with images we dealt
[00:19] the video track we are going to see another type
[00:25] to see how to extract subtitles how to burn
[00:33] hmm okay
[00:38] I see and how to manipulate them in order to
[00:45] moment I have a subunitu already behind
[00:58] okay we here we have zuboon 2 ready and the video
[01:05] singtel sintel is made by the same house let's
[01:15] video that we already seen that we already know
[01:22] a light themed as a big bug bunny there's a bit
[01:32] a little as soon as I watched this movie anyway
[01:37] using FF probe so now let's let's meet go to the
[01:47] that we have so far we are trying to invoke FF
[01:57] what are the tracks that are available right here
[02:06] um so it's quite complex it's quite well done as
[02:13] movie for example and here we see that there is a
[02:24] of the chapters is going to be seen another
[02:34] subtitle tracks so here if you would like we can
[02:45] see what it tells so I have a probe minus show
[02:57] this way yeah plane way and you see that right
[03:06] streams you have all the indications we see that
[03:13] a look at what we can do so first of all let's
[03:20] so even the subtitles have their own codecs so
[03:28] which are the um the tracks available sorry
[03:36] and take a FM pack minus codex then we put a pipe
[03:50] there's a string of research so it's
[03:56] uh in the beginning you saw the indication if
[04:04] case we want a subtitle track as this available
[04:15] and here as you can see this is all the list
[04:23] our videos here we go uh among them there
[04:33] can use it directly another way of taking out
[04:42] admin pack minus codex and again a pipe grab
[04:55] and here you have all the lists as before so
[05:01] this is easier the other is a bit more hacky
[05:08] to extract the subtitles out of the video what
[05:16] minus I name of the video so now we take as the
[05:26] the subtitle track so to invoke the subtitle
[05:34] the video track so minus the end remove the audio
[05:44] going to use for example the first so in this
[05:52] then got to take the first file and we're going
[06:04] wrong it was the German one so what I'm going
[06:11] in this case a minus C colon s s stands for
[06:23] the codec here we're going to copy
[06:32] what we can say is take as output file a file
[06:44] format for the subtitle stream subrip as it is
[06:57] and here what it does is extracting all
[07:05] here we go the type is a copy so they should
[07:12] what's the content of this video this is
[07:19] video and the audio usually the audio
[07:23] special treatment for the subtitles this is
[07:29] we can open it directly using a text editor
[07:40] video and here we see all the results here you
[07:51] subtitles so you see that there's a progressive
[07:58] you see the instant you want to show the subtitle
[08:08] there is a text way to Mark um an arrow and
[08:19] beginning and so the certain the some subtraction
[08:27] your uh of your subtitle and here you have your
[08:37] multiple lines here this is put in two lines so
[08:43] simply then all the entries must be separated
[08:52] if you would like you can type in manually there
[09:00] um you would like to use to make them better but
[09:06] subtitles okay so we dealt with the SRT subtitles
[09:14] use other types of subtitles you can so we saw the
[09:21] you would like to use that dot ass subtitles what
[09:32] you can use the input also so subtitle as input
[09:45] and in this case instead of putting SRT
[09:52] a fun pack so we have our DOT ass file
[10:00] will find the syntax that is slightly
[10:06] there's a different scanning you see dialog column
[10:17] more or less a CSV like so you see that there is
[10:27] line that you would like to display so a bit more
[10:36] in another form now we extract it before the
[10:43] some more languages for us for me personally I'm
[10:49] Italian language but now I don't know which is
[10:55] that I can do is to invoke FM pack in order to
[11:04] first language is the the German one so um we
[11:14] the languages available again local style and
[11:23] French Italian Dutch polish Portuguese Russian
[11:32] that I'm interested about are the English number
[11:40] I don't want to uh so just just an example
[11:51] minus I name of the video then I take minus VN
[12:06] and then I'm selecting through the map the if you
[12:14] here in the cart and what I would like to
[12:24] the English strikes so these are respectively the
[12:32] uh to take either the um absolute crack or the
[12:43] that I want so here uh what I can do is to put
[12:53] something like this and then
[13:03] and the name of the file as
[13:12] dot SRT so the same format as before
[13:18] and now I have my English subtitles now
[13:27] and here I see that my subtitles are in English
[13:38] command that I used before so this one but instead
[13:46] number three remember here we have S track the
[13:55] fifth track in the sequence so the fifth track is
[14:04] that was up our stream they want is a
[14:11] here I take everything as it
[14:21] I extract the video I'm sorry the
[14:26] thread let me check if this is a really
[14:35] and it seems Italian okay so
[14:42] okay now I have my English track I have my
[14:48] to create a video with only the audio the video
[14:58] is to invoke again a fun pack minus I in this
[15:06] the third file so first this then my sub first
[15:17] so my three files are rightly put then
[15:26] frame so I can take a map from the first
[15:34] from the first file I'm going to take again all
[15:44] take the subtitle tracks so I can take something
[15:54] yeah for the third file by number two I take
[16:01] I'm going to create my file my file can be with
[16:09] so what I can do is something like a singtel
[16:23] so I want a matrushka video just suppose a thing
[16:31] like this I think that supports a copy
[16:41] called B of everything so I can do also more
[16:49] subtitles what I can do is to put a minus C P so
[16:59] see if it works it seems to work
[17:05] now it's putting all together and let's see what's
[17:15] and let's see if the video is played so I'm
[17:24] video is played perfectly I'm going to check also
[17:32] the two tracks one I suppose it is the English
[17:41] so there's the the scene in the center
[17:49] and the
[17:56] matter here it is so here we have a the subtitles
[18:08] we have the subtitles in Italian so cool that's
[18:15] uh we have a languages but if we open this
[18:23] subtitle as we want but it doesn't have the
[18:31] so if you see the subtitle track you see there is
[18:37] they don't mean anything to us so we don't
[18:43] is the Italian here it seems like the first
[18:49] is to detect to tell the software that we are in
[18:59] so how can we do this thing we're going to invoke
[19:08] entry so here we're going to invoke FM pack
[19:18] burst file minus I second file that is the English
[19:33] then what we will need to do is to map these
[19:40] take the map uh video from the first file
[19:52] cool then what we're going to take is from the
[20:00] and the other has the subtitle
[20:08] then so video from the first file audio from
[20:15] and subtitles from the second file so since
[20:21] accordingly this is a to make the things easier
[20:30] set the titles accordingly so what can we do is
[20:43] the name of the flag so the name of
[20:49] has to be put with the following
[20:55] no spaces so a column that
[21:03] the we got to put a second s the s
[21:11] string so we want to take the first stream
[21:20] the other subtitle as the Italian language
[21:31] a thing like this so stream two so it does the
[21:37] say that this is the first subtitle track and
[21:46] English so the language need to have a certain
[21:55] letters are like the iso language style language
[22:04] and then finally we can put our output file
[22:11] the same in this case so we can take English
[22:21] remarkable name um yes so I forgot the thing for
[22:32] again s s one because the second subtitle stream
[22:41] equals to Eta that is for Italy Italian let's see
[22:52] waiting for the result it should be pretty
[22:57] um a string copy no it's no way not to perform
[23:03] the process here got to put in the end after
[23:14] I was wrong and now we got the set the languages
[23:30] but should be pretty fast okay good
[23:36] just to understand if our languages are set
[23:43] the name of the language so here FF probe
[23:57] and we see that there is the stream for the
[24:05] other is for the Italian so good we did what
[24:11] play the video also we can open it with the VLC
[24:23] track we got the track one English and the second
[24:30] okay so we uh if we want now to put the subtitles
[24:39] subtitle always be present uh on a video and
[24:47] the subtitles on top of the video this can be
[24:55] um subtitles filter and it works in this way
[25:05] as this in this case we don't um give the name
[25:15] but we give it as input in the filter subtitles
[25:25] B subtitles is the name of the filter and then
[25:35] this case uh let's use the English one and then
[25:46] this is a video that uses a filter we cannot
[25:53] we got to give the information about the video
[26:03] to put the CRF the contrast the concentrate
[26:13] but preserving the quality presets slow to be
[26:22] with the best quality possible without any nasty
[26:33] we can take the Stream so the video
[26:40] can be kept so what you can do is something
[26:53] and here we can change the video to MKV and
[27:02] and so we are going to wait until the end of
[27:11] and we are ready to play it when we play it
[27:20] here we can see that the subtitles are heartburned
[27:29] system and here you can see that this subtitle
[27:36] the subtitles tracks okay so today we dealt with
[27:43] and how do they appear at least format a couple
[27:53] subtitles within the videos and also how to
[27:59] now we have the reference within the video and
[28:05] to put a multi-language subtitles if you want
[28:13] frames you can do it with the filter V subtitles
[28:19] put and you had subtitles directly put inside
[28:26] you can change the font you can change the
[28:33] also pay particular attention when you crop when
[28:38] middle it requires some particular attention for
[28:46] um you can work with if you want to deal with
[28:51] if you reach this point uh I suggest
[28:56] the notification Bell here down below and
[29:00] with new content regarding multimedia streams
[29:22] thank you
⚡ Saved you 0h 29m reading this? Transcribe any YouTube video for free — no signup needed.