Fix/remux mp4 to get correct video length

I captured a roughly two hour MS Teams video session using vlc. No audio, that is fine. When I open the file in a video player, it erroneously reports a length of 36 minutes, however it keeps playing to the end just fine. Plays also fine if I open the mp4 in Firefox. Firefox just continues counting seconds past the reported length.

I require this file to be regularly playable with correct duration report.

I already did the following:

ffprobe out.mp4 -show_entries stream=codec_type,start_time,duration -of compact

Output is:

ffprobe version n4.4.1 Copyright (c) 2007-2021 the FFmpeg developers
  built with gcc 11.1.0 (GCC)
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librav1e --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-nvdec --enable-nvenc --enable-shared --enable-version3
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55b59e4b4e80] st: 0 edit list: 1 Missing key frame while searching for timestamp: 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55b59e4b4e80] st: 0 edit list 1 Cannot find an index entry before timestamp: 0.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 0
    compatible_brands: mp41avc1
    creation_time   : 2021-12-02T09:59:14.000000Z
    encoder         : vlc 3.0.16 stream output
    encoder-eng     : vlc 3.0.16 stream output
  Duration: 00:36:11.50, start: 0.000000, bitrate: 188 kb/s
  Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, unknown/unknown/bt709), 1920x1080 [SAR 1:1 DAR 16:9], 186 kb/s, 3.44 fps, 11.75 tbr, 1000k tbn, 50 tbc (default)
    Metadata:
      creation_time   : 2021-12-02T09:59:14.000000Z
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
stream|codec_type=video|start_time=0.000000|duration=2171.496004

If I render to the null device with ffmpeg -i out.mp4 -f null - the result is:

frame= 7561 fps=532 q=-0.0 Lsize=N/A time=00:36:14.12 bitrate=N/A speed= 153x  

So again ffmpeg stubbornly refuses to "play" past the duration. Thus If I copy the input stream with ffmpeg -i out.mp4 -codec copy out1.mp4 the resulting file size is roughly a quarter of the original - ffmpeg just chops of the remaining video.

Please help me to resurrect the file!


An edit list, located in the moov atom, can instruct applications to play certain segments of a video. If the edit list is written incorrectly, it may prevent correct play back.
You can disable the reading of the edit list with the option: -ignore_editlist 1.
Input option. Concerns mov, mp4, m4a, 3gp, 3g2, mj2.
To refer to the ffmpeg documentation.