Thank you. I will dig into this solution. In parallel I found an example on how to setup a callback with buffer data. https://gist.github.com/AlexVestin/15b90d72f51ff7521cd7ce4b70056dff
Den tor. 21. maj 2020 kl. 05.17 skrev Richard Hussong <[email protected] >: > > > On Wed, May 20, 2020 at 10:10 AM Jesper Taxbøl <[email protected]> wrote: > >> Hi, >> >> I am using libavformat to encapsulate video and audio in a mpegts >> container. >> >> I have it working when I outputting to a file, but I need the data in >> memory for further distribution. >> >> I have been seeking for a callback or some other way to extract the bytes >> normally is written to the output file. >> >> How would I go about outputting the data to memory instead? >> > > 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: > > // Create a dynamic buffer for your AVFormatContext and do some writes. > avio_open_dyn_buf(&avContext->pb); > av_write_frame(avContext, ...); > ... > // Get the buffer contents and length, and do what you like with them. > uint8_t *buffer = 0; > int nbytes = avio_close_dyn_buf(&avContext->pb, &buffer); > if (nbytes > 0) { > // whatever > } > av_free(buffer); > > You need to do this little dance for each block of output data you want to > process. > > - Richard > > >> Kind regards >> >> Jesper >> >> _______________________________________________ >> Libav-user mailing list >> [email protected] >> https://ffmpeg.org/mailman/listinfo/libav-user >> >> To unsubscribe, visit link above, or email >> [email protected] with subject "unsubscribe". > > _______________________________________________ > Libav-user mailing list > [email protected] > https://ffmpeg.org/mailman/listinfo/libav-user > > To unsubscribe, visit link above, or email > [email protected] with subject "unsubscribe". -- Jesper Taxbøl +45 61627501
_______________________________________________ Libav-user mailing list [email protected] https://ffmpeg.org/mailman/listinfo/libav-user To unsubscribe, visit link above, or email [email protected] with subject "unsubscribe".
