hevc_qsv producing empty file

Questions involving a Windows version of FFmpeg.
Post Reply
honza
Posts: 2
Joined: Fri Jun 21, 2019 7:28 am

hevc_qsv producing empty file

Post by honza » Fri Jun 21, 2019 7:50 am

Hi there,

I am trying to encode to HEVC codec. While it works no problem using libx265, I am struggling with hevc_qsv. When I try to run the following, all I get is an empty output file (0 bytes). It gives no errors, the command takes only approx. 1 second and the result is empty file.

Code: Select all

ffmpeg -loglevel verbose -y -i in.mp4 -load_plugin hevc_hw -c:v hevc_qsv -c:a copy out.mp4
ffmpeg version N-92722-gf22fcd4483 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 8.2.1 (GCC) 20181201
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enabl
e-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amr
wb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enab
le-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --
enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc -
-enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --e
nable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 24.101 / 56. 24.101
  libavcodec     58. 42.102 / 58. 42.102
  libavformat    58. 24.101 / 58. 24.101
  libavdevice    58.  6.101 / 58.  6.101
  libavfilter     7. 46.101 /  7. 46.101
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
[h264 @ 0000020b3a13d4c0] Reinit context to 1920x1088, pix_fmt: yuv420p
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'in.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.24.101
  Duration: 00:02:30.88, start: 0.000000, bitrate: 2640 kb/s
    Stream #0:0(und): Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p(left), 1920x1080 (1920x1088) [S
AR 1:1 DAR 16:9], 2504 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> hevc (hevc_qsv))
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[h264 @ 0000020b3a1fdb00] Reinit context to 1920x1088, pix_fmt: yuv420p
[graph 0 input from stream 0:0 @ 0000020b3b789dc0] w:1920 h:1080 pixfmt:yuv420p tb:1/12800 fr:25/1 sar:1/1 sws_param:fla
gs=2
[auto_scaler_0 @ 0000020b3a62c600] w:iw h:ih flags:'bicubic' interl:0
[format @ 0000020b3c3c9540] auto-inserting filter 'auto_scaler_0' between the filter 'Parsed_null_0' and the filter 'for
mat'
[auto_scaler_0 @ 0000020b3a62c600] w:1920 h:1080 fmt:yuv420p sar:1/1 -> w:1920 h:1080 fmt:nv12 sar:1/1 flags:0x4
[hevc_qsv @ 0000020b3a770980] Initialized an internal MFX session using hardware accelerated implementation
[hevc_qsv @ 0000020b3a770980] Using the average variable bitrate (AVBR) ratecontrol method
Running on a laptop with i5 6300U (I know it is not a fast powerful machine to encode video, but that is what I have). This is a Skylake family and based on this chart it should have support for HVEC hardware encoding.

Just for curiosity, I also tried h264_qsv codec, but the result is the same — empty file.

Any help?

pandy
Posts: 255
Joined: Mon Feb 24, 2014 1:46 pm

Re: hevc_qsv producing empty file

Post by pandy » Mon Jul 01, 2019 7:31 pm

Over 26 months ago this worked for me:

Code: Select all

-c:v hevc_qsv -preset:v 7 -profile:v 1 -load_plugin 2 -level:v 5.1 -b:v 38M -maxrate:v 40M-1 -minrate:v 1M -bufsize:v 19M-1 -qmin:v 4 -qmax:v 69 -g:v 250 -bf:v 3 -refs:v 5 -bitrate_limit 1 -async_depth 4
It may not work today...

honza
Posts: 2
Joined: Fri Jun 21, 2019 7:28 am

Re: hevc_qsv producing empty file

Post by honza » Mon Jul 15, 2019 11:23 am

Hey there,

really appreciate your attemtp to help. The params you sent produce error

Code: Select all

[hevc_qsv @ 0000020022c66cc0] Selected ratecontrol mode is unsupported
[hevc_qsv @ 0000020022c66cc0] 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
[aac @ 0000020022c64400] Qavg: 194.289
[aac @ 0000020022c64400] 2 frames left in the queue on closing
Conversion failed!
Found out it is caused by parameter -level:v 5.1. When I ommited that parameter, then I get the same behaviour as before — no error reporting, the command ends after approx. 1 second and the output file is empty (0 bytes).

pandy
Posts: 255
Joined: Mon Feb 24, 2014 1:46 pm

Re: hevc_qsv producing empty file

Post by pandy » Mon Jul 15, 2019 4:52 pm

Check this: http://www.intel.com/content/dam/www/pu ... -paper.pdf - bit old, also search for current Intel API references (perhaps check ffmpeg hevc_qsv source) - from my perspective only NVidia NVEnc provided working solution, Intel QSV was quite demanding and i would say capricious (works but starting and stopping encoder required some time, not easy to reuse session etc).

Post Reply
'