In FFmpeg, you can utilize the subtitle filter (subtitles) to add subtitles to a video stream. This filter enables you to specify a subtitle file and render it onto the video. You can adjust the font size and other style properties by configuring filter options.
To modify the font size of subtitles, use the force_style parameter within the subtitles filter. Within this parameter, specify the FontSize value to adjust the font size.
The following example demonstrates using FFmpeg to add and adjust subtitle font size within a video filter:
bashffmpeg -i input_video.mp4 -vf "subtitles=subtitles.srt:force_style='FontSize=24'" -c:a copy output_video.mp4
In this command:
-i input_video.mp4specifies the input video file.-vfdefines the video filter chain.subtitles=subtitles.srtspecifies the subtitle file.force_style='FontSize=24'sets the subtitle font size to 24 via the force style option.-c:a copyindicates that audio encoding is copied without re-encoding.output_video.mp4is the output video file with subtitles added.
Please note that the subtitle file used (as shown in this example, subtitles.srt) must be in the correct SRT or ASS format. If you are using an ASS subtitle file, it typically includes style information such as font size. In such cases, you may not require the force_style option unless you intend to override the styles specified in the ASS file.
Furthermore, the FFmpeg version, compilation settings, and the subtitle library used (e.g., libass) can impact the availability and functionality of the subtitles filter. Ensure you have the latest version of FFmpeg installed and that it was compiled with subtitle-supporting options.