<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 20, 2020 at 10:10 AM Jesper Taxbøl <<a href="mailto:jesper@taxboel.dk" target="_blank">jesper@taxboel.dk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi,</div><div><br></div><div>I am using libavformat to encapsulate video and audio in a mpegts container. </div><div><br></div><div>I have it working when I outputting to a file, but I need the data in memory for further distribution. </div><div><br></div><div>I have been seeking for a callback or some other way to extract the bytes normally is written to the output file.</div><div><br></div><div>How would I go about outputting the data to memory instead?</div></div></blockquote><div><br></div><div>Use avio_open_dyn_buf and avio_close_dyn_buf to get libavformat to write to a buffer and return the buffer address. The usual way to do it is:</div><div><br></div><div>// Create a dynamic buffer for your AVFormatContext and do some writes.</div><div>avio_open_dyn_buf(&avContext->pb);<br></div><div>av_write_frame(avContext, ...);</div><div>...</div><div>// Get the buffer contents and length, and do what you like with them.</div><div>uint8_t *buffer = 0;</div><div>int nbytes = avio_close_dyn_buf(&avContext->pb, &buffer);</div><div>if (nbytes > 0) {</div><div> // whatever</div><div>}</div><div>av_free(buffer);</div><div><br></div><div>You need to do this little dance for each block of output data you want to process.</div><div><br></div><div>- Richard</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>Kind regards</div><div><br></div><div>Jesper</div><div dir="ltr"><br></div></div>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".</blockquote></div></div>