diff options
author | Anton Khirnov <anton@khirnov.net> | 2012-02-25 09:53:35 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2012-02-29 14:16:32 +0100 |
commit | 079ea6ca5f8f108ec328d3c2c1792e676fc30b9c (patch) | |
tree | 15d38cabd66e3c5219fd66badb9410447c049683 /libavformat/id3v2.c | |
parent | dd2a4bcfd72eee85710142943a1c68ac02520771 (diff) | |
download | ffmpeg-079ea6ca5f8f108ec328d3c2c1792e676fc30b9c.tar.gz |
lavf: export id3v2 attached pictures as streams.
Diffstat (limited to 'libavformat/id3v2.c')
-rw-r--r-- | libavformat/id3v2.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c index 853a04c78e..4170c853a6 100644 --- a/libavformat/id3v2.c +++ b/libavformat/id3v2.c @@ -702,3 +702,37 @@ void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta) current = next; } } + +int ff_id3v2_parse_apic(AVFormatContext *s, ID3v2ExtraMeta **extra_meta) +{ + ID3v2ExtraMeta *cur; + + for (cur = *extra_meta; cur; cur = cur->next) { + ID3v2ExtraMetaAPIC *apic; + AVStream *st; + + if (strcmp(cur->tag, "APIC")) + continue; + apic = cur->data; + + if (!(st = avformat_new_stream(s, NULL))) + return AVERROR(ENOMEM); + + st->disposition |= AV_DISPOSITION_ATTACHED_PIC; + st->codec->codec_type = AVMEDIA_TYPE_VIDEO; + st->codec->codec_id = apic->id; + av_dict_set(&st->metadata, "title", apic->description, 0); + av_dict_set(&st->metadata, "comment", apic->type, 0); + + av_init_packet(&st->attached_pic); + st->attached_pic.data = apic->data; + st->attached_pic.size = apic->len; + st->attached_pic.destruct = av_destruct_packet; + st->attached_pic.stream_index = st->index; + + apic->data = NULL; + apic->len = 0; + } + + return 0; +} |