Using libav-tools versus libav built from source - video quality much worse

158 views Asked by At

We are trying to create a video from still images, running on Ubuntu 14.04.

If we have installed libav-tools then the output video is much higher quality than if we have installed libav manually. Unfortunately, we need to run a solution where libav is built from source, so we want to find out how to improve the quality.

Here is the console output for the libav-tools (higher quality):

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

Here is the console output for libav built manually (lower quality):

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%

In case it helps: the images are named frame.0000.jpg, frame.0001.jpg, etc., so our command is: avconv -y -f image2 -r 8 -i frame.%04d.jpg -vf "setpts=2*PTS" videofile.mp4 for both runs shown above. Any help would be hugely appreciated!

1

There are 1 answers

0
kislo On BEST ANSWER

I posted this as a bug report on libav's Bugzilla as well. John Van Sickle generously responded:

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/