[Libav-user] avcodec_decode_video2 decode h264 file return -1

曲亚东 quyadong at hotmail.com
Tue Nov 15 04:25:11 CET 2011

Recently I investigate this issue further. The profile of this h264 video is main, not baseline. Using avcodec_decode_video
with old avcodec library can parse this file, but avcodec_decode_video2 can't. I have read the following thread, but it can't solve my question. http://ffmpeg.arrozcru.org/forum/viewtopic.php?f=8&t=1512
 Can you please give me a hint? 
Thank you a lot !
From: quyadong at hotmail.com
To: libav-user at ffmpeg.org
Date: Wed, 9 Nov 2011 15:32:24 +0800
Subject: [Libav-user] avcodec_decode_video2 decode h264 file return -1

hi all,
I write a H264
decode program referring to the following link:
Because I use the FFmpeg 0.8.6, I change this sample from avcodec_decode_video to avcodec_decode_video2, just like the following codes:
AVPacket g_avpkt;

bool GetNextFrame(AVFormatContext *pFormatCtx, AVCodecContext *pCodecCtx, int videoStream, AVFrame *pFrame)


if(av_read_frame(pFormatCtx, &g_avpkt)<0)    bytesDecoded=avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &g_avpkt);

Firstly av_read_frame
read some data from an h264 file(D1), but avcodec_decode_video2 always
return with -1. I have tried these code with h264 file(safe), it is ok. How to use avcodec_decode_video2 to decode h264 files correctly? Thanks a lot.  

Libav-user mailing list
Libav-user at ffmpeg.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20111115/a389d81c/attachment.html>

More information about the Libav-user mailing list