0

Can ffmpeg count size of stream in bytes? I want to write NUMBER_OF_BYTES tag for every stream in file output on the fly. Like MKVToolNix does.

Input #0, matroska,webm, from 'm:\S01E18.mkv':   Metadata:
    encoder         : libebml v1.3.6 + libmatroska v1.4.9
    creation_time   : 2019-01-02T12:02:39.000000Z   Duration: 00:21:28.83, start: 0.000000, bitrate: 2742 kb/s
    Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
    Metadata:
      BPS-eng         : 2577777
      DURATION-eng    : 00:21:28.800000000
      NUMBER_OF_FRAMES-eng: 32220

      NUMBER_OF_BYTES-eng: 415279992 <--- !!!!!!!!!!!!!!!!!!!!

      _STATISTICS_WRITING_APP-eng: mkvmerge v29.0.0 ('Like It Or Not') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2019-01-02 12:02:39
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:1(rus): Audio: aac (LC), 48000 Hz, stereo, fltp (default)
    Metadata:
      BPS-eng         : 162801
      DURATION-eng    : 00:21:28.832000000
      NUMBER_OF_FRAMES-eng: 60414

      NUMBER_OF_BYTES-eng: 26227949 <--- !!!!!!!!!!!!!!!!!!!!

      _STATISTICS_WRITING_APP-eng: mkvmerge v29.0.0 ('Like It Or Not') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2019-01-02 12:02:39
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
0

FFmpeg can't do this. These tags are not part of the Matroska specification; they are idiosyncratic to mkvtoolnix (7.0+).

| improve this answer | |
  • Ok, thanks for the answer. I can still add any tag manually I want with ffmpeg, right? The problem is just to get somewhere value for this tag. Can ffmpeg just count length of the stream? – kot-da-vinci Feb 18 '19 at 14:15
  • Yes, you can manually add any tag. ffmpeg can give a rough measure of stream size using ffmpeg -i file.mkv -map 0:0 -c copy -f null - for the first stream. See the frame= and then the size value on the last line. – Gyan Feb 18 '19 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.