* [FFmpeg-devel] [PATCH] Add support for flac in-stream metadata.
@ 2023-04-22 15:45 toots
0 siblings, 0 replies; only message in thread
From: toots @ 2023-04-22 15:45 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Romain Beauxis
From: Romain Beauxis <toots@rastageeks.org>
This patch adds support for in-stream metadata updates in the ogg/flac parser.
Code for detecting metadata frame is based on libavcodec/flacdec.c, code for
handling comment update is based on libavformat/oggparsevorbis.c.
This has been successfully tested locally. To reproduce:
* Setup an ogg/flac icecast stream.
* Read the stream
* Check the associated AVStream metadata
There seems to be similar issues with opus as well, which will be addressed
in a separate patch.
---
libavformat/oggparseflac.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c
index eef6e09927..1dd292483d 100644
--- a/libavformat/oggparseflac.c
+++ b/libavformat/oggparseflac.c
@@ -126,10 +126,30 @@ fail:
return ret;
}
+static int flac_packet(AVFormatContext *s, int idx)
+{
+ struct ogg *ogg = s->priv_data;
+ struct ogg_stream *os = ogg->streams + idx;
+ int ret;
+
+ if (os->psize > 4 && (*(os->buf + os->pstart) & 0x7F) == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
+ AVStream *st = s->streams[idx];
+ av_dict_free(&st->metadata);
+ ret = ff_vorbis_stream_comment(s, st, os->buf + os->pstart + 4,
+ os->psize - 4);
+
+ if (ret < 0) return ret;
+ }
+
+ return 0;
+}
+
+
const struct ogg_codec ff_flac_codec = {
.magic = "\177FLAC",
.magicsize = 5,
.header = flac_header,
+ .packet = flac_packet,
.nb_header = 2,
};
--
2.37.1 (Apple Git-137.1)
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-04-22 15:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-22 15:45 [FFmpeg-devel] [PATCH] Add support for flac in-stream metadata toots
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git