<p>FFmpeg can't do this. These tags are not part of the Matroska specification; they are <a href="https://gitlab.com/mbunkus/mkvtoolnix/wikis/Automatic-tag-generation" rel="nofollow noreferrer">idiosyncratic</a> to mkvtoolnix (7.0+).</p>

CC BY-SA 4.0
2019-02-18T14:15:19.500Z
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
CC BY-SA 4.0
2019-02-18T16:16:39.230Z
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
CC BY-SA 4.0
2019-02-18T05:48:36.047Z
2019-02-18T05:48:36.047Z
Gyan
<p>Can ffmpeg count size of stream in bytes? I want to write <code>NUMBER_OF_BYTES</code> tag for every stream in file output on the fly. Like <code>MKVToolNix</code> does.</p>

<pre><code>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 &lt;--- !!!!!!!!!!!!!!!!!!!!

      _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 &lt;--- !!!!!!!!!!!!!!!!!!!!

      _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
</code></pre>

<video><ffmpeg><mkv><metadata>
How to make ffmpeg to generate NUMBER_OF_BYTES tag for every stream in file output?
kot-da-vinci
# How to make ffmpeg to generate NUMBER_OF_BYTES tag for every stream in file output?

(Asked by: username_0 on 2019-02-17)

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

**Tags:** video, ffmpeg, mkv, metadata


---

## 1 answers

### Answer by username_1 on 2019-02-18. Score: 0

FFmpeg can't do this. These tags are not part of the Matroska specification; they are [idiosyncratic](https://gitlab.com/mbunkus/mkvtoolnix/wikis/Automatic-tag-generation) to mkvtoolnix (7.0+).

> **Comments:**
> **username_0**: 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?  
> **username_1**: 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.  

---

