[Libav-user] libav output into a byte array

francesco at bltitalia.com francesco at bltitalia.com
Tue Jan 10 12:05:15 CET 2012


At 14.39 10/01/2012 +0530, you wrote:
>Hi,
>
>What are all the different ways i can produce the output by using libav
>libraries . some of the ways i knew is unix stdout, into a file, rtp.
>
>How can i use some shared buffer? or bytes array
>
>Thanks
>
>
>
>__________ Informazioni da ESET NOD32 Antivirus, versione del database
delle firme digitali 6777 (20120108) __________
>
>Il messaggio è stato controllato da ESET NOD32 Antivirus.
>
>www.nod32.it
>
>Hi,<br><br>What are all the different ways i can produce the output by
using libav libraries . some of the ways i knew is unix stdout, into a file,
rtp. <br><br>How can i use some shared buffer? or bytes array <br><br>Thanks<br>
>_______________________________________________
>Libav-user mailing list
>Libav-user at ffmpeg.org
>http://ffmpeg.org/mailman/listinfo/libav-user
>
>
>
>__________ Informazioni da ESET NOD32 Antivirus, versione del database
delle firme digitali 6777 (20120108) __________
>
>Il messaggio è stato controllato da ESET NOD32 Antivirus.
>
>www.nod32.it
>
>
I took access directly to buffer, here is how:

      while (!frameFinished) {
      // Decode video frame
       err = avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished,&packet);
       Sleep(1);
       Application->ProcessMessages();
       }
       if(err<0) { Memo1->Lines->Add("Error returned from
avcodec_decode_video2, exited"); goto end_conv;}

      if(frameFinished)
      {
        ofile = "reconv_Y.raw";
        hDstLuma=CreateFile(ofile.c_str(),GENERIC_READ|GENERIC_WRITE,0,NULL,
CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
        if(hDstLuma==INVALID_HANDLE_VALUE ) {Memo1->Lines->Add("Error
creating luma output file"); goto end_conv1;}

        ofile = "reconv_U.raw";
        hDstCr1=CreateFile(ofile.c_str(),GENERIC_READ|GENERIC_WRITE,0,NULL,C
REATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
        if(hDstCr1==INVALID_HANDLE_VALUE ) {Memo1->Lines->Add("Error
creating Cr1 output file"); goto end_conv1;}

        ofile = "reconv_V.raw";
        hDstCr2=CreateFile(ofile.c_str(),GENERIC_READ|GENERIC_WRITE,0,NULL,C
REATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
        if(hDstCr2==INVALID_HANDLE_VALUE ) {Memo1->Lines->Add("Error
creating Cr2 output file"); goto end_conv1;}


        for(i=0;i<pCodecCtx->height;i++)
        {
          WriteFile(hDstLuma,pFrame->data[0]+i*pFrame->linesize[0],pCodecCtx
->width,&BytesRead,NULL);
          WriteFile(hDstCr1,pFrame->data[1]+i*pFrame->linesize[1],pCodecCtx-
>width/2,&BytesRead,NULL);
          WriteFile(hDstCr2,pFrame->data[2]+i*pFrame->linesize[2],pCodecCtx-
>width/2,&BytesRead,NULL);

        }

         Memo1->Lines->Add("File decompressed");
      }

in this way I save in three file the three components (Y,Cr1 and Cr2) of a
frame coded in 4:2:2 format.
I hope this help you
best regards



More information about the Libav-user mailing list