aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorAurelien Jacobs <aurel@gnuage.org>2009-02-26 13:13:48 +0000
committerAurelien Jacobs <aurel@gnuage.org>2009-02-26 13:13:48 +0000
commitd9fc9ff31bcc94f52cccd4b5a3d763d36bc70a8f (patch)
treee5d642559c4df6a5a23ce30659eee1f8541d9d8e /libavformat
parent2904fd398f26f0a2db99dcec54cd009826344c61 (diff)
downloadffmpeg-d9fc9ff31bcc94f52cccd4b5a3d763d36bc70a8f.tar.gz
movenc: add muxing of language along with metadata tags when available
Originally committed as revision 17612 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/movenc.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 0a37eb4fcb..491588ab80 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1200,7 +1200,7 @@ static int mov_write_itunes_hdlr_tag(ByteIOContext *pb, MOVContext *mov,
}
/* helper function to write a data tag with the specified string as data */
-static int mov_write_string_data_tag(ByteIOContext *pb, const char *data, int long_style)
+static int mov_write_string_data_tag(ByteIOContext *pb, const char *data, int lang, int long_style)
{
if(long_style){
int64_t pos = url_ftell(pb);
@@ -1212,19 +1212,19 @@ static int mov_write_string_data_tag(ByteIOContext *pb, const char *data, int lo
return updateSize(pb, pos);
}else{
put_be16(pb, strlen(data)); /* string length */
- put_be16(pb, 0);
+ put_be16(pb, lang);
put_buffer(pb, data, strlen(data));
return strlen(data) + 4;
}
}
-static int mov_write_string_tag(ByteIOContext *pb, const char *name, const char *value, int long_style){
+static int mov_write_string_tag(ByteIOContext *pb, const char *name, const char *value, int lang, int long_style){
int size = 0;
if (value && value[0]) {
int64_t pos = url_ftell(pb);
put_be32(pb, 0); /* size */
put_tag(pb, name);
- mov_write_string_data_tag(pb, value, long_style);
+ mov_write_string_data_tag(pb, value, lang, long_style);
size= updateSize(pb, pos);
}
return size;
@@ -1234,12 +1234,24 @@ static int mov_write_string_metadata(AVFormatContext *s, ByteIOContext *pb,
const char *name, const char *tag,
int long_style)
{
- AVMetadataTag *t;
+ int l, lang = 0, len, len2;
+ AVMetadataTag *t, *t2 = NULL;
+ char tag2[16];
if (!(t = av_metadata_get(s->metadata, tag, NULL, 0)))
return 0;
- return mov_write_string_tag(pb, name, t->value, long_style);
+ len = strlen(t->key);
+ snprintf(tag2, sizeof(tag2), "%s-", tag);
+ while ((t2 = av_metadata_get(s->metadata, tag2, t2, AV_METADATA_IGNORE_SUFFIX))) {
+ len2 = strlen(t2->key);
+ if (len2 == len+4 && !strcmp(t->value, t2->value)
+ && (l=ff_mov_iso639_to_lang(&t2->key[len2-3], 0)) >= 0) {
+ lang = l;
+ break;
+ }
+ }
+ return mov_write_string_tag(pb, name, t->value, lang, long_style);
}
/* iTunes track number */
@@ -1281,7 +1293,7 @@ static int mov_write_ilst_tag(ByteIOContext *pb, MOVContext *mov,
mov_write_string_metadata(s, pb, "\251wrt", "author" , 1);
mov_write_string_metadata(s, pb, "\251alb", "album" , 1);
mov_write_string_metadata(s, pb, "\251day", "year" , 1);
- mov_write_string_tag(pb, "\251too", LIBAVFORMAT_IDENT, 1);
+ mov_write_string_tag(pb, "\251too", LIBAVFORMAT_IDENT, 0, 1);
mov_write_string_metadata(s, pb, "\251cmt", "comment" , 1);
mov_write_string_metadata(s, pb, "\251gen", "genre" , 1);
mov_write_string_metadata(s, pb, "\251cpy", "copyright", 1);
@@ -1382,7 +1394,7 @@ static int mov_write_udta_tag(ByteIOContext *pb, MOVContext *mov,
mov_write_string_metadata(s, pb_buf, "\251aut", "author" , 0);
mov_write_string_metadata(s, pb_buf, "\251alb", "album" , 0);
mov_write_string_metadata(s, pb_buf, "\251day", "year" , 0);
- mov_write_string_tag(pb_buf, "\251enc", LIBAVFORMAT_IDENT, 0);
+ mov_write_string_tag(pb_buf, "\251enc", LIBAVFORMAT_IDENT, 0, 0);
mov_write_string_metadata(s, pb_buf, "\251des", "comment" , 0);
mov_write_string_metadata(s, pb_buf, "\251gen", "genre" , 0);
mov_write_string_metadata(s, pb_buf, "\251cpy", "copyright" , 0);