Author Topic: [Fix] SDL_Mixer: Can't play ogg file ?  (Read 2106 times)

Thedahu (OP)

  • Posts: 2
[Fix] SDL_Mixer: Can't play ogg file ?
« on: November 30, 2015, 12:28:05 pm »
Hi everyone !
You can find the solution below.
Quote
I think I found a bug in the library SDL_Mixer 1.2.

When I play a music (ogg/vorbis), the CPU runs at 100% and the program seems to be blocked (infinite loop).

When I compile this program on my computer (linux on virtualbox), the music was played nicely.
I've checked if the file has been loaded correctly, seems to be ok.
In the subject http://boards.dingoonity.org/gcw-development/sdl_mixer1-2-bug/msg112539, Senor Quack seems to have the same issue and had converted the OGG file to WAV to avoid this bug. But I don?t really like this solution. :(

Should I recompile the SDL2 + Mixer ?
Here the sources and ogg file to test it by yourself (C++): Click-here (2Mo).

Solution:
(http://boards.dingoonity.org/gcw-development/sdl_mixer-can't-play-ogg-file/msg134594/#msg134594)
In fact, the bug appear when the ogg file has a "video channel". It could work great on your computer but block your program on the GCW.
To check if your ogg file has or not a video channel, do (on linux):
Code: [Select]
file your_file_name.ogg

# If your file is good:
your_file_name.ogg: Ogg data, Vorbis audio

# else
your_file_name.ogg: Ogg data, Theora video

If you want to keep only the audio channel, you have to use ffmpeg:
Quote
ffmpeg -i your_file_name.ogg -acodec copy -vn output-file.ogg

Thanks a lot to Senor Quack and Pcercuei for this solution !
« Last Edit: December 01, 2015, 07:24:58 am by Thedahu »

Senor Quack

  • Posts: 223
Re: SDL_Mixer: Can't play ogg file ?
« Reply #1 on: November 30, 2015, 04:26:35 pm »
In the subject http://boards.dingoonity.org/gcw-development/sdl_mixer1-2-bug/msg112539, Senor Quack seems to have the same issue and had converted the OGG file to WAV to avoid this bug. But I don?t really like this solution. :(

I only mentioned that because it occured once on a single OGG file a long time ago on a completely different platform (GP2X). When I later ported the same game to GCW Zero, the problem with that same file did not occur and I've never had a single issue playing OGG files on the GCW Zero.

First off, is it just one OGG file that is causing your problem or do all OGG files cause the same problem?

EDIT:
After testing out your source code, first modifying it to use SDL1.2 headers in both ZeroG.cpp and mix_test.h, I verified your OGG would not play, but others would. Pcercuei in IRC chat suggested I check your OGG to see what it contained and it is a OGG video, not an OGG vorbis audio file, as you can see running linux 'file' command on it:
test.ogg: Ogg data, Theora video

You can losslessly extract a Ogg vorbis audio substream from a OGG Theora video file by installing the ffmpeg package and running the following command:
ffmpeg -i input-file.ogg -acodec copy -vn output-file.ogg

I tested this method using your file and successfully played the resulting OGG using your code on the GCW Zero.
« Last Edit: November 30, 2015, 05:37:08 pm by Senor Quack »

Thedahu (OP)

  • Posts: 2
Re: SDL_Mixer: Can't play ogg file ?
« Reply #2 on: December 01, 2015, 07:08:50 am »
In the subject http://boards.dingoonity.org/gcw-development/sdl_mixer1-2-bug/msg112539, Senor Quack seems to have the same issue and had converted the OGG file to WAV to avoid this bug. But I don?t really like this solution. :(

I only mentioned that because it occured once on a single OGG file a long time ago on a completely different platform (GP2X). When I later ported the same game to GCW Zero, the problem with that same file did not occur and I've never had a single issue playing OGG files on the GCW Zero.

First off, is it just one OGG file that is causing your problem or do all OGG files cause the same problem?

EDIT:
After testing out your source code, first modifying it to use SDL1.2 headers in both ZeroG.cpp and mix_test.h, I verified your OGG would not play, but others would. Pcercuei in IRC chat suggested I check your OGG to see what it contained and it is a OGG video, not an OGG vorbis audio file, as you can see running linux 'file' command on it:
test.ogg: Ogg data, Theora video

You can losslessly extract a Ogg vorbis audio substream from a OGG Theora video file by installing the ffmpeg package and running the following command:
ffmpeg -i input-file.ogg -acodec copy -vn output-file.ogg

I tested this method using your file and successfully played the resulting OGG using your code on the GCW Zero.

Awesome, thanks a lot Senor Quack and Pcercuei!
Well I'm happy that not come from my code.
I never think about video channel in this ogg file (I'll use the file command each time now ;)) ... Still strange that I could it run perferctly on my computer ! :o

 

Post a new topic
Post a new topic