Subtitels with ffmpeg-python

31 views Asked by At

I'm currently working on a video processor project and aiming to generate subtitles for the videos processed.

I've found that code that combines audio, video, and adds subtitles. However, I'm struggling to figure out how to format the subtitles, such as changing their size or location within the video.

input_video = ffmpeg.input(video_path)
input_audio = ffmpeg.input(audio_path)
    
ffmpeg.concat(input_video, input_audio, v=1, a=1).filter("subtitles", subtitle_path).output(output_path).run()

Thank you in advance for any advice or suggestions.

I want the Subtitles in the midel off the screen, but they were at the bottom

1

There are 1 answers

0
Gustje04 On

Hi just found the solution and i wanted to let other now in case they also search for it:

style = "FontName=Londrina Solid,FontSize=20,PrimaryColour=&H00ffffff,OutlineColour=&H00000000,BackColour=&H80000000,Bold=1,Italic=0,Alignment=10"
ffmpeg.concat(input_video, input_audio, v=1, a=1).filter("subtitles", subtitle_path, force_style=style).output(output_path).run()