How to set background to subtitle in ffmpeg? -


it described here how ot burn srt file video. however, want put semi-transparent background subtitles texts can read more easily. how can that?

using ass subtitles create opaque text background

ass subtitles can have semi-transparent background text.

with aegisub

the easiest way aegisub.

enter image description here

  1. open subtitles file aegisub.
  2. click subtitlestyles manager.
  3. under current script choose default, press edit button.
  4. experiment outline , shadow values. check opaque box.
  5. under colors click color under outline or shadows. window appear. adjust value of alpha box change transparency.
  6. save subtitles .ass file.

now can use aas file make hardsubs or softsubs ffmpeg.

without aegisub

if want hardsubs can use subtitles filter add transparent background force_style option.

ffmpeg -i input -filter_complex "subtitles=subs.ass:force_style='outlinecolour=&h80000000,borderstyle=3,outline=1,shadow=0,marginv=20'" output 

issue multiple lines

if subtitles contains multiple lines, due auto-wrapping of long lines or intentional line break, backgrounds overlap , potentially ugly shown below:

enter image description here

you can avoid by:

  1. changing outline , shadow sizes 0.
  2. the alpha settings of shadow control transparency of background box. click on shadow color adjust alpha of shadow color desired transparency level.
  3. edit ass file in text editor. in style line change value corresponding borderstyle 4. fill bounding box background of each subtitle event. example style line:

    style: default,arial,20,&h00ffffff,&h000000ff,&h80000000,&h80000000,-1,0,0,0,100,100,0,0,4,0,0,2,10,10,10,1 

example:

enter image description here

note borderstyle=4 non-standard value, may not work in players.

thanks sup , wm4 borderstyle suggestion.

using drawbox

the drawbox filter can used create background box. may useful if want box span width.

enter image description here

ffmpeg -i input -filter_complex "drawbox=w=iw:h=24:y=ih-28:t=max:color=black@0.4,subtitles=subs.ass" output 

downside have account line breaks or word wrapping long subtitles. making box taller compensate suffice, ugly because subtitles baseline remains static: single line subtitles have more padding on top bottom.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -