[PATCH 1/3] lavf/movenc: use ffio_fill()
--- libavformat/movenc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index cff0760..8cf7fdc 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2640,8 +2640,7 @@ static int mov_write_tfrf_tag(AVIOContext *pb, MOVMuxContext *mov, int free_size = 16*(mov->ism_lookahead - n); avio_wb32(pb, free_size); ffio_wfourcc(pb, "free"); - for (i = 0; i < free_size - 8; i++) - avio_w8(pb, 0); + ffio_fill(pb, 0, free_size - 8); } return 0; -- 1.8.3.1
Fix metadata display under iTunes for files using pgap, hdvd, stick, tvsn and tves tags. --- libavformat/movenc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 8cf7fdc..5577530 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2046,16 +2046,25 @@ static int mov_write_int8_metadata(AVFormatContext *s, AVIOContext *pb, { AVDictionaryEntry *t = NULL; uint8_t num; + int size = 25 + 3 * (len == 4); + + if (len != 1 && len != 4) + return -1; if (!(t = av_dict_get(s->metadata, tag, NULL, 0))) return 0; num = atoi(t->value); - avio_wb32(pb, len+8); + avio_wb32(pb, size); ffio_wfourcc(pb, name); + avio_wb32(pb, size - 8); + ffio_wfourcc(pb, "data"); + avio_wb32(pb, 0x15); + avio_wb32(pb, 0); if (len==4) avio_wb32(pb, num); else avio_w8 (pb, num); - return len+8; + + return size; } /* iTunes meta data list */ -- 1.8.3.1
On Sun, Jun 30, 2013 at 04:15:45PM +0200, Matthieu Bouron wrote:
Fix metadata display under iTunes for files using pgap, hdvd, stick, tvsn and tves tags. --- libavformat/movenc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 8cf7fdc..5577530 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2046,16 +2046,25 @@ static int mov_write_int8_metadata(AVFormatContext *s, AVIOContext *pb, { AVDictionaryEntry *t = NULL; uint8_t num; + int size = 25 + 3 * (len == 4);
24 + len or you could maybe use update_size() [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In fact, the RIAA has been known to suggest that students drop out of college or go to community college in order to be able to afford settlements. -- The RIAA
On Tue, Jul 2, 2013 at 7:01 PM, Michael Niedermayer <michaelni@gmx.at>wrote:
On Sun, Jun 30, 2013 at 04:15:45PM +0200, Matthieu Bouron wrote:
Fix metadata display under iTunes for files using pgap, hdvd, stick, tvsn and tves tags. --- libavformat/movenc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 8cf7fdc..5577530 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2046,16 +2046,25 @@ static int mov_write_int8_metadata(AVFormatContext *s, AVIOContext *pb, { AVDictionaryEntry *t = NULL; uint8_t num; + int size = 25 + 3 * (len == 4);
24 + len
Size include the real data size (1byte or 3 padding byte + 1 byte), the resulting size is either 25 or 28. [ 4b size ] [ 4b "name" ] [ 4b data size ] [ 4b "data" ] [ 4b data type ] [ 4b flags ] [ (1b or 4b) data value ]
or you could maybe use update_size()
Size is re-used for the data atom and is equal to size - 8. Matthieu
On Tue, Jul 02, 2013 at 09:21:51PM +0200, Matthieu Bouron wrote:
On Tue, Jul 2, 2013 at 7:01 PM, Michael Niedermayer <michaelni@gmx.at>wrote:
On Sun, Jun 30, 2013 at 04:15:45PM +0200, Matthieu Bouron wrote:
Fix metadata display under iTunes for files using pgap, hdvd, stick, tvsn and tves tags. --- libavformat/movenc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 8cf7fdc..5577530 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2046,16 +2046,25 @@ static int mov_write_int8_metadata(AVFormatContext *s, AVIOContext *pb, { AVDictionaryEntry *t = NULL; uint8_t num; + int size = 25 + 3 * (len == 4);
24 + len
Size include the real data size (1byte or 3 padding byte + 1 byte), the resulting size is either 25 or 28. [ 4b size ] [ 4b "name" ] [ 4b data size ] [ 4b "data" ] [ 4b data type ] [ 4b flags ] [ (1b or 4b) data value ]
24 + len is as correct as yours, they give the same values. Iam fine with either but i thought 24 + len is simpler and clearer [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Democracy is the form of government in which you can choose your dictator
On Tue, Jul 02, 2013 at 10:42:29PM +0200, Michael Niedermayer wrote:
On Tue, Jul 02, 2013 at 09:21:51PM +0200, Matthieu Bouron wrote:
On Tue, Jul 2, 2013 at 7:01 PM, Michael Niedermayer <michaelni@gmx.at>wrote:
On Sun, Jun 30, 2013 at 04:15:45PM +0200, Matthieu Bouron wrote:
Fix metadata display under iTunes for files using pgap, hdvd, stick, tvsn and tves tags. --- libavformat/movenc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 8cf7fdc..5577530 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2046,16 +2046,25 @@ static int mov_write_int8_metadata(AVFormatContext *s, AVIOContext *pb, { AVDictionaryEntry *t = NULL; uint8_t num; + int size = 25 + 3 * (len == 4);
24 + len
Size include the real data size (1byte or 3 padding byte + 1 byte), the resulting size is either 25 or 28. [ 4b size ] [ 4b "name" ] [ 4b data size ] [ 4b "data" ] [ 4b data type ] [ 4b flags ] [ (1b or 4b) data value ]
24 + len is as correct as yours, they give the same values. Iam fine with either but i thought 24 + len is simpler and clearer
I totally misread your first reply :( Sure 24 + len is correct and lot more clearer. Updated patch attached. Thanks, Matthieu [...]
On Wed, Jul 03, 2013 at 10:56:23AM +0200, Matthieu Bouron wrote:
On Tue, Jul 02, 2013 at 10:42:29PM +0200, Michael Niedermayer wrote:
On Tue, Jul 02, 2013 at 09:21:51PM +0200, Matthieu Bouron wrote:
On Tue, Jul 2, 2013 at 7:01 PM, Michael Niedermayer <michaelni@gmx.at>wrote:
On Sun, Jun 30, 2013 at 04:15:45PM +0200, Matthieu Bouron wrote:
Fix metadata display under iTunes for files using pgap, hdvd, stick, tvsn and tves tags. --- libavformat/movenc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 8cf7fdc..5577530 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2046,16 +2046,25 @@ static int mov_write_int8_metadata(AVFormatContext *s, AVIOContext *pb, { AVDictionaryEntry *t = NULL; uint8_t num; + int size = 25 + 3 * (len == 4);
24 + len
Size include the real data size (1byte or 3 padding byte + 1 byte), the resulting size is either 25 or 28. [ 4b size ] [ 4b "name" ] [ 4b data size ] [ 4b "data" ] [ 4b data type ] [ 4b flags ] [ (1b or 4b) data value ]
24 + len is as correct as yours, they give the same values. Iam fine with either but i thought 24 + len is simpler and clearer
I totally misread your first reply :( Sure 24 + len is correct and lot more clearer. Updated patch attached.
Thanks, Matthieu
[...]
movenc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) d0c50b8ffbbf26917f5d7cebf1248aae4d8a5b00 0001-lavf-movenc-fix-writing-of-some-iTunes-metadata-tag.patch From fa3e90030c68774b7daae143bbd058b80874337b Mon Sep 17 00:00:00 2001 From: Matthieu Bouron <matthieu.bouron@gmail.com> Date: Sat, 29 Jun 2013 17:56:49 +0200 Subject: [PATCH 1/2] lavf/movenc: fix writing of some iTunes metadata tag
Fix metadata display under iTunes for files using pgap, hdvd, stick, tvsn and tves tags.
applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I know you won't believe me, but the highest form of Human Excellence is to question oneself and others. -- Socrates
Cover art muxing is done by introducing the -cover_stream_index option which takes an output stream index as argument. The stream used for the cover art is not muxed as a track in the resulting file. --- libavformat/movenc.c | 157 +++++++++++++++++++++++++++++++++++++++++++---- libavformat/movenc.h | 5 ++ libavformat/movenchint.c | 1 + 3 files changed, 152 insertions(+), 11 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 5577530..f411493 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -63,6 +63,7 @@ static const AVOption options[] = { { "ism_lookahead", "Number of lookahead entries for ISM files", offsetof(MOVMuxContext, ism_lookahead), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, { "use_editlist", "use edit list", offsetof(MOVMuxContext, use_editlist), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, AV_OPT_FLAG_ENCODING_PARAM}, { "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}, + { "cover_stream_index", "video stream index to use for cover art", offsetof(MOVMuxContext, cover_stream_index), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, { NULL }, }; @@ -2067,6 +2068,46 @@ static int mov_write_int8_metadata(AVFormatContext *s, AVIOContext *pb, return size; } +static int mov_write_covr(AVFormatContext *s, AVIOContext *pb, AVPacketList *covers) +{ + int64_t pos = avio_tell(pb); + + avio_wb32(pb, 0); + ffio_wfourcc(pb, "covr"); + + while (covers) { + int type; + AVPacket *pkt = &covers->pkt; + enum AVCodecID codec_id = s->streams[pkt->stream_index]->codec->codec_id; + + switch(codec_id) { + case CODEC_ID_MJPEG: + type = 0xD; + break; + case CODEC_ID_PNG: + type = 0xE; + break; + case CODEC_ID_BMP: + type = 0x1B; + break; + default: + covers = covers->next; + av_log(s, AV_LOG_ERROR, "unsupported codec %s for cover, skipping", s->streams[pkt->stream_index]->codec->codec_name); + continue; + } + + avio_wb32(pb, 16 + pkt->size); + ffio_wfourcc(pb, "data"); + avio_wb32(pb, type); + avio_wb32(pb , 0); + avio_write(pb, pkt->data, pkt->size); + + covers = covers->next; + } + + return update_size(pb, pos); +} + /* iTunes meta data list */ static int mov_write_ilst_tag(AVIOContext *pb, MOVMuxContext *mov, AVFormatContext *s) @@ -2096,6 +2137,10 @@ static int mov_write_ilst_tag(AVIOContext *pb, MOVMuxContext *mov, mov_write_int8_metadata (s, pb, "stik", "media_type",1); mov_write_int8_metadata (s, pb, "hdvd", "hd_video", 1); mov_write_int8_metadata (s, pb, "pgap", "gapless_playback",1); + + if (mov->covers) + mov_write_covr(s, pb, mov->covers); + mov_write_trkn_tag(pb, mov, s); mov_write_tmpo_tag(pb, s); return update_size(pb, pos); @@ -2198,7 +2243,7 @@ static int mov_write_udta_tag(AVIOContext *pb, MOVMuxContext *mov, int i, ret, size; uint8_t *buf; - for (i = 0; i < s->nb_streams; i++) + for (i = 0; i < mov->nb_streams; i++) if (mov->tracks[i].enc->flags & CODEC_FLAG_BITEXACT) { return 0; } @@ -2801,7 +2846,7 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s) for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; - if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) + if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && i != mov->cover_stream_index) has_video = 1; if (st->codec->codec_id == AV_CODEC_ID_H264) has_h264 = 1; @@ -3008,6 +3053,18 @@ static int get_moov_size(AVFormatContext *s) return ret; } +static MOVTrack *mov_get_track(MOVMuxContext *mov, int stream_index) +{ + int i; + + for (i = 0; i < mov->nb_streams; i++) { + MOVTrack *track = &mov->tracks[i]; + if (track->stream_index == stream_index) + return track; + } + return NULL; +} + static int mov_flush_fragment(AVFormatContext *s) { MOVMuxContext *mov = s->priv_data; @@ -3137,12 +3194,15 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) { MOVMuxContext *mov = s->priv_data; AVIOContext *pb = s->pb; - MOVTrack *trk = &mov->tracks[pkt->stream_index]; - AVCodecContext *enc = trk->enc; + MOVTrack *trk = mov_get_track(mov, pkt->stream_index); + AVCodecContext *enc; unsigned int samples_in_chunk = 0; int size= pkt->size; uint8_t *reformatted_data = NULL; + if (!trk) return 0; + enc = trk->enc; + if (mov->flags & FF_MOV_FLAG_FRAGMENT) { int ret; if (mov->fragments > 0) { @@ -3290,11 +3350,14 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) static int mov_write_single_packet(AVFormatContext *s, AVPacket *pkt) { MOVMuxContext *mov = s->priv_data; - MOVTrack *trk = &mov->tracks[pkt->stream_index]; - AVCodecContext *enc = trk->enc; + MOVTrack *trk = mov_get_track(mov, pkt->stream_index); + AVCodecContext *enc; int64_t frag_duration = 0; int size = pkt->size; + if (!trk) return 0; + enc = trk->enc; + if (!pkt->size) return 0; /* Discard 0 sized packets */ if (trk->entry && pkt->stream_index < s->nb_streams) @@ -3378,6 +3441,37 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt) } } + if (pkt->stream_index == mov->cover_stream_index) { + AVStream *st = s->streams[pkt->stream_index]; + + /* warn only once */ + if (st->nb_frames == 1) { + av_log(s, AV_LOG_WARNING, "Got more than one picture in stream %d," + " ignoring.\n", pkt->stream_index); + } + + if (st->nb_frames == 0) { + int ret; + AVPacketList *last, *covers = av_mallocz(sizeof(AVPacketList)); + if (!covers) + return AVERROR(ENOMEM); + + if ((ret = av_copy_packet(&covers->pkt, pkt)) < 0) { + av_freep(&covers); + return ret; + } + + if (!mov->covers) + mov->covers = covers; + else { + last = mov->covers; + while (last->next) + last = last->next; + last->next = covers; + } + } + } + return mov_write_single_packet(s, pkt); } } @@ -3489,6 +3583,7 @@ static int mov_create_timecode_track(AVFormatContext *s, int index, int src_inde track->mode = mov->mode; track->tag = MKTAG('t','m','c','d'); track->src_track = src_index; + track->stream_index = index; track->timescale = mov->tracks[src_index].timescale; if (tc.flags & AV_TIMECODE_FLAG_DROPFRAME) track->timecode_flags |= MOV_TIMECODE_FLAG_DROPFRAME; @@ -3512,7 +3607,7 @@ static int mov_write_header(AVFormatContext *s) AVIOContext *pb = s->pb; MOVMuxContext *mov = s->priv_data; AVDictionaryEntry *t, *global_tcr = av_dict_get(s->metadata, "timecode", NULL, 0); - int i, hint_track = 0, tmcd_track = 0; + int i, hint_track = 0, tmcd_track = 0, stream_index = -1; /* Set the FRAGMENT flag if any of the fragmentation methods are * enabled. */ @@ -3567,6 +3662,30 @@ static int mov_write_header(AVFormatContext *s) } mov->nb_streams = s->nb_streams; + + if (mov->cover_stream_index >= 0) { + AVStream *st; + if (mov->cover_stream_index >= s->nb_streams) { + av_log(s, AV_LOG_ERROR, "cover stream #%d does not exist\n", mov->cover_stream_index); + return -1; + } + + st = s->streams[mov->cover_stream_index]; + if (st->codec->codec_type != AVMEDIA_TYPE_VIDEO) { + av_log(s, AV_LOG_ERROR, "cover stream #%d is not a video stream\n", mov->cover_stream_index); + return -1; + } + + if (st->codec->codec_id != CODEC_ID_MJPEG && + st->codec->codec_id != CODEC_ID_PNG && + st->codec->codec_id != CODEC_ID_BMP) { + av_log(s, AV_LOG_ERROR, "cover stream #%d has wrong codec type, must be either png, mjpeg or bmp\n", mov->cover_stream_index); + return -1; + } + + mov->nb_streams--; + } + if (mov->mode & (MODE_MOV|MODE_IPOD) && s->nb_chapters) mov->chapter_track = mov->nb_streams++; @@ -3575,7 +3694,7 @@ static int mov_write_header(AVFormatContext *s) hint_track = mov->nb_streams; for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; - if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO || + if ((st->codec->codec_type == AVMEDIA_TYPE_VIDEO && i != mov->cover_stream_index) || st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { mov->nb_streams++; } @@ -3588,7 +3707,7 @@ static int mov_write_header(AVFormatContext *s) /* +1 tmcd track for each video stream with a timecode */ for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; - if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && + if ((st->codec->codec_type == AVMEDIA_TYPE_VIDEO && i != mov->cover_stream_index) && (global_tcr || av_dict_get(st->metadata, "timecode", NULL, 0))) mov->nb_meta_tmcd++; } @@ -3614,7 +3733,15 @@ static int mov_write_header(AVFormatContext *s) for(i=0; i<s->nb_streams; i++){ AVStream *st= s->streams[i]; - MOVTrack *track= &mov->tracks[i]; + MOVTrack *track; + + /* skip cover art stream */ + if (i == mov->cover_stream_index) + continue; + + stream_index++; + track = &mov->tracks[stream_index]; + track->stream_index = i; AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0); track->enc = st->codec; @@ -3731,7 +3858,7 @@ static int mov_write_header(AVFormatContext *s) /* Initialize the hint tracks for each audio and video stream */ for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; - if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO || + if ((st->codec->codec_type == AVMEDIA_TYPE_VIDEO && i != mov->cover_stream_index) || st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { ff_mov_init_hinting(s, hint_track, i); hint_track++; @@ -3871,6 +3998,7 @@ static int mov_write_trailer(AVFormatContext *s) { MOVMuxContext *mov = s->priv_data; AVIOContext *pb = s->pb; + AVPacketList *covers = mov->covers; int64_t moov_pos; int res = 0; int i; @@ -3962,6 +4090,13 @@ static int mov_write_trailer(AVFormatContext *s) av_freep(&mov->tracks); + while (covers) { + AVPacketList *next = covers->next; + av_free_packet(&covers->pkt); + av_freep(&covers); + covers = next; + } + return res; } diff --git a/libavformat/movenc.h b/libavformat/movenc.h index a6571d5..dbdba3d 100644 --- a/libavformat/movenc.h +++ b/libavformat/movenc.h @@ -141,6 +141,8 @@ typedef struct MOVTrack { int packet_entry; int slices; } vc1_info; + + int stream_index; } MOVTrack; typedef struct MOVMuxContext { @@ -172,6 +174,9 @@ typedef struct MOVMuxContext { int use_editlist; int video_track_timescale; + + AVPacketList *covers; + int cover_stream_index; } MOVMuxContext; #define FF_MOV_FLAG_RTP_HINT 1 diff --git a/libavformat/movenchint.c b/libavformat/movenchint.c index cc90f0b..82c19dc 100644 --- a/libavformat/movenchint.c +++ b/libavformat/movenchint.c @@ -36,6 +36,7 @@ int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index) track->tag = MKTAG('r','t','p',' '); track->src_track = src_index; + track->stream_index = index; track->enc = avcodec_alloc_context3(NULL); if (!track->enc) -- 1.8.3.1
On Sun, Jun 30, 2013 at 04:15:46PM +0200, Matthieu Bouron wrote:
Cover art muxing is done by introducing the -cover_stream_index option which takes an output stream index as argument. The stream used for the cover art is not muxed as a track in the resulting file. --- libavformat/movenc.c | 157 +++++++++++++++++++++++++++++++++++++++++++---- libavformat/movenc.h | 5 ++ libavformat/movenchint.c | 1 + 3 files changed, 152 insertions(+), 11 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 5577530..f411493 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -63,6 +63,7 @@ static const AVOption options[] = { { "ism_lookahead", "Number of lookahead entries for ISM files", offsetof(MOVMuxContext, ism_lookahead), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, { "use_editlist", "use edit list", offsetof(MOVMuxContext, use_editlist), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, AV_OPT_FLAG_ENCODING_PARAM}, { "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}, + { "cover_stream_index", "video stream index to use for cover art", offsetof(MOVMuxContext, cover_stream_index), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, { NULL },
isnt AV_DISPOSITION_ATTACHED_PIC enough ? why is this option needed ? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User questions about the command line tools should be sent to the ffmpeg-user ML. And questions about how to use libav* should be sent to the libav-user ML.
On Tue, Jul 2, 2013 at 7:46 PM, Michael Niedermayer <michaelni@gmx.at>wrote:
On Sun, Jun 30, 2013 at 04:15:46PM +0200, Matthieu Bouron wrote:
Cover art muxing is done by introducing the -cover_stream_index option which takes an output stream index as argument. The stream used for the cover art is not muxed as a track in the resulting file. --- libavformat/movenc.c | 157 +++++++++++++++++++++++++++++++++++++++++++---- libavformat/movenc.h | 5 ++ libavformat/movenchint.c | 1 + 3 files changed, 152 insertions(+), 11 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 5577530..f411493 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -63,6 +63,7 @@ static const AVOption options[] = { { "ism_lookahead", "Number of lookahead entries for ISM files", offsetof(MOVMuxContext, ism_lookahead), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, { "use_editlist", "use edit list", offsetof(MOVMuxContext, use_editlist), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, AV_OPT_FLAG_ENCODING_PARAM}, { "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}, + { "cover_stream_index", "video stream index to use for cover art", offsetof(MOVMuxContext, cover_stream_index), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, { NULL },
isnt AV_DISPOSITION_ATTACHED_PIC enough ? why is this option needed ?
I guess AV_DISPOSITION_ATTACHED_PIC could be enough. My idea here was to let the user choose the cover art from any output streams he likes with -cover_stream_index. If the input does not have any cover arts, can a custom stream be flagged as an attached pic ? Matthieu
On Tue, Jul 02, 2013 at 09:33:04PM +0200, Matthieu Bouron wrote:
On Tue, Jul 2, 2013 at 7:46 PM, Michael Niedermayer <michaelni@gmx.at>wrote:
On Sun, Jun 30, 2013 at 04:15:46PM +0200, Matthieu Bouron wrote:
Cover art muxing is done by introducing the -cover_stream_index option which takes an output stream index as argument. The stream used for the cover art is not muxed as a track in the resulting file. --- libavformat/movenc.c | 157 +++++++++++++++++++++++++++++++++++++++++++---- libavformat/movenc.h | 5 ++ libavformat/movenchint.c | 1 + 3 files changed, 152 insertions(+), 11 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 5577530..f411493 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -63,6 +63,7 @@ static const AVOption options[] = { { "ism_lookahead", "Number of lookahead entries for ISM files", offsetof(MOVMuxContext, ism_lookahead), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, { "use_editlist", "use edit list", offsetof(MOVMuxContext, use_editlist), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, AV_OPT_FLAG_ENCODING_PARAM}, { "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}, + { "cover_stream_index", "video stream index to use for cover art", offsetof(MOVMuxContext, cover_stream_index), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, { NULL },
isnt AV_DISPOSITION_ATTACHED_PIC enough ? why is this option needed ?
I guess AV_DISPOSITION_ATTACHED_PIC could be enough. My idea here was to let the user choose the cover art from any output streams he likes with -cover_stream_index. If the input does not have any cover arts, can a custom stream be flagged as an attached pic ?
if it cannot then such feature should be added but certainly doesnt belong in a single individual muxer [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Many things microsoft did are stupid, but not doing something just because microsoft did it is even more stupid. If everything ms did were stupid they would be bankrupt already.
On Tue, Jul 02, 2013 at 10:43:39PM +0200, Michael Niedermayer wrote:
On Tue, Jul 02, 2013 at 09:33:04PM +0200, Matthieu Bouron wrote:
On Tue, Jul 2, 2013 at 7:46 PM, Michael Niedermayer <michaelni@gmx.at>wrote:
On Sun, Jun 30, 2013 at 04:15:46PM +0200, Matthieu Bouron wrote:
Cover art muxing is done by introducing the -cover_stream_index option which takes an output stream index as argument. The stream used for the cover art is not muxed as a track in the resulting file. --- libavformat/movenc.c | 157 +++++++++++++++++++++++++++++++++++++++++++---- libavformat/movenc.h | 5 ++ libavformat/movenchint.c | 1 + 3 files changed, 152 insertions(+), 11 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 5577530..f411493 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -63,6 +63,7 @@ static const AVOption options[] = { { "ism_lookahead", "Number of lookahead entries for ISM files", offsetof(MOVMuxContext, ism_lookahead), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, { "use_editlist", "use edit list", offsetof(MOVMuxContext, use_editlist), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, AV_OPT_FLAG_ENCODING_PARAM}, { "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}, + { "cover_stream_index", "video stream index to use for cover art", offsetof(MOVMuxContext, cover_stream_index), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, { NULL },
isnt AV_DISPOSITION_ATTACHED_PIC enough ? why is this option needed ?
I guess AV_DISPOSITION_ATTACHED_PIC could be enough. My idea here was to let the user choose the cover art from any output streams he likes with -cover_stream_index. If the input does not have any cover arts, can a custom stream be flagged as an attached pic ?
if it cannot then such feature should be added but certainly doesnt belong in a single individual muxer
You're right, using AV_DISPOSITON_ATTACHED_PIC seems a better solution than introducing the cover_stream_index. Here is a new patch which uses all stream with AV_DISPOSITON_ATTACHED_PIC as cover arts. It works for all modes which use the iTunes metadata (!3gp and !mov). Actually the cover art codec is only checked at the end (when writing the metadata). If not BMP, MJPEG or PNG the user is warned that the cover art is ignored. Do you think this check should be included in the new mov_stream_is_apic function and discard all apic streams which have not the right codec (and use them as normal stream ? (IMHO it do not feel right to me to use them as normal stream)). Matthieu
On Wed, Jul 03, 2013 at 12:08:38PM +0200, Matthieu Bouron wrote:
On Tue, Jul 02, 2013 at 10:43:39PM +0200, Michael Niedermayer wrote:
On Tue, Jul 02, 2013 at 09:33:04PM +0200, Matthieu Bouron wrote:
On Tue, Jul 2, 2013 at 7:46 PM, Michael Niedermayer <michaelni@gmx.at>wrote:
On Sun, Jun 30, 2013 at 04:15:46PM +0200, Matthieu Bouron wrote:
Cover art muxing is done by introducing the -cover_stream_index option which takes an output stream index as argument. The stream used for the cover art is not muxed as a track in the resulting file. --- libavformat/movenc.c | 157 +++++++++++++++++++++++++++++++++++++++++++---- libavformat/movenc.h | 5 ++ libavformat/movenchint.c | 1 + 3 files changed, 152 insertions(+), 11 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 5577530..f411493 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -63,6 +63,7 @@ static const AVOption options[] = { { "ism_lookahead", "Number of lookahead entries for ISM files", offsetof(MOVMuxContext, ism_lookahead), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, { "use_editlist", "use edit list", offsetof(MOVMuxContext, use_editlist), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, AV_OPT_FLAG_ENCODING_PARAM}, { "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}, + { "cover_stream_index", "video stream index to use for cover art", offsetof(MOVMuxContext, cover_stream_index), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, { NULL },
isnt AV_DISPOSITION_ATTACHED_PIC enough ? why is this option needed ?
I guess AV_DISPOSITION_ATTACHED_PIC could be enough. My idea here was to let the user choose the cover art from any output streams he likes with -cover_stream_index. If the input does not have any cover arts, can a custom stream be flagged as an attached pic ?
if it cannot then such feature should be added but certainly doesnt belong in a single individual muxer
You're right, using AV_DISPOSITON_ATTACHED_PIC seems a better solution than introducing the cover_stream_index.
Here is a new patch which uses all stream with AV_DISPOSITON_ATTACHED_PIC as cover arts. It works for all modes which use the iTunes metadata (!3gp and !mov).
Actually the cover art codec is only checked at the end (when writing the metadata). If not BMP, MJPEG or PNG the user is warned that the cover art is ignored.
Do you think this check should be included in the new mov_stream_is_apic function and discard all apic streams which have not the right codec (and use them as normal stream ? (IMHO it do not feel right to me to use them as normal stream)).
probably not did you test this with subtitles & chapters ? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Let us carefully observe those good qualities wherein our enemies excel us and endeavor to excel them, by avoiding what is faulty, and imitating what is excellent in them. -- Plutarch
On Wed, Jul 3, 2013 at 10:50 PM, Michael Niedermayer <michaelni@gmx.at>wrote:
On Tue, Jul 02, 2013 at 10:43:39PM +0200, Michael Niedermayer wrote:
On Tue, Jul 02, 2013 at 09:33:04PM +0200, Matthieu Bouron wrote:
On Tue, Jul 2, 2013 at 7:46 PM, Michael Niedermayer < michaelni@gmx.at>wrote:
On Sun, Jun 30, 2013 at 04:15:46PM +0200, Matthieu Bouron wrote:
Cover art muxing is done by introducing the -cover_stream_index
which takes an output stream index as argument. The stream used for the cover art is not muxed as a track in the resulting file. --- libavformat/movenc.c | 157 +++++++++++++++++++++++++++++++++++++++++++---- libavformat/movenc.h | 5 ++ libavformat/movenchint.c | 1 + 3 files changed, 152 insertions(+), 11 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 5577530..f411493 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -63,6 +63,7 @@ static const AVOption options[] = { { "ism_lookahead", "Number of lookahead entries for ISM files", offsetof(MOVMuxContext, ism_lookahead), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, { "use_editlist", "use edit list", offsetof(MOVMuxContext, use_editlist), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, AV_OPT_FLAG_ENCODING_PARAM}, { "video_track_timescale", "set timescale of all video
On Wed, Jul 03, 2013 at 12:08:38PM +0200, Matthieu Bouron wrote: option tracks",
offsetof(MOVMuxContext, video_track_timescale), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
+ { "cover_stream_index", "video stream index to use for cover art", offsetof(MOVMuxContext, cover_stream_index), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, { NULL },
isnt AV_DISPOSITION_ATTACHED_PIC enough ? why is this option needed ?
I guess AV_DISPOSITION_ATTACHED_PIC could be enough. My idea here was to let the user choose the cover art from any output streams he likes with -cover_stream_index. If the input does not have any cover arts, can a custom stream be flagged as an attached pic ?
if it cannot then such feature should be added but certainly doesnt belong in a single individual muxer
You're right, using AV_DISPOSITON_ATTACHED_PIC seems a better solution than introducing the cover_stream_index.
Here is a new patch which uses all stream with AV_DISPOSITON_ATTACHED_PIC as cover arts. It works for all modes which use the iTunes metadata (!3gp and !mov).
Actually the cover art codec is only checked at the end (when writing the metadata). If not BMP, MJPEG or PNG the user is warned that the cover art is ignored.
Do you think this check should be included in the new mov_stream_is_apic function and discard all apic streams which have not the right codec (and use them as normal stream ? (IMHO it do not feel right to me to use them as normal stream)).
probably not
did you test this with subtitles & chapters ?
I'm currently testing it with chapters and rtphint, i'll send an updated patch as soon as all problems are fixed. [...]
On Thu, Jul 04, 2013 at 01:20:56PM +0200, Matthieu Bouron wrote:
On Wed, Jul 3, 2013 at 10:50 PM, Michael Niedermayer <michaelni@gmx.at>wrote:
On Tue, Jul 02, 2013 at 10:43:39PM +0200, Michael Niedermayer wrote:
On Tue, Jul 02, 2013 at 09:33:04PM +0200, Matthieu Bouron wrote:
On Tue, Jul 2, 2013 at 7:46 PM, Michael Niedermayer < michaelni@gmx.at>wrote:
On Sun, Jun 30, 2013 at 04:15:46PM +0200, Matthieu Bouron wrote: > Cover art muxing is done by introducing the -cover_stream_index
> which takes an output stream index as argument. > The stream used for the cover art is not muxed as a track in the > resulting file. > --- > libavformat/movenc.c | 157 +++++++++++++++++++++++++++++++++++++++++++---- > libavformat/movenc.h | 5 ++ > libavformat/movenchint.c | 1 + > 3 files changed, 152 insertions(+), 11 deletions(-) > > diff --git a/libavformat/movenc.c b/libavformat/movenc.c > index 5577530..f411493 100644 > --- a/libavformat/movenc.c > +++ b/libavformat/movenc.c > @@ -63,6 +63,7 @@ static const AVOption options[] = { > { "ism_lookahead", "Number of lookahead entries for ISM files", offsetof(MOVMuxContext, ism_lookahead), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, > { "use_editlist", "use edit list", offsetof(MOVMuxContext, use_editlist), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, AV_OPT_FLAG_ENCODING_PARAM}, > { "video_track_timescale", "set timescale of all video
On Wed, Jul 03, 2013 at 12:08:38PM +0200, Matthieu Bouron wrote: option tracks",
offsetof(MOVMuxContext, video_track_timescale), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, > + { "cover_stream_index", "video stream index to use for cover art", offsetof(MOVMuxContext, cover_stream_index), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, > { NULL },
isnt AV_DISPOSITION_ATTACHED_PIC enough ? why is this option needed ?
I guess AV_DISPOSITION_ATTACHED_PIC could be enough. My idea here was to let the user choose the cover art from any output streams he likes with -cover_stream_index. If the input does not have any cover arts, can a custom stream be flagged as an attached pic ?
if it cannot then such feature should be added but certainly doesnt belong in a single individual muxer
You're right, using AV_DISPOSITON_ATTACHED_PIC seems a better solution than introducing the cover_stream_index.
Here is a new patch which uses all stream with AV_DISPOSITON_ATTACHED_PIC as cover arts. It works for all modes which use the iTunes metadata (!3gp and !mov).
Actually the cover art codec is only checked at the end (when writing the metadata). If not BMP, MJPEG or PNG the user is warned that the cover art is ignored.
Do you think this check should be included in the new mov_stream_is_apic function and discard all apic streams which have not the right codec (and use them as normal stream ? (IMHO it do not feel right to me to use them as normal stream)).
probably not
did you test this with subtitles & chapters ?
I'm currently testing it with chapters and rtphint, i'll send an updated patch as soon as all problems are fixed.
New patch attached tested with chapters + subtitles + cover art + rtphint. TODO: bump lavf version Regards, Matthieu
On Fri, Jul 05, 2013 at 02:18:57PM +0200, Matthieu Bouron wrote:
On Thu, Jul 04, 2013 at 01:20:56PM +0200, Matthieu Bouron wrote:
On Wed, Jul 3, 2013 at 10:50 PM, Michael Niedermayer <michaelni@gmx.at>wrote:
On Tue, Jul 02, 2013 at 10:43:39PM +0200, Michael Niedermayer wrote:
On Tue, Jul 02, 2013 at 09:33:04PM +0200, Matthieu Bouron wrote:
On Tue, Jul 2, 2013 at 7:46 PM, Michael Niedermayer < michaelni@gmx.at>wrote:
> On Sun, Jun 30, 2013 at 04:15:46PM +0200, Matthieu Bouron wrote: > > Cover art muxing is done by introducing the -cover_stream_index
> > which takes an output stream index as argument. > > The stream used for the cover art is not muxed as a track in the > > resulting file. > > --- > > libavformat/movenc.c | 157 > +++++++++++++++++++++++++++++++++++++++++++---- > > libavformat/movenc.h | 5 ++ > > libavformat/movenchint.c | 1 + > > 3 files changed, 152 insertions(+), 11 deletions(-) > > > > diff --git a/libavformat/movenc.c b/libavformat/movenc.c > > index 5577530..f411493 100644 > > --- a/libavformat/movenc.c > > +++ b/libavformat/movenc.c > > @@ -63,6 +63,7 @@ static const AVOption options[] = { > > { "ism_lookahead", "Number of lookahead entries for ISM files", > offsetof(MOVMuxContext, ism_lookahead), AV_OPT_TYPE_INT, {.i64 = 0}, 0, > INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, > > { "use_editlist", "use edit list", offsetof(MOVMuxContext, > use_editlist), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, > AV_OPT_FLAG_ENCODING_PARAM}, > > { "video_track_timescale", "set timescale of all video
On Wed, Jul 03, 2013 at 12:08:38PM +0200, Matthieu Bouron wrote: option tracks",
> offsetof(MOVMuxContext, video_track_timescale), AV_OPT_TYPE_INT, {.i64 = > 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, > > + { "cover_stream_index", "video stream index to use for cover art", > offsetof(MOVMuxContext, cover_stream_index), AV_OPT_TYPE_INT, {.i64 = -1}, > -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, > > { NULL }, > > isnt AV_DISPOSITION_ATTACHED_PIC enough ? > why is this option needed ? >
I guess AV_DISPOSITION_ATTACHED_PIC could be enough. My idea here was to let the user choose the cover art from any output streams he likes with -cover_stream_index. If the input does not have any cover arts, can a custom stream be flagged as an attached pic ?
if it cannot then such feature should be added but certainly doesnt belong in a single individual muxer
You're right, using AV_DISPOSITON_ATTACHED_PIC seems a better solution than introducing the cover_stream_index.
Here is a new patch which uses all stream with AV_DISPOSITON_ATTACHED_PIC as cover arts. It works for all modes which use the iTunes metadata (!3gp and !mov).
Actually the cover art codec is only checked at the end (when writing the metadata). If not BMP, MJPEG or PNG the user is warned that the cover art is ignored.
Do you think this check should be included in the new mov_stream_is_apic function and discard all apic streams which have not the right codec (and use them as normal stream ? (IMHO it do not feel right to me to use them as normal stream)).
probably not
did you test this with subtitles & chapters ?
I'm currently testing it with chapters and rtphint, i'll send an updated patch as soon as all problems are fixed.
New patch attached tested with chapters + subtitles + cover art + rtphint.
Rebased patch attached. Matthieu
On Tue, Jul 9, 2013 at 12:22 PM, Matthieu Bouron <matthieu.bouron@gmail.com>wrote:
On Fri, Jul 05, 2013 at 02:18:57PM +0200, Matthieu Bouron wrote:
On Thu, Jul 04, 2013 at 01:20:56PM +0200, Matthieu Bouron wrote: New patch attached tested with chapters + subtitles + cover art + rtphint.
Rebased patch attached.
Ping
On Wed, Jul 10, 2013 at 7:48 AM, Matthieu Bouron <matthieu.bouron@gmail.com>wrote:
On Tue, Jul 9, 2013 at 12:22 PM, Matthieu Bouron < matthieu.bouron@gmail.com> wrote:
On Fri, Jul 05, 2013 at 02:18:57PM +0200, Matthieu Bouron wrote:
On Thu, Jul 04, 2013 at 01:20:56PM +0200, Matthieu Bouron wrote: New patch attached tested with chapters + subtitles + cover art + rtphint.
Rebased patch attached.
Ping
Ping
On Tue, Jul 09, 2013 at 12:22:50PM +0200, Matthieu Bouron wrote:
On Fri, Jul 05, 2013 at 02:18:57PM +0200, Matthieu Bouron wrote:
On Thu, Jul 04, 2013 at 01:20:56PM +0200, Matthieu Bouron wrote:
On Wed, Jul 3, 2013 at 10:50 PM, Michael Niedermayer <michaelni@gmx.at>wrote:
On Tue, Jul 02, 2013 at 10:43:39PM +0200, Michael Niedermayer wrote:
On Tue, Jul 02, 2013 at 09:33:04PM +0200, Matthieu Bouron wrote: > On Tue, Jul 2, 2013 at 7:46 PM, Michael Niedermayer < michaelni@gmx.at>wrote: > > > On Sun, Jun 30, 2013 at 04:15:46PM +0200, Matthieu Bouron wrote: > > > Cover art muxing is done by introducing the -cover_stream_index
> > > which takes an output stream index as argument. > > > The stream used for the cover art is not muxed as a track in the > > > resulting file. > > > --- > > > libavformat/movenc.c | 157 > > +++++++++++++++++++++++++++++++++++++++++++---- > > > libavformat/movenc.h | 5 ++ > > > libavformat/movenchint.c | 1 + > > > 3 files changed, 152 insertions(+), 11 deletions(-) > > > > > > diff --git a/libavformat/movenc.c b/libavformat/movenc.c > > > index 5577530..f411493 100644 > > > --- a/libavformat/movenc.c > > > +++ b/libavformat/movenc.c > > > @@ -63,6 +63,7 @@ static const AVOption options[] = { > > > { "ism_lookahead", "Number of lookahead entries for ISM files", > > offsetof(MOVMuxContext, ism_lookahead), AV_OPT_TYPE_INT, {.i64 = 0}, 0, > > INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, > > > { "use_editlist", "use edit list", offsetof(MOVMuxContext, > > use_editlist), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, > > AV_OPT_FLAG_ENCODING_PARAM}, > > > { "video_track_timescale", "set timescale of all video
On Wed, Jul 03, 2013 at 12:08:38PM +0200, Matthieu Bouron wrote: option tracks",
> > offsetof(MOVMuxContext, video_track_timescale), AV_OPT_TYPE_INT, {.i64 = > > 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, > > > + { "cover_stream_index", "video stream index to use for cover art", > > offsetof(MOVMuxContext, cover_stream_index), AV_OPT_TYPE_INT, {.i64 = -1}, > > -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, > > > { NULL }, > > > > isnt AV_DISPOSITION_ATTACHED_PIC enough ? > > why is this option needed ? > > > > I guess AV_DISPOSITION_ATTACHED_PIC could be enough. > My idea here was to let the user choose the cover art from any output > streams he likes with -cover_stream_index. If the input does not have any > cover arts, can a custom stream be flagged as an attached pic ?
if it cannot then such feature should be added but certainly doesnt belong in a single individual muxer
You're right, using AV_DISPOSITON_ATTACHED_PIC seems a better solution than introducing the cover_stream_index.
Here is a new patch which uses all stream with AV_DISPOSITON_ATTACHED_PIC as cover arts. It works for all modes which use the iTunes metadata (!3gp and !mov).
Actually the cover art codec is only checked at the end (when writing the metadata). If not BMP, MJPEG or PNG the user is warned that the cover art is ignored.
Do you think this check should be included in the new mov_stream_is_apic function and discard all apic streams which have not the right codec (and use them as normal stream ? (IMHO it do not feel right to me to use them as normal stream)).
probably not
did you test this with subtitles & chapters ?
I'm currently testing it with chapters and rtphint, i'll send an updated patch as soon as all problems are fixed.
New patch attached tested with chapters + subtitles + cover art + rtphint.
Rebased patch attached.
Matthieu
movenc.c | 194 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- movenc.h | 10 ++- movenchint.c | 14 +++- 3 files changed, 190 insertions(+), 28 deletions(-) 7dddc2097412a3691adace52efca4d5510b4b655 0001-lavf-movenc-support-iTunes-cover-art.patch From b69af041df927f87735cffb128b6f54550d17800 Mon Sep 17 00:00:00 2001 From: Matthieu Bouron <matthieu.bouron@gmail.com> Date: Thu, 27 Jun 2013 18:12:50 +0200 Subject: [PATCH] lavf/movenc: support iTunes cover art
Video streams with AV_DISPOSITON_ATTACHED_PIC will be used as cover arts and won't be muxed as normal tracks in the resulting file. --- libavformat/movenc.c | 194 +++++++++++++++++++++++++++++++++++++++++------ libavformat/movenc.h | 10 ++- libavformat/movenchint.c | 14 +++- 3 files changed, 190 insertions(+), 28 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 42e7c48..92279f5 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -104,6 +104,15 @@ static int is_co64_required(const MOVTrack *track) return 0; }
+static int mov_stream_is_apic(MOVMuxContext *mov, AVStream *st) +{ + if ((mov->mode & MODE_3GP) || (mov->mode & MODE_MOV)) + return 0; + if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) + return 1; + return 0; +}
maybe 3gp/mov AV_DISPOSITION_ATTACHED_PIC should print a warning or be treates as error or something [...]
@@ -3136,12 +3202,17 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) { MOVMuxContext *mov = s->priv_data; AVIOContext *pb = s->pb; - MOVTrack *trk = &mov->tracks[pkt->stream_index]; - AVCodecContext *enc = trk->enc; + int trk_index = ff_mov_get_track_index(mov, pkt->stream_index); + MOVTrack *trk; + AVCodecContext *enc; unsigned int samples_in_chunk = 0; int size = pkt->size; uint8_t *reformatted_data = NULL;
+ if (trk_index < 0) return 0;
this looks a bit like a hack calling a function just to do nothing also the patch is somewhat intrusive (and ugly) for what it does theres no way this can be achived simpler and cleaner ? for exmple by seperating the extra stream out in generic code before the muxer, but thats just an idea that could allow simplifications for other muxers too. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If you think the mosad wants you dead since a long time then you are either wrong or dead since a long time.
On Wed, Jul 17, 2013 at 05:39:18PM +0200, Michael Niedermayer wrote:
On Tue, Jul 09, 2013 at 12:22:50PM +0200, Matthieu Bouron wrote:
On Fri, Jul 05, 2013 at 02:18:57PM +0200, Matthieu Bouron wrote:
On Thu, Jul 04, 2013 at 01:20:56PM +0200, Matthieu Bouron wrote:
On Wed, Jul 3, 2013 at 10:50 PM, Michael Niedermayer <michaelni@gmx.at>wrote:
On Tue, Jul 02, 2013 at 10:43:39PM +0200, Michael Niedermayer wrote: > On Tue, Jul 02, 2013 at 09:33:04PM +0200, Matthieu Bouron wrote: > > On Tue, Jul 2, 2013 at 7:46 PM, Michael Niedermayer < michaelni@gmx.at>wrote: > > > > > On Sun, Jun 30, 2013 at 04:15:46PM +0200, Matthieu Bouron wrote: > > > > Cover art muxing is done by introducing the -cover_stream_index
> > > > which takes an output stream index as argument. > > > > The stream used for the cover art is not muxed as a track in the > > > > resulting file. > > > > --- > > > > libavformat/movenc.c | 157 > > > +++++++++++++++++++++++++++++++++++++++++++---- > > > > libavformat/movenc.h | 5 ++ > > > > libavformat/movenchint.c | 1 + > > > > 3 files changed, 152 insertions(+), 11 deletions(-) > > > > > > > > diff --git a/libavformat/movenc.c b/libavformat/movenc.c > > > > index 5577530..f411493 100644 > > > > --- a/libavformat/movenc.c > > > > +++ b/libavformat/movenc.c > > > > @@ -63,6 +63,7 @@ static const AVOption options[] = { > > > > { "ism_lookahead", "Number of lookahead entries for ISM files", > > > offsetof(MOVMuxContext, ism_lookahead), AV_OPT_TYPE_INT, {.i64 = 0}, 0, > > > INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, > > > > { "use_editlist", "use edit list", offsetof(MOVMuxContext, > > > use_editlist), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, > > > AV_OPT_FLAG_ENCODING_PARAM}, > > > > { "video_track_timescale", "set timescale of all video
On Wed, Jul 03, 2013 at 12:08:38PM +0200, Matthieu Bouron wrote: option tracks",
> > > offsetof(MOVMuxContext, video_track_timescale), AV_OPT_TYPE_INT, {.i64 = > > > 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, > > > > + { "cover_stream_index", "video stream index to use for cover art", > > > offsetof(MOVMuxContext, cover_stream_index), AV_OPT_TYPE_INT, {.i64 = -1}, > > > -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, > > > > { NULL }, > > > > > > isnt AV_DISPOSITION_ATTACHED_PIC enough ? > > > why is this option needed ? > > > > > > > I guess AV_DISPOSITION_ATTACHED_PIC could be enough. > > My idea here was to let the user choose the cover art from any output > > streams he likes with -cover_stream_index. If the input does not have any > > cover arts, can a custom stream be flagged as an attached pic ? > > if it cannot then such feature should be added but certainly doesnt > belong in a single individual muxer
You're right, using AV_DISPOSITON_ATTACHED_PIC seems a better solution than introducing the cover_stream_index.
Here is a new patch which uses all stream with AV_DISPOSITON_ATTACHED_PIC as cover arts. It works for all modes which use the iTunes metadata (!3gp and !mov).
Actually the cover art codec is only checked at the end (when writing the metadata). If not BMP, MJPEG or PNG the user is warned that the cover art is ignored.
Do you think this check should be included in the new mov_stream_is_apic function and discard all apic streams which have not the right codec (and use them as normal stream ? (IMHO it do not feel right to me to use them as normal stream)).
probably not
did you test this with subtitles & chapters ?
I'm currently testing it with chapters and rtphint, i'll send an updated patch as soon as all problems are fixed.
New patch attached tested with chapters + subtitles + cover art + rtphint.
Rebased patch attached.
Matthieu
movenc.c | 194 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- movenc.h | 10 ++- movenchint.c | 14 +++- 3 files changed, 190 insertions(+), 28 deletions(-) 7dddc2097412a3691adace52efca4d5510b4b655 0001-lavf-movenc-support-iTunes-cover-art.patch From b69af041df927f87735cffb128b6f54550d17800 Mon Sep 17 00:00:00 2001 From: Matthieu Bouron <matthieu.bouron@gmail.com> Date: Thu, 27 Jun 2013 18:12:50 +0200 Subject: [PATCH] lavf/movenc: support iTunes cover art
Video streams with AV_DISPOSITON_ATTACHED_PIC will be used as cover arts and won't be muxed as normal tracks in the resulting file. --- libavformat/movenc.c | 194 +++++++++++++++++++++++++++++++++++++++++------ libavformat/movenc.h | 10 ++- libavformat/movenchint.c | 14 +++- 3 files changed, 190 insertions(+), 28 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 42e7c48..92279f5 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -104,6 +104,15 @@ static int is_co64_required(const MOVTrack *track) return 0; }
+static int mov_stream_is_apic(MOVMuxContext *mov, AVStream *st) +{ + if ((mov->mode & MODE_3GP) || (mov->mode & MODE_MOV)) + return 0; + if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) + return 1; + return 0; +}
maybe 3gp/mov AV_DISPOSITION_ATTACHED_PIC should print a warning or be treates as error or something
[...]
@@ -3136,12 +3202,17 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) { MOVMuxContext *mov = s->priv_data; AVIOContext *pb = s->pb; - MOVTrack *trk = &mov->tracks[pkt->stream_index]; - AVCodecContext *enc = trk->enc; + int trk_index = ff_mov_get_track_index(mov, pkt->stream_index); + MOVTrack *trk; + AVCodecContext *enc; unsigned int samples_in_chunk = 0; int size = pkt->size; uint8_t *reformatted_data = NULL;
+ if (trk_index < 0) return 0;
this looks a bit like a hack calling a function just to do nothing
If the stream index is not related to an existing track the packet is discarded (which is the case for attached pic streams).
also the patch is somewhat intrusive (and ugly) for what it does theres no way this can be achived simpler and cleaner ? for exmple by seperating the extra stream out in generic code before the muxer, but thats just an idea that could allow simplifications for other muxers too.
Indeed, the patch is a bit (too much) intrusive since I have to find a way to discard a specific stream and avoid writing a track for it. AFAIK, It is basically the only solution without adding a dedicated mechanism in lavf to handle streams with AV_DISPOSITION_ATTACHED_PIC. Has some work been started on such mechanism ? Regards, Matthieu [...]
On Wed, Jul 17, 2013 at 04:21:16PM +0000, Matthieu Bouron wrote:
On Wed, Jul 17, 2013 at 05:39:18PM +0200, Michael Niedermayer wrote:
On Tue, Jul 09, 2013 at 12:22:50PM +0200, Matthieu Bouron wrote:
On Fri, Jul 05, 2013 at 02:18:57PM +0200, Matthieu Bouron wrote:
On Thu, Jul 04, 2013 at 01:20:56PM +0200, Matthieu Bouron wrote:
On Wed, Jul 3, 2013 at 10:50 PM, Michael Niedermayer <michaelni@gmx.at>wrote:
On Wed, Jul 03, 2013 at 12:08:38PM +0200, Matthieu Bouron wrote: > On Tue, Jul 02, 2013 at 10:43:39PM +0200, Michael Niedermayer wrote: > > On Tue, Jul 02, 2013 at 09:33:04PM +0200, Matthieu Bouron wrote: > > > On Tue, Jul 2, 2013 at 7:46 PM, Michael Niedermayer < michaelni@gmx.at>wrote: > > > > > > > On Sun, Jun 30, 2013 at 04:15:46PM +0200, Matthieu Bouron wrote: > > > > > Cover art muxing is done by introducing the -cover_stream_index option > > > > > which takes an output stream index as argument. > > > > > The stream used for the cover art is not muxed as a track in the > > > > > resulting file. > > > > > --- > > > > > libavformat/movenc.c | 157 > > > > +++++++++++++++++++++++++++++++++++++++++++---- > > > > > libavformat/movenc.h | 5 ++ > > > > > libavformat/movenchint.c | 1 + > > > > > 3 files changed, 152 insertions(+), 11 deletions(-) > > > > > > > > > > diff --git a/libavformat/movenc.c b/libavformat/movenc.c > > > > > index 5577530..f411493 100644 > > > > > --- a/libavformat/movenc.c > > > > > +++ b/libavformat/movenc.c > > > > > @@ -63,6 +63,7 @@ static const AVOption options[] = { > > > > > { "ism_lookahead", "Number of lookahead entries for ISM files", > > > > offsetof(MOVMuxContext, ism_lookahead), AV_OPT_TYPE_INT, {.i64 = 0}, 0, > > > > INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, > > > > > { "use_editlist", "use edit list", offsetof(MOVMuxContext, > > > > use_editlist), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, > > > > AV_OPT_FLAG_ENCODING_PARAM}, > > > > > { "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}, > > > > > + { "cover_stream_index", "video stream index to use for cover art", > > > > offsetof(MOVMuxContext, cover_stream_index), AV_OPT_TYPE_INT, {.i64 = -1}, > > > > -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, > > > > > { NULL }, > > > > > > > > isnt AV_DISPOSITION_ATTACHED_PIC enough ? > > > > why is this option needed ? > > > > > > > > > > I guess AV_DISPOSITION_ATTACHED_PIC could be enough. > > > My idea here was to let the user choose the cover art from any output > > > streams he likes with -cover_stream_index. If the input does not have any > > > cover arts, can a custom stream be flagged as an attached pic ? > > > > if it cannot then such feature should be added but certainly doesnt > > belong in a single individual muxer > > You're right, using AV_DISPOSITON_ATTACHED_PIC seems a better solution > than introducing the cover_stream_index. > > Here is a new patch which uses all stream with AV_DISPOSITON_ATTACHED_PIC > as cover arts. It works for all modes which use the iTunes metadata (!3gp > and !mov). > > Actually the cover art codec is only checked at the end (when writing the > metadata). If not BMP, MJPEG or PNG the user is warned that the cover art > is ignored. > > Do you think this check should be included in the new mov_stream_is_apic > function and discard all apic streams which have not the right codec (and > use them as normal stream ? (IMHO it do not feel right to me to use them > as normal stream)).
probably not
did you test this with subtitles & chapters ?
I'm currently testing it with chapters and rtphint, i'll send an updated patch as soon as all problems are fixed.
New patch attached tested with chapters + subtitles + cover art + rtphint.
Rebased patch attached.
Matthieu
movenc.c | 194 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- movenc.h | 10 ++- movenchint.c | 14 +++- 3 files changed, 190 insertions(+), 28 deletions(-) 7dddc2097412a3691adace52efca4d5510b4b655 0001-lavf-movenc-support-iTunes-cover-art.patch From b69af041df927f87735cffb128b6f54550d17800 Mon Sep 17 00:00:00 2001 From: Matthieu Bouron <matthieu.bouron@gmail.com> Date: Thu, 27 Jun 2013 18:12:50 +0200 Subject: [PATCH] lavf/movenc: support iTunes cover art
Video streams with AV_DISPOSITON_ATTACHED_PIC will be used as cover arts and won't be muxed as normal tracks in the resulting file. --- libavformat/movenc.c | 194 +++++++++++++++++++++++++++++++++++++++++------ libavformat/movenc.h | 10 ++- libavformat/movenchint.c | 14 +++- 3 files changed, 190 insertions(+), 28 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 42e7c48..92279f5 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -104,6 +104,15 @@ static int is_co64_required(const MOVTrack *track) return 0; }
+static int mov_stream_is_apic(MOVMuxContext *mov, AVStream *st) +{ + if ((mov->mode & MODE_3GP) || (mov->mode & MODE_MOV)) + return 0; + if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) + return 1; + return 0; +}
maybe 3gp/mov AV_DISPOSITION_ATTACHED_PIC should print a warning or be treates as error or something
[...]
@@ -3136,12 +3202,17 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) { MOVMuxContext *mov = s->priv_data; AVIOContext *pb = s->pb; - MOVTrack *trk = &mov->tracks[pkt->stream_index]; - AVCodecContext *enc = trk->enc; + int trk_index = ff_mov_get_track_index(mov, pkt->stream_index); + MOVTrack *trk; + AVCodecContext *enc; unsigned int samples_in_chunk = 0; int size = pkt->size; uint8_t *reformatted_data = NULL;
+ if (trk_index < 0) return 0;
this looks a bit like a hack calling a function just to do nothing
If the stream index is not related to an existing track the packet is discarded (which is the case for attached pic streams).
also the patch is somewhat intrusive (and ugly) for what it does theres no way this can be achived simpler and cleaner ? for exmple by seperating the extra stream out in generic code before the muxer, but thats just an idea that could allow simplifications for other muxers too.
Indeed, the patch is a bit (too much) intrusive since I have to find a way to discard a specific stream and avoid writing a track for it. AFAIK, It is basically the only solution without adding a dedicated mechanism in lavf to handle streams with AV_DISPOSITION_ATTACHED_PIC.
To avoid all the intrusive code in the mov/mp4 muxer, all apic streams must not be referenced in the muxer streams array (s->streams) since the muxer map stream indexes to track indexes. This means, adding s->apic_streams + s->write_apic_packets to the muxer, don't break the reference between packets and streams and makes ffmpeg works with this. This probably also means adding the same things on the demuxer side. Do you think this could be an acceptable solution ? Maybe there is a better way to do it. Please comment, Matthieu [...]
On Mon, Jul 22, 2013 at 09:42:43AM +0000, Matthieu Bouron wrote:
On Wed, Jul 17, 2013 at 04:21:16PM +0000, Matthieu Bouron wrote:
On Wed, Jul 17, 2013 at 05:39:18PM +0200, Michael Niedermayer wrote:
On Tue, Jul 09, 2013 at 12:22:50PM +0200, Matthieu Bouron wrote:
On Fri, Jul 05, 2013 at 02:18:57PM +0200, Matthieu Bouron wrote:
On Thu, Jul 04, 2013 at 01:20:56PM +0200, Matthieu Bouron wrote:
On Wed, Jul 3, 2013 at 10:50 PM, Michael Niedermayer <michaelni@gmx.at>wrote:
> On Wed, Jul 03, 2013 at 12:08:38PM +0200, Matthieu Bouron wrote: > > On Tue, Jul 02, 2013 at 10:43:39PM +0200, Michael Niedermayer wrote: > > > On Tue, Jul 02, 2013 at 09:33:04PM +0200, Matthieu Bouron wrote: > > > > On Tue, Jul 2, 2013 at 7:46 PM, Michael Niedermayer < > michaelni@gmx.at>wrote: > > > > > > > > > On Sun, Jun 30, 2013 at 04:15:46PM +0200, Matthieu Bouron wrote: > > > > > > Cover art muxing is done by introducing the -cover_stream_index > option > > > > > > which takes an output stream index as argument. > > > > > > The stream used for the cover art is not muxed as a track in the > > > > > > resulting file. > > > > > > --- > > > > > > libavformat/movenc.c | 157 > > > > > +++++++++++++++++++++++++++++++++++++++++++---- > > > > > > libavformat/movenc.h | 5 ++ > > > > > > libavformat/movenchint.c | 1 + > > > > > > 3 files changed, 152 insertions(+), 11 deletions(-) > > > > > > > > > > > > diff --git a/libavformat/movenc.c b/libavformat/movenc.c > > > > > > index 5577530..f411493 100644 > > > > > > --- a/libavformat/movenc.c > > > > > > +++ b/libavformat/movenc.c > > > > > > @@ -63,6 +63,7 @@ static const AVOption options[] = { > > > > > > { "ism_lookahead", "Number of lookahead entries for ISM > files", > > > > > offsetof(MOVMuxContext, ism_lookahead), AV_OPT_TYPE_INT, {.i64 = > 0}, 0, > > > > > INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, > > > > > > { "use_editlist", "use edit list", offsetof(MOVMuxContext, > > > > > use_editlist), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, > > > > > AV_OPT_FLAG_ENCODING_PARAM}, > > > > > > { "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}, > > > > > > + { "cover_stream_index", "video stream index to use for > cover art", > > > > > offsetof(MOVMuxContext, cover_stream_index), AV_OPT_TYPE_INT, > {.i64 = -1}, > > > > > -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, > > > > > > { NULL }, > > > > > > > > > > isnt AV_DISPOSITION_ATTACHED_PIC enough ? > > > > > why is this option needed ? > > > > > > > > > > > > > I guess AV_DISPOSITION_ATTACHED_PIC could be enough. > > > > My idea here was to let the user choose the cover art from any output > > > > streams he likes with -cover_stream_index. If the input does not > have any > > > > cover arts, can a custom stream be flagged as an attached pic ? > > > > > > if it cannot then such feature should be added but certainly doesnt > > > belong in a single individual muxer > > > > You're right, using AV_DISPOSITON_ATTACHED_PIC seems a better solution > > than introducing the cover_stream_index. > > > > Here is a new patch which uses all stream with AV_DISPOSITON_ATTACHED_PIC > > as cover arts. It works for all modes which use the iTunes metadata (!3gp > > and !mov). > > > > Actually the cover art codec is only checked at the end (when writing the > > metadata). If not BMP, MJPEG or PNG the user is warned that the cover art > > is ignored. > > > > Do you think this check should be included in the new mov_stream_is_apic > > function and discard all apic streams which have not the right codec (and > > use them as normal stream ? (IMHO it do not feel right to me to use them > > as normal stream)). > > probably not > > did you test this with subtitles & chapters ? >
I'm currently testing it with chapters and rtphint, i'll send an updated patch as soon as all problems are fixed.
New patch attached tested with chapters + subtitles + cover art + rtphint.
Rebased patch attached.
Matthieu
movenc.c | 194 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- movenc.h | 10 ++- movenchint.c | 14 +++- 3 files changed, 190 insertions(+), 28 deletions(-) 7dddc2097412a3691adace52efca4d5510b4b655 0001-lavf-movenc-support-iTunes-cover-art.patch From b69af041df927f87735cffb128b6f54550d17800 Mon Sep 17 00:00:00 2001 From: Matthieu Bouron <matthieu.bouron@gmail.com> Date: Thu, 27 Jun 2013 18:12:50 +0200 Subject: [PATCH] lavf/movenc: support iTunes cover art
Video streams with AV_DISPOSITON_ATTACHED_PIC will be used as cover arts and won't be muxed as normal tracks in the resulting file. --- libavformat/movenc.c | 194 +++++++++++++++++++++++++++++++++++++++++------ libavformat/movenc.h | 10 ++- libavformat/movenchint.c | 14 +++- 3 files changed, 190 insertions(+), 28 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 42e7c48..92279f5 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -104,6 +104,15 @@ static int is_co64_required(const MOVTrack *track) return 0; }
+static int mov_stream_is_apic(MOVMuxContext *mov, AVStream *st) +{ + if ((mov->mode & MODE_3GP) || (mov->mode & MODE_MOV)) + return 0; + if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) + return 1; + return 0; +}
maybe 3gp/mov AV_DISPOSITION_ATTACHED_PIC should print a warning or be treates as error or something
[...]
@@ -3136,12 +3202,17 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) { MOVMuxContext *mov = s->priv_data; AVIOContext *pb = s->pb; - MOVTrack *trk = &mov->tracks[pkt->stream_index]; - AVCodecContext *enc = trk->enc; + int trk_index = ff_mov_get_track_index(mov, pkt->stream_index); + MOVTrack *trk; + AVCodecContext *enc; unsigned int samples_in_chunk = 0; int size = pkt->size; uint8_t *reformatted_data = NULL;
+ if (trk_index < 0) return 0;
this looks a bit like a hack calling a function just to do nothing
If the stream index is not related to an existing track the packet is discarded (which is the case for attached pic streams).
also the patch is somewhat intrusive (and ugly) for what it does theres no way this can be achived simpler and cleaner ? for exmple by seperating the extra stream out in generic code before the muxer, but thats just an idea that could allow simplifications for other muxers too.
Indeed, the patch is a bit (too much) intrusive since I have to find a way to discard a specific stream and avoid writing a track for it. AFAIK, It is basically the only solution without adding a dedicated mechanism in lavf to handle streams with AV_DISPOSITION_ATTACHED_PIC.
To avoid all the intrusive code in the mov/mp4 muxer, all apic streams must not be referenced in the muxer streams array (s->streams) since the muxer map stream indexes to track indexes. This means, adding s->apic_streams + s->write_apic_packets to the muxer, don't break the reference between packets and streams and makes ffmpeg works with this. This probably also means adding the same things on the demuxer side.
Do you think this could be an acceptable solution ? Maybe there is a better way to do it.
Any comments ? Thanks, Matthieu
On Sat, Jul 27, 2013 at 07:27:11PM +0200, Matthieu Bouron wrote:
On Mon, Jul 22, 2013 at 09:42:43AM +0000, Matthieu Bouron wrote:
On Wed, Jul 17, 2013 at 04:21:16PM +0000, Matthieu Bouron wrote:
On Wed, Jul 17, 2013 at 05:39:18PM +0200, Michael Niedermayer wrote:
On Tue, Jul 09, 2013 at 12:22:50PM +0200, Matthieu Bouron wrote:
On Fri, Jul 05, 2013 at 02:18:57PM +0200, Matthieu Bouron wrote:
On Thu, Jul 04, 2013 at 01:20:56PM +0200, Matthieu Bouron wrote: > On Wed, Jul 3, 2013 at 10:50 PM, Michael Niedermayer <michaelni@gmx.at>wrote: > > > On Wed, Jul 03, 2013 at 12:08:38PM +0200, Matthieu Bouron wrote: > > > On Tue, Jul 02, 2013 at 10:43:39PM +0200, Michael Niedermayer wrote: > > > > On Tue, Jul 02, 2013 at 09:33:04PM +0200, Matthieu Bouron wrote: > > > > > On Tue, Jul 2, 2013 at 7:46 PM, Michael Niedermayer < > > michaelni@gmx.at>wrote: > > > > > > > > > > > On Sun, Jun 30, 2013 at 04:15:46PM +0200, Matthieu Bouron wrote: > > > > > > > Cover art muxing is done by introducing the -cover_stream_index > > option > > > > > > > which takes an output stream index as argument. > > > > > > > The stream used for the cover art is not muxed as a track in the > > > > > > > resulting file. > > > > > > > --- > > > > > > > libavformat/movenc.c | 157 > > > > > > +++++++++++++++++++++++++++++++++++++++++++---- > > > > > > > libavformat/movenc.h | 5 ++ > > > > > > > libavformat/movenchint.c | 1 + > > > > > > > 3 files changed, 152 insertions(+), 11 deletions(-) > > > > > > > > > > > > > > diff --git a/libavformat/movenc.c b/libavformat/movenc.c > > > > > > > index 5577530..f411493 100644 > > > > > > > --- a/libavformat/movenc.c > > > > > > > +++ b/libavformat/movenc.c > > > > > > > @@ -63,6 +63,7 @@ static const AVOption options[] = { > > > > > > > { "ism_lookahead", "Number of lookahead entries for ISM > > files", > > > > > > offsetof(MOVMuxContext, ism_lookahead), AV_OPT_TYPE_INT, {.i64 = > > 0}, 0, > > > > > > INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, > > > > > > > { "use_editlist", "use edit list", offsetof(MOVMuxContext, > > > > > > use_editlist), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, > > > > > > AV_OPT_FLAG_ENCODING_PARAM}, > > > > > > > { "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}, > > > > > > > + { "cover_stream_index", "video stream index to use for > > cover art", > > > > > > offsetof(MOVMuxContext, cover_stream_index), AV_OPT_TYPE_INT, > > {.i64 = -1}, > > > > > > -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, > > > > > > > { NULL }, > > > > > > > > > > > > isnt AV_DISPOSITION_ATTACHED_PIC enough ? > > > > > > why is this option needed ? > > > > > > > > > > > > > > > > I guess AV_DISPOSITION_ATTACHED_PIC could be enough. > > > > > My idea here was to let the user choose the cover art from any output > > > > > streams he likes with -cover_stream_index. If the input does not > > have any > > > > > cover arts, can a custom stream be flagged as an attached pic ? > > > > > > > > if it cannot then such feature should be added but certainly doesnt > > > > belong in a single individual muxer > > > > > > You're right, using AV_DISPOSITON_ATTACHED_PIC seems a better solution > > > than introducing the cover_stream_index. > > > > > > Here is a new patch which uses all stream with AV_DISPOSITON_ATTACHED_PIC > > > as cover arts. It works for all modes which use the iTunes metadata (!3gp > > > and !mov). > > > > > > Actually the cover art codec is only checked at the end (when writing the > > > metadata). If not BMP, MJPEG or PNG the user is warned that the cover art > > > is ignored. > > > > > > Do you think this check should be included in the new mov_stream_is_apic > > > function and discard all apic streams which have not the right codec (and > > > use them as normal stream ? (IMHO it do not feel right to me to use them > > > as normal stream)). > > > > probably not > > > > did you test this with subtitles & chapters ? > > > > I'm currently testing it with chapters and rtphint, i'll send an updated > patch as soon as all problems are fixed. >
New patch attached tested with chapters + subtitles + cover art + rtphint.
Rebased patch attached.
Matthieu
movenc.c | 194 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- movenc.h | 10 ++- movenchint.c | 14 +++- 3 files changed, 190 insertions(+), 28 deletions(-) 7dddc2097412a3691adace52efca4d5510b4b655 0001-lavf-movenc-support-iTunes-cover-art.patch From b69af041df927f87735cffb128b6f54550d17800 Mon Sep 17 00:00:00 2001 From: Matthieu Bouron <matthieu.bouron@gmail.com> Date: Thu, 27 Jun 2013 18:12:50 +0200 Subject: [PATCH] lavf/movenc: support iTunes cover art
Video streams with AV_DISPOSITON_ATTACHED_PIC will be used as cover arts and won't be muxed as normal tracks in the resulting file. --- libavformat/movenc.c | 194 +++++++++++++++++++++++++++++++++++++++++------ libavformat/movenc.h | 10 ++- libavformat/movenchint.c | 14 +++- 3 files changed, 190 insertions(+), 28 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 42e7c48..92279f5 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -104,6 +104,15 @@ static int is_co64_required(const MOVTrack *track) return 0; }
+static int mov_stream_is_apic(MOVMuxContext *mov, AVStream *st) +{ + if ((mov->mode & MODE_3GP) || (mov->mode & MODE_MOV)) + return 0; + if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) + return 1; + return 0; +}
maybe 3gp/mov AV_DISPOSITION_ATTACHED_PIC should print a warning or be treates as error or something
[...]
@@ -3136,12 +3202,17 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) { MOVMuxContext *mov = s->priv_data; AVIOContext *pb = s->pb; - MOVTrack *trk = &mov->tracks[pkt->stream_index]; - AVCodecContext *enc = trk->enc; + int trk_index = ff_mov_get_track_index(mov, pkt->stream_index); + MOVTrack *trk; + AVCodecContext *enc; unsigned int samples_in_chunk = 0; int size = pkt->size; uint8_t *reformatted_data = NULL;
+ if (trk_index < 0) return 0;
this looks a bit like a hack calling a function just to do nothing
If the stream index is not related to an existing track the packet is discarded (which is the case for attached pic streams).
also the patch is somewhat intrusive (and ugly) for what it does theres no way this can be achived simpler and cleaner ? for exmple by seperating the extra stream out in generic code before the muxer, but thats just an idea that could allow simplifications for other muxers too.
Indeed, the patch is a bit (too much) intrusive since I have to find a way to discard a specific stream and avoid writing a track for it. AFAIK, It is basically the only solution without adding a dedicated mechanism in lavf to handle streams with AV_DISPOSITION_ATTACHED_PIC.
To avoid all the intrusive code in the mov/mp4 muxer, all apic streams must not be referenced in the muxer streams array (s->streams) since the muxer map stream indexes to track indexes. This means, adding s->apic_streams + s->write_apic_packets to the muxer, don't break the reference between packets and streams and makes ffmpeg works with this. This probably also means adding the same things on the demuxer side.
Do you think this could be an acceptable solution ? Maybe there is a better way to do it.
Any comments ?
BTW, updated patch attached (fixing an indentation mistake + return immediately after storing attached pic in mov_write_packet function).
On Sat, Jul 27, 2013 at 09:37:25PM +0200, Matthieu Bouron wrote:
BTW, updated patch attached (fixing an indentation mistake + return immediately after storing attached pic in mov_write_packet function).
Updated and rebased patch attached (take psp check into account + fix a warning). [...]
On Sun, Jul 28, 2013 at 05:28:30PM +0200, Matthieu Bouron wrote:
On Sat, Jul 27, 2013 at 09:37:25PM +0200, Matthieu Bouron wrote:
BTW, updated patch attached (fixing an indentation mistake + return immediately after storing attached pic in mov_write_packet function).
Updated and rebased patch attached (take psp check into account + fix a warning).
Sorry to bring this up again, but i would like to know if this patch has any chances to be accepted since the tradeoff of this feature is "instrusive" code (required to discard apic streams from being referenced as mov/mp4 tracks). Reviews and comments welcomed :) Matthieu [...]
On 7/31/13, Matthieu Bouron <matthieu.bouron@gmail.com> wrote:
On Sun, Jul 28, 2013 at 05:28:30PM +0200, Matthieu Bouron wrote:
On Sat, Jul 27, 2013 at 09:37:25PM +0200, Matthieu Bouron wrote:
BTW, updated patch attached (fixing an indentation mistake + return immediately after storing attached pic in mov_write_packet function).
Updated and rebased patch attached (take psp check into account + fix a warning).
Sorry to bring this up again, but i would like to know if this patch has any chances to be accepted since the tradeoff of this feature is "instrusive" code (required to discard apic streams from being referenced as mov/mp4 tracks).
Reviews and comments welcomed :)
Well, apic streams just confuse users, but as you may already know final design decisions are made by Michael.
Matthieu
[...] _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
On Wed, Jul 31, 2013 at 07:25:22PM +0100, Matthieu Bouron wrote:
On Sun, Jul 28, 2013 at 05:28:30PM +0200, Matthieu Bouron wrote:
On Sat, Jul 27, 2013 at 09:37:25PM +0200, Matthieu Bouron wrote:
BTW, updated patch attached (fixing an indentation mistake + return immediately after storing attached pic in mov_write_packet function).
Updated and rebased patch attached (take psp check into account + fix a warning).
Sorry to bring this up again, but i would like to know if this patch has any chances to be accepted since the tradeoff of this feature is "instrusive" code (required to discard apic streams from being referenced as mov/mp4 tracks).
Reviews and comments welcomed :)
If you take over maintaince of the mov muxer then you can just push the change to your repository and ask me to merge it. I already maintain quite abit of code and loosing the 1:1 relation of streams in a moderately complex muxer has the potential of increasing the maintaince burden for that code. Iam thus not entirely happy about that ... So basically iam happy to apply this but it must not increas the maintaince burden on my side. the mov muxer either should get a new maintainer or some other part of the codebase that i maintain should get a new maintainer or some other responsibility i have should be taken over by someone else. Thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Those who are best at talking, realize last or never when they are wrong.
On Thu, Aug 01, 2013 at 03:54:45AM +0200, Michael Niedermayer wrote:
On Wed, Jul 31, 2013 at 07:25:22PM +0100, Matthieu Bouron wrote:
On Sun, Jul 28, 2013 at 05:28:30PM +0200, Matthieu Bouron wrote:
On Sat, Jul 27, 2013 at 09:37:25PM +0200, Matthieu Bouron wrote:
BTW, updated patch attached (fixing an indentation mistake + return immediately after storing attached pic in mov_write_packet function).
Updated and rebased patch attached (take psp check into account + fix a warning).
Sorry to bring this up again, but i would like to know if this patch has any chances to be accepted since the tradeoff of this feature is "instrusive" code (required to discard apic streams from being referenced as mov/mp4 tracks).
Reviews and comments welcomed :)
If you take over maintaince of the mov muxer then you can just push the change to your repository and ask me to merge it.
I already maintain quite abit of code and loosing the 1:1 relation of streams in a moderately complex muxer has the potential of increasing the maintaince burden for that code. Iam thus not entirely happy about that ...
So basically iam happy to apply this but it must not increas the maintaince burden on my side. the mov muxer either should get a new maintainer or some other part of the codebase that i maintain should get a new maintainer or some other responsibility i have should be taken over by someone else.
Which other parts of the codebase require a maintainer ? My knowledge of the mov/mp4 formats is far from perfect but I would be happy to take maintenance over it if it can help. Matthieu
On Fri, Aug 02, 2013 at 09:51:12PM +0100, Matthieu Bouron wrote:
On Thu, Aug 01, 2013 at 03:54:45AM +0200, Michael Niedermayer wrote:
On Wed, Jul 31, 2013 at 07:25:22PM +0100, Matthieu Bouron wrote:
On Sun, Jul 28, 2013 at 05:28:30PM +0200, Matthieu Bouron wrote:
On Sat, Jul 27, 2013 at 09:37:25PM +0200, Matthieu Bouron wrote:
BTW, updated patch attached (fixing an indentation mistake + return immediately after storing attached pic in mov_write_packet function).
Updated and rebased patch attached (take psp check into account + fix a warning).
Sorry to bring this up again, but i would like to know if this patch has any chances to be accepted since the tradeoff of this feature is "instrusive" code (required to discard apic streams from being referenced as mov/mp4 tracks).
Reviews and comments welcomed :)
If you take over maintaince of the mov muxer then you can just push the change to your repository and ask me to merge it.
I already maintain quite abit of code and loosing the 1:1 relation of streams in a moderately complex muxer has the potential of increasing the maintaince burden for that code. Iam thus not entirely happy about that ...
So basically iam happy to apply this but it must not increas the maintaince burden on my side. the mov muxer either should get a new maintainer or some other part of the codebase that i maintain should get a new maintainer or some other responsibility i have should be taken over by someone else.
Which other parts of the codebase require a maintainer ?
see MAINTAINERS (anything that doesnt list a maintainer or lists developers who have been inactive for longer than a year surely need a new maintainer) also if you spot inaccuracies in the MAINTAINERS file dont hesitate to fix them
My knowledge of the mov/mp4 formats is far from perfect but I would be happy to take maintenance over it if it can help.
mov/mp4 is a important format and the current lack of a active maintainer for it is a real problem, so yes it should help quite a bit [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Dictatorship naturally arises out of democracy, and the most aggravated form of tyranny and slavery out of the most extreme liberty. -- Plato
On Sun, Jun 30, 2013 at 04:15:44PM +0200, Matthieu Bouron wrote:
--- libavformat/movenc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Opposition brings concord. Out of discord comes the fairest harmony. -- Heraclitus
participants (3)
-
Matthieu Bouron -
Michael Niedermayer -
Paul B Mahol