Burning Subtitles into a Video with FFmpeg
To burn subtitles into a video with FFmpeg, add -vf subtitles=subtitle_file and re-encode the video. Burned-in subtitles become part of the picture, so they show up even in players that don't support subtitle tracks, and on sites that don't let you attach a separate subtitle file. This is useful when you want subtitles embedded in the video, like captions (hardcoded subtitles).
Japanese subtitles tend to run into trouble with font selection and character encoding, so I focused on those points.
The test environment was Ubuntu 24.04.5, FFmpeg 6.1.1 (Ubuntu package 6.1.1-3ubuntu5, built with --enable-libass), and libass 0.17.1. For Japanese fonts I installed Noto Sans CJK JP (fonts-noto-cjk). The source video was a 1280×720, 8-second H.264 video with audio, generated with FFmpeg's testsrc2. I did not test FFmpeg on Windows or macOS, image-based subtitles such as PGS or DVD subtitles, or how the output looks in actual players.
Burning in an SRT subtitle
I used the following SRT file. The second subtitle spans two lines.
1
00:00:01,000 --> 00:00:03,000
猫が窓の外を見ています
2
00:00:03,500 --> 00:00:05,500
鳥が飛んできました
しっぽが揺れています
3
00:00:06,000 --> 00:00:07,500
Hello, subtitles!
This is the command to burn it in. It copies the audio as-is and re-encodes only the video.
ffmpeg -i src.mp4 -vf subtitles=sub.srt -c:a copy burn.mp4
When I checked the output with ffprobe, it had only two streams, video and audio, and no subtitle stream. The subtitles are drawn into the video.
index=0|codec_name=h264|codec_type=video|width=1280|height=720
index=1|codec_name=aac|codec_type=audio
The subtitles filter draws subtitles using libass. As the subtitles section of the FFmpeg filters documentation explains, FFmpeg must be built with --enable-libass. In the test environment's FFmpeg, ffmpeg -filters listed both subtitles and ass.
You cannot burn subtitles in while copying the video with -c:v copy. When I tried it, the command stopped with this message:
Filtergraph 'subtitles=sub.srt' was specified, but codec copy was selected. Filtering and streamcopy cannot be used together.
I didn't specify any video encoder options, so the video was re-encoded with libx264's default settings. The runtime output also shows h264 (native) -> h264 (libx264). How CRF affects image quality and file size is compared in a separate article, "How Changing CRF in FFmpeg Affects Quality and File Size."
For Japanese subtitles, specify a font
If you don't specify anything, the subtitles are drawn quite small. I ran it with -v debug to see how FFmpeg converted the SRT to ASS (the format libass works with). The default style was Arial at size 16, on a 384×288 canvas.
PlayResX: 384
PlayResY: 288
Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,1,1,0,2,10,10,10,1
The style values are based on a 288-pixel-high screen. For a 720-pixel-high video, they were scaled up by 2.5 times (720 ÷ 288). When I changed MarginV, which sets the subtitle position, from 20 to 80, the subtitle moved up by about 150 px (about 2.5 times the change of 60).
The test environment has no Arial, so fontconfig substituted Liberation Sans. The kanji for "cat" (U+732B) is not in Liberation Sans, so libass looked for another font, and it drew the Japanese text with WenQuanYi Zen Hei.
fontselect: (Arial, 400, 0) -> /usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf, 0, LiberationSans
fontselect: (Arial, 400, 0) -> /usr/share/fonts/truetype/wqy/wqy-zenhei.ttc, 0, WenQuanYiZenHei
Which font gets substituted depends on the fonts installed on that machine. For Japanese subtitles, it's safer to name a Japanese font explicitly with force_style.
ffmpeg -i src.mp4 -vf "subtitles=sub.srt:force_style='FontName=Noto Sans CJK JP,FontSize=24,Outline=2,MarginV=20'" -c:a copy burn_style.mp4
This time, Noto Sans CJK JP was selected.
fontselect: (Noto Sans CJK JP, 400, 0) -> /usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc, 0, NotoSansCJKjp-Regular

force_style takes ASS style fields as name=value pairs separated by commas. Here I set the font name (FontName) and also changed the font size (FontSize) from the default 16 to 24, the outline width (Outline) from 1 to 2, and MarginV from 10 to 20. Compared with the default, the text is larger and the outline is thicker. Before writing the font name, check the installed Japanese fonts with fc-list :lang=ja family.
Without a Japanese font, you get tofu (□)
In an environment with no font that contains Japanese characters, the subtitles are replaced with boxes. When I burned the subtitles with fontconfig set up to see only DejaVu fonts, a message such as Glyph 0x732B not found was printed for each missing character. FFmpeg did not fail, and it produced a video with subtitles like the one in the image below. The exit code was also 0.

The number of boxes matches the 11 characters in the Japanese subtitle meaning "The cat is looking out the window." Because FFmpeg does not stop, open the output video and check it. If no Japanese font is installed, install a font package such as fonts-noto-cjk, or point to a directory containing fonts with the fontsdir option.
Use an ASS file to control position and color
To set the position or color of each subtitle, write the styles in an ASS file instead of SRT, and burn it in with the ass filter. In the following file, I set the canvas size to 1280×720, the same as the video, and created two styles: a white subtitle at the bottom and a yellow subtitle at the top.
[Script Info]
ScriptType: v4.00+
PlayResX: 1280
PlayResY: 720
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Noto Sans CJK JP,48,&H00FFFFFF,&H00FFFFFF,&H00000000,&H80000000,0,0,0,0,100,100,0,0,1,3,0,2,40,40,40,1
Style: Top,Noto Sans CJK JP,40,&H0000FFFF,&H00FFFFFF,&H00000000,&H80000000,1,0,0,0,100,100,0,0,3,2,0,8,40,40,30,1
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:01.00,0:00:03.00,Default,,0,0,0,,猫が窓の外を見ています
Dialogue: 0,0:00:01.00,0:00:07.50,Top,,0,0,0,,検証用の動画
ffmpeg -i src.mp4 -vf ass=sub.ass -c:a copy burn_ass.mp4
In the frame at 2 seconds, the white Japanese subtitle meaning "The cat is looking out the window" appeared at the bottom center, and the yellow bold Japanese text meaning "test video" appeared at the top center on a black box. ASS colors are written as &H followed by two hex digits each for alpha, blue, green, and red, in that order. The yellow &H0000FFFF (red and green at maximum, blue at 0) was drawn as yellow.
According to the documentation, the ass filter is the same as subtitles but is limited to ASS files.
Specify the character encoding with charenc for Shift_JIS SRT files
When I passed an SRT saved in Shift_JIS (CP932) as-is, the following two warnings were printed four times for the 8-second video.
[srt] Invalid UTF-8 in decoded subtitles text; maybe missing -sub_charenc option
[Parsed_subtitles_0] Error decoding: Invalid data found when processing input (ignored)
The exit code was 0 and the video was created, but no Japanese subtitles were drawn. The frames at 2 and 4 seconds matched the video encoded without any subtitles. Only the third subtitle, the English-only "Hello, subtitles!", was drawn. Specifying the encoding with charenc made the Japanese subtitles display correctly.
ffmpeg -i src.mp4 -vf "subtitles=sub_sjis.srt:charenc=CP932:force_style='FontName=Noto Sans CJK JP'" -c:a copy sjis.mp4
Cutting from the middle with -ss shifts the subtitles
When you cut part of a video and burn in subtitles at the same time, where you put -ss changes the result. I cut 3 seconds starting at the 3-second mark of the source video and compared the cut video's first second (the source's 4th second). In the SRT, the source's 4th second falls within the second subtitle (3.5 to 5.5 seconds).
# Put -ss before -i
ffmpeg -ss 3 -i src.mp4 -t 3 -vf "subtitles=sub.srt:force_style='FontName=Noto Sans CJK JP'" -c:a copy before.mp4
# Put -ss after -i
ffmpeg -i src.mp4 -ss 3 -t 3 -vf "subtitles=sub.srt:force_style='FontName=Noto Sans CJK JP'" -c:a copy after.mp4

When -ss came before -i, the source's 4th-second footage showed the subtitle for the 1–3 second range, which reads "The cat is looking out the window." The timestamps of the cut video start again from 0, and the subtitles filter selects subtitles based on those timestamps, so the subtitles appear 3 seconds early. When -ss came after -i, the correct second subtitle appeared.
When -ss is placed after -i, FFmpeg decodes from the beginning and discards everything up to the specified position, as described in the ffmpeg command documentation. The later the cut point, the more footage is decoded and thrown away. If you want to keep -ss before -i and still align the subtitles, use -copyts to keep the original timestamps and then reset them to start at 0 with setpts in the filter chain. Because asetpts resets the audio timestamps the same way, the audio must be re-encoded rather than copied. With this approach too, the second subtitle appeared at the 1-second mark. The difference in how cutting works depending on the -ss position is covered in a separate article, "Why the Position of -ss Changes the Result When Cutting Video with FFmpeg."
ffmpeg -ss 3 -copyts -i src.mp4 -t 3 -vf "subtitles=sub.srt:force_style='FontName=Noto Sans CJK JP',setpts=PTS-STARTPTS" -af asetpts=PTS-STARTPTS -c:a aac copyts.mp4
Burning in versus adding subtitles as a track
If you want to be able to turn subtitles on and off or switch between them, you can instead add them to an MP4 as a subtitle stream without burning them in. For MP4, specify mov_text as the subtitle format.
ffmpeg -i src.mp4 -i sub.srt -map 0 -map 1 -c:v copy -c:a copy -c:s mov_text -metadata:s:s:0 language=jpn soft.mp4
I compared the same video in the burned-in and subtitle-stream versions. The processing times are the ranges from three runs.
| Burned in | Subtitle stream | |
|---|---|---|
| Streams | Video, audio | Video, audio, subtitle (mov_text) |
| File size | 2,976,787 bytes | 3,096,761 bytes |
| Processing time | 2.10–2.17 s | 0.06–0.08 s |
| Video re-encoded | Yes | No (copied) |
Adding subtitles as a stream only copies the video, so processing finished almost instantly. The file grew by only 698 bytes compared with the original video (3,096,063 bytes). The burned-in file is smaller because the video was re-encoded with libx264's default settings. When I re-encoded the video the same way without any subtitles, the file was 2,937,084 bytes, so the burned-in version was 39,703 bytes larger than that.





