[FFmpeg-user] av_video_decode2 returns -1094995529 .

kifayat ullah kifayat.ullah at yahoo.com
Fri May 23 17:08:06 CEST 2014


There are two things that you need to keep in mind.
1. When packet is read and put it in Queue should not be freed until is been used by decoding thread, however if you are freeing that packet soon after putting into queue using av_packet_free you must create a duplicate using av_dup_packet() of the packet before pushing it to Queue, which will extend its life.
2. Ideally your reading thread should only read and allocate packets. your consumer thread should use these packets i.e. for decoding and 
 than free them.
Hope it will help.
- Regards KU
On Friday, 23 May 2014, 15:50, sithruk sana <get2jils at gmail.com> wrote:
 


I am developing rtsp streaming player, and followed the below approach.



*1) Read packet, decode, display -> works perfectly.*

           while (1) {
                   if ( av_read_frame(pFormatCtx, &packet) >= 0) {
                           if (packet.stream_index == videoStream) {
                                   retDecoder =
avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);
                                   if  ( retDecoder <= 0)
                                        LOGD (" Unable to Decode...retval
%d ", retDecoder);
                                   if (frameFinished) {
                                   }
                           }
                                av_free_packet (&packet);
                   }
           }




Whereas,


*I introduced 2 thread, one is reading and pushing into the LIst. and the
second one is reading from the queue. *
My problem is while reading the same packet, and decode, i m unable to
decode, the return value of the
*av_video_decode2 is -1094995529 .*
Below is the short description of code.  Kindly help to solve this issue?.



AVPacketList *firstNode=NULL, *lastNode=NULL;


int pushPacket (AVPacket * pkt)
{
        AVPacketList *newNode = av_malloc(sizeof(AVPacketList));
        newNode->pkt = *pkt;     // IS IT OK ?
        newNode->next = NULL;

        SDL_LockMutex (rwMutex);

        if (lastNode != NULL )  {
                lastNode->next = newNode;
                lastNode = newNode;
        } else {
             firstNode = lastNode = newNode;
        }

SDL_UnlockMutex (rwMutex);

}




int pullPacket ()
{

        AVPacketList *tempNode;
        AVPacket *pkt;
        int res=0;

        SDL_LockMutex (rwMutex);

                if ( firstNode != NULL ) {
                        tempNode = firstNode;
                        *pkt = tempNode->pkt;
                           res = avcodec_decode_video2(pCodecCtx, pFrame,
&frameFinished, pkt);  // HERE IS THE PROBLEM.
                           if (frameFinished) {
                                        LOGD (" fRAME DECODED.. %d \n",
counter++);
                                }


                        if (firstNode->next != NULL) {
                                firstNode = firstNode->next;
                        }
                        else {
                                firstNode = NULL;
                                lastNode = NULL;
                        }
                        av_free (tempNode);
                }

}


In Thread 1:

int PacketReader (void *ptr)
{
        AVPacket pkt1, *rpacket;
        rpacket = &pkt1;
        while (globalQuit != 0)  {

                if ( av_read_frame(pFormatCtx, rpacket) >= 0) {

                        if (packet.stream_index == videoStream) {
                                pushPacket (rpacket);
                                }
                                av_free_packet(rpacket);
                        }

                }

}


In thread 2:

while (1) {
   pullPacket ();
}
_______________________________________________
ffmpeg-user mailing list
ffmpeg-user at ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user


More information about the ffmpeg-user mailing list