Jul-04-2022, 11:23 AM
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:
Any suggestions ?
Thanks.
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.