Python Forum
How to 'soft-embedd' subtitles with python-ffmpeg
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to 'soft-embedd' subtitles with python-ffmpeg
#1
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.
Reply
#2
(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).
Reply
#3
(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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Merge video with subtitles Pavel_47 26 6,691 Jul-06-2022, 02:27 PM
Last Post: Pavel_47
  Python Flask Realtime system printout (console) ffmpeg jttolleson 3 2,958 Apr-18-2022, 06:39 PM
Last Post: jttolleson
  MovieWriter ffmpeg unavailable; using Pillow instead. Joni_Engr 1 29,431 Aug-13-2021, 03:39 PM
Last Post: deanhystad
  [split] Launch soft on Terminal in silent mode Note3409 2 2,071 Oct-03-2020, 08:21 PM
Last Post: Note3409
  When piping a FFMPEG stream to PyAudio, I get a "click" on every loop klehman 0 4,852 Dec-15-2019, 04:22 AM
Last Post: klehman
  how do you use stupid ffmpeg ineedastupidusername 0 4,342 Nov-10-2017, 05:38 AM
Last Post: ineedastupidusername

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020