使用 libav-tools 与从源代码构建的 libav - 视频质量更差
Using libav-tools versus libav built from source - video quality much worse
我们正在尝试从静止图像创建视频,运行宁 Ubuntu 14.04。
如果我们安装了 libav-tools,那么输出的视频质量要比我们手动安装 libav 的质量高得多。不幸的是,我们需要 运行 一个从源代码构建 libav 的解决方案,因此我们想了解如何提高质量。
这是 libav-tools(更高质量)的控制台输出:
avconv version 9.18-6:9.18-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
built on Mar 16 2015 13:19:10 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
[image2 @ 0x22ae120] max_analyze_duration reached
Input #0, image2, from 'frame.%04d.jpg':
Duration: 00:00:10.00, start: 0.000000, bitrate: N/A
Stream #0.0: Video: mjpeg, yuvj420p, 1280x720 [PAR 1:1 DAR 16:9], 8 fps, 8 tbr, 8 tbn
[libx264 @ 0x22afac0] using SAR=1/1
[libx264 @ 0x22afac0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[libx264 @ 0x22afac0] profile High, level 3.1
[libx264 @ 0x22afac0] 264 - core 142 r2389 956c8d8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=8 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.25 aq=1:1.00
Output #0, mp4, to 'a1.mp4':
Metadata:
encoder : Lavf54.20.4
Stream #0.0: Video: libx264, yuvj420p, 1280x720 [PAR 1:1 DAR 16:9], q=-1--1, 8 tbn, 8 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg -> libx264)
Press ctrl-c to stop encoding
frame= 159 fps= 43 q=32766.0 Lsize= 1580kB time=19.62 bitrate= 659.3kbits/s
video:607kB audio:0kB global headers:0kB muxing overhead 160.388953%
[libx264 @ 0x22afac0] frame I:21 Avg QP:14.32 size: 21142
[libx264 @ 0x22afac0] frame P:132 Avg QP:16.12 size: 8691
[libx264 @ 0x22afac0] frame B:6 Avg QP:13.61 size: 3874
[libx264 @ 0x22afac0] consecutive B-frames: 95.0% 0.0% 0.0% 5.0%
[libx264 @ 0x22afac0] mb I I16..4: 37.4% 61.4% 1.2%
[libx264 @ 0x22afac0] mb P I16..4: 9.1% 19.2% 0.3% P16..4: 6.2% 2.8% 1.3% 0.0% 0.0% skip:61.1%
[libx264 @ 0x22afac0] mb B I16..4: 1.8% 2.0% 0.0% B16..8: 31.9% 7.1% 0.7% direct: 9.2% skip:47.3% L0:69.8% L1:29.5% BI: 0.8%
[libx264 @ 0x22afac0] 8x8 transform intra:65.0% inter:92.8%
[libx264 @ 0x22afac0] coded y,uvDC,uvAC intra: 36.3% 31.8% 7.1% inter: 3.6% 6.0% 0.7%
[libx264 @ 0x22afac0] i16 v,h,dc,p: 74% 14% 6% 6%
[libx264 @ 0x22afac0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 24% 32% 5% 2% 3% 2% 1% 3%
[libx264 @ 0x22afac0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 51% 23% 9% 2% 3% 6% 3% 1% 2%
[libx264 @ 0x22afac0] i8c dc,h,v,p: 52% 20% 25% 2%
[libx264 @ 0x22afac0] Weighted P-Frames: Y:6.8% UV:6.1%
[libx264 @ 0x22afac0] ref P L0: 58.1% 6.2% 12.1% 22.6% 0.9%
[libx264 @ 0x22afac0] ref B L0: 83.0% 16.3% 0.7%
[libx264 @ 0x22afac0] ref B L1: 93.5% 6.5%
[libx264 @ 0x22afac0] kb/s:649.85
这是手动构建的 libav 的控制台输出(质量较低):
avconv version 11.4, Copyright (c) 2000-2014 the Libav developers
built on Jun 17 2015 02:19:28 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
[image2 @ 0x329f140] max_analyze_duration 5000000 reached
Input #0, image2, from 'frame.%04d.jpg':
Duration: 00:00:10.00, start: 0.000000, bitrate: N/A
Stream #0.0: Video: mjpeg, yuvj420p, 1280x720 [PAR 1:1 DAR 16:9], 8 fps, 8 tbn
Output #0, mp4, to 'a2.mp4':
Metadata:
encoder : Lavf56.1.0
Stream #0.0: Video: mpeg4, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 8 fps, 8 tbn, 8 tbc
Metadata:
encoder : Lavc56.1.0 mpeg4
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> mpeg4 (native))
Press ctrl-c to stop encoding
frame= 159 fps= 0 q=31.0 Lsize= 902kB time=19.75 bitrate= 374.2kbits/s
video:900kB audio:0kB other streams:0kB global headers:0kB muxing overhead: 0.239928%
以防万一:图像被命名为 frame.0000.jpg、frame.0001.jpg 等,所以我们的命令是:
avconv -y -f image2 -r 8 -i frame.%04d.jpg -vf "setpts=2*PTS" videofile.mp4
对于上面显示的两个 运行。任何帮助将不胜感激!
我也将此作为错误报告发布在 libav 的 Bugzilla 上。 John Van Sickle 慷慨回应:
The difference in quality is due to the older version being built with libx264 support, which is a h264 encoder. Since I'm guessing the newer build isn't, it's defaulting to the mpeg4 codec. You can either install libx264-dev and rebuild libav with libx264 support or try my static builds: http://johnvansickle.com/libav/
我们正在尝试从静止图像创建视频,运行宁 Ubuntu 14.04。
如果我们安装了 libav-tools,那么输出的视频质量要比我们手动安装 libav 的质量高得多。不幸的是,我们需要 运行 一个从源代码构建 libav 的解决方案,因此我们想了解如何提高质量。
这是 libav-tools(更高质量)的控制台输出:
avconv version 9.18-6:9.18-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
built on Mar 16 2015 13:19:10 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
[image2 @ 0x22ae120] max_analyze_duration reached
Input #0, image2, from 'frame.%04d.jpg':
Duration: 00:00:10.00, start: 0.000000, bitrate: N/A
Stream #0.0: Video: mjpeg, yuvj420p, 1280x720 [PAR 1:1 DAR 16:9], 8 fps, 8 tbr, 8 tbn
[libx264 @ 0x22afac0] using SAR=1/1
[libx264 @ 0x22afac0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[libx264 @ 0x22afac0] profile High, level 3.1
[libx264 @ 0x22afac0] 264 - core 142 r2389 956c8d8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=8 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.25 aq=1:1.00
Output #0, mp4, to 'a1.mp4':
Metadata:
encoder : Lavf54.20.4
Stream #0.0: Video: libx264, yuvj420p, 1280x720 [PAR 1:1 DAR 16:9], q=-1--1, 8 tbn, 8 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg -> libx264)
Press ctrl-c to stop encoding
frame= 159 fps= 43 q=32766.0 Lsize= 1580kB time=19.62 bitrate= 659.3kbits/s
video:607kB audio:0kB global headers:0kB muxing overhead 160.388953%
[libx264 @ 0x22afac0] frame I:21 Avg QP:14.32 size: 21142
[libx264 @ 0x22afac0] frame P:132 Avg QP:16.12 size: 8691
[libx264 @ 0x22afac0] frame B:6 Avg QP:13.61 size: 3874
[libx264 @ 0x22afac0] consecutive B-frames: 95.0% 0.0% 0.0% 5.0%
[libx264 @ 0x22afac0] mb I I16..4: 37.4% 61.4% 1.2%
[libx264 @ 0x22afac0] mb P I16..4: 9.1% 19.2% 0.3% P16..4: 6.2% 2.8% 1.3% 0.0% 0.0% skip:61.1%
[libx264 @ 0x22afac0] mb B I16..4: 1.8% 2.0% 0.0% B16..8: 31.9% 7.1% 0.7% direct: 9.2% skip:47.3% L0:69.8% L1:29.5% BI: 0.8%
[libx264 @ 0x22afac0] 8x8 transform intra:65.0% inter:92.8%
[libx264 @ 0x22afac0] coded y,uvDC,uvAC intra: 36.3% 31.8% 7.1% inter: 3.6% 6.0% 0.7%
[libx264 @ 0x22afac0] i16 v,h,dc,p: 74% 14% 6% 6%
[libx264 @ 0x22afac0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 24% 32% 5% 2% 3% 2% 1% 3%
[libx264 @ 0x22afac0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 51% 23% 9% 2% 3% 6% 3% 1% 2%
[libx264 @ 0x22afac0] i8c dc,h,v,p: 52% 20% 25% 2%
[libx264 @ 0x22afac0] Weighted P-Frames: Y:6.8% UV:6.1%
[libx264 @ 0x22afac0] ref P L0: 58.1% 6.2% 12.1% 22.6% 0.9%
[libx264 @ 0x22afac0] ref B L0: 83.0% 16.3% 0.7%
[libx264 @ 0x22afac0] ref B L1: 93.5% 6.5%
[libx264 @ 0x22afac0] kb/s:649.85
这是手动构建的 libav 的控制台输出(质量较低):
avconv version 11.4, Copyright (c) 2000-2014 the Libav developers
built on Jun 17 2015 02:19:28 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
[image2 @ 0x329f140] max_analyze_duration 5000000 reached
Input #0, image2, from 'frame.%04d.jpg':
Duration: 00:00:10.00, start: 0.000000, bitrate: N/A
Stream #0.0: Video: mjpeg, yuvj420p, 1280x720 [PAR 1:1 DAR 16:9], 8 fps, 8 tbn
Output #0, mp4, to 'a2.mp4':
Metadata:
encoder : Lavf56.1.0
Stream #0.0: Video: mpeg4, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 8 fps, 8 tbn, 8 tbc
Metadata:
encoder : Lavc56.1.0 mpeg4
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> mpeg4 (native))
Press ctrl-c to stop encoding
frame= 159 fps= 0 q=31.0 Lsize= 902kB time=19.75 bitrate= 374.2kbits/s
video:900kB audio:0kB other streams:0kB global headers:0kB muxing overhead: 0.239928%
以防万一:图像被命名为 frame.0000.jpg、frame.0001.jpg 等,所以我们的命令是:
avconv -y -f image2 -r 8 -i frame.%04d.jpg -vf "setpts=2*PTS" videofile.mp4
对于上面显示的两个 运行。任何帮助将不胜感激!
我也将此作为错误报告发布在 libav 的 Bugzilla 上。 John Van Sickle 慷慨回应:
The difference in quality is due to the older version being built with libx264 support, which is a h264 encoder. Since I'm guessing the newer build isn't, it's defaulting to the mpeg4 codec. You can either install libx264-dev and rebuild libav with libx264 support or try my static builds: http://johnvansickle.com/libav/