20230403在WIN10下通过ffmpeg调用NVIDIA的硬件加速wmv视频转码为MP4格式
20230403在WIN10下通过ffmpeg调用NVIDIA的硬件加速wmv视频转码为MP4格式
2023/4/3 15:50
最近向学习日语,找到日语发音的视频中,大多数是MP4格式,少量是WMV格式,PR2023貌似不能识别WMV格式。
于是:万能的ffmpeg上场了!
手动指定编解码器
通过 ffmpeg -codecs | findstr "vc1" 查看 vc1 的编解码器
可以看到有 i卡 专用的 vc1_qsv 和 N卡 专用的 vc1_cuivid 解码器
加入参数-c:v来指定解码器:ffmpeg -c:v vc1_cuvid -i input2.wmv -c:v h264_nvenc output.mp4 (根据你的显卡选择对应的编解码器,我这里是 N卡 所以选择了 vc1_cuvid 作为解码器,h264_nvenc 作为编码器)
可以看到转码速度非常快,并且硬件编解码器也得到了充分的利用,CPU 占用也较低。
同样也是注意 nvenc 默认编码输出为 2000k 码率,可以手动设置码率来降低画质损失。
ffmpeg -c:v vc1_cuvid -i input2.wmv -c:v h264_nvenc output.mp4
C:\Users\Sun>cd G:\迅雷下载\三上悠亚(三上悠亜-Mikami Yua)\TEK-067
C:\Users\Sun>g:
G:\迅雷下载\三上悠亚(三上悠亜-Mikami Yua)\TEK-067>
G:\迅雷下载\三上悠亚(三上悠亜-Mikami Yua)\TEK-067>dir
驱动器 G 中的卷是 18680688682
卷的序列号是 2A59-69C0
G:\迅雷下载\三上悠亚(三上悠亜-Mikami Yua)\TEK-067 的目录
2023/03/18 19:03 <DIR> .
2023/03/18 19:03 <DIR> ..
2023/03/18 19:03 137,393 TEK-067.jpg
2023/03/17 10:46 7,785,976,422 TEK-067.wmv
2 个文件 7,786,113,815 字节
2 个目录 133,153,181,696 可用字节
G:\迅雷下载\三上悠亚(三上悠亜-Mikami Yua)\TEK-067>ffmpeg -c:v vc1_cuvid -i TEK-067.wmv -c:v h264_nvenc d:\2.mp4
ffmpeg version git-2020-06-28-4cfcfb3 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9.3.1 (GCC) 20200621
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libgsm --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
libavutil 56. 55.100 / 56. 55.100
libavcodec 58. 93.100 / 58. 93.100
libavformat 58. 47.100 / 58. 47.100
libavdevice 58. 11.100 / 58. 11.100
libavfilter 7. 86.100 / 7. 86.100
libswscale 5. 8.100 / 5. 8.100
libswresample 3. 8.100 / 3. 8.100
libpostproc 55. 8.100 / 55. 8.100
Input #0, asf, from 'TEK-067.wmv':
Metadata:
copyright : MUTEKI
DeviceConformanceTemplate: AP@L3
WM/WMADRCPeakReference: 32767
WM/WMADRCPeakTarget: 32767
WM/WMADRCAverageReference: 3283
WM/WMADRCAverageTarget: 3283
artist : MUTEKI
IsVBR : 0
WMFSDKNeeded : 0.0.0.0000
WMFSDKVersion : 12.0.7601.17514
Duration: 02:56:19.69, start: 0.000000, bitrate: 5887 kb/s
Stream #0:0(jpn): Audio: wmapro (b[1][0][0] / 0x0162), 44100 Hz, stereo, fltp, 256 kb/s
Stream #0:1(jpn): Video: vc1 (Advanced) (WVC1 / 0x31435657), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 5744 kb/s, 29.97 tbr, 1k tbn, 59.94 tbc
Stream mapping:
Stream #0:1 -> #0:0 (vc1 (vc1_cuvid) -> h264 (h264_nvenc))
Stream #0:0 -> #0:1 (wmapro (native) -> aac (native))
Press [q] to stop, [?] for help
Output #0, mp4, to 'd:\2.mp4':
Metadata:
copyright : MUTEKI
DeviceConformanceTemplate: AP@L3
WM/WMADRCPeakReference: 32767
WM/WMADRCPeakTarget: 32767
WM/WMADRCAverageReference: 3283
WM/WMADRCAverageTarget: 3283
artist : MUTEKI
IsVBR : 0
WMFSDKNeeded : 0.0.0.0000
WMFSDKVersion : 12.0.7601.17514
encoder : Lavf58.47.100
Stream #0:0(jpn): Video: h264 (h264_nvenc) (Main) (avc1 / 0x31637661), nv12(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 2000 kb/s, 29.97 fps, 30k tbn, 29.97 tbc
Metadata:
encoder : Lavc58.93.100 h264_nvenc
Side data:
cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 4000000 vbv_delay: N/A
Stream #0:1(jpn): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc58.93.100 aac
[aac @ 000001804f1195c0] Queue input is backward in time.94 bitrate=1954.7kbits/s speed=6.95x
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 508373, current: 507900; changing to 508374. This may result in incorrect timestamps in the output file.
[aac @ 000001804f1195c0] Queue input is backward in time.08 bitrate=2291.3kbits/s speed=7.56x
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 2442202, current: 2441200; changing to 2442203. This may result in incorrect timestamps in the output file.
[aac @ 000001804f1195c0] Queue input is backward in time.32 bitrate=2222.9kbits/s speed=8.25x
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 9405416, current: 9403840; changing to 9405417. This may result in incorrect timestamps in the output file.
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 9405417, current: 9404864; changing to 9405418. This may result in incorrect timestamps in the output file.
[aac @ 000001804f1195c0] Queue input is backward in time.36 bitrate=2137.0kbits/s speed=8.08x
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 12993524, current: 12992477; changing to 12993525. This may result in incorrect timestamps in the output file.
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 12993525, current: 12993501; changing to 12993526. This may result in incorrect timestamps in the output file.
[aac @ 000001804f1195c0] Queue input is backward in time.16 bitrate=2195.6kbits/s speed=7.77x
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 30819293, current: 30818271; changing to 30819294. This may result in incorrect timestamps in the output file.
[aac @ 000001804f1195c0] Queue input is backward in time.65 bitrate=2178.4kbits/s speed=7.88x
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 39093227, current: 39092180; changing to 39093228. This may result in incorrect timestamps in the output file.
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 39093228, current: 39093204; changing to 39093229. This may result in incorrect timestamps in the output file.
[aac @ 000001804f1195c0] Queue input is backward in time.19 bitrate=2189.7kbits/s speed= 7.9x
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 40715225, current: 40714223; changing to 40715226. This may result in incorrect timestamps in the output file.
[aac @ 000001804f1195c0] Queue input is backward in time.89 bitrate=2210.5kbits/s speed=6.41x
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 84823029, current: 84821984; changing to 84823030. This may result in incorrect timestamps in the output file.
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 84823030, current: 84823008; changing to 84823031. This may result in incorrect timestamps in the output file.
[aac @ 000001804f1195c0] Queue input is backward in time.48 bitrate=2189.7kbits/s speed=6.27x
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 93422573, current: 93421528; changing to 93422574. This may result in incorrect timestamps in the output file.
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 93422574, current: 93422552; changing to 93422575. This may result in incorrect timestamps in the output file.
[aac @ 000001804f1195c0] Queue input is backward in time.48 bitrate=2189.6kbits/s speed=6.27x
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 93619173, current: 93617597; changing to 93619174. This may result in incorrect timestamps in the output file.
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 93619174, current: 93618621; changing to 93619175. This may result in incorrect timestamps in the output file.
[aac @ 000001804f1195c0] Queue input is backward in time.35 bitrate=2188.6kbits/s speed=6.27x
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 93668344, current: 93666768; changing to 93668345. This may result in incorrect timestamps in the output file.
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 93668345, current: 93667792; changing to 93668346. This may result in incorrect timestamps in the output file.
[aac @ 000001804f1195c0] Queue input is backward in time.62 bitrate=2189.1kbits/s speed=6.26x
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 93897708, current: 93896662; changing to 93897709. This may result in incorrect timestamps in the output file.
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 93897709, current: 93897686; changing to 93897710. This may result in incorrect timestamps in the output file.
[aac @ 000001804f1195c0] Queue input is backward in time.20 bitrate=2188.1kbits/s speed=6.26x
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 94405608, current: 94404605; changing to 94405609. This may result in incorrect timestamps in the output file.
[aac @ 000001804f1195c0] Queue input is backward in time.54 bitrate=2186.4kbits/s speed=6.25x
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 94831589, current: 94830567; changing to 94831590. This may result in incorrect timestamps in the output file.
[aac @ 000001804f1195c0] Queue input is backward in time.51 bitrate=2185.3kbits/s speed=6.25x
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 94946274, current: 94945271; changing to 94946275. This may result in incorrect timestamps in the output file.
[aac @ 000001804f1195c0] Queue input is backward in time.58 bitrate=2185.2kbits/s speed=6.25x
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 94995445, current: 94994399; changing to 94995446. This may result in incorrect timestamps in the output file.
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 94995446, current: 94995423; changing to 94995447. This may result in incorrect timestamps in the output file.
[aac @ 000001804f1195c0] Queue input is backward in time.39 bitrate=2183.1kbits/s speed=6.24x
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 95241215, current: 95240168; changing to 95241216. This may result in incorrect timestamps in the output file.
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 95241216, current: 95241192; changing to 95241217. This may result in incorrect timestamps in the output file.
[aac @ 000001804f1195c0] Queue input is backward in time.76 bitrate=2193.1kbits/s speed=6.21x
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 98436078, current: 98435037; changing to 98436079. This may result in incorrect timestamps in the output file.
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 98436079, current: 98436061; changing to 98436080. This may result in incorrect timestamps in the output file.
[aac @ 000001804f1195c0] Queue input is backward in time2.88 bitrate=2200.1kbits/s speed=7.11x
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 215712746, current: 215711710; changing to 215712747. This may result in incorrect timestamps in the output file.
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 215712747, current: 215712734; changing to 215712748. This may result in incorrect timestamps in the output file.
[aac @ 000001804f1195c0] Queue input is backward in time1.08 bitrate=2196.4kbits/s speed=7.12x
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 216945622, current: 216944614; changing to 216945623. This may result in incorrect timestamps in the output file.
[aac @ 000001804f1195c0] Queue input is backward in time6.74 bitrate=2197.6kbits/s speed=7.14x
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 221201399, current: 221200352; changing to 221201400. This may result in incorrect timestamps in the output file.
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 221201400, current: 221201376; changing to 221201401. This may result in incorrect timestamps in the output file.
[aac @ 000001804f1195c0] Queue input is backward in time5.43 bitrate=2213.6kbits/s speed=7.43x
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 316339164, current: 316338164; changing to 316339165. This may result in incorrect timestamps in the output file.
[aac @ 000001804f1195c0] Queue input is backward in time3.78 bitrate=2203.3kbits/s speed=7.44x
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 321651673, current: 321650141; changing to 321651674. This may result in incorrect timestamps in the output file.
[mp4 @ 000001804f5a3580] Non-monotonous DTS in output stream 0:1; previous: 321651674, current: 321651165; changing to 321651675. This may result in incorrect timestamps in the output file.
frame=317078 fps=229 q=24.0 Lsize= 2851835kB time=02:56:19.80 bitrate=2208.2kbits/s dup=6 drop=0 speed=7.64x
video:2677348kB audio:165245kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.325136%
[aac @ 000001804f1195c0] Qavg: 521.184
G:\迅雷下载\三上悠亚(三上悠亜-Mikami Yua)\TEK-067>
转码过程中,CPU和GPU的消耗都比较大,可能是我用的电脑比较古老/经典吧!
参考资料:
https://blog.csdn.net/ramondq/article/details/127803494
ffmpeg 硬件加速 wmv 视频转码
kotlean已于 2022-12-22 22:41:39 修改