[libav-devel] [libav-commits] qsvenc: Provide a detailed error message if the parameters are invalid

Li, Zhong zhong.li at intel.com
Thu Mar 15 10:14:53 CET 2018


> From: libav-devel [mailto:libav-devel-bounces at libav.org] On Behalf Of Mark
> Thompson
> Sent: Tuesday, March 6, 2018 8:17 AM
> To: libav-devel at libav.org
> Subject: Re: [libav-devel] [libav-commits] qsvenc: Provide a detailed error
> message if the parameters are invalid
> """
> $ LIBVA_DRIVER_NAME=iHD
> LIBVA_DRIVERS_PATH=/opt/intel/mediasdk/lib64/ DISPLAY= ./avconv -v 55
> -y -i bbb_1080_264.mp4 -an -vf 'scale=7680:4320' -c:v h264_qsv -b:v 5M
> -la_depth 50 -frames:v 1000 out.mp4 avconv version
> v13_dev0-1487-g2d6b3f3, Copyright (c) 2000-2018 the Libav developers ...
> [buffer @ 0x375eca0] w:1920 h:1080 pixfmt:yuv420p tb:1/60000 sar:1/1
> [fps @ 0x3aac380] fps=60/1 [buffersink @ 0x37c79e0] auto-inserting filter
> 'auto-inserted fifo 0' between the filter 'fps for output stream 0:0' and the
> filter 'output stream 0:0'
> [scale @ 0x3ab0300] w:1920 h:1080 fmt:yuv420p -> w:7680 h:4320
> fmt:nv12 flags:0x4 [h264_qsv @ 0x381e660] Initialized an internal MFX
> session using hardware accelerated implementation [h264_qsv @
> 0x381e660] Using the VBR with lookahead (LA) ratecontrol method libva info:
> VA-API version 0.99.0 libva info: va_getDriverName() returns 0 libva info:
> User requested driver 'iHD'
> libva info: Trying to open /opt/intel/mediasdk/lib64//iHD_drv_video.so
> libva info: Found init function __vaDriverInit_0_32 libva info: va_openDriver()
> returns 0 [h264_qsv @ 0x381e660] Current profile is unsupported [h264_qsv
> @ 0x381e660] Selected ratecontrol mode is unsupported [h264_qsv @
> 0x381e660] Current frame rate is unsupported [h264_qsv @ 0x381e660]
> some encoding parameters are not supported by the QSV runtime. Please
> double check the input parameters.
> Error initializing output stream 0:0 -- Error while opening encoder for output
> stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or
> height """
> 
> I was hoping for "resolution is unsupported" there, but that's one thing
> which it didn't reject:
> 
> """
> (gdb) p q->param.mfx
> $4 = {reserved = {0, 0, 0, 0, 0, 0, 0}, LowPower = 0, BRCParamMultiplier = 0,
> FrameInfo = {reserved = {0, 0, 0, 0}, reserved4 = 0, BitDepthLuma = 8,
>     BitDepthChroma = 8, Shift = 0, FrameId = {TemporalId = 0, PriorityId = 0,
> {{DependencyId = 0, QualityId = 0}, {ViewId = 0}}}, FourCC = 842094158, {{
>         Width = 7680, Height = 4320, CropX = 0, CropY = 0, CropW = 7680,
> CropH = 4320}, {BufferSize = 283123200, reserved5 = 283123200}},
> FrameRateExtN = 60,
>     FrameRateExtD = 1, reserved3 = 0, AspectRatioW = 1, AspectRatioH = 1,
> PicStruct = 1, ChromaFormat = 1, reserved2 = 0}, CodecId = 541283905,
>   CodecProfile = 0, CodecLevel = 0, NumThread = 0, {{TargetUsage = 4,
> GopPicSize = 250, GopRefDist = 4, GopOptFlag = 1, IdrInterval = 0,
>       RateControlMethod = 8, {InitialDelayInKB = 0, QPI = 0, Accuracy = 0},
> BufferSizeInKB = 0, {TargetKbps = 5000, QPP = 5000, ICQQuality = 5000}, {
>         MaxKbps = 0, QPB = 0, Convergence = 0}, NumSlice = 0,
> NumRefFrame = 0, EncodedOrder = 0}, {DecodedOrder = 4,
> ExtendedPicStruct = 250,
>       TimeStampCalc = 4, SliceGroupsPresent = 1, MaxDecFrameBuffering
> = 0, EnableReallocRequest = 8, reserved2 = {0, 0, 5000, 0, 0, 0, 0}}, {
>       JPEGChromaFormat = 4, Rotation = 250, JPEGColorFormat = 4,
> InterleavedDec = 1, SamplingFactorH = "\000\000\b", SamplingFactorV =
> "\000\000\000",
>       reserved3 = {5000, 0, 0, 0, 0}}, {Interleaved = 4, Quality = 250,
> RestartInterval = 4, reserved5 = {1, 0, 8, 0, 0, 5000, 0, 0, 0, 0}}}}
> (gdb) p param_out.mfx
> $5 = {reserved = {0, 0, 0, 0, 0, 0, 0}, LowPower = 0, BRCParamMultiplier = 1,
> FrameInfo = {reserved = {0, 0, 0, 0}, reserved4 = 0, BitDepthLuma = 0,
>     BitDepthChroma = 0, Shift = 0, FrameId = {TemporalId = 0, PriorityId = 0,
> {{DependencyId = 0, QualityId = 0}, {ViewId = 0}}}, FourCC = 842094158, {{
>         Width = 7680, Height = 4320, CropX = 0, CropY = 0, CropW = 7680,
> CropH = 4320}, {BufferSize = 283123200, reserved5 = 283123200}},
> FrameRateExtN = 16,
>     FrameRateExtD = 1, reserved3 = 0, AspectRatioW = 1, AspectRatioH = 1,
> PicStruct = 1, ChromaFormat = 1, reserved2 = 0}, CodecId = 541283905,
>   CodecProfile = 77, CodecLevel = 52, NumThread = 0, {{TargetUsage = 4,
> GopPicSize = 250, GopRefDist = 4, GopOptFlag = 1, IdrInterval = 0,
>       RateControlMethod = 0, {InitialDelayInKB = 0, QPI = 0, Accuracy = 0},
> BufferSizeInKB = 0, {TargetKbps = 34125, QPP = 34125, ICQQuality = 34125},
> {
>         MaxKbps = 0, QPB = 0, Convergence = 0}, NumSlice = 0,
> NumRefFrame = 0, EncodedOrder = 0}, {DecodedOrder = 4,
> ExtendedPicStruct = 250,
>       TimeStampCalc = 4, SliceGroupsPresent = 1, MaxDecFrameBuffering
> = 0, EnableReallocRequest = 0, reserved2 = {0, 0, 34125, 0, 0, 0, 0}}, {
>       JPEGChromaFormat = 4, Rotation = 250, JPEGColorFormat = 4,
> InterleavedDec = 1, SamplingFactorH = "\000\000\000", SamplingFactorV =
> "\000\000\000",
>       reserved3 = {34125, 0, 0, 0, 0}}, {Interleaved = 4, Quality = 250,
> RestartInterval = 4, reserved5 = {1, 0, 0, 0, 0, 34125, 0, 0, 0, 0}}}} """
> 
> (Resolutions up to 4096x4096 do work with the same command.)
> 

When I was going to reproduce your issue and check what happens in MSDK. I found that I could not reproduce your case (7680x4320 failed and 4096x4096 works). 
4096x4096 also failed as my testing:
./avconv -v 55 -y -i /samba/anonymous/Videos/bbb_sunflower_1080p_30fps_normal.mp4 -an -vf 'scale=4096:4096' -c:v h264_qsv -b:v 5M -la_depth 50 -frames:v 1000 out.mp4
avconv version v13_dev0-1487-g2d6b3f3, Copyright (c) 2000-2018 the Libav developers
  built on Mar  9 2018 16:47:25 with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-11)
  configuration: --enable-libmfx --enable-libx264 --enable-gpl --disable-optimizations --enable-debug=3 --enable-vaapi
[buffer @ 0x28af240] w:1920 h:1080 pixfmt:yuv420p tb:1/30000 sar:1/1
[fps @ 0x282bf40] fps=30/1
[buffersink @ 0x2b61c20] auto-inserting filter 'auto-inserted fifo 0' between the filter 'fps for output stream 0:0' and the filter 'output stream 0:0'
[scale @ 0x28b0060] w:1920 h:1080 fmt:yuv420p -> w:4096 h:4096 fmt:nv12 flags:0x4
[h264_qsv @ 0x27a3b20] Initialized an internal MFX session using hardware accelerated implementation
[h264_qsv @ 0x27a3b20] Using the VBR with lookahead (LA) ratecontrol method
[h264_qsv @ 0x27a3b20] Current profile is unsupported
[h264_qsv @ 0x27a3b20] Selected ratecontrol mode is unsupported
[h264_qsv @ 0x27a3b20] some encoding parameters are not supported by the QSV runtime. Please double check the input parameters.
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
[fps @ 0x282bf40] 0 frames in, 0 frames out; 0 frames dropped, 0 frames duplicated.

Other resolutions also failed such as 2096x2096

And encoding a rawvideo also failed: 
./avconv -y -init_hw_device qsv=foo -s 352x288 -i /samba/anonymous/Videos/FOOTBALL_352x288_orig.yuv -vcodec h264_qsv -b:v 2000k -maxrate 2000k -cavlc 1 test.h264
[h264_qsv @ 0x21480c0] Encoder will work with partial HW acceleration
[h264_qsv @ 0x21480c0] Warning in encoder initialization: partial acceleration (4)
[h264_qsv @ 0x21480c0] Error calling GetVideoParam: unsupported (-3)
[h264_qsv @ 0x21480c0] Error retrieving encoding parameters.
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

I am not sure why it can works on your side but I found when I revert the commit before ddea22a684611c1fec9d8b5c70d835e983a9252e (avconv: Use codec hardware config to configure hwaccels). 
It works for the resolution of "4096x4096" and failed for "7680x4320". It also works for the raw video encoding case.

Looks like the commit ddea22a684611c1fec9d8b5c70d835e983a9252e breaks qsv encoding with system memory input? 








More information about the libav-devel mailing list