[FFmpeg-user] how to use Intel qsv codec for ffmpeg 4.0

Dennis Mungai dmngaie at gmail.com
Wed Jun 20 09:03:09 EEST 2018


Also, one question to the OP:

What version/variant of the Media SDK did you use to build FFmpeg?
Is it the one issued in the licensed Media SDK or the opensource iMSDK (see
https://github.com/Intel-Media-SDK/MediaSDK)?

Either way, you may need to insert a hwupload filter into the video filters
with a fixed frame pool size, as shown below:

ffmpeg -hwaccel qsv -vcodec h264_qsv -i input-file -acodec aac -ac 2 -b:a
48k -vcodec h264_qsv -b:v 2000k -vf
"hwupload=extra_hw_frames=10,scale_qsv=960:720" -g 25 -r 25.0 -f flv
output-file

Should that bring you any issues (such as a fallback to software-based
encoding), you may also pick up the h/w device for qsv as shown below:

ffmpeg -init_hw_device qsv=qsv:MFX_IMPL_hw_any -hwaccel qsv
-filter_hw_device qsv -vcodec h264_qsv -i input-file -acodec aac -ac 2 -b:a
48k -vcodec h264_qsv -b:v 2000k -vf
"hwupload=extra_hw_frames=10,scale_qsv=960:720" -g 25 -r 25.0 -f flv
output-file

See that with the second command:

(a). We initialize a hwaccel device named qsv, picking the IMPL_hw_any qsv
platform device, and

(b). Specify that we want to use that device for both hwaccel (-hwaccel
qsv) and for the video filter chain (-filter_hw_device qsv).

(c). The extra_hw_frames=n option is used to set an initial pool size.

If it's feeding into a scaler, then probably 2 or 3 frames are sufficient,
but if it's feeding into an encoder with look-ahead enabled (LA-BRC with
target usage equivalent of 1), then you might need over 100. As such, it's
currently under user control.

Test and report back.



On 20 June 2018 at 08:40, Li, Zhong <zhong.li at intel.com> wrote:

> Looks like qsv transcoding on system memory is broken.
> Would you please create a ticket on https://trac.ffmpeg.org/?
>
> And for you case, switching to full hardware path is benefit to
> performance.
> Try: ffmpeg -hwaccel qsv -vcodec h264_qsv -i input-file -acodec aac -ac 2
> -b:a 48k -vcodec h264_qsv -b:v 2000k -vf " scale_qsv=960:720" -g 25 -r 25.0
> -f flv output-file
>
>
> > -----Original Message-----
> > From: ffmpeg-user [mailto:ffmpeg-user-bounces at ffmpeg.org] On Behalf Of
> > qw
> > Sent: Wednesday, June 20, 2018 10:17 AM
> > To: FFmpeg user questions <ffmpeg-user at ffmpeg.org>
> > Subject: Re: [FFmpeg-user] how to use Intel qsv codec for ffmpeg 4.0
> >
> > Hi,
> >
> >
> > I use the following ffmpeg command, and it's ok for ffmpeg 3.4.1.
> >
> >
> > /usr/local/bin/ffmpeg -vcodec h264_qsv -i input-file -acodec aac -ac 2
> -b:a
> > 48k -vcodec h264_qsv -b:v 2000k -vf "scale=960:720" -g 25 -r 25.0 -f flv
> > output-file
> >
> >
> > But the command fails for ffmpeg 4.0. The error message is shown as
> below:
> >
> >
> > ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers
> >   built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-16)
> >   configuration: --prefix=/usr/local --enable-nonfree --enable-static
> > --enable-libmfx --enable-gpl
> >   libavutil      56. 14.100 / 56. 14.100
> >   libavcodec     58. 18.100 / 58. 18.100
> >   libavformat    58. 12.100 / 58. 12.100
> >   libavdevice    58.  3.100 / 58.  3.100
> >   libavfilter     7. 16.100 /  7. 16.100
> >   libswscale      5.  1.100 /  5.  1.100
> >   libswresample   3.  1.100 /  3.  1.100
> >   libpostproc    55.  1.100 / 55.  1.100
> > Input #0, flv, from './1.flv':
> >   Metadata:
> >     jd-6cn-test     : hello jdcloud
> >     hasMetadata     : true
> >     hasVideo        : true
> >     hasAudio        : true
> >     lasttimestamp   : 33
> >     lastkeyframetimestamp: 33
> >     videosize       : 8229939
> >     audiosize       : 526094
> >     datasize        : 848
> >     metadatacreator : flvmeta 1.2.1
> >     audiodelay      : 0
> >     canSeekToEnd    : true
> >     hasCuePoints    : false
> >     hasKeyframes    : true
> >   Duration: 00:00:32.60, start: 0.040000, bitrate: 2151 kb/s
> >     Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive),
> > 1920x1080 [SAR 1:1 DAR 16:9], 2017 kb/s, 25 fps, 25 tbr, 1k tbn, 50 tbc
> >     Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp, 124 kb/s File
> > './ffmpeg_qsv_transcoder_1.flv' already exists. Overwrite ? [y/N] y
> Stream
> > mapping:
> >   Stream #0:0 -> #0:0 (h264 (h264_qsv) -> h264 (h264_qsv))
> >   Stream #0:1 -> #0:1 (aac (native) -> aac (native)) Press [q] to stop,
> [?] for
> > help [h264_qsv @ 0x2032e80] Error initializing the MFX video decoder: not
> > initialized (-8) Error while decoding stream #0:0: Internal bug, should
> not
> > have happened [h264_qsv @ 0x2032e80] Error initializing the MFX video
> > decoder: not initialized (-8) Error while decoding stream #0:0: Internal
> bug,
> > should not have happened [h264_qsv @ 0x2032e80] Error initializing the
> > MFX video decoder: not initialized (-8) Error while decoding stream #0:0:
> > Internal bug, should not have happened [h264_qsv @ 0x2032e80] Error
> > initializing the MFX video decoder: not initialized (-8) Error while
> decoding
> > stream #0:0: Internal bug, should not have happened [h264_qsv @
> > 0x2032e80] Error initializing the MFX video decoder: not initialized
> (-8) Error
> > while decoding stream #0:0: Internal bug, should not have happened
> > [h264_qsv @ 0x2032e80] Error initializing the MFX video decoder: not
> > initialized (-8) Error while decoding stream #0:0: Internal bug, should
> not
> > have happened [h264_qsv @ 0x2032e80] Error initializing the MFX video
> > decoder: not initialized (-8) Error while decoding stream #0:0: Internal
> bug,
> > should not have happened [h264_qsv @ 0x2032e80] Error initializing the
> > MFX video decoder: not initialized (-8) Error while decoding stream #0:0:
> > Internal bug, should not have happened [h264_qsv @ 0x2032e80] Error
> > initializing the MFX video decoder: not initialized (-8) Error while
> decoding
> > stream #0:0: Internal bug, should not have happened [h264_qsv @
> > 0x2032e80] Error initializing the MFX video decoder: not initialized
> (-8) Error
> > while decoding stream #0:0: Internal bug, should not have happened
> > [h264_qsv @ 0x2032e80] Error initializing the MFX video decoder: not
> > initialized (-8) Error while decoding stream #0:0: Internal bug, should
> not
> > have happened [h264_qsv @ 0x2032e80] Error initializing the MFX video
> > decoder: not initialized (-8) Error while decoding stream #0:0: Internal
> bug,
> > should not have happened [h264_qsv @ 0x2032e80] Error initializing the
> > MFX video decoder: not initialized (-8) Error while decoding stream #0:0:
> > Internal bug, should not have happened [h264_qsv @ 0x2032e80] Error
> > initializing the MFX video decoder: not initialized (-8) Error while
> decoding
> > stream #0:0: Internal bug, should not have happened [h264_qsv @
> > 0x2032e80] Error initializing the MFX video decoder: not initialized
> (-8) Error
> > while decoding stream #0:0: Internal bug, should not have happened
> > [h264_qsv @ 0x2032e80] Error initializing the MFX video decoder: not
> > initialized (-8) Error while decoding stream #0:0: Internal bug, should
> not
> > have happened [h264_qsv @ 0x2032e80] Error initializing the MFX video
> > decoder: not initialized (-8) Error while decoding stream #0:0: Internal
> bug,
> > should not have happened [h264_qsv @ 0x2032e80] Error initializing the
> > MFX video decoder: not initialized (-8) Error while decoding stream #0:0:
> > Internal bug, should not have happened [h264_qsv @ 0x2032e80] Error
> > initializing the MFX video decoder: not initialized (-8) Error while
> decoding
> > stream #0:0: Internal bug, should not have happened [h264_qsv @
> > 0x2032e80] Error initializing the MFX video decoder: not initialized
> (-8) Error
> > while decoding stream #0:0: Internal bug, should not have happened
> > [h264_qsv @ 0x2032e80] Error initializing the MFX video decoder: not
> > initialized (-8) Error while decoding stream #0:0: Internal bug, should
> not
> > have happened [h264_qsv @ 0x2032e80] Error initializing the MFX video
> > decoder: not initialized (-8) Error while decoding stream #0:0: Internal
> bug,
> > should not have happened [h264_qsv @ 0x2032e80] Error initializing the
> > MFX video decoder: not initialized (-8) Error while decoding stream #0:0:
> > Internal bug, should not have happened [h264_qsv @ 0x2032e80] Error
> > initializing the MFX video decoder: not initialized (-8) Error while
> decoding
> > stream #0:0: Internal bug, should not have happened [h264_qsv @
> > 0x2032e80] Error initializing the MFX video decoder: not initialized
> (-8) Error
> > while decoding stream #0:0: Internal bug, should not have happened
> > [h264_qsv @ 0x2032e80] Error initializing the MFX video decoder: not
> > initialized (-8) Error while decoding stream #0:0: Internal bug, should
> not
> > have happened [h264_qsv @ 0x2032e80] Error initializing the MFX video
> > decoder: not initialized (-8) Error while decoding stream #0:0: Internal
> bug,
> > should not have happened [h264_qsv @ 0x2032e80] Error initializing the
> > MFX video decoder: not initialized (-8) Error while decoding stream #0:0:
> > Internal bug, should not have happened [h264_qsv @ 0x2032e80] Error
> > initializing the MFX video decoder: not initialized (-8) Error while
> decoding
> > stream #0:0: Internal bug, should not have happened [h264_qsv @
> > 0x2032e80] Error initializing the MFX video decoder: not initialized
> (-8) Error
> > while decoding stream #0:0: Internal bug, should not have happened
> > [h264_qsv @ 0x2032e80] Error initializing the MFX video decoder: not
> > initialized (-8) Error while decoding stream #0:0: Internal bug, should
> not
> > have happened [h264_qsv @ 0x2032e80] Error initializing the MFX video
> > decoder: not initialized (-8) Error while decoding stream #0:0: Internal
> bug,
> > should not have happened [h264_qsv @ 0x2032e80] Error initializing the
> > MFX video decoder: not initialized (-8) Error while decoding stream #0:0:
> > Internal bug, should not have happened [h264_qsv @ 0x2032e80] Error
> > initializing the MFX video decoder: not initialized (-8) Error while
> decoding
> > stream #0:0: Internal bug, should not have happened [h264_qsv @
> > 0x2032e80] Error initializing the MFX video decoder: not initialized
> (-8) Error
> > while decoding stream #0:0: Internal bug, should not have happened
> > [h264_qsv @ 0x2032e80] Error initializing the MFX video decoder: not
> > initialized (-8) Error while decoding stream #0:0: Internal bug, should
> not
> > have happened [h264_qsv @ 0x2032e80] Error initializing the MFX video
> > decoder: not initialized (-8) Error while decoding stream #0:0: Internal
> bug,
> > should not have happened [h264_qsv @ 0x2032e80] Error initializing the
> > MFX video decoder: not initialized (-8) Error while decoding stream #0:0:
> > Internal bug, should not have happened [h264_qsv @ 0x2032e80] Error
> > initializing the MFX video decoder: not initialized (-8) Error while
> decoding
> > stream #0:0: Internal bug, should not have happened [h264_qsv @
> > 0x2032e80] Error initializing the MFX video decoder: not initialized
> (-8) Error
> > while decoding stream #0:0: Internal bug, should not have happened
> > [h264_qsv @ 0x2032e80] Error initializing the MFX video decoder: not
> > initialized (-8) Error while decoding stream #0:0: Internal bug, should
> not
> > have happened [h264_qsv @ 0x2032e80] Error initializing the MFX video
> > decoder: not initialized (-8) Error while decoding stream #0:0: Internal
> bug,
> > should not have happened [h264_qsv @ 0x2032e80] Error initializing the
> > MFX video decoder: not initialized (-8) Error while decoding stream #0:0:
> > Internal bug, should not have happened [h264_qsv @ 0x2032e80] Error
> > initializing the MFX video decoder: not initialized (-8) Error while
> decoding
> > stream #0:0: Internal bug, should not have happened [h264_qsv @
> > 0x2032e80] Error initializing the MFX video decoder: not initialized
> (-8) Error
> > while decoding stream #0:0: Internal bug, should not have happened
> > [h264_qsv @ 0x2032e80] Error initializing the MFX video decoder: not
> > initialized (-8) Error while decoding stream #0:0: Internal bug, should
> not
> > have happened [h264_qsv @ 0x2032e80] Error initializing the MFX video
> > decoder: not initialized (-8) Error while decoding stream #0:0: Internal
> bug,
> > should not have happened [h264_qsv @ 0x2032e80] Error initializing the
> > MFX video decoder: not initialized (-8) Error while decoding stream #0:0:
> > Internal bug, should not have happened [h264_qsv @ 0x2032e80] Error
> > initializing the MFX video decoder: not initialized (-8) Error while
> decoding
> > stream #0:0: Internal bug, should not have happened [h264_qsv @
> > 0x2032e80] Error initializing the MFX video decoder: not initialized
> (-8) Error
> > while decoding stream #0:0: Internal bug, should not have happened
> > [h264_qsv @ 0x2032e80] Error initializing the MFX video decoder: not
> > initialized (-8) Error while decoding stream #0:0: Internal bug, should
> not
> > have happened [h264_qsv @ 0x2032e80] Error initializing the MFX video
> > decoder: not initialized (-8) Error while decoding stream #0:0: Internal
> bug,
> > should not have happened [h264_qsv @ 0x2032e80] Error initializing the
> > MFX video decoder: not initialized (-8) Error while decoding stream #0:0:
> > Internal bug, should not have happened [h264_qsv @ 0x2032e80] Error
> > initializing the MFX video decoder: not initialized (-8) Error while
> decoding
> > stream #0:0: Internal bug, should not have happened [h264_qsv @
> > 0x2032e80] Error initializing the MFX video decoder: not initialized
> (-8) Error
> > while decoding stream #0:0: Internal bug, should not have happened
> > [h264_qsv @ 0x2032e80] Error initializing the MFX video decoder: not
> > initialized (-8) Error while decoding stream #0:0: Internal bug, should
> not
> > have happened [h264_qsv @ 0x2032e80] Error initializing the MFX video
> > decoder: not initialized (-8) Error while decoding stream #0:0: Internal
> bug,
> > should not have happened [h264_qsv @ 0x2032e80] Error initializing the
> > MFX video decoder: not initialized (-8) Error while decoding stream #0:0:
> > Internal bug, should not have happened [h264_qsv @ 0x2032e80] Error
> > initializing the MFX video decoder: not initialized (-8) Error while
> decoding
> > stream #0:0: Internal bug, should not have happened [h264_qsv @
> > 0x2032e80] Error initializing the MFX video decoder: not initialized
> (-8) Error
> > while decoding stream #0:0: Internal bug, should not have happened
> > [h264_qsv @ 0x2032e80] Error initializing the MFX video decoder: not
> > initialized (-8) Error while decoding stream #0:0: Internal bug, should
> not
> > have happened [h264_qsv @ 0x2032e80] Error initializing the MFX video
> > decoder: not initialized (-8) Error while decoding stream #0:0: Internal
> bug,
> > should not have happened [h264_qsv @ 0x2032e80] Error initializing the
> > MFX video decoder: not initialized (-8) Error while decoding stream #0:0:
> > Internal bug, should not have happened [h264_qsv @ 0x2032e80] Error
> > initializing the MFX video decoder: not initialized (-8) Error while
> decoding
> > stream #0:0: Internal bug, should not have happened [h264_qsv @
> > 0x2032e80] Error initializing the MFX video decoder: not initialized
> (-8) Error
> > while decoding stream #0:0: Internal bug, should not have happened
> > [h264_qsv @ 0x2032e80] Error initializing the MFX video decoder: not
> > initialized (-8) Error while decoding stream #0:0: Internal bug, should
> not
> > have happened [h264_qsv @ 0x2032e80] Error initializing the MFX video
> > decoder: not initialized (-8) Error while decoding stream #0:0: Internal
> bug,
> > should not have happened [h264_qsv @ 0x2032e80] Error initializing the
> > MFX video decoder: not initialized (-8) Error while decoding stream #0:0:
> > Internal bug, should not have happened [h264_qsv @ 0x2032e80] Error
> > initializing the MFX video decoder: not initialized (-8) Error while
> decoding
> > stream #0:0: Internal bug, should not have happened [h264_qsv @
> > 0x2032e80] Error initializing the MFX video decoder: not initialized
> (-8) Error
> > while decoding stream #0:0: Internal bug, should not have happened
> > [h264_qsv @ 0x2032e80] Error initializing the MFX video decoder: not
> > initialized (-8) Error while decoding stream #0:0: Internal bug, should
> not
> > have happened [h264_qsv @ 0x2032e80] Error initializing the MFX video
> > decoder: not initialized (-8) Error while decoding stream #0:0: Internal
> bug,
> > should not have happened [h264_qsv @ 0x2032e80] Error initializing the
> > MFX video decoder: not initialized (-8) Error while decoding stream #0:0:
> > Internal bug, should not have happened [h264_qsv @ 0x2032e80] Error
> > initializing the MFX video decoder: not initialized (-8) Error while
> decoding
> > stream #0:0: Internal bug, should not have happened [h264_qsv @
> > 0x2032e80] Error initializing the MFX video decoder: not initialized
> (-8) Error
> > while decoding stream #0:0: Internal bug, should not have happened
> > [h264_qsv @ 0x2032e80] Error initializing the MFX video decoder: not
> > initialized (-8) Error while decoding stream #0:0: Internal bug, should
> not
> > have happened Too many packets buffered for output stream 0:1.
> > [aac @ 0x21398c0] Qavg: 1872.197
> > [aac @ 0x21398c0] 2 frames left in the queue on closing Conversion
> failed!
> >
> >
> >
> >
> > What's wrong with the ffmpeg command?
> >
> >
> > Thanks!
> >
> >
> > Regards
> >
> >
> > andrew
> >
> >
> >
> >
> >
> >
> > At 2018-06-19 23:30:28, "DopeLabs" <dopelabs at dubstep.fm> wrote:
> > >have you searched the man page or. this page for "qsv" ?
> > >
> > >https://ffmpeg.org/ffmpeg-all.html
> > >
> > >> On Jun 19, 2018, at 1:44 46AM, qw <applemax82 at 163.com> wrote:
> > >>
> > >> Hi,
> > >>
> > >>
> > >> I want to use Intel qsv encoder/decoder for ffmpeg 4.0. I use
> > '--enable-libmfx' to configure ffmpeg, and build it. What's ffmpeg
> command
> > to use Intel qsv h.264 encoder/decoder to do transcoding?
> > >>
> > >>
> > >> Thanks!
> > >>
> > >>
> > >> Regards
> > >>
> > >>
> > >> Andrew
> > >> _______________________________________________
> > >> ffmpeg-user mailing list
> > >> ffmpeg-user at ffmpeg.org
> > >> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
> > >>
> > >> To unsubscribe, visit link above, or email
> > >> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
> > >
> > >_______________________________________________
> > >ffmpeg-user mailing list
> > >ffmpeg-user at ffmpeg.org
> > >http://ffmpeg.org/mailman/listinfo/ffmpeg-user
> > >
> > >To unsubscribe, visit link above, or email
> > >ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
> > _______________________________________________
> > ffmpeg-user mailing list
> > ffmpeg-user at ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-user
> >
> > To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org
> > with subject "unsubscribe".
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
>


More information about the ffmpeg-user mailing list