V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
wapollo9
V2EX  ›  FFmpeg

FFmpeg 使用 qsv 加速失败

  •  
  •   wapollo9 · 2022-11-13 21:13:09 +08:00 · 3583 次点击
    这是一个创建于 775 天前的主题,其中的信息可能已经有所发展或是发生改变。

    ffmpeg 命令如下

    ffmpeg -y -c:v h264_qsv -i input.mp4 -c:v hevc_qsv -low_power 1 output.mp4
    

    输出的错误信息如下

    [hevc_qsv @ 0x562ef30a0480] Selected ratecontrol mode is unsupported
    [hevc_qsv @ 0x562ef30a0480] 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 @ 0x562ef34099c0] Qavg: 65536.000
    [aac @ 0x562ef34099c0] 2 frames left in the queue on closing
    Conversion failed!
    

    vainfo 输出如下

    Trying display: wayland
    Trying display: x11
    error: can't connect to X server!
    Trying display: drm
    vainfo: VA-API version: 1.16 (libva 2.16.0)
    vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 22.4.4 ()
    vainfo: Supported profile and entrypoints
          VAProfileNone                   : VAEntrypointVideoProc
          VAProfileNone                   : VAEntrypointStats
          VAProfileMPEG2Simple            : VAEntrypointVLD
          VAProfileMPEG2Main              : VAEntrypointVLD
          VAProfileH264Main               : VAEntrypointVLD
          VAProfileH264Main               : VAEntrypointEncSliceLP
          VAProfileH264High               : VAEntrypointVLD
          VAProfileH264High               : VAEntrypointEncSliceLP
          VAProfileVC1Simple              : VAEntrypointVLD
          VAProfileVC1Main                : VAEntrypointVLD
          VAProfileVC1Advanced            : VAEntrypointVLD
          VAProfileJPEGBaseline           : VAEntrypointVLD
          VAProfileJPEGBaseline           : VAEntrypointEncPicture
          VAProfileH264ConstrainedBaseline: VAEntrypointVLD
          VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
          VAProfileVP8Version0_3          : VAEntrypointVLD
          VAProfileHEVCMain               : VAEntrypointVLD
          VAProfileHEVCMain               : VAEntrypointEncSliceLP
          VAProfileHEVCMain10             : VAEntrypointVLD
          VAProfileHEVCMain10             : VAEntrypointEncSliceLP
          VAProfileVP9Profile0            : VAEntrypointVLD
          VAProfileVP9Profile1            : VAEntrypointVLD
          VAProfileVP9Profile2            : VAEntrypointVLD
          VAProfileVP9Profile3            : VAEntrypointVLD
          VAProfileHEVCMain422_10         : VAEntrypointVLD
          VAProfileHEVCMain444            : VAEntrypointVLD
          VAProfileHEVCMain444            : VAEntrypointEncSliceLP
          VAProfileHEVCMain444_10         : VAEntrypointVLD
          VAProfileHEVCMain444_10         : VAEntrypointEncSliceLP
    

    CPU 和 GPU 分别如下

    CPU: Intel Celeron N5105 (4) @ 2.900GHz
    GPU: Intel JasperLake [UHD Graphics] 
    

    谢谢各位了

    13 条回复    2023-03-30 05:49:58 +08:00
    datou
        1
    datou  
       2022-11-13 21:31:43 +08:00
    你这 vainfo 都是解码规格支持吧?

    qsv 编码应该只支持 avc ,hevc 和 vp9/av1
    RangerWolf
        2
    RangerWolf  
       2022-11-13 21:34:29 +08:00
    我在我的 i5-5800H 上面成功执行下面转码率的命令
    .\ffmpeg.exe -hwaccel qsv -c:v h264_qsv -i input.mp4 -c:v h264_qsv -b:v 5M output-qsv.mp4

    你可以试试看。不知道是不是所有的 Intel CPU 都支持 QSV
    ysc3839
        3
    ysc3839  
       2022-11-13 22:23:20 +08:00 via Android
    QSV 和 VAAPI 不是同一个东西,建议先确认一下有没有装 Intel MSDK
    acreti
        4
    acreti  
       2022-11-14 00:16:08 +08:00
    ffmpeg -h encoder=hevc_qsv
    -low_power 是实验选项,有限制
    L4Linux
        5
    L4Linux  
       2022-11-14 10:06:22 +08:00 via Android
    要装 intel media sdk
    Huelse
        6
    Huelse  
       2022-11-14 10:16:23 +08:00
    先看下有没有支持

    `ffmpeg -hide_banner -encoders | grep qsv`
    wapollo9
        7
    wapollo9  
    OP
       2022-11-15 23:10:14 +08:00
    首先谢谢各位的回复

    @datou
    @Huelse
    @acreti
    ffmpeg -hide_banner -encoders | grep qsv 结果如下
    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)

    @RangerWolf
    同样的报错,也是说 some encoding parameters are not supported by the QSV runtime. Please double check the input parameters.
    另外,我也查了,我的 CPU 是支持 QSV 的
    https://www.intel.com/content/www/us/en/products/sku/212328/intel-celeron-processor-n5105-4m-cache-up-to-2-90-ghz/specifications.html

    @ysc3839
    @L4Linux
    已经确认安装了 intel-media-sdk
    wapollo9
        8
    wapollo9  
    OP
       2022-11-15 23:32:36 +08:00
    或者能使用 VAAPI 实现 h264 转 hevc 也行
    执行
    ffmpeg -vaapi_device /dev/dri/renderD128 -i 1.mp4 -vf "format=nv12,hwupload" -map 0:0 -c:v hevc_vaapi -
    map 0:a 2.mp4
    的结果是

    [hevc_vaapi @ 0x563cb06ea780] Failed to map output buffers: 24 (internal encoding error).
    [hevc_vaapi @ 0x563cb06ea780] Output failed: -5.
    Error submitting video frame to the encoder
    [aac @ 0x563cb0c28b80] Qavg: 65536.000
    [aac @ 0x563cb0c28b80] 2 frames left in the queue on closing
    Conversion failed!
    acreti
        9
    acreti  
       2022-11-15 23:49:27 +08:00
    ffmpeg -y -i input.mp4 -c:v hevc_qsv output.mp4
    ysc3839
        10
    ysc3839  
       2022-11-16 00:23:54 +08:00 via Android
    @wapollo9 VAAPI 好像不支持编码?
    另外可以试试 GStreamer
    https://gstreamer.freedesktop.org/documentation/msdk/index.html
    wapollo9
        11
    wapollo9  
    OP
       2022-11-16 13:26:14 +08:00
    @acreti
    ffmpeg version n5.1.2 Copyright (c) 2000-2022 the FFmpeg developers
    built with gcc 12.2.0 (GCC)
    configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librav1e --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-nvdec --enable-nvenc --enable-opencl --enable-opengl --enable-shared --enable-version3 --enable-vulkan
    libavutil 57. 28.100 / 57. 28.100
    libavcodec 59. 37.100 / 59. 37.100
    libavformat 59. 27.100 / 59. 27.100
    libavdevice 59. 7.100 / 59. 7.100
    libavfilter 8. 44.100 / 8. 44.100
    libswscale 6. 7.100 / 6. 7.100
    libswresample 4. 7.100 / 4. 7.100
    libpostproc 56. 6.100 / 56. 6.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mp4':
    Metadata:
    major_brand : isom
    minor_version : 512
    compatible_brands: isomiso2avc1mp41
    encoder : Lavf58.29.100
    Duration: 00:24:37.65, start: 0.000000, bitrate: 140 kb/s
    Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, progressive), 2160x1080, 10 kb/s, 15.01 fps, 15 tbr, 90k tbn (default)
    Metadata:
    handler_name : VideoHandler
    vendor_id : [0][0][0][0]
    Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 32000 Hz, mono, fltp, 126 kb/s (default)
    Metadata:
    handler_name : SoundHandler
    vendor_id : [0][0][0][0]
    Stream mapping:
    Stream #0:0 -> #0:0 (h264 (native) -> hevc (hevc_qsv))
    Stream #0:1 -> #0:1 (aac (native) -> aac (native))
    Press [q] to stop, [?] for help
    [swscaler @ 0x559ba6524d80] [swscaler @ 0x559ba6532540] deprecated pixel format used, make sure you did set range correctly
    [swscaler @ 0x559ba6524d80] [swscaler @ 0x559ba657b6c0] deprecated pixel format used, make sure you did set range correctly
    [swscaler @ 0x559ba6524d80] [swscaler @ 0x559ba65c2140] deprecated pixel format used, make sure you did set range correctly
    [swscaler @ 0x559ba6524d80] [swscaler @ 0x559ba6608bc0] deprecated pixel format used, make sure you did set range correctly
    [swscaler @ 0x559ba6524d80] [swscaler @ 0x559ba664f640] deprecated pixel format used, make sure you did set range correctly
    [swscaler @ 0x559ba6524d80] [swscaler @ 0x559ba6532540] deprecated pixel format used, make sure you did set range correctly
    [swscaler @ 0x559ba6524d80] [swscaler @ 0x559ba6651680] deprecated pixel format used, make sure you did set range correctly
    [swscaler @ 0x559ba6524d80] [swscaler @ 0x559ba6587f80] deprecated pixel format used, make sure you did set range correctly
    [swscaler @ 0x559ba6524d80] [swscaler @ 0x559ba65cfd40] deprecated pixel format used, make sure you did set range correctly
    [swscaler @ 0x559ba6524d80] [swscaler @ 0x559ba66167c0] deprecated pixel format used, make sure you did set range correctly
    [swscaler @ 0x559ba6524d80] [swscaler @ 0x559ba6532540] deprecated pixel format used, make sure you did set range correctly
    [swscaler @ 0x559ba6524d80] [swscaler @ 0x559ba6618b00] deprecated pixel format used, make sure you did set range correctly
    [swscaler @ 0x559ba6524d80] [swscaler @ 0x559ba655d3c0] deprecated pixel format used, make sure you did set range correctly
    [swscaler @ 0x559ba6524d80] [swscaler @ 0x559ba659a740] deprecated pixel format used, make sure you did set range correctly
    [swscaler @ 0x559ba6524d80] [swscaler @ 0x559ba65dde00] deprecated pixel format used, make sure you did set range correctly
    [swscaler @ 0x559ba6524d80] [swscaler @ 0x559ba659a740] deprecated pixel format used, make sure you did set range correctly
    [swscaler @ 0x559ba6524d80] [swscaler @ 0x559ba65feb00] deprecated pixel format used, make sure you did set range correctly
    [swscaler @ 0x559ba6524d80] [swscaler @ 0x559ba6646980] deprecated pixel format used, make sure you did set range correctly
    [swscaler @ 0x559ba6524d80] [swscaler @ 0x559ba657da40] deprecated pixel format used, make sure you did set range correctly
    [swscaler @ 0x559ba6524d80] [swscaler @ 0x559ba65e1b00] deprecated pixel format used, make sure you did set range correctly
    [hevc_qsv @ 0x559ba5b13e40] Selected ratecontrol mode is unsupported
    [hevc_qsv @ 0x559ba5b13e40] Low power mode is unsupported
    [hevc_qsv @ 0x559ba5b13e40] 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 @ 0x559ba5b12f80] Qavg: 34924.375
    [aac @ 0x559ba5b12f80] 2 frames left in the queue on closing
    Conversion failed!

    @ysc3839
    我研究一下,谢谢!
    acreti
        12
    acreti  
       2022-11-17 02:52:02 +08:00
    你用的命令是什么?另外 yuvj420p 一般是给图片用的,视频用 yuv420p
    s7lx
        13
    s7lx  
       2023-03-30 05:49:58 +08:00
    应该是 HuC/GuC 开启失败。N5105 N6005 都有这个问题。
    sudo dmesg |grep i915 应该可以看到一个错误。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   957 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 21:39 · PVG 05:39 · LAX 13:39 · JFK 16:39
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.