Opened 6 years ago

Last modified 16 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 6 years ago.
libavformat/movenc.c patch

Download all attachments as: .zip

Change History (13)

comment:2 by Mista_D, 6 years ago

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 by oscord, 6 years ago

@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 by oscord, 6 years ago


comment:5 by Mista_D, 6 years ago

Its adding some junk into MOOV after btrt. Not working

Thank you for trying though

comment:6 by Mista_D, 6 years ago

Resolution: worksforme
Status: newclosed

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

comment:7 by Mista_D, 6 years ago

Donated $250 to to help sick kids

Transaction ID 91Y16613BC393983T

Thank you.

comment:8 by Carl Eugen Hoyos, 6 years ago

Keywords: btrt moov mp4 removed
Priority: importantwish
Resolution: worksforme
Status: closedreopened

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

by Mista_D, 6 years ago

Attachment: btrt_moovatom.patch added

libavformat/movenc.c patch

comment:9 by Mista_D, 6 years ago

got it, submitting to the mailing list

Last edited 6 years ago by Mista_D (previous) (diff)

comment:10 by Carl Eugen Hoyos, 6 years ago


Please submit a patch made with git format-patch.

comment:11 by Andy Dust, 16 months ago

It'd be great if this could be added. Thanks.

comment:12 by Balling, 16 months ago

It was added though? 3838e8fc210aa09a9f9058506c0ce80b6ad9b9c3

And it is being written. I verified it like some 6 months ago.

Last edited 16 months ago by Balling (previous) (diff)
Note: See TracTickets for help on using tickets.