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?

ass subtitles can have semi-transparent background text.
with aegisub
the easiest way aegisub.
- open subtitles file aegisub.
- click
subtitle→styles manager. - under
current scriptchoosedefault, presseditbutton. - experiment
outline,shadowvalues. checkopaque box. - under
colorsclick color underoutlineorshadows. window appear. adjust value ofalphabox change transparency. - save subtitles
.assfile.
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 this work text based subtitles supported ffmpeg because filter automatically convert them ass.
see substation alpha (ass) style fields formatting options.
issue multiple lines
if subtitles contains multiple lines, due auto-wrapping of long lines or intentional line break, backgrounds overlap , potentially ugly shown below:
you can avoid by:
- changing
outline,shadowsizes0. - the alpha settings of shadow control transparency of background box. click on shadow color adjust
alphaof shadow color desired transparency level. edit ass file in text editor. in
styleline change value correspondingborderstyle4. fill bounding box background of each subtitle event. examplestyleline: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:
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.
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
Post a Comment