[mythtv-users] Command line to stream audio/video from

Joe Borne joe.borne at gmail.com
Wed Jan 9 16:07:01 UTC 2008


> > The menu part is easy since I know how to launch a command from a menu
> item.
> >  BUT....does anyone know how to start a stream from the command line?
>
> Mplayer can play streams so you could just create menu items that
> invoke mplayer.
>
> Alternatively you could do the following:
> 1) Create a playlist file (extension .m3u I think) which contains the
> URL of the stream.
> 2) Create a mythvideo entry that has a custom command line to call
> invoke mplayer with the playlist file. In that command line you can
> also tell it how much to buffer before it starts plaaying etc. I have
> an example at home if you'd like me to post it later.


Phil, I'd be interested in seeing your implementation of this.

Here is how I handle this. I've written a bash script that parses several of
the major movie trailer websites and puts the entries into a custom menu I
have inserted into MythTV.

A typical menu entry looks like this:

*****************

<button>
                <type>MOVIETIMES</type>
                <text>The Dark Knight</text>
                <action>EXEC MplayerWrap '
http://movies.apple.com/movies/wb/the_dark_knight/the_dark_knight-tlr1_h720p.mov'
</action>
</button>

*****************

Now MplayerWrap is just that, a wrapper that uses wget to download the
trailer into a specified directory, fires up mplayer and plays it, then
deletes it. I keep it in /usr/local/bin/.

*****************

#!/bin/bash


cd  /video/trailers/


rm -f *.mov


URL=`echo $1 |sed 's,\&amp\;,\&,g'`


# Blind download, it works but you have no idea how long you'll be waiting.

# wget $URL  ;


# "Fred Flintstone" quality progress bar, ugly but works.

xterm -e wget $URL ;


# Pretty GUI version - ooooooh. NOTE - this line does not currently work on
Fedora Core 6. For functionality zenity must be compiled from source at
version 2.2 or higher, plus the sed statement must be adjusted. I'm working
on this. All debian/ubuntu based distros work out of the box.

# wget $URL 2>&1 | sed -e 's/.*\ \([0-9]\+%\)\ \+\([0-9.]\+\
[KMB\/s]\+\)$/\1\n# Downloading \2/' | zenity --progress
--title="Downloading Trailer..." --auto-close --width=700 ;


mv *.mov* trailer.mov


mplayer -fs -zoom -quiet
/video/MythCinema-MovieTrailers/trailers/trailer.mov;


# Use this line to stream the media rather than download.

# mplayer -fs -zoom -quiet -user-agent NSPlayer $URL


rm -f /video/MythCinema-MovieTrailers/trailers/trailer.mov


# END

*****************

You can easily alter this behavior to play the video directly off the net as
a stream by commenting out the wget lines/mplayer line and uncommenting the
streaming line. All the sed line does up there is fix the ampersands from
the xml valid format of "&amp;" to a standard "&" so that wget and mplayer
don't freak out. You can also play with the "-cache" option to adjust your
buffer.

I have another player script written for Xine if anyone wants it.


Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mythtv.org/pipermail/mythtv-users/attachments/20080109/432be576/attachment.htm 


More information about the mythtv-users mailing list