Hello,
I am working on an ESP32 + VS1053 based Ogg audio record that will send audio files to a web server. I'd like split continuos audio into sequential files (of about 1 minute time lenght).
I am able to start VL1053 chip, start Ogg recording and save data to SD card.
In forum (viewtopic.php?f=11&t=1345&p=5975&hilit= ... tart#p5975) I see an old answer "If you need uninterrupted audio, then you need to store the header in a separate place so that you can apply it in front of any subsequent piece of the whole stream".
From Ogg stream, how can I identify the Ogg header I have to apply to every file?
Thank you
VS1053 split Ogg stream uninterrupted audio
-
- User
- Posts: 6
- Joined: Fri 2019-07-12 16:39
Re: VS1053 split Ogg stream uninterrupted audio
Hi!
Hmm, I started to write an answer, but it seems that Henrik has already explained it in the post to which you link (the part with the OggS strings etc).
Maybe these can help you further:
Ogg bitstream reference: https://xiph.org/vorbis/doc/oggstream.html
Vorbis framing reference: https://xiph.org/vorbis/doc/framing.html
-Panu
Hmm, I started to write an answer, but it seems that Henrik has already explained it in the post to which you link (the part with the OggS strings etc).
Maybe these can help you further:
Ogg bitstream reference: https://xiph.org/vorbis/doc/oggstream.html
Vorbis framing reference: https://xiph.org/vorbis/doc/framing.html
-Panu
Info: Line In and Line Out, VS1000 User interface, Overlay howto, Latest VSIDE, MCU Howto, Youtube
Panu-Kristian Poiksalo
Panu-Kristian Poiksalo
-
- User
- Posts: 6
- Joined: Fri 2019-07-12 16:39
Re: VS1053 split Ogg stream uninterrupted audio
Hello,
I can not find in the older answer of Henrik and in the two links you paste how to detect the Ogg header that I need to save and replicate for different files.
Thank you
I can not find in the older answer of Henrik and in the two links you paste how to detect the Ogg header that I need to save and replicate for different files.
Thank you
Re: VS1053 split Ogg stream uninterrupted audio
Hello!
Your situation is different. If I understand correctly, you want to write separate Ogg Vorbis files which could be decoded (with some standard tools) to a continuous audio stream. (If I misunderstood, please let me know!)
Unfortunately your situation is tricky. To do what you require needs deep understanding on how the actual Vorbis audio data is encoded, because it would require certain pieces of compressed audio data to be duplicated to guarantee separate streams that could be combined seamlessly.
If you are ok with there being a seam, or missing audio for 3-20 milliseconds between files, then you can use the copy-headers method. In this method, you copy all data from the beginning of the file to the point where you see the first Ogg frame that does not contain the string "vorbis". Example below is a file created with an old version of the VS1053 Ogg Vorbis Encoder:
In the example, you can find the OggS string at offsets 0x0000, 0x003a, 0x008e, and 0x579. In the three first frames, you can find the "vorbis" string a little bit later, so they are headers that need to be copied to the beginning of each file. The frame starting from 0x579 is audio data, and you don't need to copy that data to each Ogg Vorbis file.
Kind regards,
- Henrik
The instructions in the message you quoted is for a situation where you encode audio continuously, but someone comes in the middle of the stream to listen. In that case the headers need to be sent to the receiver before any audio data.davideferrario wrote: ↑Fri 2019-07-19 16:57 I am working on an ESP32 + VS1053 based Ogg audio record that will send audio files to a web server. I'd like split continuos audio into sequential files (of about 1 minute time lenght).
I am able to start VL1053 chip, start Ogg recording and save data to SD card.
In forum (viewtopic.php?f=11&t=1345&p=5975&hilit= ... tart#p5975) I see an old answer "If you need uninterrupted audio, then you need to store the header in a separate place so that you can apply it in front of any subsequent piece of the whole stream".
From Ogg stream, how can I identify the Ogg header I have to apply to every file?
Your situation is different. If I understand correctly, you want to write separate Ogg Vorbis files which could be decoded (with some standard tools) to a continuous audio stream. (If I misunderstood, please let me know!)
Unfortunately your situation is tricky. To do what you require needs deep understanding on how the actual Vorbis audio data is encoded, because it would require certain pieces of compressed audio data to be duplicated to guarantee separate streams that could be combined seamlessly.
If you are ok with there being a seam, or missing audio for 3-20 milliseconds between files, then you can use the copy-headers method. In this method, you copy all data from the beginning of the file to the point where you see the first Ogg frame that does not contain the string "vorbis". Example below is a file created with an old version of the VS1053 Ogg Vorbis Encoder:
Code: Select all
0000 4f 67 67 53 00 02 00 00 00 00 00 00 00 00 78 56 |OggS..........xV|
0010 34 12 00 00 00 00 d8 0b d5 86 01 1e 01 76 6f 72 |4.....Ø.Õ....vor|
0020 62 69 73 00 00 00 00 02 44 ac 00 00 00 00 00 00 |bis.....D¬......|
0030 58 0f 02 00 00 00 00 00 b8 01 4f 67 67 53 00 00 |X.......¸.OggS..|
0040 00 00 00 00 00 00 00 00 78 56 34 12 01 00 00 00 |........xV4.....|
0050 27 de 7a 38 01 38 03 76 6f 72 62 69 73 10 00 00 |'Þz8.8.vorbis...|
0060 00 56 4c 53 49 20 53 6f 6c 75 74 69 6f 6e 20 4f |.VLSI Solution O|
0070 79 01 00 00 00 14 00 00 00 45 4e 43 4f 44 45 52 |y........ENCODER|
0080 3d 56 53 31 30 35 33 20 76 31 2e 35 30 01 4f 67 |=VS1053 v1.50.Og|
0090 67 53 00 00 00 00 00 00 00 00 00 00 78 56 34 12 |gS..........xV4.|
00a0 02 00 00 00 11 a1 cb 59 05 ff ff ff ff cf 05 76 |.....¡ËY.ÿÿÿÿÏ.v|
00b0 6f 72 62 69 73 0d 42 43 56 01 00 40 00 00 26 49 |orbis.BCV..@..&I|
[...]
0570 00 00 00 02 00 00 00 04 04 4f 67 67 53 00 00 40 |.........OggS..@|
0580 e7 00 00 00 00 00 00 78 56 34 12 03 00 00 00 4c |ç......xV4.....L|
0590 cc cb 51 51 11 11 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b |ÌËQQ............|
05a0 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b 1b |................|
[...]
Kind regards,
- Henrik
Good signatures never die. They just fade away.
-
- User
- Posts: 6
- Joined: Fri 2019-07-12 16:39
Re: VS1053 split Ogg stream uninterrupted audio
Thank you Henrik.
You understand correctly my situation and thank you for your answer.
I think I understood your explanation and I think I am able to implement it in ESP32 source code.
Thank you really much.
You understand correctly my situation and thank you for your answer.
I think I understood your explanation and I think I am able to implement it in ESP32 source code.
Thank you really much.
-
- User
- Posts: 6
- Joined: Fri 2019-07-12 16:39
Re: VS1053 split Ogg stream uninterrupted audio
Hello,
regarding this post, I had success to split ogg frame into different files.
But I have the problem that if I open the ogg files with PC, I can listen captured audio correctly but the audio index of single files are wrong.
May you help me?
regarding this post, I had success to split ogg frame into different files.
But I have the problem that if I open the ogg files with PC, I can listen captured audio correctly but the audio index of single files are wrong.
May you help me?
Re: VS1053 split Ogg stream uninterrupted audio
What do you mean by "wrong"? Do you mean it doesn't start from 0?
That's not surprising, because each cut piece still has their own sample counters / playback positions. The same happens in WMA streaming, the timecode doesn't need to start from 0.
That's not surprising, because each cut piece still has their own sample counters / playback positions. The same happens in WMA streaming, the timecode doesn't need to start from 0.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook
-
- User
- Posts: 6
- Joined: Fri 2019-07-12 16:39
Re: VS1053 split Ogg stream uninterrupted audio
It is correct. For "wrong" I mean it doesn't start from 0.
It is not possible to configure to start index from 0?
Or to edit ogg frame so index start from 0?
I agree with you that it is not needed that timecode start from 0, but my customer need it in that way.
It is not possible to configure to start index from 0?
Or to edit ogg frame so index start from 0?
I agree with you that it is not needed that timecode start from 0, but my customer need it in that way.
Re: VS1053 split Ogg stream uninterrupted audio
I think you would need to adjust all of the sample positions in all of the Ogg frames accordingly.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook