[FFmpeg-user] Decoding raw h264 frame using libavcodec

Imran Khan imranhkhan1989 at gmail.com
Sun Feb 3 13:30:24 CET 2013


Hello All

I am trying to decode raw h264 frames that I got from h264 encoder. I have
create decoder context by setting width , height and pixel format. when i
am passing the frame array in avcodec_decode_video2() method it is not
decompressing the frame. the program  shows same size for decoded frame and
encoded frame. Can anyone tell me the way I am creating AVCodecContext for
decoder is correct or not.

this is how I have created AVCodecContext...

       AVCodecContext avctx;

AVCodec* codec;

av_init_packet(&avpkt);

codec = avcodec_find_decoder(codec_id);

if(!codec){

return "codec not found";


}

avctx = avcodec_alloc_context3(codec);

if(!avctx){

return "can not allocate avcontext :: avocdec_alloc_context";

}

avctx->width=640;
 avctx->height=480;

avctx->pix_fmt=AV_PIX_FMT_YUV420P;

error = avcodec_open2(avctx ,codec ,NULL);

if(error < 0 ){
 return "can not open codec :: avcodec_open2";
 }

what are other option that I should set to decode the raw frames.


More information about the ffmpeg-user mailing list