[FFmpeg-devel] Trouble with packet duplication/queue
Michael Niedermayer
michaelni at gmx.at
Thu Mar 22 03:51:21 CET 2012
On Wed, Mar 21, 2012 at 04:09:06PM -0600, Deron wrote:
>
> Trying to fix some odd bugs in the decklink patch I posted awhile
> ago. The last big one seems to be related to the way I am putting
> packets into the queue. I tried using the same basic code from
> ffplay and the various player demos, but they crash a violent death
> (double free).
>
> here is the code in question from ffplay that does not work for me:
>
> if (av_dup_packet(pkt) < 0)
> return -1;
>
> pkt1 = (AVPacketList*)av_malloc(sizeof(AVPacketList));
> if (!pkt1)
> return -1;
> pkt1->pkt = *pkt;
>
>
> if instead I do this in my code (more or less borrowed from
> avformat/utils.c as I recall):
>
> pkt1 = (AVPacketList *)av_malloc(sizeof(AVPacketList));
> if (!pkt1)
> return -1;
> pkt1->pkt = *pkt;
> pkt->destruct = NULL; // do not free original but
> only the copy
> /* duplicate the packet */
> if (av_dup_packet(&pkt1->pkt) < 0) {
> av_free(pkt1);
> return -1;
> }
>
>
> It works 99% of the time. In fact, it was working so well I thought
> all was well. Until I ran across a set of videos which have a
> _bunch_ of frame with just 75 samples. The audio is also being
> resampled from 30khz to 48khz with -ar 48000 in the ffmpeg line.
> This audio comes out as complete garbage (lot of stuttering noise),
> and sounds like the audio when I had the queue almost right. If I
> first reencode the video to 48k then is plays fine (but it also ends
> up with bigger frames of audio).
>
> So I guess the first question is what is the proper way to stuff a
> packet into a queue inside an avdevice encoder?
either you copy them or you have to implement something else in
interleave_packet()
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Old school: Use the lowest level language in which you can solve the problem
conveniently.
New school: Use the highest level language in which the latest supercomputer
can solve the problem without the user falling asleep waiting.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120322/d5876279/attachment.asc>
More information about the ffmpeg-devel
mailing list