[FFmpeg-devel] [PATCH] caf muxer: write metadata
Paul B Mahol
onemda at gmail.com
Fri Oct 26 14:32:37 CEST 2012
On 10/26/12, Paul B Mahol <onemda at gmail.com> wrote:
> On 10/26/12, Michael Niedermayer <michaelni at gmx.at> wrote:
>> On Thu, Oct 25, 2012 at 11:52:40PM +0000, Paul B Mahol wrote:
>>> Signed-off-by: Paul B Mahol <onemda at gmail.com>
>>> ---
>>> libavformat/cafenc.c | 16 ++++++++++++++++
>>> 1 file changed, 16 insertions(+)
>>>
>>> diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c
>>> index dc222cd..baa8270 100644
>>> --- a/libavformat/cafenc.c
>>> +++ b/libavformat/cafenc.c
>>> @@ -25,6 +25,7 @@
>>> #include "isom.h"
>>> #include "avio_internal.h"
>>> #include "libavutil/intfloat.h"
>>> +#include "libavutil/dict.h"
>>>
>>> typedef struct {
>>> int64_t data;
>>> @@ -102,7 +103,9 @@ static int caf_write_header(AVFormatContext *s)
>>> AVIOContext *pb = s->pb;
>>> AVCodecContext *enc = s->streams[0]->codec;
>>> CAFContext *caf = s->priv_data;
>>> + AVDictionaryEntry *t = NULL;
>>> unsigned int codec_tag = ff_codec_get_tag(ff_codec_caf_tags,
>>> enc->codec_id);
>>> + int64_t chunk_size;
>>>
>>> switch (enc->codec_id) {
>>> case AV_CODEC_ID_AAC:
>>> @@ -180,6 +183,19 @@ static int caf_write_header(AVFormatContext *s)
>>> avio_write(pb, enc->extradata, enc->extradata_size);
>>> }
>>>
>>> + ffio_wfourcc(pb, "info"); //< Information chunk
>>> + caf->data = avio_tell(pb);
>>> + avio_wb64(pb, 0);
>>> + avio_wb32(pb, av_dict_count(s->metadata));
>>> + while ((t = av_dict_get(s->metadata, "", t,
>>> AV_DICT_IGNORE_SUFFIX)))
>>> {
>>> + avio_put_str(pb, t->key);
>>> + avio_put_str(pb, t->value);
>>> + }
>>> + chunk_size = avio_tell(pb) - caf->data;
>>> + avio_seek(pb, caf->data, SEEK_SET);
>>> + avio_wb64(pb, chunk_size - 8);
>>
>> this is not guranteed to work with non seekable output.
>
> same is done in riff.c
>>
>> otherwise LGTM
>>
>> [...]
Fixed and applied.
Feel free to add av_dict_len() or something like that because
code may be useful for other muxers too.
>> --
>> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>>
>> Democracy is the form of government in which you can choose your dictator
>>
>
More information about the ffmpeg-devel
mailing list