[FFmpeg-devel] ffmpeg stuck in transcoding H264 using QSV

Chao Liu yijinliu at gmail.com
Tue Jul 26 09:08:27 EEST 2016

On Mon, Jul 25, 2016 at 11:04 PM, Chao Liu <yijinliu at gmail.com> wrote:

> Hi,
> (Ivan, I am sending this mail to you directly because you said you are the
> maintainer of QSV related code in a recent mail. Apologize if this is
> inappropriate.. )
> I am trying to use h264_qsv to transcode a MP4 file. This is my command:
> ffmpeg -c:v h264_qsv -i input.mp4 -look_ahead 0 -c:v h264_qsv -b:v 800k
> -maxrate 1600k -preset fast output.mp4
> It always stucks in this loop
> <https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/qsvenc.c#L970>.
> It works if I change the command to
> ffmpeg -i input.mp4 -look_ahead 0 -c:v h264_qsv -b:v 800k -maxrate 1600k
> -preset fast output.mp4
> (not using qsv for decoding).
> Looks like the decoding and encoding were contending for the resources and
> there is a deadlock or sth. like that..
> I tried to debug it a bit by comparing ffmpeg code with intel media SDK.
> There is sth. I don't understand. Not sure whether it's related..
> In ffmpeg, we decode the frame in a loop
> <https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/qsvdec.c#L357>,
> it sleeps and retries as long as MFXVideoDECODE_DecodeFrameAsync returns
> busy.
> In intel media SDK sample_decode, it calls SyncOperation when
> MFXVideoDECODE_DecodeFrameAsync returns busy.
Sorry, forgot to paste the link to the code

> Could this be the cause?

More information about the ffmpeg-devel mailing list