I am having hard time adding .srt subtitles to the newly creating video. I am using Python.
subtitles:
f"{PROJECT_PATH}/data/subtitles/final_subtitle_srt/all_slides.srt"
I have checked they are correct.
pieces of my code that does not work:
audio = f'{PROJECT_PATH}/data/ppt-elements/audio_{file_id}.txt'
images = f'{PROJECT_PATH}/data/ppt-elements/images_{file_id}.txt'
image_input = ffmpeg.input(images, f='concat', safe=0, t=seconds).video
audio_input = ffmpeg.input(audio, f='concat', safe=0, t=seconds).audio
inputs = [image_input, audio_input]
command = (
ffmpeg.filter('subtitles', f"{PROJECT_PATH}/data/subtitles/final_subtitle_srt/all_slides.srt")
.output(*inputs,f"{PROJECT_PATH}/data/subtitles/final_subtitle_srt_all_slides.srt",
f"{PROJECT_PATH}/data/final-{file_id}.mp4",
vf="fps=10,format=yuv420p",
preset="veryfast",
shortest=None,
r=10,
max_muxing_queue_size=4000,
**additional_parameters,
)
)
Am I using subtitles filter well?
subtitlesfilter applies the video, we may use it as follows:In case there are other video filters to be chain we may chain the filters:
We don't need to pass the subtitles stream as an input stream (use the subtitles only in the subtitles filter).
Code sample:
Note that concatenating images using concat demuxer is not a good practice because images don't have timetags.
I recommend you to rename the images to numbered sequence
0001.png,0002.png,0003.png... and useffmpeg.input('%04d', r=fps, ...)withoutfpsfilter and withoutr=fpsfor the output.