[FFmpeg-devel] [PATCH] Add writing of vorbis comments to flac files
Aurelien Jacobs
aurel
Fri Mar 12 13:44:39 CET 2010
On Wed, Mar 10, 2010 at 10:45:52PM +0100, James Darnley wrote:
> ping...
>
> Another version attached.
> Added static to the two new functions only used in flacenc.c (thanks patcheck)
> Corrected the test filename due to a recent change
>
> An updated patch for ogg files is attached too.
>
> [...]
>
> diff --git a/libavformat/vorbiscomment.c b/libavformat/vorbiscomment.c
> new file mode 100644
> index 0000000..24c811d
> --- /dev/null
> +++ b/libavformat/vorbiscomment.c
>
> [...]
>
> +int ff_vorbiscomment_write(uint8_t **p, AVMetadata *m,
> + const char *vendor_string)
> +{
> + int i;
> + bytestream_put_le32(p, strlen(vendor_string));
> + bytestream_put_buffer(p, vendor_string, strlen(vendor_string));
> + if (m) {
> + bytestream_put_le32(p, m->count);
> + for (i = 0; i < m->count; i++) {
> + unsigned int len1 = strlen(m->elems[i].key);
> + unsigned int len2 = strlen(m->elems[i].value);
> + bytestream_put_le32(p, len1+1+len2);
> + bytestream_put_buffer(p, m->elems[i].key, len1);
> + bytestream_put_byte(p, '=');
> + bytestream_put_buffer(p, m->elems[i].value, len2);
> + }
> + } else
> + bytestream_put_le32(p, 0);
> + return 0;
> +}
You are not allowed to access to the content of AVMetadata *m by
yourself. You must not use anything else than what's described in
Public Metadata API (avformat.h).
Basically you should use av_metadata_get() to iterate over all the
elements.
Something like this should do the trick:
AVMetadataTag *t = NULL;
while ((t = av_metadata_get(m, "", t, AV_METADATA_IGNORE_SUFFIX))) {
/* do wathever you want with 't' */
}
Aurel
More information about the ffmpeg-devel
mailing list