[FFmpeg-user] av_video_decode2 returns -1094995529 .

sithruk sana get2jils at gmail.com
Fri May 23 16:50:46 CEST 2014


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 ();
}


More information about the ffmpeg-user mailing list