Rockbox Technical Forums

Support and General Use => Audio Playback, Database and Playlists => Topic started by: Bockrox on August 28, 2010, 02:01:59 PM

Title: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: Bockrox on August 28, 2010, 02:01:59 PM
I've noticed that Rockbox is unable to play some mp4 files that were downloaded with iTunes. When I attempt to play any of these files, it skips over them without playing any music.

I've done some research, and this seems to be related to the way metadata is stored in these files. Rockbox requires all metadata to be at the start of the file, but this is not always the case with iTunes music. Please correct me if I am wrong about this.

I've seen two solutions proposed for this problem -- using mp4creator --optimize on the files and using some tool provided by MP4Box on the files.

Does anyone have any experience using MP4Box to solve this issue? I try using MP4Box -flat filename.mp4, but I get the following message and the file is not altered:
Code: [Select]
[iso file] Box "stsd" has [some number] extra bytes
Any insight would be greatly appreciated. Thanks!
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: saratoga on August 28, 2010, 02:15:41 PM
I've noticed that Rockbox is unable to play some mp4 files that were downloaded with iTunes. When I attempt to play any of these files, it skips over them without playing any music.

I've never heard of this problem.  Post one of the files.

I've done some research, and this seems to be related to the way metadata is stored in these files. Rockbox requires all metadata to be at the start of the file, but this is not always the case with iTunes music. Please correct me if I am wrong about this.

This should be fixed in r24147:

http://svn.rockbox.org/viewvc.cgi?view=rev;revision=24147
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: Bockrox on August 28, 2010, 02:23:50 PM
Thank you for the info, saratoga.

I believe these were the two primary threads that led me to this understanding. They discuss a very similar issue to the one I am having and recommend mp4creator --optimize as a solution.
http://forums.rockbox.org/index.php?topic=14368.msg115048#msg115048
http://forums.rockbox.org/index.php?topic=6748.0

The only problem my distro doesn't (seem) to provide mp4creator. I was hoping I could accomplish the same task using MP4Box, but as I said I seem to be having some problems with that tool.
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: AlexP on August 28, 2010, 02:24:39 PM
What version of Rockbox do you have?
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: Bockrox on August 28, 2010, 02:29:24 PM
I'm currently running Rockbox 3.6.
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: saratoga on August 28, 2010, 02:31:08 PM
Post one of the files or its unlikely anyone can help you.
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: Bockrox on August 28, 2010, 02:46:21 PM
Hello again, saratoga. Thanks for the suggestion. I was a bit hesitant to submit a music file for obvious reasons.

Linked below is a music file that plays fine with most players (Totem, VLC, etc.) but cannot be played with Rockbox. I will most likely be removing it after this issue is resolved.

http://drop.io/hidden/8prkgfmoc8wvpdr/asset/YnJva2VuLW00YS1tNGE%253D

One additional thing I just remembered -- this file didn't come directly from iTunes. It was first downloaded from iTunes but then cracked with a DRM-removal tool (hymn, I believe).
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: Buschel on August 29, 2010, 04:44:15 AM
The issue is located in libm4a/demux.c. I cannot say whether there is a bug in the code or the header of the file...
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: Lear on August 29, 2010, 09:04:34 AM
demux.c expects a single atom in stsd, but there are two (mp4a and free) - making the following for-loop kind of silly. :) Don't know what the standard says, but it seems reasonable to ignore free chunks here.

Working on a fix... [edit] And fixed in r27938.
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: Bockrox on August 29, 2010, 11:47:41 AM
Interesting. So I guess this was an unknown bug after all...

Is there an expected release date for 3.7? If not, I can try upgrading to the current build and report my results, as long as the current build is stable enough for day-to-day usage.
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: AlexP on August 29, 2010, 12:40:28 PM
It is.  It is very rare that the current build is broken.
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: Bockrox on August 29, 2010, 05:33:27 PM
Bad news. :-(

I installed r27943, but the issue was not fixed. Rockbox still skips the m4a song I posted (and all other songs on that album). In fact, r27943 even caused some issues with my theme, but that may be my own fault.
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: soap on August 29, 2010, 05:47:01 PM
Just to be sure...
You overwrote the entire .rockbox directory and not just the main file?

(no offense intended)
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: Buschel on August 29, 2010, 05:57:46 PM
I see some strange behaviour as well. On PCSim the fix is indeed working very well. On my iPod Video the fix is not working.

(Same is happening with another fix I submitted: r27939/r27940. Works fine on PCSim but not on target...)
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: Bockrox on August 29, 2010, 06:14:35 PM
On my iPod Video the fix is not working.

I am also using iPod Video 5G.

You overwrote the entire .rockbox directory and not just the main file?

No offense taken. I used the Rockbox Utility to install r27943. That overwrites the entire directory, right?

Thanks again for staying on top of this with me.
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: soap on August 29, 2010, 07:29:56 PM
No offense taken. I used the Rockbox Utility to install r27943. That overwrites the entire directory, right?

Yea, you're right.

Edit (by gevaerts): I'm assuming that you mean "right", not "tight" as your fingers typed
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: [Saint] on August 30, 2010, 04:06:19 AM
In fact, r27943 even caused some issues with my theme, but that may be my own fault.


Just checking...but, what issues did you see exactly?

PS: Have you tried using a metadata tag editor (like Mp3Tag (http://www.mp3tag.de/en/download.html)) to strip the file(s) of metadata tags and see if you can play the file(s) then?
I've seen funky metadata tags cause all kinds of weird and unpredictable things...so, it's worth a shot.



[St.]
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: Lear on August 30, 2010, 01:05:00 PM
Heh, for me the track plays on a FuzeV2 - if I play another (AAC) track first. So maybe there's a buffering-related problem too.
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: saratoga on August 30, 2010, 01:29:09 PM
Heh, for me the track plays on a FuzeV2 - if I play another (AAC) track first. So maybe there's a buffering-related problem too.

Sounds like something isn't being initialized correctly.
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: Lear on August 30, 2010, 02:33:45 PM
Sounds like something isn't being initialized correctly.

Maybe, but what happens here is that during buffering, the codec first skips to the end of the file, then searches back to the beginning.

If another file is played first, the buffering is complete when the codec does the skipping forth and back. The only reason I tried with an AAC file was that I happened to have one in the same directory.

[Edit]

Tested on an e200. The file worked (when played directly) if dircache was on. That suggests a buffering problem, I'd say (and especially the timing between the codec, audio and buffer threads). Also, playing an MP3 file first also helps.
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: Buschel on August 30, 2010, 06:36:30 PM
Bockrox, please check again with r27950. Lear, kugel and I did some research and hope to have found the root cause.
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: saratoga on August 30, 2010, 06:59:58 PM
Nice find.  That looks like a nasty bug.
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: Bockrox on August 30, 2010, 11:48:07 PM
Still no luck with r27956, unfortunately.

There are two interesting things I do notice with this build, however.

If I try to play an album that is made up of "unplayable" m4a tracks (like the one I posted earlier), Rockbox skips every other track. It will start at track 1, immediately skip to track 3, quickly skip to track 5, etc.

The other interesting thing is that Rockbox displays the text "(no id3)" on the WPS of "unplayable" songs.

Weird...
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: Buschel on August 31, 2010, 01:30:01 PM
Hmm, is the file you have linked playing, if you move it to another directory that only contains other playable files? Can you provide links to some other files that do not play?
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: Bockrox on August 31, 2010, 02:09:11 PM
Putting the song in a directory that contains playable files doesn't have any effect. In fact, it causes Rockbox to skip over one playable file.

For example:
Code: [Select]
01 Playable 1.mp3
02 Playable 2.mp3
03 Unplayable.m4a
04 Playable 4.mp3
05 Playable 5.mp3

If I play "02 Playable 2.mp3" until it finishes, Rockbox then tries to play "03 Unplayable.m4a", fails, and then skips to "05 Playable 5.mp3".

To the earlier question of whether removing the tags makes any difference -- unfortunately, it doesn't seem to. The file I posted in this thread was stripped of all tags to make it less identifiable. This is the same file I have been testing on my iPod.
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: Bockrox on September 02, 2010, 07:24:16 PM
Random thought.

As I wrote in the first post (and sourced in my second) I have heard that the solution is to use mp4creator --optimize on the files in question. As I said, my distro doesn't seem to ship that package, but if anybody is interested in optimizing the file I posted and sending it back to me, I can try it on my iPod and report back.
Title: Re: Using MP4Box to fix iTunes-downloaded mp4 files
Post by: Buschel on September 05, 2010, 04:22:14 AM
Bockrox, another thing you might try is to test with enabled vs. disabled DirCache (see manual). Also: Are you sure you have fully updated your .rockbox folder to the current version? I cannot explain why the file works for me on my iPod 5G and not on yours (for the same test case, of course).