At BetaSeries, we often need to provide our professional clients with videos that have embedded subtitles. This ensures that the subtitles are always visible, regardless of the player or device used. One efficient way to achieve this is by using FFmpeg, a powerful multimedia framework. Here’s a quick guide on how you can burn subtitles onto your videos using a simple FFmpeg command.
The Command
Here is the FFmpeg command we use:
ffmpeg -i input.mp4 -filter_complex "subtitles=input.srt:force_style='BackColour=&HA0000000,BorderStyle=4,Fontsize=18'" output.mp4
Breakdown of the Command
- ffmpeg: This calls the FFmpeg program.
- -i input.mp4: Specifies the input video file.
- -filter_complex: This option allows us to apply complex filters to the input. In this case, we’re using it to add subtitles.
- ”subtitles=input.srt:force_style=‘BackColour=&HA0000000,BorderStyle=4,Fontsize=18’”: This part applies the subtitles from
input.srt
to the video and customizes their appearance.- subtitles=input.srt: Points to the subtitle file.
- force_style: Customizes the appearance of the subtitles.
- BackColour=&HA0000000: Sets the background color of the subtitles to a semi-transparent black.
- BorderStyle=4: Defines the border style for better readability.
- Fontsize=18: Sets the font size of the subtitles to 18.
- output.mp4: Specifies the output file.
Customizing Subtitles
The force_style
option allows a wide range of customizations to ensure that subtitles are clear and aesthetically pleasing. Here are a few more options you can experiment with:
- FontName=Arial: Change the font type.
- PrimaryColour=&H00FFFFFF: Set the subtitle text color (hexadecimal ARGB value).
- OutlineColour=&H00000000: Set the color of the subtitle outline.
Example of Customization
If you want to change the font to Arial and the text color to white, the command would look like this:
ffmpeg -i input.mp4 -filter_complex "subtitles=input.srt:force_style='BackColour=&HA0000000,BorderStyle=4,Fontsize=18,FontName=Arial,PrimaryColour=&H00FFFFFF'" output.mp4
For more detailed options and configurations, refer to the FFmpeg documentation.