[英]Split ogg vorbis stream without BOS
Input: a stream of ogg/vorbis coming from an encoder chip of an embedded system.输入:来自嵌入式系统的编码器芯片的 ogg/vorbis 的 stream。
Problem: create output chunks of one second without transcoding.问题:无需转码即可创建一秒的 output 块。
Issue: the stream is being read "in the middle", so the first page with BOS (Beginning of Stream) is not available.问题:stream 正在“中间”读取,因此带有 BOS(流开始)的第一页不可用。 Since the encoder chip has always the same parameters, I'd like to recreate the BOS page using the BOS page of a stream that was read from the start (reference stream).
由于编码器芯片始终具有相同的参数,因此我想使用从一开始就读取的 stream 的 BOS 页面(参考流)重新创建 BOS 页面。
I am trying to use vcut .我正在尝试使用vcut 。 I modified it so that it creates infinite chunks of one second.
我对其进行了修改,以便它创建一秒钟的无限块。 It was easy, and it works with files and streams with BOS.
这很简单,并且可以使用 BOS 处理文件和流。 I also hacked it so that I wrote to a file the first pages of the reference stream and then read them before reading the production stream with no BOS.
我还破解了它,以便我将参考 stream 的第一页写入文件,然后在阅读没有 BOS 的生产 stream 之前阅读它们。 In this way, vs->headers are populated.
这样,vs->headers 就被填充了。 When I detect a page serial number change, I change it so that vcut and libogg do not freak:
当我检测到页面序列号发生变化时,我会对其进行更改,以使 vcut 和 libogg 不会惊慌失措:
int process_page(vcut_state *s, ogg_page *page) {
...
else if(vs->serial != ogg_page_serialno(page))
{
// fprintf(stderr, _("Multiplexed bitstreams are not supported.\n"));
vs->stream_in.serialno = ogg_page_serialno(page);
vs->serial = ogg_page_serialno(page);
vs->granulepos = -1;
vs->initial_granpos = 0;
// ogg_stream_init(&vs->stream_in, vs->serial);
// vorbis_info_init(&vs->vi);
// vorbis_comment_init(&vs->vc);
s->vorbis_init = 1;
}
However, this gigantic hack does not work.但是,这个巨大的 hack 不起作用。 How to solve this issue?
如何解决这个问题?
It actually works: see VS1053 split ogg .它确实有效:参见VS1053 split ogg 。
What I needed to do was to consider that starting reading in the middle of the stream, granulepos was naturally high.我需要做的是考虑在stream中间开始阅读,granulepos自然很高。 So it was mine logical mistake.
所以这是我的逻辑错误。
In process_audio_packet, I added:在 process_audio_packet 中,我添加了:
int process_audio_packet(vcut_state *s,
vcut_vorbis_stream *vs, ogg_packet *packet)
{
...
if(packet->granulepos >= 0)
{
if (!firstNonZeroGranule) { // my addition
firstNonZeroGranule = 1;
vs->initial_granpos = packet->granulepos - bs;
if(vs->initial_granpos < 0)
vs->initial_granpos = 0;
} else if(vs->granulepos == 0 && packet->granulepos != bs) {
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.