[FFmpeg-user] Repair/Fix an mpeg4 bitstream

Mathieu Malaterre mathieu.malaterre at gmail.com
Thu Nov 26 09:58:23 EET 2020


Hi there,

I am trying to repair an mpeg4 (mastroka container with mpeg4+mp3)
movie. The movie runs smoothly when played with mpv, but appears to
have a different frame rate when played with ffplay.

Is there a magical option to fix/repair this file ? If not how do I
re-encode it as-close as possible to the original one ?

Typical output:

$ ffmpeg -y -hide_banner -i input.mkv -c copy output.mkv
[mpeg4 @ 0x55983b4d4900] Failed to parse extradata
Input #0, matroska,webm, from 'input.mkv':
  Metadata:
    ENCODER         : Lavf58.20.100
  Duration: 01:07:47.92, start: 0.000000, bitrate: 1433 kb/s
    Stream #0:0: Video: mpeg4 (Advanced Simple Profile), yuv420p,
688x512 [SAR 1:1 DAR 43:32], 25 fps, 25 tbr, 1k tbn, 25 tbc (default)
    Metadata:
      DURATION        : 01:07:47.920000000
    Stream #0:1: Audio: mp3, 48000 Hz, stereo, fltp, 80 kb/s (default)
    Metadata:
      DURATION        : 01:07:47.880000000
Output #0, matroska, to 'output.mkv':
  Metadata:
    encoder         : Lavf58.20.100
    Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (FMP4 /
0x34504D46), yuv420p, 688x512 [SAR 1:1 DAR 43:32], q=2-31, 25 fps, 25
tbr, 1k tbn, 1k tbc (default)
    Metadata:
      DURATION        : 01:07:47.920000000
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo,
fltp, 80 kb/s (default)
    Metadata:
      DURATION        : 01:07:47.880000000
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[matroska @ 0x5623e5235200] Non-monotonous DTS in output stream 0:0;
previous: 120, current: 80; changing to 120. This may result in
incorrect timestamps in the output file.
[matroska @ 0x5623e5235200] Non-monotonous DTS in output stream 0:0;
previous: 200, current: 160; changing to 200. This may result in
incorrect timestamps in the output file.
[...]
[matroska @ 0x5623e5235200] Non-monotonous DTS in output stream 0:0;
previous: 4067760, current: 4067720; changing to 4067760. This may
result in incorrect timestamps in the output file.
[matroska @ 0x5623e5235200] Non-monotonous DTS in output stream 0:0;
previous: 4067840, current: 4067800; changing to 4067840. This may
result in incorrect timestamps in the output file.
frame=101697 fps=25330 q=-1.0 Lsize=  712029kB time=01:07:47.85
bitrate=1433.9kbits/s speed=1.01e+03x
video:652268kB audio:57828kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: 0.272119%

For reference:

$ mediainfo input.mkv
General
Unique ID                                :
32397768192667318044859340091939212367
(0x185F954BE5D18C685B5A2C008439CC4F)
Complete name                            : input.mkv
Format                                   : Matroska
Format version                           : Version 4
File size                                : 695 MiB
Duration                                 : 1 h 7 min
Overall bit rate mode                    : Variable
Overall bit rate                         : 1 434 kb/s
Writing application                      : Lavf58.20.100
Writing library                          : Lavf58.20.100
ErrorDetectionType                       : Per level 1

Video
ID                                       : 1
Format                                   : MPEG-4 Visual
Format profile                           : Advanced Simple at L5
Format settings                          : BVOP1
Format settings, BVOP                    : 1
Format settings, QPel                    : No
Format settings, GMC                     : No warppoints
Format settings, Matrix                  : Default (H.263)
Codec ID                                 : V_MPEG4/ISO/ASP
Codec ID/Info                            : Advanced Simple Profile
Duration                                 : 1 h 7 min
Width                                    : 688 pixels
Height                                   : 512 pixels
Display aspect ratio                     : 4:3
Frame rate mode                          : Constant
Frame rate                               : 25.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Compression mode                         : Lossy
Writing library                          : XviD 1.2.0.dev47 (UTC 2006-11-01)
Default                                  : Yes
Forced                                   : No

Audio
ID                                       : 2
Format                                   : MPEG Audio
Format version                           : Version 1
Format profile                           : Layer 3
Format settings                          : Joint stereo
Codec ID                                 : A_MPEG/L3
Codec ID/Hint                            : MP3
Duration                                 : 1 h 7 min
Bit rate mode                            : Variable
Channel(s)                               : 2 channels
Sampling rate                            : 48.0 kHz
Compression mode                         : Lossy
Delay relative to video                  : -40 ms
Default                                  : Yes
Forced                                   : No

and (Debian/buster)

$ ffmpeg  -version
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

Thanks,
-- 
Mathieu


More information about the ffmpeg-user mailing list