OpenWrt Forum Archive

Topic: mplayer and Youtube videos

The content of this topic has been archived on 24 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello everyone,

I just wanted to establish that it is possible to "listen" to youtube videos using mplayer in a TP-LINK MR3020 router.
This is not a post with a question about something then but rather an informative one. I thought it may be of interest to people using a router as a music player as I do. I didn't find anything specifically about mplayer-youtube on this device or other router actually, but luckily I found the qi-hardware project which is based on Openwrt.

I know it may sound odd to only listen to Youtube, but there are a lot of videos uploaded that are just music with still pictures.

For accomplishing it, I used the feed's definitions from:

src-git qipackages git://

The branch used was AA. I had to tweak mplayer's Makefile a bit, but I don't know exactly what is that finally did the trick.
+libfaad2 +libffmpeg-full were added to the DEPENDS list and also --enable-x264-lavc and --enable-demuxer=FLV_DEMUXER as Configure arguments.
I don't know if all the changes are necessary but now it works.
It is necessary to add TARGET_CFLAGS+= -DFIXED_POINT to the Faad Makefile when building from AA feeds. I know that change is already in the feeds coming from trunk as an option in the menu.

After compiling and installing everything I installed python from the repos and then wget-ed the youtube-dl script.
I reused a cgi-ash script that I already had for controlling mpd and netcat + madplay, which in turn were being used for listening to Youtube through a much more complicated (ugly, really) setup involving a raspberry pi in another room doing the transcoding. The youtube API allow me to make a search and give me related videos and thumbnails. So from a WiFi-equipped cellphone it can all be controlled.

My scripts are really messy and ugly as I stop thinking after they do what I want. What I mean is they are certainly not efficient. I know some day I'll have to rewrite them all. Also, using python in such a small device is a bad idea because there is like a 20 second delay until youtube-dl gets the link from youtube and I think that could be much faster if it was written in C for example. Just loading python in console takes like 5 seconds in this device.

If, as I said, this is of interest to anyone and/or you have a question about it, please feel free to email me.


I have adapted the Perl script at (credits to them) to replace the youtube-dl script. Now is ash-fast.


# Preferred format.

# Get the video's page.
sitio="$(wget -Ncq -e convert-links=off --keep-session-cookies --save-cookies /dev/null --no-check-certificate -O- "$1")"  

# Loop unitl finding one of the declared formats. 
while [ -z "$url" -a -n "$formato" ]; do
url="$(echo "$sitio" | sed 's/"url_encoded_fmt_stream_map"\(.*\)/\1/g' | sed 's/,/\n\n/g' | grep itag="$formato")"  

case "$formato" in
35) formato="44" ;; 
44) formato="34" ;;  
34) formato="43" ;; 
43) formato="18" ;; 
18) formato="" 


# Put things in order
url="$(echo "$url" | sed 's/\:\ \"//' | sed 's/%3A/:/g' | sed 's/%2F/\//g' | sed 's/%3F/\?/g' | sed 's/%3D/\=/g' | \
sed 's/%252C/%2C/g' | sed 's/%26/\&/g' | sed 's/sig=/signature=/g' | sed 's/\\u0026/\&/g' | sed 's/type=[^&]\+//g' \
| sed 's/fallback_host=[^&]\+//g' | sed 's/quality=[^&]\+//g')" 

signature="$(echo "$url" | sed 's/.*\(signature=[^&]\+\).*/\1/')"  
youtubeurl="$(echo "$url" | sed 's/.*\(http\?:.\+\).*/\1/'| sed 's/&signature.\+$//')"     
download=$(echo "$download" | sed 's/&\+/\&/g' | sed 's/&itag=[0-9]\+&signature=/\&signature=/g' ) 

# Print the long, signed URL.
echo "$download"

can you give detail how you got mplayer running.  I compiled no error with AA branch and installed on my wr703n but when i run mplayer, i get Segmentation fault.  I want to able to stream online radio with this.  mpd cpu usage is very high and don't work well.  Thanks.


I've lost my original Makefile and I can't recall where I've got it from. I remember changing it, so that it uses the external libfaad2 -or something like that comes to my mind. Which Makefile are you using?

Anyway, I can tell you two things:
I never got a segfault with mplayer and I use AA.
And secondly, mpd should be less resource hungry than mplayer actually. Your problem might be related to other thing. Are those streams AAC's ones? Could you try listening to a radio that streams using MP3 (eg.,
I'm guessing you don't have the fixed point flag enabled in libfaad2.


mpd work great except it doesn't stream mms well especially wma.  http stream consume around 5-10% cpu.
other user have the same issue … 60#p153660 … 68#p106468

my though was the cpu was not fast enough so i tried on the pogoplug with ALARM.  mpd cpu usage was 99%.  Then i install mplayer on the pogoplug, all format work so great, cpu remain around 1% and audio come right on vs mpd need 5s wait.

maybe mplayer will work better with openwrt too.  ok i recompiled and got it running.  it work for most audio but wma.  run into another problem Requested audio codec family [wmadmo] (afm=dmo) not available.

You won't be able to decode wma on the wr703n, because it doesn't have a floating point unit. That's why cpu usage goes up so high. I suspect the pogoplug device (which I don't know) has one. Using a router with openwrt and mpd, you can listen right know, instantly, to a mp3, flac, ogg or aac (if you pass -DFIXED_POINT to the faad2 Makefile) file or stream.

There is a wma fixed point implementation ( … n=2&q=) made for the Rockbox firmware, but no one has adapted it to openwrt yet

thanks gsenna for the clarification.

I don't think pogoplug have floating point either, that explain mpd usage is also very high.  I don't know what mplayer have but it definitely work perfectly (I tried with debian and alarm OS on pogoplug).  Too bad wma codec is not included with mplayer in openwrt.

The discussion might have continued from here.