FMOD_ERR_FORMAT or FMOD_ERR_FILE_EOF ERROR in Android

Hello,

I ran into an error when using Fmod API in Android system.

I’ve been trying to play MP3 files, which are saved in the server, directly from url, and I downloaded all the mp3 files in a legal way(I paid for them). While I could play some of them without any problem, there has been errors shown for some files.

The first log is when mp3 files are played properly.

03-28 14:21:25.021 6205-6205/com.example.ysj.recommendingmusicplayer I/fmod: SystemI::createSoundInternal             : filename = http://27.102.206.204/music/The%20Chainsmokers-Closer%20(Feat.%20Halsey).mp3 : mode 00000089
03-28 14:21:25.531 6205-6205/com.example.ysj.recommendingmusicplayer I/fmod: SystemI::createSoundInternal             : Format has 0 subsounds.
03-28 14:21:25.531 6205-6205/com.example.ysj.recommendingmusicplayer I/fmod: SystemI::createSoundInternal             : Create as FMOD_CREATESTREAM
03-28 14:21:25.531 6205-6205/com.example.ysj.recommendingmusicplayer I/fmod: System::createSoundInternal              : decode buffersize = 17280 : blocksize = 1152 : format = 2
03-28 14:21:25.531 6205-6205/com.example.ysj.recommendingmusicplayer I/fmod: SystemI::createSample                    : mode 0000008a length 17280 samples, lengthbytes 9824258
03-28 14:21:25.531 6205-6205/com.example.ysj.recommendingmusicplayer I/fmod: SystemI::createSample                    : channels = 2
03-28 14:21:25.531 6205-6205/com.example.ysj.recommendingmusicplayer I/fmod: SystemI::createSample                    : output = 0x6185ebd0
03-28 14:21:25.531 6205-6205/com.example.ysj.recommendingmusicplayer I/fmod: OutputSoftware::createSample             : lengthpcm 17280, lengthbytes 9824258, channels 2, format 2, freq 44100, mode 0000008a
03-28 14:21:25.531 6205-6205/com.example.ysj.recommendingmusicplayer I/fmod: System::createSoundInternal              : Seek stream to start
03-28 14:21:25.531 6205-6205/com.example.ysj.recommendingmusicplayer I/fmod: System::createSoundInternal              : flush stream buffer
03-28 14:21:25.541 6205-6205/com.example.ysj.recommendingmusicplayer I/fmod: System::createSoundInternal              : flush successful.
03-28 14:21:25.541 6205-6205/com.example.ysj.recommendingmusicplayer I/fmod: System::createSoundInternal              : switch file handle from small blocking single buffered to large nonblocking doublebuffered.
03-28 14:21:25.541 6205-6205/com.example.ysj.recommendingmusicplayer I/fmod: Thread::initThread                       :     Initializing FMOD file thread.  priority 1
03-28 14:21:25.541 6205-6205/com.example.ysj.recommendingmusicplayer I/fmod: Thread::initThread                       :     - Stacksize 16384.  Stack pointer 0x0 : usesemaphore = 0 : sleeptime = 10
03-28 14:21:25.541 6205-6347/com.example.ysj.recommendingmusicplayer I/fmod: Thread::callback                         :     * FMOD file thread started

The second log is when the error occurred(mp3 files are not played due to errors)

03-28 14:22:39.501 6205-6205/com.example.ysj.recommendingmusicplayer I/fmod: SystemI::createSoundInternal             : filename = http://27.102.206.204/music/Ariana%20Grande-Problem%20(Feat.%20Iggy%20Azalea).mp3 : mode 00000089
03-28 14:22:39.756 6205-6205/com.example.ysj.recommendingmusicplayer E/fmod: SystemI::createCodec                     : Fatal error (14) scanning the codecs.  (ie not FMOD_ERR_FORMAT or FMOD_ERR_FILE_EOF)

As you can see from the second log, the error is shown as FMOD_ERR_FORMAT or FMOD_ERR_FILE_EOF. Since all of them are files of mp3 extension, I think there shouldn’t be any problem in terms of format.

Could you any please tell me the reason why?

Thank you so much!

My test didnt get this problem, can you copy the netstream example code and add this before your createsound call

result = system->setStreamBufferSize(64*1024, FMOD_TIMEUNIT_RAWBYTES);

Sometimes if the chunk of data isnt read into memory fully at the start, it might execute a seek instruction. This results in FMOD_ERR_FILE_COULDNOTSEEK with a netstream.
The reason it might try to seek is because it has ID3V2 tags in the file at the start, and they’re large.

If that doesn’t work try FMOD_IGNORETAGS and FMOD_MPEGSEARCH. Let me know how you go.

I really appreciate your help!

I have modified the code and tried it as what you’ve advised, still the same error occurs.

(modified code)

result = system->setStreamBufferSize(512*1024, FMOD_TIMEUNIT_RAWBYTES);
result = system->createSound(“http://27.102.206.204/music/Ariana%20Grande-Problem%20(Feat.%20Iggy%20Azalea).mp3”, FMOD_IGNORETAGS | FMOD_MPEGSEARCH | FMOD_CREATESTREAM | FMOD_NONBLOCKING, 0, &sound);

The difference is that it used to show the error log right after CreateSound, but now it runs for a short period of time and the error is now shown as ‘Fatal error (14) scanning the codecs. (i.e. not FMOD_ERR_FORMAT or FMOD_ERR_FILE_EOF)’.

(log)

03-30 14:56:43.323 17141-17165/com.example.ysj.fomdtest I/fmod: SystemI::init : Set up emulated output
03-30 14:56:43.323 17141-17165/com.example.ysj.fomdtest I/fmod: SystemI::init : create the channel pool
03-30 14:56:43.323 17141-17165/com.example.ysj.fomdtest I/fmod: Thread::initThread : Initializing FMOD stream thread. priority 2
03-30 14:56:43.323 17141-17165/com.example.ysj.fomdtest I/fmod: Thread::initThread : – Stacksize 65536. Stack pointer 0x0 : usesemaphore = 0 : sleeptime = 10
03-30 14:56:43.323 17141-17168/com.example.ysj.fomdtest I/fmod: Thread::callback : * FMOD stream thread started
03-30 14:56:43.323 17141-17165/com.example.ysj.fomdtest I/fmod: SystemI::createSound : filename = http://27.102.206.204/music/Ariana%20Grande-Problem%20(Feat.%20Iggy%20Azalea).mp3 : mode 02018080
03-30 14:56:43.323 17141-17165/com.example.ysj.fomdtest I/fmod: SystemI::createSound : FMOD_NONBLOCKING specified. Putting into queue to be opened asynchronously!
03-30 14:56:43.323 17141-17165/com.example.ysj.fomdtest I/fmod: Thread::initThread : Initializing FMOD nonblocking thread (0). priority 1
03-30 14:56:43.323 17141-17165/com.example.ysj.fomdtest I/fmod: Thread::initThread : – Stacksize 81920. Stack pointer 0x0 : usesemaphore = 1 : sleeptime = 0
03-30 14:56:43.323 17141-17169/com.example.ysj.fomdtest I/fmod: Thread::callback : * FMOD nonblocking thread (0) started
03-30 14:56:43.323 17141-17165/com.example.ysj.fomdtest I/fmod: SystemI::createSound : setdata soundi = 0x619328c0 : node = 0x6194d788
03-30 14:56:43.323 17141-17165/com.example.ysj.fomdtest I/fmod: SystemI::createSound : add node to async list : head = 0x6194d9d8. list count = 0
03-30 14:56:43.323 17141-17169/com.example.ysj.fomdtest I/fmod: AsyncThread::threadFunc : Starting Asynchronous operation on sound 0x619328c0
03-30 14:56:43.323 17141-17169/com.example.ysj.fomdtest I/fmod: SystemI::createSoundInternal : filename = http://27.102.206.204/music/Ariana%20Grande-Problem%20(Feat.%20Iggy%20Azalea).mp3 : mode 02018080
03-30 14:56:43.358 17141-17141/com.example.ysj.fomdtest D/libEGL: loaded /system/lib/egl/libEGL_mali.so
03-30 14:56:43.358 17141-17141/com.example.ysj.fomdtest D/libEGL: loaded /system/lib/egl/libGLESv1_CM_mali.so
03-30 14:56:43.363 17141-17141/com.example.ysj.fomdtest D/libEGL: loaded /system/lib/egl/libGLESv2_mali.so

[ 03-30 14:56:43.363 17141:17141 E/ ]
Device driver API match
Device driver API version: 29
User space API version: 29

[ 03-30 14:56:43.363 17141:17141 E/ ]
mali: REVISION=Linux-r3p2-01rel3 BUILD_DATE=Tue Jul 22 19:59:34 KST 2014
03-30 14:56:43.433 17141-17141/com.example.ysj.fomdtest D/OpenGLRenderer: Enabling debug mode 0
03-30 14:56:43.453 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.463 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.463 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.463 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.468 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.468 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.468 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.468 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.468 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.468 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.473 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.478 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.478 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.478 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.478 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.478 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.478 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.478 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.478 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.478 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.483 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.483 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.483 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.483 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.483 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.483 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.483 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.483 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.483 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.513 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:43.543 17141-17141/com.example.ysj.fomdtest D/TextLayoutCache: Enable myanmar Zawgyi converter
03-30 14:56:44.013 17141-17169/com.example.ysj.fomdtest E/fmod: SystemI::createCodec : Fatal error (14) scanning the codecs. (ie not FMOD_ERR_FORMAT or FMOD_ERR_FILE_EOF)
03-30 14:56:44.013 17141-17169/com.example.ysj.fomdtest I/fmod: AsyncThread::threadFunc : Finished Asynchronous operation on sound 0x619328c0

Is there any way to solve this problem?

Thank you in advance :slight_smile:

There is a large amount of tag data at the start of your MP3 file that is failing.

Are you able to remove that from the file?
That would allow it to load correctly.