[Libav-user] Decoding/encoding api
Timur Guseynov
s1.sam.1.93 at gmail.com
Fri Sep 16 13:26:12 EEST 2016
So I can write something like this and it would be ok?
AVCodecContext *codecContext;
AVPacket *packet;
AVFrame *frame;
// allocating codec context, getting packet
.................................
//
avcodec_send_packet(codecContext, packet);
while(avcodec_receive_frame(codecContext, frame) == 0)
{
av_frame_unref(frame);
}
пт, 16 сент. 2016 г. в 2:26, Steve <musicspeedchanger at gmail.com>:
> 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.
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160916/7a0fcf9d/attachment.html>
More information about the Libav-user
mailing list