[FFmpeg-devel] [PATCH] use new metadata API in mov (de)muxer
Aurelien Jacobs
aurel
Sun Feb 15 15:39:20 CET 2009
Aurelien Jacobs wrote:
> Baptiste Coudurier wrote:
>
> > Hi Aurelien,
> >
> > Aurelien Jacobs wrote:
> > > Hi,
> > >
> > > Attached patch converts the mov muxer and demuxer to the new metadata API.
> > > It properly (de)mux lang when available. Note that current muxer code set
> > > lang to english when lang is unknown. I left this behavior unchanged,
> > > especially because I don't know what numeric language code to use for
> > > unknown language.
> > >
> > > [...]
> > >
> > >
> > > - if (mov->mode & MODE_3GP) {
> > > - mov_write_3gp_udta_tag(pb, s, "titl", s->title);
> > > - mov_write_3gp_udta_tag(pb, s, "auth", s->author);
> > > - mov_write_3gp_udta_tag(pb, s, "gnre", s->genre);
> > > - mov_write_3gp_udta_tag(pb, s, "dscp", s->comment);
> > > - mov_write_3gp_udta_tag(pb, s, "albm", s->album);
> > > - mov_write_3gp_udta_tag(pb, s, "cprt", s->copyright);
> > > - mov_write_3gp_udta_tag(pb, s, "yrrc", "nil");
> > > - } else if (mov->mode == MODE_MOV) { // the title field breaks gtkpod with mp4 and my suspicion is that stuff is not valid in mp4
> > > - mov_write_string_tag(pb, "\251nam", s->title , 0);
> > > - mov_write_string_tag(pb, "\251aut", s->author , 0);
> > > - mov_write_string_tag(pb, "\251alb", s->album , 0);
> > > - mov_write_day_tag(pb, s->year, 0);
> > > - mov_write_string_tag(pb, "\251enc", LIBAVFORMAT_IDENT, 0);
> > > - mov_write_string_tag(pb, "\251des", s->comment , 0);
> > > - mov_write_string_tag(pb, "\251gen", s->genre , 0);
> > > - mov_write_string_tag(pb, "\251cpy", s->copyright , 0);
> > > - } else {
> > > - /* iTunes meta data */
> > > - mov_write_meta_tag(pb, mov, s);
> > > - }
> > > - return updateSize(pb, pos);
> > > + put_be32(pb_buf, 0); /* size */
> > > + put_tag(pb_buf, "udta");
> > > +
> > > + if (mov->mode & MODE_3GP) {
> > > + count += mov_write_3gp_udta_tag(pb_buf, s, "titl", "title");
> > > + count += mov_write_3gp_udta_tag(pb_buf, s, "auth", "author");
> > > + count += mov_write_3gp_udta_tag(pb_buf, s, "gnre", "genre");
> > > + count += mov_write_3gp_udta_tag(pb_buf, s, "dscp", "comment");
> > > + count += mov_write_3gp_udta_tag(pb_buf, s, "albm", "album");
> > > + count += mov_write_3gp_udta_tag(pb_buf, s, "cprt", "copyright");
> > > + count += mov_write_3gp_udta_tag(pb_buf, s, "yrrc", "year");
> > > + } else if (mov->mode == MODE_MOV) { // the title field breaks gtkpod with mp4 and my suspicion is that stuff is not valid in mp4
> > > + count += mov_write_string_metadata(s, pb_buf, "\251nam", "title" , 0);
> > > + count += mov_write_string_metadata(s, pb_buf, "\251aut", "author" , 0);
> > > + count += mov_write_string_metadata(s, pb_buf, "\251alb", "album" , 0);
> > > + count += mov_write_string_metadata(s, pb_buf, "\251day", "year" , 0);
> > > + mov_write_string_tag(pb_buf, "\251enc", LIBAVFORMAT_IDENT, 0, 0);
> > > + count += mov_write_string_metadata(s, pb_buf, "\251des", "comment" , 0);
> > > + count += mov_write_string_metadata(s, pb_buf, "\251gen", "genre" , 0);
> > > + count += mov_write_string_metadata(s, pb_buf, "\251cpy", "copyright" , 0);
> > > + } else {
> > > + /* iTunes meta data */
> > > + count = mov_write_meta_tag(pb_buf, mov, s);
> > > }
> > > + updateSize(pb_buf, pos);
> > >
> > > + if (count > 0) {
> > > + uint8_t *buf;
> > > + int size = url_close_dyn_buf(pb_buf, &buf);
> > > + put_buffer(pb, buf, size);
> > > + av_free(buf);
> > > + }
> > > +
> > > return 0;
> > > }
> >
> > I believe size will be 0 when if nothing has been written, why using
> > count ?
>
> Size won't be zero, because at least the "preamble" was already written
> unconditionally. But maybe I could move this and get ride of count.
> Will have a look at it.
OK. I was able to get ride of count and only use the size of the dyn_buf.
I also split the muxer patch in several parts. First one is a straight
and simple conversion to the new metadata API. Second one adds a return -1
for errors in ff_mov_iso639_to_lang and is useful for the third patch,
which adds support for muxing language along with tags.
Aurel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: md_mov_muxer_1.diff
Type: text/x-patch
Size: 9249 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090215/183bc27f/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: md_mov_muxer_2.diff
Type: text/x-patch
Size: 1278 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090215/183bc27f/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: md_mov_muxer_3.diff
Type: text/x-patch
Size: 3539 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090215/183bc27f/attachment-0002.bin>
More information about the ffmpeg-devel
mailing list