[FFmpeg-cvslog] caf muxer: write metadata
Paul B Mahol
git at videolan.org
Fri Oct 26 14:50:00 CEST 2012
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Thu Oct 25 23:33:34 2012 +0000| [7fe6f6e2b10fe278fecea850fda1d8e321330c15] | committer: Paul B Mahol
caf muxer: write metadata
Signed-off-by: Paul B Mahol <onemda at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7fe6f6e2b10fe278fecea850fda1d8e321330c15
---
Changelog | 1 +
libavformat/cafenc.c | 17 +++++++++++++++++
libavformat/version.h | 2 +-
tests/ref/lavf/caf | 4 ++--
4 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/Changelog b/Changelog
index c7d2fdb..6f0c2b6 100644
--- a/Changelog
+++ b/Changelog
@@ -17,6 +17,7 @@ version <next>:
- support for building DLLs using MSVC
- LVF demuxer
- ffescape tool
+- metadata (info chunk) support in CAF muxer
version 1.0:
diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c
index dc222cd..cc39a83 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 = 0;
switch (enc->codec_id) {
case AV_CODEC_ID_AAC:
@@ -180,6 +183,20 @@ static int caf_write_header(AVFormatContext *s)
avio_write(pb, enc->extradata, enc->extradata_size);
}
+ if (av_dict_count(s->metadata)) {
+ ffio_wfourcc(pb, "info"); //< Information chunk
+ while ((t = av_dict_get(s->metadata, "", t, AV_DICT_IGNORE_SUFFIX))) {
+ chunk_size += strlen(t->key) + strlen(t->value) + 2;
+ }
+ avio_wb64(pb, chunk_size + 4);
+ avio_wb32(pb, av_dict_count(s->metadata));
+ t = NULL;
+ while ((t = av_dict_get(s->metadata, "", t, AV_DICT_IGNORE_SUFFIX))) {
+ avio_put_str(pb, t->key);
+ avio_put_str(pb, t->value);
+ }
+ }
+
ffio_wfourcc(pb, "data"); //< Audio Data chunk
caf->data = avio_tell(pb);
avio_wb64(pb, -1); //< mChunkSize
diff --git a/libavformat/version.h b/libavformat/version.h
index fe31a7d..bab294c 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -30,7 +30,7 @@
#include "libavutil/avutil.h"
#define LIBAVFORMAT_VERSION_MAJOR 54
-#define LIBAVFORMAT_VERSION_MINOR 34
+#define LIBAVFORMAT_VERSION_MINOR 35
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
diff --git a/tests/ref/lavf/caf b/tests/ref/lavf/caf
index 972b27c..f2ae9c3 100644
--- a/tests/ref/lavf/caf
+++ b/tests/ref/lavf/caf
@@ -1,3 +1,3 @@
-71e1abdfc59613fe05fca2939f02e02d *./tests/data/lavf/lavf.caf
-90204 ./tests/data/lavf/lavf.caf
+6c97bfc8e455d5fb8b3b45806857a953 *./tests/data/lavf/lavf.caf
+90235 ./tests/data/lavf/lavf.caf
./tests/data/lavf/lavf.caf CRC=0xf1ae5536
More information about the ffmpeg-cvslog
mailing list