Currently there is no support to copy these MEBX tracks, so they are dropped. These tracks often appear on iPhones, especially when shooting cinematic mode, so allowing this to pass through makes it easier to transparently work with these files.
Signed-off-by: Lukas Holliger <[email protected]> --- libavcodec/codec_desc.c | 6 ++++++ libavcodec/codec_id.h | 1 + libavformat/isom.c | 1 + libavformat/mov.c | 7 +++++++ libavformat/movenc.c | 39 ++++++++++++++++++++++++++++++++++++++- 5 files changed, 53 insertions(+), 1 deletion(-) diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index c72271bfad..40c8235f60 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -3839,6 +3839,12 @@ static const AVCodecDescriptor codec_descriptors[] = { .name = "smpte_436m_anc", .long_name = NULL_IF_CONFIG_SMALL("MXF SMPTE-436M ANC"), }, + { + .id = AV_CODEC_ID_MEBX, + .type = AVMEDIA_TYPE_DATA, + .name = "mebx", + .long_name = NULL_IF_CONFIG_SMALL("Metadata Boxed"), + }, { .id = AV_CODEC_ID_MPEG2TS, .type = AVMEDIA_TYPE_DATA, diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h index 8c98ac6335..c623efa0c3 100644 --- a/libavcodec/codec_id.h +++ b/libavcodec/codec_id.h @@ -613,6 +613,7 @@ enum AVCodecID { AV_CODEC_ID_SMPTE_2038, AV_CODEC_ID_LCEVC, AV_CODEC_ID_SMPTE_436M_ANC, + AV_CODEC_ID_MEBX, AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it diff --git a/libavformat/isom.c b/libavformat/isom.c index 29171fea40..7dbc934330 100644 --- a/libavformat/isom.c +++ b/libavformat/isom.c @@ -81,6 +81,7 @@ const AVCodecTag ff_codec_movsubtitle_tags[] = { const AVCodecTag ff_codec_movdata_tags[] = { { AV_CODEC_ID_BIN_DATA, MKTAG('g', 'p', 'm', 'd') }, + { AV_CODEC_ID_MEBX, MKTAG('m', 'e', 'b', 'x') }, { AV_CODEC_ID_NONE, 0 }, }; diff --git a/libavformat/mov.c b/libavformat/mov.c index 7fe4678234..35db690709 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2895,6 +2895,13 @@ static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb, } } } + } else if (st->codecpar->codec_tag == MKTAG('m','e','b','x')) { + if ((int)size != size) + return AVERROR(ENOMEM); + + ret = ff_get_extradata(c->fc, st->codecpar, pb, size); + if (ret < 0) + return ret; } else { /* other codec type, just skip (rtp, mp4s ...) */ avio_skip(pb, size); diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 067d38b14b..6519225935 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -3052,6 +3052,36 @@ static int mov_write_gpmd_tag(AVIOContext *pb, const MOVTrack *track) return update_size(pb, pos); } +static int mov_write_mebx_keys_tag(AVIOContext *pb, const MOVTrack *track) +{ + int64_t pos = avio_tell(pb); + avio_wb32(pb, 0); /* size */ + ffio_wfourcc(pb, "keys"); + avio_wb32(pb, 0); /* version and flags */ + + return update_size(pb, pos); +} + +static int mov_write_mebx_tag(AVIOContext *pb, const MOVTrack *track) +{ + int64_t pos = avio_tell(pb); + avio_wb32(pb, 0); /* size */ + ffio_wfourcc(pb, "mebx"); + avio_wb32(pb, 0); /* Reserved */ + avio_wb16(pb, 0); /* Reserved */ + avio_wb16(pb, 1); /* Data-reference index */ + + // Write the keys box (and any other boxes) from extradata + if (track->par->extradata_size > 0) { + avio_write(pb, track->par->extradata, track->par->extradata_size); + } else { + // No extradata, write minimal empty keys box + mov_write_mebx_keys_tag(pb, track); + } + + return update_size(pb, pos); +} + static int mov_write_stsd_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track) { int64_t pos = avio_tell(pb); @@ -3077,7 +3107,8 @@ static int mov_write_stsd_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext ret = mov_write_tmcd_tag(pb, track); else if (track->par->codec_tag == MKTAG('g','p','m','d')) ret = mov_write_gpmd_tag(pb, track); - + else if (track->par->codec_tag == MKTAG('m','e','b','x')) + ret = mov_write_mebx_tag(pb, track); if (ret < 0) return ret; } @@ -3499,6 +3530,9 @@ static int mov_write_hdlr_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *tra } else if (track->par->codec_tag == MKTAG('g','p','m','d')) { hdlr_type = "meta"; descr = "GoPro MET"; // GoPro Metadata + } else if (track->par->codec_tag == MKTAG('m','e','b','x')) { + hdlr_type = "meta"; + descr = "Metadata Boxed"; } else { av_log(s, AV_LOG_WARNING, "Unknown hdlr_type for %s, writing dummy values\n", @@ -3734,6 +3768,8 @@ static int mov_write_minf_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext mov_write_gmhd_tag(pb, track); } else if (track->tag == MKTAG('g','p','m','d')) { mov_write_gmhd_tag(pb, track); + } else if (track->tag == MKTAG('m','e','b','x')) { + mov_write_gmhd_tag(pb, track); } if (track->mode == MODE_MOV) /* ISO 14496-12 8.4.3.1 specifies hdlr only within mdia or meta boxes */ mov_write_hdlr_tag(s, pb, NULL); @@ -8803,6 +8839,7 @@ static const AVCodecTag codec_mp4_tags[] = { { AV_CODEC_ID_DVD_SUBTITLE, MKTAG('m', 'p', '4', 's') }, { AV_CODEC_ID_MOV_TEXT, MKTAG('t', 'x', '3', 'g') }, { AV_CODEC_ID_BIN_DATA, MKTAG('g', 'p', 'm', 'd') }, + { AV_CODEC_ID_MEBX, MKTAG('m', 'e', 'b', 'x') }, { AV_CODEC_ID_MPEGH_3D_AUDIO, MKTAG('m', 'h', 'm', '1') }, { AV_CODEC_ID_TTML, MOV_MP4_TTML_TAG }, { AV_CODEC_ID_TTML, MOV_ISMV_TTML_TAG }, -- 2.49.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
