Joining ogg files into one file

Writing software that controls the system and peripherals such as displays, SD cards, Buttons, LEDs, Serial Ports etc.
Post Reply
theophilus
Senior User
Posts: 21
Joined: Fri 2011-04-01 12:37

Joining ogg files into one file

Post by theophilus »

Greetings,

I'm not sure where to post this question, but this forum seems to be the closest fit.

I am trying to join multiple ogg files together into one file. Various people suggest:
cat file1.ogg file2.ogg > joined.ogg

I can play all of joined.ogg with ogg123, but the VS1000 only plays the first part (from file1.ogg).

What is the correct way to join multiple ogg files so that the VS1000 can play them all from one file?

Thanks
Steven
theophilus
Senior User
Posts: 21
Joined: Fri 2011-04-01 12:37

Re: Joining ogg files into one file

Post by theophilus »

Found the answer here:
http://www.g-raffa.eu/Cinelerra/HOWTO/rendering.html

Just install oggvideotools and use oggCat as follows:

oggCat joined.ogg file1.ogg file2.ogg
User avatar
Henrik
VLSI Staff
Posts: 1311
Joined: Tue 2010-06-22 14:10

Re: Joining ogg files into one file

Post by Henrik »

theophilus wrote:Greetings,

I'm not sure where to post this question, but this forum seems to be the closest fit.
This is certainly good enough a place. :)
theophilus wrote:I am trying to join multiple ogg files together into one file. Various people suggest:
cat file1.ogg file2.ogg > joined.ogg

I can play all of joined.ogg with ogg123, but the VS1000 only plays the first part (from file1.ogg).
As you already noticed, simply combining two .ogg files doesn't create a new valid Ogg Vorbis stream. The reason why this doesn't work is that an Ogg Vorbis file has a certain structure to it:
1) Header information (upto 4 KiB and absolutely necessary for the rest of the file to be decodable at all)
2) Actual audio data.
3) The last Ogg (audio) frame has the "last frame" special bit set, and this is the point where VS1000 stops decoding and expects any additional data in the file to be "not Ogg Vorbis".

Technically, the VS1000 firmware could have been written so that it would allow concatenated Ogg files, but, frankly, the thought never crossed our minds. But next time we create a completely new firmware version for a new IC, this will have to be reconsidered. It's always good to be able to play even slightly weird files.

This is, by the way, different from the MP3 format where you can concatenate files with a similar samplerate and number of channels, and expect to resultant files to be nicely decodable. The reason for this is that there is no concept of "file" in the MP3 format, only "audio frames". Sometimes this is bad (e.g. no way of reliably checking duration of file before decoding it), but for concatenating files this is convenient.
theophilus wrote:What is the correct way to join multiple ogg files so that the VS1000 can play them all from one file?
I'm happy you already found the Ogg Video Tools / oggCat utility. I mainly wrote this message to provide some technical explanation why things are as they are.

As long as the source files are "compatible anough", you will be able to concatenate them into one. Note, however, that even using this utility there is a chance of occasional clicks and pops when going from one file to another, so check for them before making this your standard workflow.

Kind regards,
- Henrik
Good signatures never die. They just fade away.
theophilus
Senior User
Posts: 21
Joined: Fri 2011-04-01 12:37

Re: Joining ogg files into one file

Post by theophilus »

Thanks for your comprehensive reply, Henrik!

Kind regards,
Steven
Post Reply