Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] Add support for copying metadata boxed/mebx defined in ISO 14496-12
@ 2025-10-21 17:45 Holliger, Lukas J via ffmpeg-devel
  2025-10-25 20:59 ` [FFmpeg-devel] " Michael Niedermayer via ffmpeg-devel
  0 siblings, 1 reply; 2+ messages in thread
From: Holliger, Lukas J via ffmpeg-devel @ 2025-10-21 17:45 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Holliger, Lukas J

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 <lholliger3@gatech.edu>
---
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 -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [FFmpeg-devel] Re: [PATCH] Add support for copying metadata boxed/mebx defined in ISO 14496-12
  2025-10-21 17:45 [FFmpeg-devel] [PATCH] Add support for copying metadata boxed/mebx defined in ISO 14496-12 Holliger, Lukas J via ffmpeg-devel
@ 2025-10-25 20:59 ` Michael Niedermayer via ffmpeg-devel
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Niedermayer via ffmpeg-devel @ 2025-10-25 20:59 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Michael Niedermayer


[-- Attachment #1.1: Type: text/plain, Size: 1670 bytes --]

Hi

On Tue, Oct 21, 2025 at 05:45:15PM +0000, Holliger, Lukas J via ffmpeg-devel wrote:
> 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 <lholliger3@gatech.edu>
> ---
> 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"),
>     },
> +    {

Applying: Add support for copying metadata boxed/mebx defined in ISO 14496-12
error: corrupt patch at line 44
Patch failed at 0001 Add support for copying metadata boxed/mebx defined in ISO 14496-12

whitespace seems corrupted, attaching the patch likely helps

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If the United States is serious about tackling the national security threats 
related to an insecure 5G network, it needs to rethink the extent to which it
values corporate profits and government espionage over security.-Bruce Schneier

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 163 bytes --]

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-10-25 21:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-21 17:45 [FFmpeg-devel] [PATCH] Add support for copying metadata boxed/mebx defined in ISO 14496-12 Holliger, Lukas J via ffmpeg-devel
2025-10-25 20:59 ` [FFmpeg-devel] " Michael Niedermayer via ffmpeg-devel

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