Rockbox.org home
Downloads
Release release
Dev builds dev builds
Extras extras
themes themes
Documentation
Manual manual
Wiki wiki
Device Status device status
Support
Forums forums
Mailing lists mailing lists
IRC IRC
Development
Bugs bugs
Patches patches
Dev Guide dev guide
Search



Donate

Rockbox Technical Forums


Login with username, password and session length
Home Help Search Staff List Login Register
News:

Rockbox Ports are now being developed for various digital audio players!

+  Rockbox Technical Forums
|-+  Support and General Use
| |-+  Audio Playback, Database and Playlists
| | |-+  [solved] youtube aac and ffmpeg
« previous next »
  • Print
Pages: [1] 2

Author Topic: [solved] youtube aac and ffmpeg  (Read 10622 times)

Offline Crispin

  • Member
  • *
  • Posts: 4
[solved] youtube aac and ffmpeg
« on: July 26, 2009, 04:37:04 PM »
Hello out there

I would like to play the audio stream of some youtube videos on my Sansa e200. I get the audio by downloading the video. 'ffplay -stats' says that the audio is aac. To extract it I use the following line: 'ffmpeg -i FlashY1234 -vn -acodec copy some_output_file.m4a'
I don't use the .aac-ending because these files don't even show up in rockbox. These m4a-aac-files don't play in rockbox. They do on my computer. Anyone got an idea what's wrong?

Thanks, Crispin

P.S. I don't like converting already lossly compressed audio to another format
« Last Edit: July 29, 2009, 07:53:34 AM by Crispin »
Logged

Offline RotAtoR

  • Developer
  • Member
  • *
  • Posts: 170
  • Somewhere but not here
Re: youtube aac and ffmpeg
« Reply #1 on: July 26, 2009, 05:06:50 PM »
If the audio extracted by ffmpeg is a raw aac stream (which the ".aac" file extension appears to indicate) you can't just rename it to ".m4a" and have it work, you actually need to mux the stream into an mp4 container.
Logged

Offline sirdan

  • Member
  • *
  • Posts: 29
Re: youtube aac and ffmpeg
« Reply #2 on: July 27, 2009, 03:55:05 AM »
Funny, i had exactly the same problem recently.
Solution is easy. Use mp4Muxer from here http://www.dvbportal.de/projects/mp4muxer/ Drag ang drop file, on streaming tab check optimize and then multiplex. So far i found its the only tool that produce mp4 files playable on rockbox. Crispin, muxing is completely lossless process.
Logged

Offline Crispin

  • Member
  • *
  • Posts: 4
Re: youtube aac and ffmpeg
« Reply #3 on: July 28, 2009, 11:14:35 AM »
ffmpeg choses, AFAIK, the container appropriate to the file extension. The command line output also indicates this, as it says "Output #0, ipod, to 'test.m4a'" for the m4a extension and "Output #0, adts, to 'test.aac'" when I call the output file a *.aac.

Does anyone know which output format or container for aac I should use with ffmpeg so that the resulting file is playable in Rockbox?

Thanks, Crispin
Logged

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 8974
Re: youtube aac and ffmpeg
« Reply #4 on: July 28, 2009, 01:38:42 PM »
Quote from: Crispin on July 28, 2009, 11:14:35 AM

Does anyone know which output format or container for aac I should use with ffmpeg so that the resulting file is playable in Rockbox?


As RotAtoR said, you'll need to use either MP4/M4A.  Alternatively, you can probably use RM too, but support was just implemented so it may be a little untested at the moment. 

Also, FWIW, adts/aac isn't a container.  Its the format itself, with no container at all, and won't be playable in much of anything. 
Logged

Offline Crispin

  • Member
  • *
  • Posts: 4
Re: youtube aac and ffmpeg
« Reply #5 on: July 28, 2009, 07:17:13 PM »
I now tried the following formats/containers

*.m4a - ffmpeg name: ipod : Rockbox skips the file when opening
*.mp4 - ffmpeg name: mp4 : Rockbox skips the file when opening
*.rm   - ffmpeg name: rm : Rockbox hangs when trying to play the file

When I rename the Youtube video file to *.mp4 without (de)muxing or converting, Rockbox manages to play the first 15 seconds of the embedded audio stream and then hangs. ffmpeg identifies the container as 'mov,mp4,m4a,3gp,3g2,mj2' but is not able to write such a container.

What's next? Thank you very much!
Crispin
Logged

Offline sirdan

  • Member
  • *
  • Posts: 29
Re: youtube aac and ffmpeg
« Reply #6 on: July 29, 2009, 02:00:46 AM »
The only appropriate container for aac is mp4 with .mp4 extension. M4a is only for itunes crap.


Crispin.... i discussed your problem just few topics earlier.... You have to optimize mp4 file layout. Mainly put all metadata at the begining of the file.
You can use mp4creator with -optimize parameter. If you are on linux, you can compile it from source archive. Or maybe someone did it already.
Logged

Offline Crispin

  • Member
  • *
  • Posts: 4
Re: youtube aac and ffmpeg
« Reply #7 on: July 29, 2009, 07:51:59 AM »
Thank you very much, sirdan, that solved my problem.
Sorry for my ignorance earlier, but I could only see you were recommending me some proprietary software.
There is an ubuntu package in the official repos called mpeg4ip-server which contains mp4creator.

My command line for extracting the aac audio from a Youtube video and putting it in a container readable for Rockbox now looks like this:
Code: [Select]
ffmpeg -i YoutubeVideo -vn -acodec copy AudioStream.aac && mp4creator AudioStream.aac -O OutputFile.mp4

Thank you very much, all of you!
Crispin
Logged

Offline Dr4pht

  • Member
  • *
  • Posts: 3
Re: [solved] youtube aac and ffmpeg
« Reply #8 on: March 20, 2011, 01:05:51 PM »
I know this topic is almost 2 years old, but I found it by doing a search and want to add some information. For me, in case I'll forget it (again  ;)) and for others having the same problem like me.

It took me quite some time to figure out, why - following the steps above - Rockbox would play some mp4 files and others not. So here are two additional hints to avoid trouble with converted mp4 files.

1st: mp4creator has modified some of the options commands. So the line of code has to be modified like this:
Code: [Select]
ffmpeg -i YoutubeVideo -vn -acodec copy AudioStream.aac && mp4creator AudioStream.aac -optimize OutputFile.mp4

2nd: Most important after this step is to add some tag information like the song's name and artist, or else Rockbox refuses to play it. (At least on my Sansa Clip+). After adding those information I optimize the file with foobar2000.

With these two steps all converted mp4 files should be playable.


Current version of Rockbox has no problem in playing tagless mp4 files. Please read my additional post below.
« Last Edit: March 21, 2011, 05:48:25 PM by Dr4pht »
Logged

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 8974
Re: [solved] youtube aac and ffmpeg
« Reply #9 on: March 20, 2011, 01:20:39 PM »
Quote from: Dr4pht on March 20, 2011, 01:05:51 PM
2nd: Most important after this step is to add some tag information like the song's name and artist, or else Rockbox refuses to play it. (At least on my Sansa Clip+). After adding those information I optimize the file with foobar2000.

With these two steps all converted mp4 files should be playable.

Hmm that shouldn't be needed.  Can you file a bug report with a link to one of these files that doesn't play?
Logged

Offline Dr4pht

  • Member
  • *
  • Posts: 3
Re: [solved] youtube aac and ffmpeg
« Reply #10 on: March 21, 2011, 06:26:23 PM »
As you can see I had to reedit my last post, because there is no problem (anymore[?]) in playing tagless mp4 files

I was about to file a bug report on this matter and created some mp4 files out of Youtube videos (no tag, tag and tag+optimize). To my surprise they all played without a problem on my Clip+. BUT I had the problem of unplayable mp4 files a few days ago and a working workaround was indeed to add some tag information.

My problem right now is that I can't remember what files/videos were causing this behavior and which Rockbox-version I was using at that time, thus I can't recreate the situation.

If the Moderators choose to erase my post(s) in order to prevent confusion, I'm OK with it.
Logged

Offline plonk

  • Member
  • *
  • Posts: 3
Re: [solved] youtube aac and ffmpeg
« Reply #11 on: March 25, 2011, 05:35:50 AM »
Just to add my experience, in case it helps:

I have a routine I wrote that downloads radio programs from the BBC iplayer, until recently I had experimented with aac/m4a, but this was brought to a head by the BBC dropping mp3 streams.

I use the following code (wrapped in a ton of lovely perl) to make the raw aac stream playable in rockbox:

ffmpeg -i file.aac -f mp4 -acodec copy -vn file.mp4

(I hate recoding because all of my linux boxes are really low power)

On my Sansa Clip+ running 3.8, some of the files I was creating wouldn't play, eventually I tracked this down to the file length. A file of 30mins long would play sometimes, 45 mins and longer never. So I rejigged the code to dump 15 minutes chunks of the program sequentially into a directory (This also speeds the download up drastically as they throttle it server side). Now they all play in rockbox perfick.

I'm assuming this is some sort of RAM limit? I can supply an hour long file if anyone wants to try it on a different player. MP4 files do seem a lot more finicky that MP3.

Now I just need to port Rockbox to ncurses, so they will play on my servers(!)
Logged

Offline Chronon

  • Rockbox Expert
  • Member
  • *
  • Posts: 4379
Re: [solved] youtube aac and ffmpeg
« Reply #12 on: March 25, 2011, 06:04:46 AM »
Long mp4/m4a files have been problematic for a while.
http://www.rockbox.org/tracker/task/8923

It looks like there has been some recent investigation on this problem.
Logged
Sansa e280, Gigabeat F40, Gigabeat S60, Sansa Clip+, iPod Mini 2g

Offline Dr4pht

  • Member
  • *
  • Posts: 3
Re: [solved] youtube aac and ffmpeg
« Reply #13 on: March 26, 2011, 01:47:07 PM »
Quote
I use the following code (wrapped in a ton of lovely perl) to make the raw aac stream playable in rockbox:

ffmpeg -i file.aac -f mp4 -acodec copy -vn file.mp4

(I hate recoding because all of my linux boxes are really low power)

I want  to apologize in advance if i misinterpreted your post, plonk, but I just want to point out that mp4creator in Crispin's and my code line isn't used for recoding the aac file. It simply muxes it into an appropriate container, which is a completely lossless process.

I don't know if ffmpeg is capable of producing mp4 containers with optimized layout.
Logged

Offline Chronon

  • Rockbox Expert
  • Member
  • *
  • Posts: 4379
Re: [solved] youtube aac and ffmpeg
« Reply #14 on: March 27, 2011, 09:48:07 PM »
I believe the "-acodec copy" bit should tell ffmpeg to use the same audio codec (i.e. no transcoding).  No idea about the layout, though.
Logged
Sansa e280, Gigabeat F40, Gigabeat S60, Sansa Clip+, iPod Mini 2g

  • Print
Pages: [1] 2
« previous next »
+  Rockbox Technical Forums
|-+  Support and General Use
| |-+  Audio Playback, Database and Playlists
| | |-+  [solved] youtube aac and ffmpeg
 

  • SMF 2.0.17 | SMF © 2019, Simple Machines
  • Rockbox Privacy Policy
  • XHTML
  • RSS
  • WAP2

Page created in 0.112 seconds with 15 queries.