0

I'm trying to convert a WebM video coming from a webcam to an MP4 x264 format. I tried to use this ffmpeg command:

ffmpeg -stats -nostdin -y -flags global_header -i "/home/Foto/incoming-video/2017-05-01-122614.webm" -c:v libx264 -preset slower -crf 20 -c:a aac "/home/Foto/rename-video/webm-test.mp4"

Log coming from the command is:

ffmpeg version 3.4.2-1~16.04.york0 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.6) 20160609
  configuration: --prefix=/usr --extra-version='1~16.04.york0' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth -enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgs --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex -enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enabl-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Input #0, matroska,webm, from '/home/Foto/incoming-video/2017-05-01-122614.webm':
  Metadata:
    encoder         : GStreamer matroskamux version 1.8.3
    creation_time   : 2017-05-01T10:26:14.000000Z
  Duration: 00:00:57.57, start: 0.000000, bitrate: 3198 kb/s
    Stream #0:0(eng): Video: vp8, yuv420p(progressive), 1280x720, SAR 1:1 DAR 16:9, 250 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      title           : Video
    Stream #0:1(eng): Audio: vorbis, 44100 Hz, mono, fltp (default)
    Metadata:
      title           : Audio
Stream mapping:
  Stream #0:0 -> #0:0 (vp8 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (vorbis (native) -> aac (native))
[libx264 @ 0x55cb6afacd80] using SAR=1/1
[libx264 @ 0x55cb6afacd80] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
[libx264 @ 0x55cb6afacd80] profile High, level 5.1
[libx264 @ 0x55cb6afacd80] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=8 deblock=1:0:0 analyse=0x3:0x133 me=umh subme=9 psy=1 psy_rd=1.00:000 mixed_ref=1 me_range=16 chroma_me=1 trellis=2 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframs=3 b_pyramid=2 b_adapt=2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=60 rc=crf mbtree=1 crf=20.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '/home/Foto/rename-video/webm-test.mp4':
  Metadata:
    encoder         : Lavf57.83.100
    Stream #0:0(eng): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 250 fps, 16k tbn, 250 tbc (default)
    Metadata:
      title           : Video
      encoder         : Lavc57.107.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 69 kb/s (default)
    Metadata:
      title           : Audio
      encoder         : Lavc57.107.100 aac
More than 1000 frames duplicated
More than 10000 frames duplicated
frame=14392 fps= 14 q=-1.0 Lsize=   44929kB time=00:00:57.55 bitrate=6394.8kbits/s dup=12683 drop=0 speed=0.0575x
video:44230kB audio:489kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.471058%
[libx264 @ 0x55cb6afacd80] frame I:61    Avg QP:17.26  size: 98800
[libx264 @ 0x55cb6afacd80] frame P:3627  Avg QP:20.45  size: 10478
[libx264 @ 0x55cb6afacd80] frame B:10704 Avg QP:23.79  size:   118
[libx264 @ 0x55cb6afacd80] consecutive B-frames:  0.8%  0.0%  0.0% 99.1%
[libx264 @ 0x55cb6afacd80] mb I  I16..4:  6.5% 79.7% 13.8%
[libx264 @ 0x55cb6afacd80] mb P  I16..4:  0.7%  1.6%  0.1%  P16..4: 33.3%  4.7%  5.2%  0.0%  0.0%    skip:54.3%
[libx264 @ 0x55cb6afacd80] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  3.2%  0.0%  0.0%  direct: 0.0%  skip:96.8%  L0:30.0% L1:69.7% BI: 0.3%
[libx264 @ 0x55cb6afacd80] 8x8 transform intra:71.1% inter:60.1%
[libx264 @ 0x55cb6afacd80] direct mvs  spatial:100.0% temporal:0.0%
[libx264 @ 0x55cb6afacd80] coded y,uvDC,uvAC intra: 68.5% 91.9% 70.6% inter: 4.2% 7.6% 1.4%
[libx264 @ 0x55cb6afacd80] i16 v,h,dc,p: 20% 17% 33% 30%
[libx264 @ 0x55cb6afacd80] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 11% 11%  6% 11% 15% 10% 10% 10%
[libx264 @ 0x55cb6afacd80] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 15%  7%  5%  5% 24% 20%  9%  7%  7%
[libx264 @ 0x55cb6afacd80] i8c dc,h,v,p: 50% 20% 16% 14%
[libx264 @ 0x55cb6afacd80] Weighted P-Frames: Y:1.7% UV:0.9%
[libx264 @ 0x55cb6afacd80] ref P L0: 68.7% 15.8%  8.2%  1.4%  1.9%  2.3%  1.3%  0.3%  0.0%
[libx264 @ 0x55cb6afacd80] ref B L0: 92.5%  6.3%  0.7%  0.3%  0.1%  0.1%  0.0%
[libx264 @ 0x55cb6afacd80] ref B L1: 95.0%  5.0%
[libx264 @ 0x55cb6afacd80] kb/s:6293.87
[aac @ 0x55cb6afc6bc0] Qavg: 233.656

I noticed the "More than 10000 frames duplicated" warning message during video compression. At the end, I obtained an MP4 file with an awful quality, a jerky video with many boxes very different from the original (which was a very smooth video with a discrete frame quality). Moreover, output file size is double respect to the original one (44 MB instead of 22), so I don't understand the reason of this lack of quality.

Can you help me?

  • 1
    A total of 12683 frames have been duplicated for a 1 minute video! The input's framerate data isn't correctly reported . Add -vsync 0 after -crf 20 and check. – Gyan Mar 27 '18 at 12:22
  • @Mulvya, it seems that adding -vsync 0 resolved the issue. Can you explain me if this parameter is useful just for this case or if it would be a good practice to use it when performing mass conversion of files in different formats? If you'll put an answer with that comment I'll accept it as the good one, thanks. – liv913 Mar 28 '18 at 8:07

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.