[FFmpeg-user] 2nd pass has more frames than 1st pass (99021)2kbits/s dup=27 drop=0 speed=4.76x

Mathieu Malaterre mathieu.malaterre at gmail.com
Sun Nov 29 17:08:06 EET 2020


Hi there,

I am staring at the following guide to re-encode an existing avi
(mpeg4+mp3) into MP4 (h264+aac):

https://trac.ffmpeg.org/wiki/Encode/H.264#twopass

My video is such that:

$ ffprobe -show_streams -show_format -print_format json -i input.avi
[...]
Input #0, avi, from 'input.avi':
  Duration: 01:06:01.97, start: 0.000000, bitrate: 1459 kb/s
    Stream #0:0: Video: mpeg4 (DIVX / 0x58564944), yuv420p, 640x480,
1321 kb/s, 24.99 fps, 25 tbr, 24.99 tbn, 30k tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo,
fltp, 127 kb/s
    "streams": [
        {
            "index": 0,
            "codec_name": "mpeg4",
            "bit_rate": "1321894",
...
            "index": 1,
            "codec_name": "mp3",
            "bit_rate": "127704",
...
    "format": {
        "format_name": "avi",
        "bit_rate": "1459407",

Does it make sense to simply copy/paste the existing bit_rate to
re-encode it ? Or did I miss something from the guide (I find it hard
to make sense of the error message given) ?

In my case, the following command:

$ ffmpeg -y -i input.avi -c:v libx264 -b:v 1321894 -pass 1 -an -f null
/dev/null && \
ffmpeg -y -i input.avi -c:v libx264 -b:v 1321894 -pass 2 -c:a aac -b:a
128k fixed.mp4

gives:

ffmpeg version 4.1.6-1~deb10u1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr --extra-version='1~deb10u1'
--toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu
--incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl
--disable-stripping --enable-avresample --disable-filter=resample
--enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom
--enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca
--enable-libcdio --enable-libcodec2 --enable-libflite
--enable-libfontconfig --enable-libfreetype --enable-libfribidi
--enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame
--enable-libmysofa --enable-libopenjpeg --enable-libopenmpt
--enable-libopus --enable-libpulse --enable-librsvg
--enable-librubberband --enable-libshine --enable-libsnappy
--enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora
--enable-libtwolame --enable-libvidstab --enable-libvorbis
--enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265
--enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi
--enable-lv2 --enable-omx --enable-openal --enable-opengl
--enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883
--enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
[mpeg4 @ 0x563b663d7580] looks like this file was encoded with
(divx4/(old)xvid/opendivx) -> forcing low_delay flag
Input #0, avi, from 'input.avi':
  Duration: 01:06:01.97, start: 0.000000, bitrate: 1459 kb/s
    Stream #0:0: Video: mpeg4 (DIVX / 0x58564944), yuv420p, 640x480,
1321 kb/s, 24.99 fps, 25 tbr, 24.99 tbn, 30k tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo,
fltp, 127 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[mpeg4 @ 0x563b667c5040] looks like this file was encoded with
(divx4/(old)xvid/opendivx) -> forcing low_delay flag
[libx264 @ 0x563b667c8380] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.2 AVX
[libx264 @ 0x563b667c8380] profile Main, level 3.0
Output #0, null, to '/dev/null':
  Metadata:
    encoder         : Lavf58.20.100
    Stream #0:0: Video: h264 (libx264), yuv420p, 640x480, q=-1--1,
1321 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.35.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/1321000 buffer size: 0 vbv_delay: -1
[mpeg4 @ 0x563b667c5040] Error at MB: 11510:57:03.56 bitrate=N/A speed=12.5x
[mpeg4 @ 0x563b667c5040] I cbpc damaged at 8 27
[mpeg4 @ 0x563b667c5040] Error at MB: 1115
[mpeg4 @ 0x563b667c5040] marker does not match f_code
    Last message repeated 23 times
[mpeg4 @ 0x563b667c5040] concealing 1200 DC, 1200 AC, 1200 MV errors in I frame
[mpeg4 @ 0x563b667c5a40] P cbpy damaged at 8 0:45.68 bitrate=N/A speed=12.5x
[mpeg4 @ 0x563b667c5a40] Error at MB: 8
[mpeg4 @ 0x563b667c5a40] marker does not match f_code
    Last message repeated 4 times
[mpeg4 @ 0x563b667c5a40] P cbpy damaged at 22 8
[mpeg4 @ 0x563b667c5a40] Error at MB: 350
[mpeg4 @ 0x563b667c5a40] marker does not match f_code
    Last message repeated 7 times
[mpeg4 @ 0x563b667c5a40] P cbpy damaged at 17 8
[mpeg4 @ 0x563b667c5a40] Error at MB: 345
[mpeg4 @ 0x563b667c5a40] marker does not match f_code
    Last message repeated 5 times
[mpeg4 @ 0x563b667c5a40] concealing 1200 DC, 1200 AC, 1200 MV errors in P frame
frame=99021 fps=315 q=-1.0 Lsize=N/A time=01:06:01.84 bitrate=N/A
speed=12.6x
video:639810kB audio:0kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: unknown
[libx264 @ 0x563b667c8380] frame I:1983  Avg QP:17.05  size: 24072
[libx264 @ 0x563b667c8380] frame P:60098 Avg QP:20.30  size:  8370
[libx264 @ 0x563b667c8380] frame B:36940 Avg QP:22.55  size:  2826
[libx264 @ 0x563b667c8380] consecutive B-frames: 37.9% 35.6%  4.9% 21.6%
[libx264 @ 0x563b667c8380] mb I  I16..4: 28.2%  0.0% 71.8%
[libx264 @ 0x563b667c8380] mb P  I16..4: 18.6%  0.0%  0.0%  P16..4:
63.7%  0.0%  0.0%  0.0%  0.0%    skip:17.6%
[libx264 @ 0x563b667c8380] mb B  I16..4:  3.7%  0.0%  0.0%  B16..8:
29.0%  0.0%  0.0%  direct:14.4%  skip:53.0%  L0:52.1% L1:35.6%
BI:12.3%
[libx264 @ 0x563b667c8380] final ratefactor: 20.25
[libx264 @ 0x563b667c8380] coded y,uvDC,uvAC intra: 44.4% 89.0% 55.0%
inter: 18.5% 35.9% 7.2%
[libx264 @ 0x563b667c8380] i16 v,h,dc,p: 33% 27% 30% 10%
[libx264 @ 0x563b667c8380] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 38% 28% 12%
4%  3%  3%  4%  3%  4%
[libx264 @ 0x563b667c8380] i8c dc,h,v,p: 44% 25% 23%  8%
[libx264 @ 0x563b667c8380] Weighted P-Frames: Y:1.2% UV:0.6%
[libx264 @ 0x563b667c8380] kb/s:1322.92
ffmpeg version 4.1.6-1~deb10u1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr --extra-version='1~deb10u1'
--toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu
--incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl
--disable-stripping --enable-avresample --disable-filter=resample
--enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom
--enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca
--enable-libcdio --enable-libcodec2 --enable-libflite
--enable-libfontconfig --enable-libfreetype --enable-libfribidi
--enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame
--enable-libmysofa --enable-libopenjpeg --enable-libopenmpt
--enable-libopus --enable-libpulse --enable-librsvg
--enable-librubberband --enable-libshine --enable-libsnappy
--enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora
--enable-libtwolame --enable-libvidstab --enable-libvorbis
--enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265
--enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi
--enable-lv2 --enable-omx --enable-openal --enable-opengl
--enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883
--enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
[mpeg4 @ 0x557341c44580] looks like this file was encoded with
(divx4/(old)xvid/opendivx) -> forcing low_delay flag
Input #0, avi, from 'input.avi':
  Duration: 01:06:01.97, start: 0.000000, bitrate: 1459 kb/s
    Stream #0:0: Video: mpeg4 (DIVX / 0x58564944), yuv420p, 640x480,
1321 kb/s, 24.99 fps, 25 tbr, 24.99 tbn, 30k tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo,
fltp, 127 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (mp3 (mp3float) -> aac (native))
Press [q] to stop, [?] for help
[mpeg4 @ 0x557342011bc0] looks like this file was encoded with
(divx4/(old)xvid/opendivx) -> forcing low_delay flag
[libx264 @ 0x557342035380] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.2 AVX
[libx264 @ 0x557342035380] profile High, level 3.0
[libx264 @ 0x557342035380] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4
AVC codec - Copyleft 2003-2018 - 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=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=2pass
mbtree=1 bitrate=1321 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4
cplxblur=20.0 qblur=0.5 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'fixed.mp4':
  Metadata:
    encoder         : Lavf58.20.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p,
640x480, q=-1--1, 1321 kb/s, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.35.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/1321000 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz,
stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc58.35.100 aac
[mpeg4 @ 0x557342011bc0] Error at MB: 1151 time=00:57:06.48
bitrate=1442.0kbits/s dup=24 drop=0 speed=5.29x
[mpeg4 @ 0x557342011bc0] I cbpc damaged at 8 27
[mpeg4 @ 0x557342011bc0] Error at MB: 1115
[mpeg4 @ 0x557342011bc0] marker does not match f_code
    Last message repeated 23 times
[mpeg4 @ 0x557342011bc0] concealing 1200 DC, 1200 AC, 1200 MV errors in I frame
[mp3float @ 0x557342034940] Header missing
Error while decoding stream #0:1: Invalid data found when processing input
[mp3float @ 0x557342034940] overread, skip -9 enddists: -1 -1
    Last message repeated 1 times
[mp3float @ 0x557342034940] overread, skip -8 enddists: -3 -3
[mpeg4 @ 0x557341c55b40] P cbpy damaged at 8 0e=00:57:51.44
bitrate=1443.8kbits/s dup=24 drop=0 speed=5.29x
[mpeg4 @ 0x557341c55b40] Error at MB: 8
[mpeg4 @ 0x557341c55b40] marker does not match f_code
    Last message repeated 4 times
[mpeg4 @ 0x557341c55b40] P cbpy damaged at 22 8
[mpeg4 @ 0x557341c55b40] Error at MB: 350
[mpeg4 @ 0x557341c55b40] marker does not match f_code
    Last message repeated 7 times
[mpeg4 @ 0x557341c55b40] P cbpy damaged at 17 8
[mpeg4 @ 0x557341c55b40] Error at MB: 345
[mpeg4 @ 0x557341c55b40] marker does not match f_code
    Last message repeated 5 times
[mpeg4 @ 0x557341c55b40] concealing 1200 DC, 1200 AC, 1200 MV errors in P frame
[libx264 @ 0x557342035380] 2nd pass has more frames than 1st pass
(99021)2kbits/s dup=27 drop=0 speed=5.37x
[libx264 @ 0x557342035380] continuing anyway, at constant QP=23
[libx264 @ 0x557342035380] disabling adaptive B-frames
zsh: segmentation fault  ffmpeg -i input.avi -c:v libx264 -b:v 1321894
-pass 2 -c:a aac -b:a 128k


-- 
Mathieu


More information about the ffmpeg-user mailing list