Python Forum

Full Version: How to 'soft-embedd' subtitles with python-ffmpeg
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I've found an example on how to embed subtitles using ffmpeg from command line:
ffmpeg -i video.mp4 -i subtitles.srt -map 0:v -map 0:a -c copy -map 1 -c:s:0 mov_text -metadata:s:s:0 language=fra output.mp4

This way subtitles are embedded as metadata ... quite rapid process.

Because I need to embed subtitles in multiple files I searched a solution that uses Python.
Indeed such a solution exist: ffmpeg-python 0.2.0

But I didn't find example how embed subtitles as metadata, i.e not burn them in video.
The only example on embedding subtitles I've found is here:

import ffmpeg
input_dir = 'mydir/'
video_file = 'video.mp4'
subtl_file = 'subtitles.srt'

(
    ffmpeg
    .input(input_dir+video_file)
    .filter('subtitles', input_dir+subtl_file)
    .output(input_dir+'output.mp4')
    .run()
)
But this way subtitles are burned into video ... quite time-consuming process.

Any suggestions ?

Thanks.
(Jul-04-2022, 11:23 AM)Pavel_47 Wrote: [ -> ]But this way subtitles are burned into video ... quite time-consuming process.

Any suggestions ?
It take 30-sec to embedding subtitles in what i use in other Thread also MKVToolNix(with Subtitle Edit if need transparent to .ass).
(Jul-04-2022, 12:06 PM)snippsat Wrote: [ -> ]It take 30-sec to embedding subtitles in what i use in other Thread also MKVToolNix(with Subtitle Edit if need transparent to .ass).

It also takes about 30 seconds for ffmpeg to embed the subtitles.
Does MKVToolNix allow batch processing, i.e. specify the directory containing multiple videos with corresponding subtitle files, then press a button and see the result after 3...5 min?