我已经习惯了ffmpeg -i VID_20210426_044355366.mp4 -acodec libmp3lame -vcodec libx264 -preset ultrafast abc.mp4
,所以只使用 libx264 软件编码器。就质量而言,默认 CRF 对我来说很好。就质量而言,那个预设的超快对我来说很好。
但我想知道我是否可以让它更快。我不介意为了速度而牺牲一些质量。
我的笔记本电脑配有 Intel Core i5 处理器。那么我是否可以使用一些硬件编码?
我试过
ffmpeg -i myvideo.mp4 -acodec libmp3lame -hwaccel qsv -vcodec h264_qsv abc.mp4
但它给了我一些错误
G:\>ffmpeg -i aaa.mp4 -acodec copy -vcodec h264_qsv blah.mp4
ffmpeg version N-94664-g0821bc4eee Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.1.1 (GCC) 20190807
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --e
nable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus -
-enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --ena
ble-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enabl
e-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid
--enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 33.100 / 56. 33.100
libavcodec 58. 55.101 / 58. 55.101
libavformat 58. 31.104 / 58. 31.104
libavdevice 58. 9.100 / 58. 9.100
libavfilter 7. 58.101 / 7. 58.101
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'aaa.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2021-04-26T03:30:13.000000Z
com.android.version: 10
com.android.manufacturer: motorola
com.android.model: moto g(7) power
Duration: 00:09:10.70, start: 0.000000, bitrate: 17326 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, smpte170m), 1920x1080, 17000 kb/s, SAR 1:1 DAR 16:9, 25.04 fps, 25 tbr, 90k
tbn, 180k tbc (default)
Metadata:
rotate : 270
creation_time : 2021-04-26T03:30:13.000000Z
handler_name : VideoHandle
Side data:
displaymatrix: rotation of 90.00 degrees
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 319 kb/s (default)
Metadata:
creation_time : 2021-04-26T03:30:13.000000Z
handler_name : SoundHandle
File 'blah.mp4' already exists. Overwrite ? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_qsv))
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[swscaler @ 0000000005414700] deprecated pixel format used, make sure you did set range correctly
[h264_qsv @ 0000000000404dc0] Error initializing the encoder: invalid video parameters (-15)
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
Conversion failed!
G:\a>ffmpeg -i aaa.mp4 -acodec copy -vcodec h264_qsv blah.mp4
黄色部分表示“使用了弃用的像素格式,请确保正确设置了范围”
红色部分为“初始化编码器时出错:视频参数无效 (-15) 初始化输出流 0:0 时出错 - 打开输出流 #0:0 的编码器时出错 - 可能是比特率、速率、宽度或高度等参数不正确”
并显示“转换失败”。
如果我这样做,我会得到类似的结果 ffmpeg -hwaccel qsv -i aaa.mp4 -acodec copy -vcodec h264_qsv blah.mp4
我认为这些页面可能相关https://trac.ffmpeg.org/wiki/Hardware/QuickSync 和https://trac.ffmpeg.org/wiki/HWAccelIntro 但我不知道该尝试什么