lisamelton / other_video_transcoding

Other tools to transcode videos.
MIT License
544 stars 25 forks source link

transcoding failed due to "[h264_qsv @ 0x557abb47a140] Error initializing the encoder: unsupported (-3)" #90

Closed rhart211 closed 3 years ago

rhart211 commented 3 years ago

Great script. Thank you. I'm try to transcode an mkv using h264_qsv but it fails with the following error:

[h264_qsv @ 0x557abb47a140] Using the VBR with lookahead (LA) ratecontrol method
[h264_qsv @ 0x557abb47a140] MFMode:2
[h264_qsv @ 0x557abb47a140] Error initializing the encoder: unsupported (-3)
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

What's interesting is that the transcoding is successful using hevc. I'm trying to use h264_qsv as I'm trying to compare the video quality between the two. I've attached the ffmpeg log.

_ffmpeg_81716_1932.mkv.log

Thank you. Richard

lisamelton commented 3 years ago

@rhart211 I'm sorry you're having this problem. And thanks for attaching your .log file.

Unfortunately, I have no idea why h264_qsv would fail if hevc_qsv is working. Does VAAPI work on your Linux system? If so, this could be a problem with the pre-release version of ffmpeg that you're using.

I'm going to ask The HiveMind™ (my team of collaborators) if they have any thoughts on this. Stay tuned...

rhart211 commented 3 years ago

Thanks @donmelton I appreciate the help. You know, vaapi does work. Here's the output from ffmpeg, which I built using instructions from Intel.

ffmpeg version N-100510-g4a160cb Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
  configuration: --enable-libmfx --enable-nonfree
  libavutil      56. 62.100 / 56. 62.100
  libavcodec     58.115.102 / 58.115.102
  libavformat    58. 65.100 / 58. 65.100
  libavdevice    58. 11.103 / 58. 11.103
  libavfilter     7. 94.100 /  7. 94.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
 V..... h264_qsv             H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (Intel Quick Sync Video acceleration) (codec h264)
 V..... hevc_qsv             HEVC (Intel Quick Sync Video acceleration) (codec hevc)
 V..... mjpeg_qsv            MJPEG (Intel Quick Sync Video acceleration) (codec mjpeg)
 V..... mpeg2_qsv            MPEG-2 video (Intel Quick Sync Video acceleration) (codec mpeg2video)
 V..... vp9_qsv              VP9 video (Intel Quick Sync Video acceleration) (codec vp9)

And

ffmpeg version N-100510-g4a160cb Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
  configuration: --enable-libmfx --enable-nonfree
  libavutil      56. 62.100 / 56. 62.100
  libavcodec     58.115.102 / 58.115.102
  libavformat    58. 65.100 / 58. 65.100
  libavdevice    58. 11.103 / 58. 11.103
  libavfilter     7. 94.100 /  7. 94.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
 V..... h264_qsv             H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (Intel Quick Sync Video acceleration) (codec h264)
 V..... h264_v4l2m2m         V4L2 mem2mem H.264 encoder wrapper (codec h264)
 V..... h264_vaapi           H.264/AVC (VAAPI) (codec h264)

Thank you again for your support.

wintervaler commented 3 years ago

Hey @rhart211, I feel your pain. This is actually infuriating and I went through this myself a year or so ago (detailed, but not solved, in Issue 16).

I think what's going on here is a dependency issue with your custom build of ffmpeg, for which I'm assuming you followed the instructions on the Intel Media SDK GitHub, which is sadly not always the silver bullet.

This used to be a bigger problem than it is now, because since Ubuntu 19.04 we have been able to install most of the right things directly from the Ubuntu repositories. Can you confirm that your setup has the following packages installed:

libmfx1
libmfx-dev
libmfx-tools
libva-drm2
libva-x11-2
libva-glx2
libx11-dev
libigfxcmrt7
libva-dev
libdrm-dev

In particular, I think you are likely missing libigfxcmrt7, which ended up being the secret sauce for AVC/H.264 on QSV for me.

Let us know if this works and if not we'll keep troubleshooting.

lisamelton commented 3 years ago

@wintervaler Thanks! 👍

rhart211 commented 3 years ago

@wintervaler That's what it was. I had everything but libx11-dev, libigfxcmrt7, libdrm-dev installed. Once I installed them, I was able to successfully run other-transcode using h264_qsv.

Thank you both, @donmelton and @wintervaler.

wintervaler commented 3 years ago

@rhart211 Yay! Another success. Good to hear. Everything else has been working great for me on my Linux QSV box after that, so you should be in good shape.

skj-dev commented 3 years ago

@rhart211 I didn't think of it until just now, but since you're on a Linux box, you might find the Docker containers that I make for other-transcode useful. The advantage is you don't have to mess around with system dependencies. The downside is you have use Docker. 😎

The repo is here: https://github.com/ttyS0/docker-other-transcode and I have images already built if you don't want to build your own available both from my personal repository and Docker Hub.

As an example, this is what I would run on one of my NUCs assuming that the source files are in a sub directory named src that is in my current working directory:

docker run --rm --device /dev/dri:/dev/dri -v $(pwd):$(pwd) -w $(pwd) hub.skj.dev/img/other-transcode:qsv-0.7.0 --eac3 --pass-dts --add-subtitle auto --burn-subtitle auto --decode all --qsv-decoder --preset veryslow src/*.mkv

The only requirement on the host is that the /dev/dri device be available. @wintervaler was instrumental with getting the QSV version working, as I was having all kinds of headaches trying to use only VAAPI.

rhart211 commented 3 years ago

@ttyS0 Thank you. This is working now for me, but this is will definitely be an option that I'll try out in the future.