How to burn subtitles into videos using FFmpeg?

I have been working on a product video for our company and I don’t want to use separate subtitle files for the video.
Is there any way I can burn subtitles on video content using FFmpeg?

Hey John!

You can subtitle a file with .srt format from where FFmpeg can pick up subtitles. In addition, the FFmpeg provides a subtitles filter that takes the following video stream as an input and gives a video stream with subtitles burned in as output.

The Subtitles filter takes the following:
Filename: The filename of the subtitle file is used to read it. It needs to be stated.
You can also pass styling options like font type, size, and colors with the force_style parameter as key-value pairs like this:

force_style=‘Fontname=DejaVu Serif,PrimaryColour=&HCCFF0000’
If you want to use custom fonts with your subtitle, you can provide a font dir parameter with value as a directory path containing fonts that the filter can use.
Following is the example FFmpeg command for subtitle burn-in:
ffmpeg -i video.mp4 -vf subtitles=filename=/path/to/‘Fontname=DejaVu Serif,PrimaryColour=&HCCFF0000’ -c copy -f mp4 output.mp4 Hope so this may help you :grin:

I am also trying to crop a video and burn subtitles in that video
For that I followed the below steps:
• Cut the piece of a video

ffmpeg -ss 25:00 -to 26:00 -i vid.mp4 -c copy out.mp4
• Cut the piece of subtitle

ffmpeg -i -ss 25:00 -to 26:00
• Used the below command to burn the subtitle in that video

ffmpeg -i out.mp4 -vf -c:a copy -y final.mp4
I just want to know if that is possible to merge these 3 commands into one?

Yes, the subtitles filter opens the subtitle file internally and isn’t aware of the seek point for the video since ffmpeg resets timestamps after seeking.
To preserve the source timestamps and then reset them i.e.

ffmpeg -ss 25:00 -to 26:00 -copyts -i vid.mp4 -vf -c:a copy -ss 25:00 -y final.mp4