[Libav-user] Encoding subtitles

Mihai Chindea mihai.chindea at uti.eu.com
Wed Nov 16 16:07:16 EET 2016

you are supposed to set "AVCodecContext::subtitle_header" before calling avcodec_open2()

From: Libav-user [libav-user-bounces at ffmpeg.org] on behalf of Jan Brehmer [Jan.Brehmer at dai-labor.de]
Sent: Wednesday, November 16, 2016 4:03 PM
To: libav-user at ffmpeg.org
Subject: [NEWSLETTER] [Libav-user] Encoding subtitles

Hey there!

I am trying to encode a subtitle stream.


Currently I am able to serve a HTTP stream in mpegts, fragmented mp4 or webm format with a video stream encoded by H.264 or VP8/VP9 respectively.

For subtitle encoding, I get an encoder like this:

subtitle_codec = avcodec_find_encoder(format_context->oformat->subtitle_codec);


subtitle_codec = avcodec_find_encoder("mov_text");

This works.

I create a new stream:

subtitle_stream = avformat_new_stream(format_context, subtitle_codec);

This works, too.

I open the codec:

avcodec_open2(subtitle_stream->codec, subtitle_codec, NULL);

This returns error code -1094995529?, which means AVERROR_INVALIDDATA?.

I tried loading some default values and setting the codec id before opening the codec:

avcodec_get_context_defaults3(subtitle_stream->codec, subtitle_codec);

subtitle_stream->codec->codec_id = subtitle_codec->id;


What am I doing wrong?

Is there any example code on this? Documentation? Ideas?

Thank you.


Libav-user mailing list
Libav-user at ffmpeg.org

More information about the Libav-user mailing list