正如标题所示,我已在两个 Windows 7 系统和一个 Windows 10 系统上成功使用了带有 x264_qsv 硬件加速的 ffmpeg。现在我尝试在第四个系统(即 Windows 7)上进行设置,但无法正常工作。我收到了一个对我来说很陌生的错误。该系统配备 i3-2120 处理器,英特尔网站称其支持 QSV 编码。我已下载英特尔所称的最新驱动程序并安装(并重新启动),没有发现任何问题。我已将处理命令减少到最低限度以进行测试:
ffmpeg -hide_banner -err_detect ignore_err -loglevel verbose ^
-stats -benchmark ^
-init_hw_device qsv:hw,child_device_type=qsv ^
-hwaccel_output_format qsv -vsync vfr -ec deblock ^
-ss "00:24:30.544" -to "00:25:33.393" ^
-i "InputFile.avi" ^
-strict normal -c:a aac -q:a 1.5 ^
-c:v h264_qsv -q:v 28 -preset veryslow ^
-movflags +faststart ^
"OutputFile.mp4" > test1.log 2>&1
这是捕获的日志文件:
Routing option err_detect to both codec and muxer layer
Routing option strict to both codec and muxer layer
[AVHWDeviceContext @ 0000000000564ac0] Using D3D9Ex device.
[AVHWDeviceContext @ 00000000005649c0] Initialize MFX session: API version is 1.34, implementation version is 1.4
[avi @ 0000000005631bc0] non-interleaved AVI
[h264 @ 0000000000581540] Reinit context to 1280x720, pix_fmt: yuv422p
Input #0, avi, from 'InputFile.avi':
Duration: 02:16:34.13, start: 0.000000, bitrate: 4495 kb/s
Stream #0:0: Video: h264 (High 4:2:2), 1 reference frame (H264 / 0x34363248), yuv422p(progressive, left), 1280x720 [SAR 1:1 DAR 16:9], 4281 kb/s, 60 fps, 60 tbr, 60 tbn, 120 tbc
Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, fltp, 192 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_qsv))
Stream #0:1 -> #0:1 (ac3 (native) -> aac (native))
Press [q] to stop, [?] for help
[h264 @ 00000000066a1540] Reinit context to 1280x720, pix_fmt: yuv422p
[graph_1_in_0_1 @ 0000000006c52540] tb:1/48000 samplefmt:fltp samplerate:48000 chlayout:0x3
[graph 0 input from stream 0:0 @ 0000000006c52a40] w:1280 h:720 pixfmt:yuv422p tb:83333/5000000 fr:60/1 sar:1/1
[auto_scaler_0 @ 0000000006c52e40] w:iw h:ih flags:'bicubic' interl:0
[format @ 0000000006c52d40] auto-inserting filter 'auto_scaler_0' between the filter 'Parsed_null_0' and the filter 'format'
[auto_scaler_0 @ 0000000006c52e40] w:1280 h:720 fmt:yuv422p sar:1/1 -> w:1280 h:720 fmt:nv12 sar:1/1 flags:0x4
[h264_qsv @ 00000000067f32c0] Using device qsv0 (type qsv) with h264_qsv encoder.
[h264_qsv @ 00000000067f32c0] Encoder: input is system memory surface
[h264_qsv @ 00000000067f32c0] Using the constant quantization parameter (CQP) ratecontrol method
[h264_qsv @ 00000000067f32c0] Error querying encoder params: 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
bench: maxrss=113992kB
[AVIOContext @ 00000000066a1040] Statistics: 0 seeks, 0 writeouts
[aac @ 00000000063f42c0] Qavg: nan
[aac @ 00000000063f42c0] 1 frames left in the queue on closing
[AVIOContext @ 0000000005631700] Statistics: 12998952 bytes read, 196 seeks
Conversion failed!
在我看来,QSV 硬件已被找到并激活,但我不明白为什么会出现错误“查询编码器参数时出错:不支持 (-3)”。我在尝试编码 2160p 视频时也看到过类似的错误,这超出了编码器的范围:但此视频为 1280x720,帧率为 60 fps,约为 4000 kbps,这应该在 x264_qsv 编码器的范围内。此外,我在两个 Windows 7 和一个 Windows 10 系统上从同一来源编码了类似的文件,没有任何问题。我使用的是从其中一个工作系统复制的 ffmpeg.exe,所以我知道可执行文件可以工作。我已经在网上搜索了错误,但没有找到相关的帖子。我查看了此处的“QSV”索引,我认为以前没有报告过此错误。
有人能指出这个问题的原因吗?希望可以解决这个问题?系统快要正常工作时却出现这个错误,这会带来很大的压力。
提前致谢。
答案1
我对 ffmpeg 完全是个新手,但我觉得这可能是由不受支持的像素格式(由该处理器)引起的。
您的捕获:
[h264 @ 0000000000581540] 将上下文重新初始化为 1280x720,pix_fmt:yuv422p
您可以尝试将像素格式更改为yuv420p
或nv12
然后yuyv422
再试一次吗?