ffmpeg hevc_vaapi:无法在过滤器“Parsed_null_0”和过滤器“auto_scaler_0”支持的格式之间进行转换

168*_*556 7 ffmpeg h.265

在 Linux 上,我尝试使用硬件加速将文件编码为 H\xe2\x82\xacVC。成功的尝试是:

\n
ffmpeg -v verbose -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -i \'/path/file.mkv\' -vcodec libx265 -crf 28 \'/path/file.mp4\'\n
Run Code Online (Sandbox Code Playgroud)\n

但速度很慢,如 30fps,“ ffmpeg -codecs|grep 265”显示:\n(编码器: libx265 nvenc_hevc hevc_amf hevc_nvenc hevc_qsv hevc_v4l2m2m hevc_vaapi )

\n

所以我尝试了hevc_vaapi:

\n
ffmpeg -v verbose -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -i \'/path/file.mkv\' -vcodec hevc_vaapi -crf 28 \'/path/file.mp4\'\n
Run Code Online (Sandbox Code Playgroud)\n

但它失败了:

\n
Impossible to convert between the formats supported by the filter \'Parsed_null_0\' and the filter \'auto_scaler_0\'\nError reinitializing filters!\nFailed to inject frame into filter network: Function not implemented\nError while processing the decoded data for stream #0:0\n[AVIOContext @ 0x55d831121340] Statistics: 0 seeks, 0 writeouts\n[aac @ 0x55d831142a00] Qavg: 30414.529\n[aac @ 0x55d831142a00] 2 frames left in the queue on closing\n[AVIOContext @ 0x55d831109ec0] Statistics: 65536 bytes read, 0 seeks\nConversion failed!\n
Run Code Online (Sandbox Code Playgroud)\n

$ ffmpeg -hwaccels 显示“

\n
Hardware acceleration methods:\nvdpau\ncuda\nvaapi\nqsv\ndrm\n
Run Code Online (Sandbox Code Playgroud)\n

\n

$ vaapi显示此\n(似乎 va-api 在那里,mesa 驱动程序)

\n

$ ls /dev/dri/*

\n
\n

/dev/dri/card0 /dev/dri/renderD128

\n

/dev/dri/by-path:

\n

pci-0000:0a:00.0-卡 pci-0000:0a:00.0-渲染

\n
\n

您对此错误有何看法,或者您将如何继续发现哪些 ffmpeg 参数用于 HW H\xe2\x82\xacVC 加速?

\n

更新:我认为“-hwaccel vaapi”可能是多余的参数

\n

168*_*556 6

我认为它需要正确的编码参数,例如如果您有VAAPI 驱动程序,-vf 'format=nv12,hwupload'则以下一行可能会起作用:

echo "Input file:" && read -r i && echo "Quality: 25=identic, 30=a bit worse but small file size, or other numbers:" && read -r q && ffmpeg -vaapi_device /dev/dri/renderD128 -i "$i" -vf 'format=nv12,hwupload' -c:v hevc_vaapi -f mp4 -rc_mode 1 -qp "$q" "$i.hevc.mp4"
Run Code Online (Sandbox Code Playgroud)