Opened 7 months ago

Last modified 7 months ago

#6575 reopened enhancement

Bitrate Atom MP4 enhancement

Reported by: Mista_D Owned by:
Priority: wish Component: avformat
Version: git-master Keywords: mov
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no


Missing btrt atom in MP4 files:

FFmpeg currently doesn't store average bitrate, max bitrate and buffer size in MP4 MOOV. Would be great to keep this info in MP4 for streaming purposes

ISO-14496 part15 page 20:

Attachments (1)

btrt_moovatom.patch (1.3 KB) - added by Mista_D 7 months ago.
libavformat/movenc.c patch

Download all attachments as: .zip

Change History (11)

comment:2 Changed 7 months ago by Mista_D

Bounty of €250 ($300 USD) to whomever implements it before August 14, 2017 please.

Some work was already done before it seems...

Thank you

comment:3 Changed 7 months ago by oscord

@line 1077

+static int mov_write_btrt_tag(AVIOContext *pb, MOVTrack *track)
+ AVCPBProperties *props;
+ int64_t pos = avio_tell(pb);
+ unsigned avg_bitrate;
+ props = (AVCPBProperties*)av_stream_get_side_data(track->st, AV_PKT_DATA_CPB_PROPERTIES, NULL);
+ avg_bitrate = compute_avg_bitrate(track);
+ avio_wb32(pb, 0);
+ ffio_wfourcc(pb, "btrt");
+ avio_wb32(pb, props ? props->buffer_size : 0);
+ avio_wb32(pb, props ? FFMAX3(props->max_bitrate, props->avg_bitrate, avg_bitrate) : FFMAX(track->par->bit_rate, avg_bitrate));
+ avio_wb32(pb, avg_bitrate);
+ return update_size(pb, pos);

@line 1939

mov_write_avcc_tag(pb, track);

+ mov_write_btrt_tag(pb, track);

if (track->mode == MODE_IPOD)

Use the cash for something good

comment:4 Changed 7 months ago by oscord


comment:5 Changed 7 months ago by Mista_D

Its adding some junk into MOOV after btrt. Not working

Thank you for trying though

comment:6 Changed 7 months ago by Mista_D

  • Resolution set to worksforme
  • Status changed from new to closed

Apologies, my file analyzer didn't recognize pasp atom. Your patch is working as intended.

comment:7 Changed 7 months ago by Mista_D

Donated $250 to to help sick kids

Transaction ID 91Y16613BC393983T

Thank you.

comment:8 Changed 7 months ago by cehoyos

  • Keywords btrt moov mp4 removed
  • Priority changed from important to wish
  • Resolution worksforme deleted
  • Status changed from closed to reopened

Please consider sending the patch - made with git format-patch - to the FFmpeg development mailing list.

Changed 7 months ago by Mista_D

libavformat/movenc.c patch

comment:9 Changed 7 months ago by Mista_D

got it, submitting to the mailing list

Last edited 7 months ago by Mista_D (previous) (diff)

comment:10 Changed 7 months ago by cehoyos


Please submit a patch made with git format-patch.

Note: See TracTickets for help on using tickets.