Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - General > Member Success Stories
User Name
Password Member Success Stories Just spent four hours configuring your favorite program? Just figured out a Linux problem that has been stumping you for months?
Post your Linux Success Stories here.


  Search this Thread
Old 07-15-2015, 05:16 PM   #1
Registered: Mar 2015
Distribution: Linux Mint
Posts: 579

Rep: Reputation: 267Reputation: 267Reputation: 267
Playing online music videos in terminal (one-liner)

pvl() { (for i in "$@"; do youtube-dl -q --max-downloads 1 --no-playlist "$i" -o - | mplayer -vo null /dev/fd/3 3<&0 </dev/tty; sleep .5; done); }
This plays video files (youtube, vimeo, etc) isolated to the terminal, without video.

I'm particularly proud of this one since it solved a lot of things I've been stumped about. Plus - it really converges the online video media and cli together.
First off, there is no downloading to a file or any conversion of files. youtube-dl downloads and sends to stdout and is immediately caught by mplayer which then dumps any video elements (-vo null). This also avoids any need for a fifo and avoids costly conversion (ffmpeg -i - -f ogg -vn -)

If you've ever piped to mplayer, you've noticed that you cannot control it. Turns out with some redirection magic (/dev/fd/3 3<&0 </dev/tty), you can!

If you're inclined and have mplayer and youtube-dl installed, try it out.

pvl 'link1' 'link2' 'link3'
Old 08-18-2015, 11:35 AM   #2
Senior Member
Registered: Oct 2004
Distribution: FreeBSD Arch
Posts: 2,010

Rep: Reputation: 310Reputation: 310Reputation: 310Reputation: 310
If you want to use youtube-dl and mplayer then give this a try. It's
a little more versatile.

#! /usr/bin/env bash

# Youtube video-audio player and downloader. Requires youtube-dl and one
# of mplayer , mpv, ffplay

[ -d $HOME/Utube ] || mkdir $HOME/Utube
cd $HOME/Utube

Select an option.:  "
while :; do
  options="Quit Formats Watch Listen Download"
    select opt in $options; do
      case $opt in
        Quit) clear; exit;;
        Formats) read -p "Paste Utube URL:  " form
          youtube-dl -F "$form"
			      	read -p "$Enter to continue.  "
				      break ;;

        Watch) read -p "Paste Utube video URL:  " view	
				      #youtube-dl -q -f 18 "$view" -o - | mpv -
			      	youtube-dl -q -f 18 "$view" -o - | mplayer -
				      #youtube-dl -q -f 18 "$view" -o - | ffplay -
			      	break ;;
        Listen) read -p "Paste Utube audio URL:  " aud
				      #youtube-dl -q -f 140 "$aud" -o - | mpv -
			      	youtube-dl -q -f 140 "$aud" -o - | mplayer -
				      #youtube-dl -q -f 140 "$aud" -o - | ffplay -
				      break ;;

        Download) read -p "Paste Utube URL:  " dl
				      read -p "What format number?  Ex: 0 18 22 140:  " fmat
				     	  until [ ! -e ut$num.* ]; do
					        	num=$(($num + 1))
				      youtube-dl -q -f "$fmat" "$dl" -o ut"$num"."%(ext)s"
				      break ;;


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: MOC - Playing Music in the Terminal LXer Syndicated Linux News 0 03-25-2014 01:40 AM
Videos not playing. paulie_linux Linux - Newbie 10 12-08-2013 10:44 AM
Install Codec for playing Music & Videos for the first time in Ubuntu/Linux st_tht Linux - Newbie 11 06-01-2013 10:35 AM
Easy script that update webpage, to show online, skype online, music playing? frenchn00b Debian 1 04-07-2008 04:12 AM
playing two videos at once. Moebius Linux - Software 1 07-09-2003 06:38 AM > Forums > Linux Forums > Linux - General > Member Success Stories

All times are GMT -5. The time now is 01:50 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration