Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: toots@rastageeks.org
To: ffmpeg-devel@ffmpeg.org
Cc: Romain Beauxis <toots@rastageeks.org>
Subject: [FFmpeg-devel] [PATCH v2 1/3] libavformat/oggparseflac.c: Decode metadata packets.
Date: Fri,  5 May 2023 08:28:47 -0500
Message-ID: <20230505132848.18011-1-toots@rastageeks.org> (raw)

From: Romain Beauxis <toots@rastageeks.org>

This is the second version of a patch to add support for in-stream metadata
updates in the ogg/flac parser.

Currently, FFmpeg is unable to decode metadata in chained ogg/flac bitstreams
past the initial track. This impacts all users relying on the FFmpeg backend to
decode chained ogg/flac streams.

Documentation on ogg chained bitstreams can be found here: https://xiph.org/ogg/doc/oggstream.html

Code for detecting metadata frame is based on libavcodec/flacdec.c, code for
handling comment update is based on libavformat/oggparsevorbis.c.

This fix has been successfully tested locally. To reproduce:
* Find a ogg/flac icecast stream, for instance from: https://dir.xiph.org/
* Decode the stream using FFMpeg API
* Check the associated AVStream metadata

I have not been able to find a reproduction test with the ffmpeg or ffplay
CLI. However, the patch is confirmed to fix the backend from liquidsoplaySee:
https://github.com/savonet/liquidsoap/issues/3010

I would be happy to provide more details or even a reproduction minimal example
using the C API.

---
 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".

             reply	other threads:[~2023-05-05 13:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-05 13:28 toots [this message]
2023-05-05 13:28 ` [FFmpeg-devel] [PATCH v2 2/3] libavformat/oggparseopus.c: Accept empty packets, decode " toots
2023-05-05 13:28 ` [FFmpeg-devel] [PATCH v2 3/3] libavformat/oggdec.c: keep reading on empty packets to accommodate for chained bitstreams toots

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230505132848.18011-1-toots@rastageeks.org \
    --to=toots@rastageeks.org \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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