Search code examples
ffmpegsubtitlesrt

ffmpeg subtitles background issue when multiple lines (using .srt format)


While using ffmpeg to burn .srt subtitles to mp4 files I'm having an issue with multiple text lines - background is overlaying each other.

Command I'm using:

ffmpeg -i source_video_path.mp4 -vf "subtitles=srt_source.srt:force_style='OutlineColour=&H80000000,BorderStyle=3,Outline=1,Shadow=0,MarginV=25,Fontname=Arial,Fontsize=10,Alignment=2'" video_destination.mp4

enter image description here

Question is - is it possible to overcome the overlay while still having a transparent background while using .srt format or I need to use .ass format as a fix?


Solution

  • You can avoid multiple lines overlaying each other by using BorderStyle=4 together with BackColour=&H80000000 which gives a 50% opaque black color background.

    Full command would be:

    ffmpeg -i source_video_path.mp4 -vf "subtitles=srt_source.srt:force_style='OutlineColour=&H80000000,BorderStyle=4,BackColour=&H80000000,Outline=0,Shadow=0,MarginV=25,Fontname=Arial,Fontsize=10,Alignment=2'" video_destination.mp4
    

    enter image description here