Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: OGG chaining libvorbis android (Read 6655 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

OGG chaining libvorbis android

I am using libvorbis to encode recorded PCM data on android. I am implementing pause/resume capability for that I have to chain multiple ogg logical bit streams into one physical bit stream but when I do that I get a file that shows wrong duration and is unseekable. It plays the audio in the correct order though. What am I not doing or doing something wrong?
what is the meaning of absolute granular position of these pages?

page 1: 0 0 0 0 0 0 0 0
page 2:  0 0 0 0 0 0 0 0
page 3:  0 0 0 0 0 0 19 -64
page 4: 0 0 0 0 0 0 41 -64
page 5: 0 0 0 0 0 0 65 -128
page 6: 0 0 0 0 0 0 88 64
page 7: 0 0 0 0 0 0 110 64

I am placing the second logical bit stream after the first logical bit stream but still I am getting this bizarre error of wrong duration and unseekable playback. Please can someone tell me the correct way of chaining multiple OGG bit streams?

This is the output of ogginfo on an chained ogg file
Code: [Select]
Processing file "G1.ogg"...

New logical stream (#1, serial: 03d2ac71): type vorbis
Vorbis headers parsed for stream 1, information follows...
Version: 0
Vendor: Xiph.Org libVorbis I 20101101 (Schaufenugget)
Channels: 1
Rate: 32000

Nominal bitrate: 189.949000 kb/s
Upper bitrate not set
Lower bitrate not set
User comments section follows...
        ENCODER=JNIVorbisEncoder
Vorbis stream 1:
        Total data length: 305896 bytes
        Playback length: 0m:13.311s
        Average bitrate: 183.831731 kb/s
Logical stream 1 ended
New logical stream (#2, serial: 34c74667): type vorbis
Vorbis headers parsed for stream 2, information follows...
Version: 0
Vendor: Xiph.Org libVorbis I 20101101 (Schaufenugget)
Channels: 1
Rate: 32000

Nominal bitrate: 189.949000 kb/s
Upper bitrate not set
Lower bitrate not set
User comments section follows...
        ENCODER=JNIVorbisEncoder
Vorbis stream 2:
        Total data length: 488682 bytes
        Playback length: 0m:20.992s
        Average bitrate: 186.235518 kb/s
Logical stream 2 ended

Re: OGG chaining libvorbis android

Reply #1
Seems OK here. Is your decoder just not able to understand the chaining?

Chaining in an ogg container is as simple as it gets. Just concatenate two separate ogg files together, the result is a chained file.

*#$%^^% stupid quick-edit! Try again

Edit: OK, it does seem like something is wrong. The second stream does not play to the supposed end at 21 seconds. It may be corrupted, I haven't looked in detail.

Re: OGG chaining libvorbis android

Reply #2
I am using libvorbis to encode recorded PCM data on android. I am implementing pause/resume capability for that I have to chain multiple ogg logical bit streams into one physical bit stream but when I do that I get a file that shows wrong duration and is unseekable. It plays the audio in the correct order though. What am I not doing or doing something wrong?

That file plays correctly in foobar, including seeking between tracks.

Are you sure your software actually supports chained files?  A lot does not.

Re: OGG chaining libvorbis android

Reply #3
I am using libvorbis to encode recorded PCM data on android. I am implementing pause/resume capability for that I have to chain multiple ogg logical bit streams into one physical bit stream but when I do that I get a file that shows wrong duration and is unseekable. It plays the audio in the correct order though. What am I not doing or doing something wrong?

That file plays correctly in foobar, including seeking between tracks.

Are you sure your software actually supports chained files?  A lot does not.

In VLC player, I can seek position within the stream which is playing but I cannot seek from stream 1 to stream 2 and vice versa. Also, I have just download foobar, it perceives that file as two separate tracks.

Should I multiplex instead of chaining?

Re: OGG chaining libvorbis android

Reply #4
So vlc is borked then ;) Most software treats chained ogg streams as separate tracks. This is almost inevitable since each chained stream can have separate metadata. I'd never noticed before that vlc doesn't, but then chained ogg files are pretty rare.

My Linux vlc loads all chained streams as a single "track" with the metadata of the first stream. It can successfully seek from a play position in the first stream to a play position in the second stream. If it doesn't do so on Android then it may be a bug. I'm using vlc v2.0.3, you may well have a different version although probably newer. My vlc does get itself slightly messed up, counting play time separately in the two chained files so that the playing time suddenly resets to zero in the middle of the single track and never reaching the total track time - also the playtime in the seekbar is off, not quite matching the play position it actually seeks to. vlc generally is quite poor at determining the length of tracks without playing them first.

It does sound like you don't really want to chain these two pieces of audio. It sounds like the simplest way to concatenate two audio streams into one stream, but that's really not what its doing. If you really want gapless concatenation of two streams, then you should re-encode into a single stream. In general you'd then have to decide what single set of metadata to have, but perhaps not an issue in your case.

Re: OGG chaining libvorbis android

Reply #5
It does sound like you don't really want to chain these two pieces of audio. It sounds like the simplest way to concatenate two audio streams into one stream, but that's really not what its doing. If you really want gapless concatenation of two streams, then you should re-encode into a single stream. In general you'd then have to decide what single set of metadata to have, but perhaps not an issue in your case.

Is multiplexing an option if I only want decoders to see only one track? If not then how to concatenate two audio streams into one stream?

 

Re: OGG chaining libvorbis android

Reply #6
Multiplexing is not a way to concatenate two streams into a single stream. It is a way to have two (or more) concurrent but separate streams. Typically these will be streams with different codecs such as a video and audio stream, but it can be used for multiple audio streams such as alternate languages or sequences in a game. You wouldn't normally play two multiplexed audio streams at the same time, and in any case that's not what you want. The strict "Ogg Vorbis I" specification doesn't allow multiple multiplexed audio tracks and some players won't work properly with them. You might want to have a play just for fun: oggz-merge will turn multiple streams into a single multiplexed file of parallel audio tracks.

The simplest way to concatenate two streams is just to re-encode. Foobar should do this for you. There are also explicit ogg "joiners", programs that will just join two ogg streams for you without messing about. ffmpeg will do it on Linux, but there is also oggCat. I believe that joining Vorbis streams gaplessly effectively requires "playback" and so would be considered to be re-encoding with a small loss of quality but there shouldn't be an issue with doing this once,