From: lholliger via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: lholliger <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH] Add support for copying metadata boxed/mebx defined in ISO 14496-12 (PR #20738)
Date: Wed, 22 Oct 2025 20:43:17 -0000
Message-ID: <176116579820.25.13088961014152099068@7d278768979e> (raw)
PR #20738 opened by lholliger
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20738
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20738.patch
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.
>From 0c0f8d74deb883fd77a2b21697fc485742f781fb Mon Sep 17 00:00:00 2001
From: Lukas Holliger <lholliger3@gatech.edu>
Date: Wed, 22 Oct 2025 16:41:47 -0400
Subject: [PATCH] Add support for copying metadata boxed/mebx defined in ISO
14496-12
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.
---
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.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
reply other threads:[~2025-10-22 20:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=176116579820.25.13088961014152099068@7d278768979e \
--to=ffmpeg-devel@ffmpeg.org \
--cc=code@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git