[Libav-user] Decoding/encoding api
Steve
musicspeedchanger at gmail.com
Fri Sep 16 02:22:36 EEST 2016
Timur Guseynov wrote
> I'm a bit confused with decoding/encoding api. I've read this
> <https://ffmpeg.org/doxygen/3.1/group__lavc__encdec.html>
> documentation and
> it says "Receive output in a loop. Periodically call one of the
> avcodec_receive_*()...".
>
> avcodec_receive_frame() docs say "the function will always call
> av_frame_unref(frame) before doing anything else." The same goes for
> avcodec_receive_packet().
>
> So, for example, I will write such code:
>
> AVCodecContext *codecContext;
> AVPacket *packet;
> AVFrame *frame;
> // allocating codec context, getting packet
> .................................
> //
> avcodec_send_packet(codecContext, packet);
> while(avcodec_receive_frame(codecContext, frame) == 0)
> {
> }
>
> Will this code be functioning right?
>
> _______________________________________________
> Libav-user mailing list
> Libav-user@
> http://ffmpeg.org/mailman/listinfo/libav-user
The doc for avcodec_receive_packet has you need to check a typo, it calls
av_packet_unref. This is just convenience, you would have to call
av_packet_unref or av_frame_unref yourself otherwise on each turn.
Your code would be ok but you need to call av_packet_unref at the end
because you retain ownership of the packet.
--
View this message in context: http://libav-users.943685.n4.nabble.com/Libav-user-Decoding-encoding-api-tp4662664p4662672.html
Sent from the libav-users mailing list archive at Nabble.com.
More information about the Libav-user
mailing list