[FFmpeg-trac] #10364(avformat:new): Missing metadata in chained ogg/flac streams
FFmpeg
trac at avcodec.org
Mon May 15 00:35:04 EEST 2023
#10364: Missing metadata in chained ogg/flac streams
----------------------------------+---------------------------------------
Reporter: toots | Type: enhancement
Status: new | Priority: normal
Component: avformat | Version: unspecified
Keywords: | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
----------------------------------+---------------------------------------
''Reproduction steps for this bug are similar to
https://trac.ffmpeg.org/ticket/10363''
How to reproduce:
* Create two short ogg/opus files:
{{{
ffmpeg -f lavfi -i "sine=frequency=1000:duration=5" -c:a libopus -metadata
title="test title" /tmp/test.ogg
ffmpeg -f lavfi -i "sine=frequency=1000:duration=5" -c:a libopus -metadata
title="test title 2" /tmp/test2.ogg
}}}
* Send a stream to a icecast server
Unfortunately, I couldn't find a way to send a chained ogg bitstream using
ffmpeg CLI. It seems to always send a single stream so I used ices
(https://icecast.org/ices/)
(Doc on ogg chained bitstreams: https://xiph.org/ogg/doc/oggstream.html)
{{{
echo /tmp/test.ogg > /tmp/test.txt
echo /tmp/test2.ogg >> /tmp/test.txt
}}}
Ices config:
{{{
<?xml version="1.0"?>
<ices>
<background>0</background>
<consolelog>1</consolelog>
<stream>
<input>
<module>playlist</module>
<param name="type">basic</param>
<param name="file">/tmp/test.m3u</param>
<param name="once">0</param>
</input>
<instance>
<hostname>localhost</hostname>
<port>8000</port>
<password>hackme</password>
<mount>/test.ogg</mount>
<yp>0</yp>
</instance>
</stream>
</ices>
}}}
Finally: ices /tmp/ices.xml
* Use the attached program to read the stream:
{{{
cc flac_chained_metadata.c -g -lavformat -lavutil -o flac_chained_metadata
./flac_chained_metadata http://localhost:8000/test.ogg
}}}
Output:
{{{
encoder=Lavc60.3.100 libopus;Lavc60.3.100 libopus;Lavc60.3.100 libopus
title=test title
....
}}}
Expected:
Title should alternate between "test title" and "test title 2"
Solution: add metadata parsing in libavformat/oggparseflac.c:
{{{
+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,
};
}}}
Patch has been sent but needs an update which will be coming soon.
--
Ticket URL: <https://trac.ffmpeg.org/ticket/10364>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list