Streaming audio and video
12 March 2006 (cf. capture streams)

Status

Currently working with VLC on chianti and clitunno from file and tv card to a single computer or the whole network. To prepare the files, see compression and mencoder manual.

Works for embedded flash movies encoded with mencoder.

Software and Guides

Commands and scripts
  • stream <filename> <port>
  • streamtv <channel> <port>
  • streamcam <port>
  • killall vlc
  • if started remotely (ssh chi streamtv 28 8080), these scripts start processes that must be killed with a remote killall command (ssh chi killall vlc)
  • Gstreamer streams MPEG-4 video using RTP over UDP:
    gst-launch rtspsrc location=<rtsp location> ! rtpmp4vdepay ! ffdec_mpeg4 ! xvimagesink
VLC

vlc streaming commands
vlc -vvv run in debug mode (very useful for seeing what goes wrong)
--loop to loop
--ttl 12
time to live -- give the number of routers the signal can cross
vlc:quit at the end of a command to quit after one play
-I dummy skip the gui
dvd:/dev/hdc@1:1 play title 1 and chapter 1 of a DVD on spello
  • If the file name has a colon (I've since removed the colons from /tv5 and the script), you must give the whole path or vlc will take what comes after the colon as a path -- so for instance
vlc -vvv /tv5/2006/2006-02/2006-02-14/2006-02-14_05:00_KCET_BBC_World_News.avi
-I dummy --sout '#std{access=mmsh,mux=ts,dst=:5900}' --ttl 12 --loop
You should be able to use this feature to create an instant playlist -- but it will have to be a playlist of files without a colon in their names.
  • To control a streaming process with a browser, open “http://spello:8080/” -- you'll have  controls to manage playlists and playback remotely (not tested)
  • Single-line remote command to start a server (tested to work on chi, but should also work on spello, cybers, and trevi):

    ssh chi stream /tv5/2006/2006-02/2006-02-19/2006-02-19_0800_KNBC_Meet_the_Press.avi 5003

    This could be put on a desktop icon -- with a variable for the date in the file name and the path, which is after all just a function of the date.
  • If you give the dst (formerly url) parameter only a port address (for instance "dst=:5900"), and the server has two IP addresses, the file can be received from both IP addresses.
  • The "access=udp" works fine, for a single targeted computer, but note that the firewall does not allow udp packets through port 8080 (try 5900 or 5300)
  • The "access=mmsh" works reliably for ports 8080, 5900, and 5003
  • For the 221 subnet, you can use any port -- we're below the firewall
  • The "access=http" doesn't work reliably -- not sure what the problem is. You need to use "mux=ogg" and it sometimes works OK, but it takes longer to receive a clear picture.
  • Streaming normal-aspect files encoded using ffmpeg to h264 works flawlessly -- in fact better than xvid or DIVX files -- perhaps not surprisingly.
Stream a file to a designated machine, skip the gui:
vlc file.avi -I dummy --sout udp://128.97.221.35:8080 --loop
The more recent syntax also works -- note the single quotes, and add "vlc:quit" to quit after the file is played:
vlc file.avi -I dummy --sout '#std{access=udp,mux=ts,dst=128.97.221.35:5900}'  vlc:quit
Receive: 
vlc udp://@:8080
Stream a file to the network (again, single quotes mandatory):
vlc file.avi -I dummy --sout '#std{access=mmsh,dst=:8080}' --ttl 12 vlc:quit

vlc ~/tv/2005-12/2005-12-13/2005-12-13_23:00_KABC_Eyewitness_News.avi -I dummy --sout '#std{access=mmsh,dst=:8080}' --ttl 12 --loop
Receive:
vlc mmsh://chi:8080
Streaming to a Windows Media Player (not tested -- and clearly not as good as VLC):
vlc -vvv my_file -I dummy --sout \
'#transcode{vcodec=DIV3,vb=256,scale=1,acodec=mp3,ab=32,channels=2}\
:std{access=mmsh,mux=asfh,url=128.97.221.36:8080}'
Receive in WMP:
mms://128.97.221.36:8080

Stream from a web cam (tested and works!):
vlc -I dummy v4l:/dev/video0:size=320x240 --sout '#std{access=mmsh,dst=:8080}'

vlc v4l:/dev/video0:size=320x240 --sout '#std{access=mmsh,dst=:8080}' -V X11 -I dummy-v --noaudio

vlc -I dummy -v --noaudio --ttl 12 v4l:/dev/video0:size=320x240 --sout '#transcode{vcodec=mp4v,vb=128}:std{access=mmsh,dst=:8080}'
codec mp4v on spello: 17% of cpu
codec h264 on spello: segfaults
Receive:
vlc mmsh://spello:8080
mplayer http://spello:8080 (mplayer not working)
Stream from television (source, see also howto) -- use this to find tv channel frequencies:
scantv - scan a v4l device for TV stations
Stream tv to a single designated machine:
vlc --color v4l:/dev/video2:norm=ntsc:frequency=77250:size=640x480:channel=5:\
adev=/dev/dsp2:audio=0 --sout #transcode{vcodec=mp4v,acodec=mpga,vb=512,\
ab=128,samplerate=44100,venc=ffmpeg{keyint=80,hurry-up,vt=800000},\
deinterlace}:std{access=udp,mux=ts,dst=128.97.221.35:8080} --ttl 12 -I dummy
Receive:
vlc udp://@:8080
Stream tv to the network:
vlc --color v4l:/dev/video2:norm=ntsc:frequency=77250:size=640x480:channel=5:\
adev=/dev/dsp2:audio=0 --sout #transcode{vcodec=mp4v,acodec=mpga,vb=512,\
ab=128,samplerate=44100,venc=ffmpeg{keyint=80,hurry-up,vt=800000},\
deinterlace}:std{access=mmsh,dst=:8080} --ttl 12 -I dummy
Receive:
vlc mmsh://chi:8080
Tested and works.

Stream a DVD, title 2 and chapter 1, on spello
Works: unicast
vlc --color dvd:/dev/hdc@2:1 :sout=#std{access=udp,mux=ts,dst=128.97.221.36:1234}

Works: unicast with player control through the vlc gui on the server (pause/play)
vlc --color dvd:/dev/hdc@2:1 :sout=#duplicate{dst=std{access=udp,mux=ts,dst=128.97.221.36:1234}}

Works: unicast with player control and on-the-fly encoding (but spello can't keep up)
vlc --color dvd:/dev/hdc@2:1 :sout=#transcode{vcodec=mp4v,vb=512,scale=1,acodec=mpga,\
ab=96,channels=1}:duplicate{dst=std{access=udp,mux=ts,dst=128.97.221.36:1234}}
No luck streaming a DVD multicast.  While spello can't do the on-the-fly encoding, a faster machine would be able to.

Note that according to the list of features, you have to use ASF muxing for MMSH, and TS muxing for UDP -- the two are not interchangeable.

VLC video on demand (VOD)

See Howto
tna@chianti:~$ vlc --ttl 12 --color -I telnet --rtsp-host 128.97.221.38:8080
It requires a web server and other resources --
VOD is a very big consumer of resources for the server and the network. VOD is unicast, not multicast. This means that if 50 clients are doing VOD with the same server, watching a 5 Mbit/s MPEG 2 video, the resources needed as a minimum are the following :
  • for the VOD server : 5*50=250 Mbit/s disk access and a 250 Mbit/s connection to the backbone,
  • for the Backbone : 250 Mbit/s bandwidth,
  • for the client : 5 Mbit/s connection to the backbone."
I'll hold off for now.

ffmpeg

A user gave this streaming command on trevi:
ffmpeg -loop -flags +bitexact -dct fastint -idct simple -y -f pgmyuv -i vsynth1/%02d.pgm http://127.0.0.1:9999/feed1.ffm
The test files are in /src/ffmpeg-my/tests/vsynth1. The pgm extension means portable graymap format (grayscale), supported by ffmpeg and possibly used for streaming?

So as far as I can see, the vsynth1 files -- the pgm files -- are streamed to port 9999 on the local server, but what's the point of that and where does the data go?

For details see /etc/ffserver.conf.

MPlayer
  • Example mplayer command:

    mplayer -rtsp-stream-over-tcp rtsp://wine.codeweavers.com/wineconf-test.sdp
If you install mplayer with the realplayer codecs and get the link above working, but you want you see it in the browser do the following.
  • Get the CVS version of http://mplayerplug-in.sf.net and install it
  • Then in the $(HOME)/.mplayer/mplayerplug-in.conf file (create the file if missing) set "enable-real=1" and "rtsp-use-tcp=1"
  • Delete $(HOME)/.mozilla/pluginreg.dat
  • Restart mozilla and the video should work in the browser window

Flash

  • mtasc -- Actionscript 2 to flash (swf) compiler (now in Debian!)

Creating a Macromedia Flash video suitable for playback in a web browser with the Macromedia Flash plugin works great.

You must start with a file that does not use B-frames.  Read the file into avidemux and see the messages in console -- they will tell you if the file has B-frames. Save as HUFFYUV to remove all B-frames (it's an mpeg thing).

Then issue,

flash <input file> 500

which sets the bitrate and does the following:
mencoder input.avi -o output.flv -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc \
-lavfopts i_certify_that_my_video_stream_does_not_use_b_frames \
-lavcopts vcodec=flv:vbitrate=500:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -srate 22050
The "-of lavf" command relies on the libavformat library from the ffmpeg project, in Marillat's version from February 2006.

The resulting file plays perfectly in VLC 0.8.5-test1 and ffplay, and acceptably in mplayer. Xine plays the video but not the sound.

The files stream perfectly with a standard swf player I found on the net that embeds the flv file in a web page and gives you player controls. This works in Windows but not yet in Linux amd64 -- the swfdec player can't handle it yet. On Linux i386 it works, but the movie is extremely jerky. The main thing is it works in Windows and hopefully OSX.

To stream, use this type of html -- this assumes the player and movie are in the same directory:
<td width="60">&nbsp;</td>
<td align="center" width="210">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" height="200" width="200">
<param name="movie" value="player.swf">
<param name="quality" value="high">
<param name="FlashVars" value="svideo=flashtest.flv&amp;slength=4">
<embed src="player.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" flashvars="svideo=flashtest.flv&amp;slength=4" height="200" width="200">
</object>
</td>
The player.swf I found at MediaCollege.com (see forum) will scale with whatever size you give it -- change height and width at will.  The length appears to be ignored; you could try to set a correct length in seconds.

This gives a beautiful result in Windows and lets students play the file at will -- it's likely harder on the server than VLC multicast.

MediaCollege is also releasing the MC Media Player, check the forum for updates.

QuickTime

Quicktime allows you to start playing a movie at a particular timecode. See the info below from
http://www.apple.com/quicktime/authoring/embed2.html:

STARTTIME=time (optional...requires QuickTime 4)

The STARTTIME attribute defines the first frame of the movie. STARTTIME can
be any time within the length of the movie. By default, STARTTIME is the
first frame of the movie (or 00:00:00). This attribute takes a time value in
the form Hours:Minutes:Seconds:Frames (30ths). The frames component can be
specified as a fixed point number so that more specific times can be
specified for instance 3:30:22.5 means 3 minutes, 30 seconds and 22.5 frames.

Note: For fast start movies, the entire file is still downloaded even if a
STARTTIME is specified.

For example:

<embed src="sample.mov" width="200" height="240" starttime="00:15:22.5">

See also: ENDTIME

It should be possible to make Quicktime movies in Linux, and this may be a good format for distribution -- and possibly also for presentations.

File settings when converting the file in QuickTime Pro (you should be able to tell the script to do this with a normal QuickTime too):
codec: h264
container: mov
size: 320x240
data rate: 128kbps
frame rame: 15 (any lower starts to look choppy
audio: AAC, mono
audio rate: 24kbps (decent for speech, way better than mp3 at this rate
optimized for streaming and with 'Fast Start' enabled
There is a setting in the conversion dialogue to optimize for streaming which allows the video to stream during download as opposed to waiting for the download to complete.

Embed code - super simple, straight off the quicktime website:
 
------------------------------
echo "<OBJECT CLASSID=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" WIDTH=\"".$v_width."\" HEIGHT=\"".$v_height."\"
CODEBASE=\"http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0\"
id=\"video\">
       <PARAM NAME=\"NAME\" VALUE=\"video\">
       <PARAM NAME=\"SRC\" VALUE=\"video/".$video."\">
       <PARAM NAME=\"SCALE\" VALUE=\"".$scale."\">
       <PARAM NAME=\"AUTOPLAY\" VALUE=\"".$autoplay."\">
       <PARAM NAME=\"KIOSKMODE\" VALUE=\"TRUE\">
       <PARAM NAME=\"PLUGINSPAGE\" VALUE=\"http://www.apple.com/quicktime/download/preview/\">
       <EMBED NAME=\"video\" WIDTH=\"".$v_width."\" HEIGHT=\"".$v_height."\" SCALE=\"".$scale."\" AUTOPLAY=\"".$autoplay."\" CONTROLLER=\"TRUE\" TARGET=\"myself\" SRC=\"video/".$video."\"
PLUGINSPAGE=\"http://www.apple.com/quicktime/download/preview/\" KIOSKMODE=\"TRUE\"></EMBED>
     </OBJECT>";
-------------------------------


Cf. original.

This should allow apache to serve quicktime files -- KFA does this, not tested here. The downside is that this method doesn't seem to have a working Linux client.

Real Media

The free version is known as "RealSystem Server Basic" and supports up to 25 simultaneous users and is licensed for 12 months -- but then you have to pay lots -- the starter kit is $3,000.

Realplayer -- Video Streaming with Real Media/Video

Installation history

12 March 2006 -- streaming flash workingb

I tested the new mencoder to see if it can create flv flash movies, and it can! They play fine in ffplay and 32-bit vlc, but not 64-bit vlc:

mencoder input.avi -o output.flv -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc \
-lavfopts i_certify_that_my_video_stream_does_not_use_b_frames \
-lavcopts vcodec=flv:vbitrate=500:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -srate 22050
Set up a directory in spello:/share/media with a player I wgetted from the net somewhere, and it works! Though not in Linux amd64.  Windows is perfect, OSX hopefully also, and Linux i386 is jerky, not very good, but it plays.

I then simply copied those working files to merton, and verified I can stream flash from the 128 class site -- it just works! I set the player to be executable, not sure that was needed.

12 February 2006 -- streaming from vlc working

Stream from televison (source, see also howto) to a single designated machine:

vlc --color v4l:/dev/video2:norm=ntsc:frequency=77250:size=640x480:channel=5:\
adev=/dev/dsp2:audio=0 --sout #transcode{vcodec=mp4v,acodec=mpga,vb=512,\
ab=128,samplerate=44100,venc=ffmpeg{keyint=80,hurry-up,vt=800000},\
deinterlace}:std{access=udp,mux=ts,dst=128.97.221.35:8080} --ttl 12
This works -- chianti chugs away at 21% cpu utilization, and vlc's menu "stream and media information" shows video stream codec i420 and audio codec araw. And I can receive it:
udp://@:8080
Clear picture and sound!!! This is the first-ever streaming video I've set up. Note this is the udp protocol that broadcasts to a specific machine.

Stream from television to the network:
vlc --color v4l:/dev/video2:norm=ntsc:frequency=77250:size=640x480:channel=5:\
adev=/dev/dsp2:audio=0 --sout #transcode{vcodec=mp4v,acodec=mpga,vb=512,\
ab=128,samplerate=44100,venc=ffmpeg{keyint=80,hurry-up,vt=800000},\
deinterlace}:std{access=mmsh,dst=:8080} --ttl 12
But there's a problem -- I get "access_output_http private error: failed to create avahi client: An unexpected DBUS error occured", the same error I got on spello. This appears to be an application error; you can get fresh packages from vlc's amd64 nightly svn builds -- I got today's vlc and wxvlc and updated the libavahi files. VLC now runs -- and broadcasts!

Receive:
vlc mmsh://chi:8080
This works!

On Spello and Cyberspace, I downloaded vlc and wxvlc 0.8.5-svn20060219-0_i386 from videolan and upgraded the avahi packages.  I ran vlc on Spello first, to generate the ~./vlc files which streaming appears to require, and then copied these to cyberspace. This may mean user root will not be able to stream. I also copied the /usr/local/bin/stream script to both machines.

Streaming works flawlessly from both Spello and Cyberspace.




 

 

top
Debate
Evolution
CogSci

Maintained by Francis F. Steen, Communication Studies, University of California Los Angeles


CogWeb