Skip to content

Commit f006c71

Browse files
committed
'jpeg' tag and custom 'kind' box in MP4
1 parent c7deab7 commit f006c71

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

Changelog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ version 7.1.1-mtv:
55
- Molotov patches
66
- Redis protocol via libhiredis
77
- h264_metadata bitstream fixed_frame_rate_flag fix
8+
- 'jpeg' tag and custom 'kind' box in MP4
89

910
version 7.1.1:
1011
avformat/hls: Partially revert "reduce default max reload to 3"

libavformat/movenc.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ static const AVOption options[] = {
128128
{ "ism_offset", "Offset to the ISM fragment start times", offsetof(MOVMuxContext, ism_offset), AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, AV_OPT_FLAG_ENCODING_PARAM},
129129
{ "video_track_timescale", "set timescale of all video tracks", offsetof(MOVMuxContext, video_track_timescale), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
130130
{ "audio_track_timescale", "set timescale of all audio tracks", offsetof(MOVMuxContext, audio_track_timescale), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
131+
{ "kind", "set custom kind for the track as schemeURI=value", offsetof(MOVMuxContext, kind), AV_OPT_TYPE_DICT, { 0 }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM },
131132
{ NULL },
132133
};
133134

@@ -4102,9 +4103,17 @@ static int mov_write_track_kind(AVIOContext *pb, const char *scheme_uri,
41024103
return update_size(pb, pos);
41034104
}
41044105

4105-
static int mov_write_track_kinds(AVIOContext *pb, AVStream *st)
4106+
static int mov_write_track_kinds(AVIOContext *pb, MOVMuxContext *mov, AVStream *st)
41064107
{
41074108
int ret = AVERROR_BUG;
4109+
AVDictionaryEntry *en = NULL;
4110+
4111+
while ((en = av_dict_get(mov->kind, "", en, AV_DICT_IGNORE_SUFFIX))) {
4112+
if ((ret = mov_write_track_kind(pb, en->key, en->value)) < 0)
4113+
return ret;
4114+
4115+
return 0;
4116+
}
41084117

41094118
for (int i = 0; ff_mov_track_kind_table[i].scheme_uri; i++) {
41104119
const struct MP4TrackKindMapping map = ff_mov_track_kind_table[i];
@@ -4140,7 +4149,7 @@ static int mov_write_track_udta_tag(AVIOContext *pb, MOVMuxContext *mov,
41404149
mov_write_track_metadata(pb_buf, st, "name", "title");
41414150

41424151
if (mov->mode & MODE_MP4) {
4143-
if ((ret = mov_write_track_kinds(pb_buf, st)) < 0)
4152+
if ((ret = mov_write_track_kinds(pb_buf, mov, st)) < 0)
41444153
return ret;
41454154
}
41464155

@@ -8072,6 +8081,9 @@ static int mov_init(AVFormatContext *s)
80728081
}
80738082
}
80748083

8084+
if (av_dict_count(mov->kind) > 1)
8085+
av_log(s, AV_LOG_WARNING, "-kind contains several entries, only the first one will be kept\n");
8086+
80758087
enable_tracks(s);
80768088
return 0;
80778089
}
@@ -8595,6 +8607,7 @@ static const AVCodecTag codec_mp4_tags[] = {
85958607
{ AV_CODEC_ID_MPEGH_3D_AUDIO, MKTAG('m', 'h', 'm', '1') },
85968608
{ AV_CODEC_ID_TTML, MOV_MP4_TTML_TAG },
85978609
{ AV_CODEC_ID_TTML, MOV_ISMV_TTML_TAG },
8610+
{ AV_CODEC_ID_MJPEG, MKTAG('j', 'p', 'e', 'g') },
85988611

85998612
/* ISO/IEC 23003-5 integer formats */
86008613
{ AV_CODEC_ID_PCM_S16BE, MOV_MP4_IPCM_TAG },

libavformat/movenc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ typedef struct MOVMuxContext {
259259
int avif_extent_length[2]; // index 0 is YUV and 1 is Alpha.
260260
int is_animated_avif;
261261
int avif_loop_count;
262+
263+
AVDictionary *kind;
262264
} MOVMuxContext;
263265

264266
#define FF_MOV_FLAG_RTP_HINT (1 << 0)

0 commit comments

Comments
 (0)