[FFmpeg-user] Add soft subtitles to YouTube Stream Now?

Moritz Barsnick barsnick at gmx.net
Wed Nov 20 17:05:12 EET 2019

On Wed, Nov 20, 2019 at 08:43:00 -0600, Steven Kan wrote:
> > https://trac.ffmpeg.org/ticket/1778#comment:10 <https://trac.ffmpeg.org/ticket/1778#comment:10>

> If I’m demuxing your answer correctly, the answer is “no,” at least
> of now. Thank for your reply; at least now I won’t spend hours trying
> to find a solution that doesn’t exist! That enhancement request has
> had no updates for 2 years :-(

Indeed, that's the conclusion. :-/

> I did find this libcaption project:
> https://github.com/szatmary/libcaption <https://github.com/szatmary/libcaption>

I had found that as well before I answered. I looked into it again, and
saw the nice examples:


The add_captions scripts shows how to use the example binaries:
as such:

$ ffmpeg -i $VIDEO -codec copy -f flv - | flv+srt - $SRT - | ffmpeg -i - -codec copy -y $OUTFILE

flv+srt even supports dynamic subtitles:

    flv+srt is capable of reading an srt from a named pipe for the use
    in live captioning. The input must still be formatted as an srt. If
    a null character is received on the pipe The internal srt buffer is
    cleared. In this case the first srt timestamps after the null is
    assumed to be immediate, and captions begins with this text on the
    next frame.

Nifty, huh?

> and this page saying that the captions can be pushed via RTMP:
> https://ghuntley.com/notes/closed-captioning/ <https://ghuntley.com/notes/closed-captioning/>
> I know this is somewhat OT for ffmpeg, but can I push two RTMP streams to YouTube, one for the a/v, and one for the captions?

As far as I understand YouTube's docs, these methods are not supported.

> Back on-topic, given that libcaption exists, how difficult a task
> would it be to integrate support into ffmpeg? Is it just a matter of
> re-muxing the output from libcaption into the ffmpeg output stream?
> I’m not programmer, unfortunately, but I’m just trying to get a sense
> for the scope of the problem.

It has an MIT license, so its code  - or just the relevant parts, as
some of the code deals with demuxing/muxing (and with filtering
streams?) - could even be integrated into ffmpeg.


More information about the ffmpeg-user mailing list