[Libav-user] How To Duplicate AVPacket

Xiemin Chen chenxiemin at gmail.com
Thu Jun 26 02:46:59 CEST 2014


Dear all:
    I want to split av_read_frame() and avcodec_decode_video2() in to
different thread so I need to put a queue behind them. av_read_frame() read
a packet then put the packet into queue, avcodec_decode_video2() read a
packet from the queue then decode.
    But sometimes the decoded frames may contain rubbish, it's random. So I
think that AVPacket shares its data memory and overwrite by somebody before
I decode it. The following code like this:
         1. av_read_frame(&packet);
         2.     av_dup_packet(&packet);
         3.     AVPacket *newPakcet = av_malloc(sizeof(AVPacket));
         4.     *newPacket = packet;
         5.  put_queue(packet);
         6.  get_queue(&packet); (Another thread)
         7.  avcodec_decode_video2(packet, &frame);
         8.  show frame;
    Is there any mistake I took on these codes? Thanks very much.

Sincerely
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20140625/b087de60/attachment.html>


More information about the Libav-user mailing list