Decode h263 stream using ffmpeg

For the developers that use FFmpeg in their software.
Post Reply
plobovikov
Posts: 2
Joined: Thu Dec 13, 2018 2:26 pm

Decode h263 stream using ffmpeg

Post by plobovikov » Tue Dec 18, 2018 12:04 pm

Hi folks!

I tried to decode h263 stream using ffmpeg, but I'm getting erros like:

Code: Select all

[h263 @ 0x28a9000] Bad picture start code
[h263 @ 0x28a9000] header damaged
But my h263 packets starts with 00000000 00000000 10000000 sequence (picture start code) !

Segment of my code:

Code: Select all

 AVCodec* vCodec = avcodec_find_decoder(coderParam.codecId);
    if (!vCodec)
    {
        DEBUG_VIDEO_DECODER("Start(): Input codec not found");
        return false;
    }

    AVCodecContextPtr vCodecCntx(avcodec_alloc_context3(vCodec));
    if (!vCodecCntx.get())
    {
        DEBUG_VIDEO_DECODER("Start(): Could not allocate input video codec context");
        return false;
    }

    vCodecCntx->width   = coderParam.width;
    vCodecCntx->height  = coderParam.height;
    //vCodecCntx->pix_fmt = coderParam.pxlFmt;
	
    vCodecCntx->sample_rate = coderParam.sampleRate;

   double framerate = 29.97 / 4.0;
	
    vCodecCntx->framerate.num = 1; 
    vCodecCntx->framerate.den = framerate;

    if (avcodec_open2(vCodecCntx.get(), vCodec, NULL) < 0)
    {
        DEBUG_VIDEO_DECODER("Start(): Could not open input codec");
        return false;
    }
     //frame is h263 packet with frameSize size
    AVPacket inputVideoPacket;
     av_new_packet(&inputVideoPacket, frameSize);
    memcpy(inputVideoPacket.data,frame, frameSize );
    inputVideoPacket.flags |= AV_PKT_FLAG_KEY;
    AVFrame* newFrame = av_frame_alloc();

    int decodedLength =
        avcodec_decode_video2(vCodecCntx.get(), newFrame, gotPictureFlag, inputVideoPacket);
Please, help!

Thanks

Post Reply
'