[FFmpeg-devel] [PATCH v8 5/8] libavformat/oggparseflac.c: Parse ogg/flac comments in new ogg packets, add them to ogg stream new_metadata.
Romain Beauxis
romain.beauxis at gmail.com
Tue Mar 11 18:55:10 EET 2025
---
libavformat/oggparseflac.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c
index f25ed9cc15..29f5904575 100644
--- a/libavformat/oggparseflac.c
+++ b/libavformat/oggparseflac.c
@@ -78,6 +78,25 @@ flac_header (AVFormatContext * s, int idx)
return 1;
}
+static int
+flac_packet (AVFormatContext * s, int idx)
+{
+ struct ogg *ogg = s->priv_data;
+ struct ogg_stream *os = ogg->streams + idx;
+ AVStream *st = s->streams[idx];
+ int ret;
+
+ if (os->psize > 0 && os->buf[os->pstart] &&
+ (os->buf[os->pstart] & 0x7F) == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
+ ret = ff_vorbis_update_metadata(s, st, os->buf + os->pstart + 4,
+ os->psize - 4);
+ if (ret < 0)
+ return ret;
+ }
+
+ return 0;
+}
+
static int
old_flac_header (AVFormatContext * s, int idx)
{
@@ -130,6 +149,7 @@ const struct ogg_codec ff_flac_codec = {
.magic = "\177FLAC",
.magicsize = 5,
.header = flac_header,
+ .packet = flac_packet,
.nb_header = 2,
};
@@ -137,5 +157,6 @@ const struct ogg_codec ff_old_flac_codec = {
.magic = "fLaC",
.magicsize = 4,
.header = old_flac_header,
+ .packet = flac_packet,
.nb_header = 0,
};
--
2.39.5 (Apple Git-154)
More information about the ffmpeg-devel
mailing list