views:

384

answers:

2

The MPEG-4 file format allows multiple streams to be present in a file. This is useful for videos containing audio in multiple languages. In the case of such a video, the audio streams are synchronized to the video.

Is it possible to create a MPEG-4 file the contains desynchronized audio streams, i.e. the audio track are played on after another?

I want to design a MPEG-4 file that contains a music album, so it is crucial that the tracks are played one after another by media players such as VLC. When I use MP4Box (from the GPAC framework) the resulting file is recognised by VLC as having synchronized audio streams. Which box of the MPEG-4 file format is responsible for this? Or how can I tell VLC that these audio streams are not synchronized?

Thanks in advance!

+1  A: 

I can think of two ways you could do that, and both would be somewhat problematic.

You could concatenate all the audio streams into one audio track in the MP4 file. This won't be ideal, for some obvious reasons. For one thing, it's not exactly what you were asking for.

You could also just store the tracks as synchronized audio streams, but set the timing information in such a way that the first sample of the second track won't start playing until the first track finished playing, etc.

I'm not aware of any tools that can do this, but the file format will support such a scheme. Since it's an unusual way to store audio in an MP4 file, I would expect players to have problems with this, too.

Ori Pessach
Thanks for your reply!The first way would work, but as you said, it's not ideal. I would loose the ability to jump to a particular track, and so on. But maybe chapters might work (although I suspect that VLC doesn't support them).The second way doesn't work, at least not for VLC. It would be the cleaner solution, but VLC still recognises them as audio streams that have to be chosen manually.Maybe, I'll have to program a plugin for VLC to get it to play my files...
MyKey_
A: 

Concatenating all streams would work and the individual tracks can be addressed by adding chapters. It works at least with VLC.

    MP4Box -new -cat track1.m4a -cat track2.m4a -chap chapters.txt album.m4a

The chapters.txt would look something like this:

    CHAPTER1=00:00:00.00
    CHAPTER1NAME=Track 1
    CHAPTER2=00:03:40.00
    CHAPTER2NAME=Track 2

But this is only a hack. The solution I'm looking for should preserve the tracks as individual streams.

MyKey_