google / mediapy

This Python library makes it easy to display images and videos in a notebook.
https://pypi.org/project/mediapy/
Apache License 2.0
389 stars 18 forks source link

ffmpeg with copy codecs is not guaranteed to contain number of frames in output #44

Open futscdav opened 7 months ago

futscdav commented 7 months ago

Noticed this when using ffmpeg installed from apt, when vcodec and acodec are copy, the frame= XXX line does not appear in the output, causing api like read_video to fail. The actual output of the ffmpeg -nostdin -i videofile.m4v -acodec copy -vcodec copy -f null - call is

ffmpeg version 6.1-3 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 13 (Debian 13.2.0-5)
  configuration: --prefix=/usr --extra-version=3 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --disable-sndio --enable-libjxl --enable-pocketsphinx --enable-librsvg --enable-libvpl --disable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libsvtav1 --enable-libx264 --enable-libplacebo --enable-librav1e --enable-shared
  libavutil      58. 29.100 / 58. 29.100
  libavcodec     60. 31.102 / 60. 31.102
  libavformat    60. 16.100 / 60. 16.100
  libavdevice    60.  3.100 / 60.  3.100
  libavfilter     9. 12.100 /  9. 12.100
  libswscale      7.  5.100 /  7.  5.100
  libswresample   4. 12.100 /  4. 12.100
  libpostproc    57.  3.100 / 57.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'videofile.m4v':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2023-04-26T22:39:08.000000Z
  Duration: 00:00:16.50, start: 0.000000, bitrate: 5329 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, progressive), 640x480, 5114 kb/s, 30.10 fps, 29.67 tbr, 90k tbn (default)
    Metadata:
      creation_time   : 2023-04-26T22:39:08.000000Z
      handler_name    : ISO Media file produced by Corp Inc. Created on: 04/26/2023.
      vendor_id       : [0][0][0][0]
    Side data:
      displaymatrix: rotation of 90.00 degrees
  Stream #0:1[0x2](und): Data: none (mett / 0x7474656D), 20 kb/s (default)
    Metadata:
      creation_time   : 2023-04-26T22:39:08.000000Z
      handler_name    : ISO Media file produced by Corp Inc. Created on: 04/26/2023.
  Stream #0:2[0x3](und): Data: none (mett / 0x7474656D), 64 kb/s (default)
    Metadata:
      creation_time   : 2023-04-26T22:39:08.000000Z
      handler_name    : ISO Media file produced by Corp Inc. Created on: 04/26/2023.
  Stream #0:3[0x4](und): Data: none (mett / 0x7474656D), 64 kb/s (default)
    Metadata:
      creation_time   : 2023-04-26T22:39:08.000000Z
      handler_name    : ISO Media file produced by Corp Inc. Created on: 04/26/2023.
Output #0, null, to 'pipe:':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    encoder         : Lavf60.16.100
  Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, progressive), 640x480, q=2-31, 5114 kb/s, 30.10 fps, 29.67 tbr, 90k tbn (default)
    Metadata:
      creation_time   : 2023-04-26T22:39:08.000000Z
      handler_name    : ISO Media file produced by Corp Inc. Created on: 04/26/2023.
      vendor_id       : [0][0][0][0]
    Side data:
      displaymatrix: rotation of 90.00 degrees
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
[out#0/null @ 0x55bbe6083100] video:10287kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
size=N/A time=00:00:16.47 bitrate=N/A speed=2.13e+03x
hhoppe commented 7 months ago

@futscdav Would you be able to share a representative video (maybe a very short snippet) with this behavior? My version of ffmpeg (4.4.2-0ubuntu0.22.04.1) is older but hopefully I can reproduce the problem. Thanks.