<div dir="ltr">update: I found out what was giving the segmentation fault, I simply forgot to do an avcodec_open2 on the output codec.<div>Now encoding to ASS format works fine, but SRT gives me no error, but no output either (avcodec_encode_subtitle returns 0).</div>

<div>I guess it should have something to do with the AVCodecContext configuration, but without an example, it's hard to find out what exactly is the problem..</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">

On Mon, Sep 23, 2013 at 2:04 PM, Marco Gulino <span dir="ltr"><<a href="mailto:marco.gulino@gmail.com" target="_blank">marco.gulino@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="HOEnZb"><div class="h5"><div dir="ltr"><div class="gmail_quote"><div dir="ltr"><div><div><div><div>Hello!<br></div>I'm pretty new to libav* development, and I'm mostly a c++ developer, not C, so forgive me if I might ask dumb questions.<br>


<br></div>What I'm trying to achieve is to open a media file and extract a subtitle track.<br>
</div>Possibly in memory, but using a temp output file would be acceptable.<br><br></div><div>I did read the muxing/demuxing c examples, and following them I'm already able to open the file, detect all streams, and decode the subtitle packets, but I'm stuck in the "reencode" part.<br>



</div><div>There is an "avcodec_encode_subtitle<span>" API, which seems undocumented (there's an unofficial doc here, though: <a href="http://wiki.aasimon.org/doku.php?id=ffmpeg:avcodec_encode_subtitle" target="_blank">http://wiki.aasimon.org/doku.php?id=ffmpeg:avcodec_encode_subtitle</a> ).<br>



</span></div><div><span>You can see my code here: <a href="http://pastebin.com/cUxCs33a" target="_blank">http://pastebin.com/cUxCs33a</a> .<br></span></div><div><span>It's just a spike of course, quick & dirty... If I comment out the </span><br>



avcodec_encode_subtitle<span> line everything runs just fine, and I can even see the subtitle lines if I print pkt.data.<br></span></div><div><span>the </span>avcodec_encode_subtitle<span></span> however, when called, always gives me a segmentation fault.<br>



</div><div>Also, it's not clear how to save the buffer data to the newly created stream (though maybe I won't need it, if the buffer will contain the raw srt data).<br><br></div><div>Thanks!<span><font color="#888888"><br>


</font></span></div><span><font color="#888888"><div>Marco<br>
</div></font></span></div>
</div><br></div>
</div></div></blockquote></div><br></div>