{{{ #!forumlinks }}} = Example Live Feed Setups = [[TracNav(DevelopersTOC)]] On this page we will describe a couple of concrete setups from broadcasting live from different video sources[[BR]] such as a DV camera, DVB-T receiver or simple webcam. == Via Windows == In general, the simplest way of getting a feed up is via Windows and the [http://www.videolan.org/vlc/ VideoLanClient (VLC)].[[BR]] VLC can stream both DirectShow capable devices such as Webcams or DV cameras, as well as[[BR]] DVB-T cards that support the [http://www.microsoft.com/whdc/archive/broadcast.mspx Windows Broadcast Driver Architecture (BDA)].[[BR]] E.g. the [http://www.hauppauge.de/nl/site/products/data_hvr900.htmlthe Hauppauge WinTV-HVR 900H]. For BDA support you need VLC 0.9.2 or above. We'll explain how to setup VLC such that it offers a ready-to-broadcast stream for both classes: 1. Attach any DirectShow capable device to the machine. 2. Install and run VLC. 3. Select "Open Capture Device" from the File menu (called Media in vlc 0.9) === DirectShow === 4. Select the video device from the "Video device name" dropdown box (may need to press "Refresh list" first) 5. Check the "Stream/Save" box at the bottom. (or use the dropdown box next to the play button (vlc 0.9)). 6. Click the "Settings..." button at the bottom. 7. Check "Play locally" and "HTTP" 8. Select encapsulation method "MPEGTS" 9. Check and select the video and audio encoding you want (We used mp4v at 512 kbps, scale .5, no audio successfully) 10. Click OK twice === BDA / DVB-T === 4. Change the "Video capture mode" from DirectShow to "DVB DirectShow" 5. Select the DVB-type: DVB-T 6. Set the Transponder/multiplex frequency. For the Netherlands, use the "Zenderlokatie" table [http://home.planet.nl/~ploe2070/fmtv/dvbt/digitenne-kpntv.html on this page.]. The frequency must be entered in kHZ, so e.g. 618000 for Amsterdam (RAI). 7. Use the dropdown box next to the play button to select "Stream" 8. Check "Play locally" and "HTTP" 9. Select encapsulation method "MPEGTS" 10. Check and select the video and audio encoding you want. 11. Click Stream It's unclear how to select another channel. When in GUI mode you can change it via [[BR]] "Playback/Programs". You may also need to run VLC from the commandline with the composed [[BR]] command-string, rather than use the GUI. TODO: investigate the "--programs=" option. === Broadcasting === After these steps VLC now offers the video transcoded according to your settings on [[BR]] http://yourhostname:1234/ This HTTP source can be used directly by the Tribler tools to [[BR]] broadcast, as follows. You can do this on Windows, Mac or Linux, broadcasting the video [[BR]] once VLC offers it is platform independent. 1. Get the source: {{{ svn co http://svn.tribler.org/abc/branches/player-release-1.0 }}} 2. Install the required additional libraries as described in [http://svn.tribler.org/abc/branches/player-release-1.0/Tribler/readme.txt Tribler/readme.txt] 3. Set the PYTHONPATH shell variable to the current dir {{{ set PYTHONPATH=. (windows) export PYTHONPATH=. (Linux) }}} 4. Start the Tribler broadcast: {{{ python Tribler/Tools/createlivestream.py --name streamname.mpegts --source http://yourhostname:1234/ --destdir . }}} 5. If you have a bitrate other than the default (512 kbps) use the {{{--bitrate xyz}}} [[BR]] option where xyz is the bitrate in bytes per second. For high bitrates you may also want[[BR]] to change the size at which we transmit data using the {{{--piecesize xyz}}} option.[[BR]] 6. The createlivestream.py program will now write a {{{streamname.mpegts.tstream}}} file [[BR]] that you should distribute to your users. They should start their swarmplayers using this[[BR]] torrent-like file. We use this setup to broadcast from a DV camera. Note that the .tstream doesn't depend on the content. So you can reuse the same .tstream [[BR]] file for broadcasting different streams at different times, as long as its parameters[[BR]] (bitrate, piecesize, name) do not change. A special case are authenticated streams (the [[BR]] default). Here the .tstream will remain the same when the public/private keypair remains [[BR]] the same (in addition to the params). In practice, keeping the public/private keypair the [[BR]] same means you should not delete the {{{streamname.sauth}}} file that the script writes [[BR]] the first time. You can disable our default source-authentication scheme to reduce the CPU[[BR]] usage during playback. For that use the {{{Tribler/Tools/createlivestream-noauth.py}}}[[BR]] script. == DVB-T on Linux == Our first setup is a DVB-T receiver attached to a Linux box. The DVB-T is a Hauppauge [[BR]] WinTV Nova-T USB stick that is supported by Linux. We assume you have setup the stick [[BR]] correctly and can watch TV from it (e.g. {{{cat /dev/dvb/adapter0/dvr0 | vlc -}}}). You [[BR]] can now broadcast the TV signal as follows. We assume the channel information needed by[[BR]] the stick is in a file called {{{channels.conf}}} 1. Tune in to the desired channel (we do this in the background) {{{ (tzap -c channels.conf -r "SomeChannel" > /dev/null 2>&1 &) }}} 2. Start the createlivestream.py {{{ python Tribler/Tools/createlivestream.py --name streamname.mpegts --source pipe:generate-video.sh --duration 1:00:00 --port 7765 --destdir . > /tmp/dvb-t-live.log 2>&1 }}} 3. This command requires a {{{generate-video.sh}}} script in the current directory that looks like: {{{ ffmpeg -f mpegts -vsync 1 -map 0.0:0.1 -map 0.1 -i /dev/dvb/adapter0/dvr0 -vcodec mpeg4 -vb 428288 -s 320x240 -acodec libmp3lame -ab 96000 -ac 1 -f mpegts - }}} 4. In other words, FFMPEG takes the raw MPEG transport stream from the DVB-T receiver[[BR]] and transcodes it to 512 kbps of MPEG4 video and MP3 audio, synchronized on audio, and[[BR]] outputs this on stdout, so createlivestream.py can read it. 5. We have experimented with H.264 via the libx264 library, but somehow the combination[[BR]] of libx264 and current ffmpeg encoding in a pipeline gives motion prediction errors. [[BR]] Try for yourself: {{{ ffmpeg -f mpegts -vsync 1 -map 0.0:0.1 -map 0.1 -i /dev/dvb/adapter0/dvr0 -vcodec libx264 -vb 428288 -g 16 -s 320x240 -acodec libfaac -ab 96000 -ac 1 -deinterlace -f mpegts - }}} We set GOP (-g) to 16 to speedup tuning in at playback. With the default ffmpeg setting this takes a long time. 6. We did manage to get H.264 working with mencoder: {{{ mencoder -cache 8192 -ovc x264 -x264encopts bitrate=1024 -nosound -of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames:format=mpegts -vf scale=640:360 -quiet -o /dev/stdout /dev/dvb/adapter0/dvr0 }}} == VLC on Linux == For some Linux sources (e.g. IP multicast) you can use VLC to do the transcoding. [[BR]] Unfortunately, there appears to be something wrong when we try to read directly from a [[BR]] DVB-T device and try to offer it via HTTP. VLC starts as it should, but its HTTP server[[BR]] produces no data with the MPEGTS demux enabled. Here's an example for 1 mbps H.264 from a[[BR]] IP multicast source: {{{ vlc --daemon udp://@224.0.0.1:2001 --sout='#transcode{vcodec=h264,venc=x264{vbv-maxrate=512,vbv-minrate=512,qcomp=0,ratetol=0,keyint=20}vb=512,width=640,height=360,acodec=none,scodec=none,me=umh}:duplicate{dst=std{access=http,mux=ts,dst=:8081}}' :sout-all }}} == DV Camera on Linux == For [http://trial.p2p-next.org/ our first public trial] we used a DV camera connected to a remote Linux box directly. [[BR]] The remote box would grab the IEEE1394, transcode it to the right format and transmit it[[BR]] to the broadcast box via SSH. This setup is described [wiki:StreamingExperiment on another page]. == Looping a File == Newer versions of Tribler support the "--fileloop True" option for createlivestream.py that allows you to loop a file as if it were a live broadcast.