[Libav-user] Problem using avcodec_decode_video2 solely? How to set qscale?

wl2776 wl2776 at gmail.com
Fri Oct 21 09:11:09 CEST 2011

Hi all.
I am involved in the project, using libav to decode video.
It uses its own code to parse video streams and avcodec_decode_video2 for
Currently, it would require too much effort to switch to libav parsing, so
I'd like to leave it as it is, just do some tuning of the AVCodecContext.

My problem is the fact that the MPEG-4 part 2 decoder doesn't decode all
video frames starting from the key one, while ffplay seems to be doing that.
I am using windows build of the git d049257 commit (2011-10-19).

The decoder is initialized as following 

Then I turn on debug information

When my application receives I-frame, having 00 in the vop_coding_type
field, call to avcodec_decode_video2() returns -1 and causes the following
debug messages:

Then, after my player receives some amount of data, I see that qp value
becomes 5 instead of 17 and it starts decoding and showing video frames.
I've observed other values of qp: 8 and 1.
ffplay always shows qp = 5 

So, could anyone give me a hint on how to make avcodec_decode_video2
consider qp = 5?
I understand that this value of 5 could be correct only for that particular
video stream
Unfortunately, my knowledge of mpeg-4 is very vague.

How can I calculate the correct qscale (QP) value and feed it in the

I've studied sources and have seen that this value is stored in the internal
structure, which is inaccessible from outside.

View this message in context: http://libav-users.943685.n4.nabble.com/Problem-using-avcodec-decode-video2-solely-How-to-set-qscale-tp3924492p3924492.html
Sent from the libav-users mailing list archive at Nabble.com.

More information about the Libav-user mailing list