Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#5859 closed defect (fixed)

ffmpeg does not work with QSV/MSS2017

Reported by: Milan Cizek Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: qsv
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

QSV on my machine works, for example:

#/opt/intel/mediasdk/samples/sample_multi_transcode -i::h264 /opt/intel/mediasdk/samples/streams/test_stream.264 -o::h264 ./test_out.h264 -hw

Multi Transcoding Sample Version 7.0.16053497

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
Pipeline surfaces number (DecPool): 20
MFX HARDWARE Session 0 API ver 1.19 parameters:
Input  video: AVC
Output video: AVC

Session 0 was NOT joined with other sessions

Transcoding started
..
Transcoding finished

Common transcoding time is  0.12 sec
MFX session 0 transcoding PASSED:
Processing time: 0.12 sec
Number of processed frames: 101

The test PASSED

# vainfo
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
vainfo: VA-API version: 0.99 (libva 1.67.0.pre1)
vainfo: Driver version: 16.5.55964-ubit
vainfo: Supported profile and entrypoints
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: <unknown entrypoint>
      VAProfileH264ConstrainedBaseline: <unknown entrypoint>
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264Main               : <unknown entrypoint>
      VAProfileH264Main               : <unknown entrypoint>
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264High               : <unknown entrypoint>
      VAProfileH264High               : <unknown entrypoint>
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileVP8Version0_3          : VAEntrypointEncSlice
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileVP8Version0_3          : <unknown entrypoint>
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileVP9Profile0            : <unknown entrypoint>
      <unknown profile>               : VAEntrypointVideoProc
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileNone                   : <unknown entrypoint>

Ffmpeg is compiled with mfx without errors.

Summary of the bug:
How to reproduce:

# ffmpeg -loglevel debug -y -i /opt/intel/mediasdk/samples/streams/test_stream.264 -c:v h264_qsv -preset:v faster ffmpeg_out.qsv.mp4

ffmpeg version N-81724-g88d79db Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.2) 20160609
  configuration: --prefix=/FFMPEG --pkg-config-flags=--static --bindir=/root/bin --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-nvenc --enable-libmfx --enable-version3 --enable-pthreads --enable-runtime-cpudetect --disable-ffserver --enable-libfreetype --enable-filter=drawtext
  libavutil      55. 30.100 / 55. 30.100
  libavcodec     57. 57.101 / 57. 57.101
  libavformat    57. 50.100 / 57. 50.100
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 62.100 /  6. 62.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-i' ... matched as input file with argument '/opt/intel/mediasdk/samples/streams/test_stream.264'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'h264_qsv'.
Reading option '-preset:v' ... matched as AVOption 'preset:v' with argument 'faster'.
Reading option 'ffmpeg_out.qsv.mp4' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Applying option y (overwrite output files) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input file /opt/intel/mediasdk/samples/streams/test_stream.264.
Successfully parsed a group of options.
Opening an input file: /opt/intel/mediasdk/samples/streams/test_stream.264.
[file @ 0x2f459e0] Setting default whitelist 'file,crypto'
[h264 @ 0x2f450c0] Format h264 probed with size=2048 and score=51
[h264 @ 0x2f450c0] Before avformat_find_stream_info() pos: 0 bytes read:32768 seeks:0 nb_streams:1
[h264 @ 0x2f467e0] ct_type:0 pic_struct:0
[h264 @ 0x2f467e0] nal_unit_type: 9, nal_ref_idc: 0
[h264 @ 0x2f467e0] nal_unit_type: 7, nal_ref_idc: 1
[h264 @ 0x2f467e0] nal_unit_type: 8, nal_ref_idc: 1
[h264 @ 0x2f467e0] nal_unit_type: 6, nal_ref_idc: 0
[h264 @ 0x2f467e0] nal_unit_type: 5, nal_ref_idc: 1
[h264 @ 0x2f467e0] ct_type:0 pic_struct:0
[h264 @ 0x2f467e0] Reinit context to 176x96, pix_fmt: yuv420p
[h264 @ 0x2f467e0] ct_type:0 pic_struct:0
[h264 @ 0x2f467e0] nal_unit_type: 9, nal_ref_idc: 0
[h264 @ 0x2f467e0] nal_unit_type: 6, nal_ref_idc: 0
[h264 @ 0x2f467e0] nal_unit_type: 1, nal_ref_idc: 1
[h264 @ 0x2f467e0] ct_type:0 pic_struct:0
[h264 @ 0x2f467e0] Increasing reorder buffer to 1
[h264 @ 0x2f467e0] no picture
[h264 @ 0x2f467e0] ct_type:0 pic_struct:0
[h264 @ 0x2f467e0] nal_unit_type: 9, nal_ref_idc: 0
[h264 @ 0x2f467e0] nal_unit_type: 6, nal_ref_idc: 0
[h264 @ 0x2f467e0] nal_unit_type: 1, nal_ref_idc: 0
[h264 @ 0x2f467e0] ct_type:0 pic_struct:0
    Last message repeated 1 times
[h264 @ 0x2f467e0] nal_unit_type: 9, nal_ref_idc: 0
[h264 @ 0x2f467e0] nal_unit_type: 6, nal_ref_idc: 0
[h264 @ 0x2f467e0] nal_unit_type: 1, nal_ref_idc: 1
[h264 @ 0x2f467e0] ct_type:0 pic_struct:0
    Last message repeated 1 times
[h264 @ 0x2f467e0] nal_unit_type: 9, nal_ref_idc: 0
[h264 @ 0x2f467e0] nal_unit_type: 6, nal_ref_idc: 0
[h264 @ 0x2f467e0] nal_unit_type: 1, nal_ref_idc: 0
[h264 @ 0x2f467e0] ct_type:0 pic_struct:0
    Last message repeated 1 times
[h264 @ 0x2f467e0] nal_unit_type: 9, nal_ref_idc: 0
[h264 @ 0x2f467e0] nal_unit_type: 6, nal_ref_idc: 0
[h264 @ 0x2f467e0] nal_unit_type: 1, nal_ref_idc: 1
[h264 @ 0x2f467e0] ct_type:0 pic_struct:0
    Last message repeated 1 times
[h264 @ 0x2f467e0] nal_unit_type: 9, nal_ref_idc: 0
[h264 @ 0x2f467e0] nal_unit_type: 6, nal_ref_idc: 0
[h264 @ 0x2f467e0] nal_unit_type: 1, nal_ref_idc: 0
[h264 @ 0x2f467e0] ct_type:0 pic_struct:0
    Last message repeated 1 times
[h264 @ 0x2f467e0] nal_unit_type: 9, nal_ref_idc: 0
[h264 @ 0x2f467e0] nal_unit_type: 6, nal_ref_idc: 0
[h264 @ 0x2f467e0] nal_unit_type: 1, nal_ref_idc: 1
[h264 @ 0x2f467e0] ct_type:0 pic_struct:0
    Last message repeated 93 times
[h264 @ 0x2f450c0] After avformat_find_stream_info() pos: 267554 bytes read:267554 seeks:0 frames:101
Input #0, h264, from '/opt/intel/mediasdk/samples/streams/test_stream.264':
  Duration: N/A, bitrate: N/A
    Stream #0:0, 101, 1/1200000: Video: h264 (High), 1 reference frame, yuv420p(left), 176x96 [SAR 1:1 DAR 11:6], 0/1, 30 fps, 30 tbr, 1200k tbn, 60 tbc
Successfully opened the file.
Parsing a group of options: output file ffmpeg_out.qsv.mp4.
Applying option c:v (codec name) with argument h264_qsv.
Successfully parsed a group of options.
Opening an output file: ffmpeg_out.qsv.mp4.
[file @ 0x2f81600] Setting default whitelist 'file,crypto'
Successfully opened the file.
detected 8 logical cores
[graph 0 input from stream 0:0 @ 0x2f44e20] Setting 'video_size' to value '176x96'
[graph 0 input from stream 0:0 @ 0x2f44e20] Setting 'pix_fmt' to value '0'
[graph 0 input from stream 0:0 @ 0x2f44e20] Setting 'time_base' to value '1/1200000'
[graph 0 input from stream 0:0 @ 0x2f44e20] Setting 'pixel_aspect' to value '1/1'
[graph 0 input from stream 0:0 @ 0x2f44e20] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 0x2f44e20] Setting 'frame_rate' to value '60/2'
[graph 0 input from stream 0:0 @ 0x2f44e20] w:176 h:96 pixfmt:yuv420p tb:1/1200000 fr:60/2 sar:1/1 sws_param:flags=2
[format @ 0x2f98160] compat: called with args=[nv12|qsv]
[format @ 0x2f98160] Setting 'pix_fmts' to value 'nv12|qsv'
[auto-inserted scaler 0 @ 0x2f98a60] Setting 'flags' to value 'bicubic'
[auto-inserted scaler 0 @ 0x2f98a60] w:iw h:ih flags:'bicubic' interl:0
[format @ 0x2f98160] auto-inserting filter 'auto-inserted scaler 0' between the filter 'Parsed_null_0' and the filter 'format'
[AVFilterGraph @ 0x2f45780] query_formats: 4 queried, 2 merged, 1 already done, 0 delayed
[auto-inserted scaler 0 @ 0x2f98a60] w:176 h:96 fmt:yuv420p sar:1/1 -> w:176 h:96 fmt:nv12 sar:1/1 flags:0x4
[h264 @ 0x2f96cc0] nal_unit_type: 9, nal_ref_idc: 0
[h264 @ 0x2f96cc0] nal_unit_type: 7, nal_ref_idc: 1
[h264 @ 0x2f96cc0] nal_unit_type: 8, nal_ref_idc: 1
[h264 @ 0x2f96cc0] Ignoring NAL type 9 in extradata
[h264_qsv @ 0x2fa39e0] Error initializing an internal MFX session
Output #0, mp4, to 'ffmpeg_out.qsv.mp4':
    Stream #0:0, 0, 0/0: Video: h264, 1 reference frame, none, q=2-31, SAR 1:1 DAR 0:0, 30 fps
    Metadata:
      encoder         : Lavc57.57.101 h264_qsv
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_qsv))
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
[AVIOContext @ 0x2fa4300] Statistics: 0 seeks, 0 writeouts
[AVIOContext @ 0x2f4dd00] Statistics: 267554 bytes read, 0 seeks

Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker.

Change History (5)

comment:1 by Milan Cizek, 7 years ago

Linux test.local 4.4.0 #1 SMP Tue Sep 20 20:45:27 CEST 2016 x86_64 x86_64 x86_64 GNU/Linux
Ubuntu 16.04.1 LTS
Media Server Studio 2017

comment:2 by Milan Cizek, 7 years ago

I solved it. My problem was in LD_LIBRARY_PATH and missing libva.a. Now, all tests, are ok, but ffmpeg fails with segmentation fault.

--------------------------
Hardware readiness checks:
--------------------------
 [ OK ] Processor name: Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
--------------------------
OS readiness checks:
--------------------------
 [ OK ] GPU visible to OS
--------------------------
Media Server Studio Install:
--------------------------
 [ OK ] user is root
 [ OK ] libva.so.1 found
 [ OK ] vainfo reports valid codec entry points
 [ OK ] /dev/dri/renderD128 connects to Intel i915
--------------------------
Component Smoke Tests:
--------------------------
 [ OK ] Media SDK HW API level:1.19
 [ OK ] Media SDK SW API level:1.19
 [ OK ] OpenCL check:platform:Intel(R) OpenCL GPU OK CPU OK

--------------------------
Media SDK Plugins available:
(for more info see /opt/intel/mediasdk/plugins/plugins.cfg)
--------------------------
    H264LA Encoder      = 588f1185d47b42968dea377bb5d0dcb4
    VP8 Decoder         = f622394d8d87452f878c51f2fc9b4131
    HEVC Decoder        = 33a61c0b4c27454ca8d85dde757c6f8e
    HEVC Encoder        = 6fadc791a0c2eb479ab6dcd5ea9da347
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
vainfo: VA-API version: 0.99 (libva 1.67.0.pre1)
vainfo: Driver version: 16.5.55964-ubit
vainfo: Supported profile and entrypoints
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: <unknown entrypoint>
      VAProfileH264ConstrainedBaseline: <unknown entrypoint>
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264Main               : <unknown entrypoint>
      VAProfileH264Main               : <unknown entrypoint>
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264High               : <unknown entrypoint>
      VAProfileH264High               : <unknown entrypoint>
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileVP8Version0_3          : VAEntrypointEncSlice
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileVP8Version0_3          : <unknown entrypoint>
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileVP9Profile0            : <unknown entrypoint>
      <unknown profile>               : VAEntrypointVideoProc
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileNone                   : <unknown entrypoint>
ffmpeg version N-81780-g4a05d2e Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.2) 20160609
  configuration: --prefix=/FFMPEG --pkg-config-flags=--static --bindir=/root/bin --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-nvenc --enable-libmfx --enable-version3 --enable-pthreads --enable-runtime-cpudetect --disable-ffserver --enable-libfreetype --enable-filter=drawtext
  libavutil      55. 30.100 / 55. 30.100
  libavcodec     57. 58.100 / 57. 58.100
  libavformat    57. 51.100 / 57. 51.100
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 63.100 /  6. 63.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  2.100 /  2.  2.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, hevc, from './test_out.h265.mp4':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: hevc (Main), yuv420p(tv), 176x96 [SAR 1:1 DAR 11:6], 30 fps, 30 tbr, 1200k tbn, 30 tbc
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
Output #0, mp4, to 'ffmpeg_out.qsv.mp4':
  Metadata:
    encoder         : Lavf57.51.100
    Stream #0:0: Video: h264 (h264_qsv) ([33][0][0][0] / 0x0021), nv12, 176x96 [SAR 1:1 DAR 11:6], q=2-31, 1000 kb/s, 30 fps, 15360 tbn, 30 tbc
    Metadata:
      encoder         : Lavc57.58.100 h264_qsv
    Side data:
      cpb: bitrate max/min/avg: 0/0/1000000 buffer size: 0 vbv_delay: -1
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (native) -> h264 (h264_qsv))
Press [q] to stop, [?] for help
./h264_qsv_test.sh: line 11: 24803 Segmentation fault      (core dumped) ffmpeg -y -i ./test_out.h265.mp4 -c:v h264_qsv ffmpeg_out.qsv.mp4

comment:3 by Milan Cizek, 7 years ago

Test command is conversion from hevc to h264.

ffmpeg -y -i ./test_out.h265.mp4 -c:v h264_qsv ffmpeg_out.qsv.mp4

comment:4 by jkqxz, 7 years ago

Resolution: fixed
Status: newclosed

Working as of 1f26a231bb065276cd80ce02957c759f3197edfa.

(Note that the implementation currently defaults to the software encoder in the media SDK for compatibility reasons; add "-load_plugin hevc_hw" to use the hardware encoder.)

comment:5 by Carl Eugen Hoyos, 7 years ago

Component: ffmpegavcodec
Keywords: mfx removed
Note: See TracTickets for help on using tickets.