Play music from youtube without download

wget -q -O - `youtube-dl -b -g $url`| ffmpeg -i - -f mp3 -vn -acodec libmp3lame -| mpg123 -
Sample Output
torrid@siebot ~ $ wget -q -O - `youtube-dl -b -g http://www.youtube.com/watch?v=OKRJfIPiJGY`| ffmpeg -i - -f mp3 -vn -acodec libmp3lame - 2>/dev/null | mpg123  -
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
        version 1.9.0; written and copyright by Michael Hipp and others
        free software (LGPL/GPL) without any warranty but with best wishes

Playing MPEG stream 1 of 1: - ...
MPEG 1.0 layer III, 64 kbit/s, 44100 Hz joint-stereo

14
By: torrid
2009-11-07 13:45:13

1 Alternatives + Submit Alt

What Others Think

awesome
JollyJumper · 462 weeks and 4 days ago
there's those backticks again... i swear we'll never rid ourselves of them
atoponce · 462 weeks and 3 days ago
ffmpeg is giving error: "Unknown encoder 'libmp3lame' " Which package contains this codec?
alperyilmaz · 462 weeks and 2 days ago
@alperyilmaz which *nix flavour? The lib of the lame command is actually libmp3lame.so/a, so the package is probably lame. To make ffmpeg use it, you have to compile it with --enable-mp3lame. @atoponce I read all about evil backticks, and I'll try to avoid them now.^^
torrid · 462 weeks and 1 day ago
How to extend this to download file directly with the name of the file matching the name on youtube title?
unixmonkey8504 · 446 weeks and 2 days ago
Technically, you're still downloading.
tommytwoeyes · 184 weeks and 1 day ago
us mpv! and forget that commands!
zodman · 105 weeks and 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: