7
votes

I am adding subtitles to a video using:

ffmpeg -i "imput.mp4" -lavfi "subtitles=subtitles.srt:force_style='OutlineColour=&H100000000,BorderStyle=3,Outline=1,Shadow=0,Fontsize=18'" -crf 1 -c:a copy "output.mp4"

Which results in:

No Alignment

I am repositioning this using Alignment :

ffmpeg -i "imput.mp4" -lavfi "subtitles=subtitles.srt:force_style='Alignment=9,OutlineColour=&H100000000,BorderStyle=3,Outline=1,Shadow=0,Fontsize=18'" -crf 1 -c:a copy "output.mp4"

Alignment=9

But according to the Line-Alignment ASS Tags docs, there are only 9 positions. 1: Bottom left, 2: Bottom center, 3: Bottom right, 5: Top left, 6: Top center, 7: Top right, 9: Middle left, 10: Middle center, 11: Middle right

Is there a way to tweak this positioning?

I want the subs to be left-aligned, but lower down. Like this:

result

3
subs to be left-aligned, but lower down --> sounds like Alignment=1Gyan
Yes, I've experimented with all 9 positions, but when trying to specify the margin it has no effect. It seems the Alignment parameter overrides the MarginV: ffmpeg -i "imput.mp4" -lavfi "subtitles=subtitles.srt:force_style='Alignment=1,OutlineColour=&H100000000,BorderStyle=3,Outline=1,Shadow=0,Fontsize=18,MarginV=25'" -crf 1 -c:a copy "output.mp4"friendlygiraffe

3 Answers

9
votes

Turns out the trick for doing this is to add Alignment=0. Then you can use MarginV and MarginL freely:

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"
1
votes

I try to small size the text and turn the margin of bottom: Alignment=2, Fontsize = 5, MarginV = 1 It's work for me. like this way:

ffmpeg -i "1.mkv" -lavfi "subtitles=1.srt:force_style='Alignment=2,OutlineColour=&H100000000,BorderStyle=3,Outline=1,Shadow=0,Fontsize= 12,MarginV=35'" -crf 1 -c:a copy  -vcodec h264_nvenc  "output.mkv"

*-vcodec h264_nvenc is cuda accelerator.

0
votes

in fact you can also put some margin like "MarginV=20" in order to teweak position of subtitles

ffmpeg2 -y -i "C:\Users\input.mxf" -pix_fmt yuv422p -vcodec mpeg2video -non_linear_quant 1 -flags +ildct+ilme -top 1 -dc 10 -intra_vlc 1 -qmax 6 -lmin "1*QP2LAMBDA" -vtag xd5c -rc_max_vbv_use 1 -rc_min_vbv_use 1 -g 12 -b:v 50000k -minrate 50000k -maxrate 51000k -bufsize 8000k -color_primaries 1 -color_trc 1 -colorspace 1 -vf "subtitles=subtitles_file.mxf_Subtitle.srt:force_style='OutlineColour=&H80000000,BorderStyle=3,Outline=1,Shadow=0,MarginV=20" -acodec copy "output.mxf"