DunceDancer
DunceDancer

Reputation: 39

Using FFMPEG, how do we add subtitles in the black bar area or under the video?

I followed these steps:

  1. Added the black bars

    -vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1" Source:How to add black borders to video

  2. Added the subtitles ("burned" it into the video)

    ffmpeg -i "imput.mp4" -lavfi "subtitles=subtitles.srt:force_style='Alignment=0,OutlineColour=&H100000000,BorderStyle=3,Outline=1,Shadow=0,Fontsize=18,MarginL=5,MarginV=25'" -crf 1 -c:a copy "output.mp4" Source: ffmpeg subtitles alignment and position

Now I am stuck as to how to place the subtitles under the video or in the black screen.

Edit: Screenshot added to clarify

Screenshot of the Problem

Upvotes: 3

Views: 2214

Answers (2)

Coises
Coises

Reputation: 75

I get good results burning subtitles beneath movies with a filter like this:

-vf "pad=1920:960:0:0:color=black,subtitles=subs.srt:si=0:force_style='Alignment=6,MarginV=246,Fontsize=18'"

The above is for subtitles with a maximum of two lines placed beneath a 1920 x 800 source video. You have to adjust the numbers for each case.

The Alignment=6 causes the subtitles to be centered horizontally and placed vertically according to the top edge of the first line; that is, the first line of a multi-line subtitle appears in the same place as a single-line subtitle. I find that makes more sense when placing subtitles beneath the picture.

I have not yet found documentation I can use to calculate MarginV. Experience tells me that increasing it moves the subtitles downward; but only by trial and error have I been able to find the correct number for any particular use. The above usually works for an original height of 800 expanded with a 160-pixel bottom border, which works well for up to two lines with Fontsize=18.

Upvotes: 0

llogan
llogan

Reputation: 133743

Without a screenshot of the video with black bars we can only guess what will work for you.

The easiest thing to try is the default subtitle positioning in the bottom center.

Here's a combined version of your commands without all the extra junk:

ffmpeg -i input.mp4 -filter_complex "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:-1:-1,setsar=1,subtitles=subtitles.srt[v]" -map "[v]" -map 0:a -c:a copy output.mp4

Subtitles will have standard position in the bottom center.

Upvotes: 1

Related Questions