User Tools

Site Tools


linux_streaming

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
linux_streaming [2006/12/06 23:46]
admin
linux_streaming [2006/12/13 12:09]
admin
Line 1: Line 1:
 ====== Linux Streaming ====== ====== Linux Streaming ======
  
-This is a note-scrape-no-paper-book for a paper i should submit to get my credits for the class. Its mainly about streaming under linux. +Hello, this is a note-scrape-no-paper-book for a paper i should submit for class on my universityIt is about streaming under linux. I will slowly develop it also after submitting it, as streaming is of big interest for me.\\ 
 +I work for [[http://www.tlis.sk|Tlis]] which is a internet-students radio, where i maintain the streaming server, and also manage programming. I am also a founding member of [[http://itchybit.org|Itchy Bit]], ((website is down because of lame registrant;)) organization and platform for promoting hybrids of arts, social activity and technology.\\ 
 + 
 +[[http://www.yolinux.com/TUTORIALS/LinuxTutorialAudioStreaming.html|Here]] is one simillar, but older article focused on audio streaming under Linux.
  
 ===== What is Streaming ===== ===== What is Streaming =====
  
-Streaming is a way how to produce and process media so that they can be seen during downloading. +Streaming is a way how to produce and process media so that they can be seen during downloading. To be able to do this the media has to be compressed to achieve a good speed. There are severall codecs which do the compression, and in this wiki we will pay more attention to the free ones.\\ 
 +Streaming content is delivered through the network, and there are three man types of delivering it: unicast, broadcast and multicast. There are terms used also anywhere where routing comes into play. Unicast just transmits data to a single point. Broadcast and Multicast transmit data to many points at once. The difference is, that broadcast sends a copy of the stream to every single user who wants it, while Multicast works so, that it sends out only a single copy at a time, which is copied for various users along the way to them. This needs a lot of computation from the side of routers, so the majority of Internet backbone routers has Multicast disabled, even though the paradigm is known since late 80's.\\ 
 +Multicast is used mainly in company private networks for e-learning and e-conferencing. Broadcast is nowadays the most used way how to send streamed media to the users. It is also ineffective in that sense, that when 10000 people want to see your stream at once (at a given bitrate), you have to have a connection to the internet which can handle 10000*bitrate throughput.\\ 
 +Another emerging way of delivering streaming data is swarm streaming. It utilizes the ideas behind the bittorent technology - the media is sent to severall people at once, each of whom gets a different part of the streamed media, and they communicate and exchange the parts between themselves. In this way the streaming point doesnt need a good connection in cases of big interest. One nice open-source example is [[http://tribler.org/test_streaming/index.php|Tribler Streaming]].
  
 +==== Architecture ====
  
 +The architecture is an abstract structure of streaming solutions. It usually consists of three independet points: source, repeater and the receiving client. In this way, the source can be on a slow link, just pushing data to a repeater which is conneced to a broad-enough link. The communication between all the members uses the ip protocol, and mostly UDP, but that depends on the solution.
  
- 
- 
- 
- 
-==== Architecture ==== 
  
 === Source === === Source ===
  
-  * Any sound input (through Alsa, Jack, OSS+  * Any sound or video input (through Alsa, Jack, Oss, IEE1394, V4l
-  * Any internal player (xmms, mp123)+  * Any internal player (xmms, mp123, VLC)
   * Source "pushes up" the data to the repeater (darkice, oggfwd, plugins for players, etc)   * Source "pushes up" the data to the repeater (darkice, oggfwd, plugins for players, etc)
  
Line 27: Line 30:
   * Can be in relation to other repeaters   * Can be in relation to other repeaters
   * Can be the same machine then source   * Can be the same machine then source
- 
- 
  
 === Client === === Client ===
    
-  * Client receives stream, decompresses, then playback +  * Client receives stream, decompresses, playback
- +
- +
- +
- +
- +
  
  
 ===== Audio Streaming ===== ===== Audio Streaming =====
  
-In this section we cover two main forms of audio streaming under linux: mp3 and ogg. We will not pay attention to other formats, like realmedia or windows media. Quicktime is a possibility ((have to check how is it with its freeness and openness)).+In this section we cover two main forms of audio streaming under linux: mp3 and ogg. We will use the Icecast Streaming Server as an repeater. We will not pay attention to other formats, like realmedia or windows media. Quicktime is a possibility, since Darwin Streaming Server is free to download from Apple. ((have to check how is it with its freeness and openness)).
  
  
Line 55: Line 50:
 === External stream-forwarder === === External stream-forwarder ===
  
-In case of sound you use various softwares, icecast people have released a number of ices bindings to different programming languages, so the possibilities are broad. The most used are: +In case of sound you can use various softwares, icecast people have released a number of ices bindings to different programming languages, so the possibilities are broad. The most used are: 
  
-  * ices http://www.icecast.org/ices.php +  * [[http://www.icecast.org/ices.php|ices]] 
-  * Oddcast http://www.oddsock.org/tools +  * [[http://www.oddsock.org/tools|Oddcast]] 
-  * Darkice http://darkice.sourceforge.net/ +  * [[http://darkice.sourceforge.net/|Darkice]] 
-  * ezstream http://www.icecast.org/ezstream.php +  * [[http://www.icecast.org/ezstream.php|ezstream]] 
-  * Nicecast http://www.rogueamoeba.com/nicecast/ +  * [[http://www.rogueamoeba.com/nicecast/|Nicecast]] 
-  * IceGenerator http://sourceforge.net/projects/icegenerator+  * [[http://sourceforge.net/projects/icegenerator|IceGenerator]]
  
  
 === Built-in stream-forwarder === === Built-in stream-forwarder ===
  
-In case of various music products, the capability to send out the data to a streaming-server is allready built-in or in the possibillity of plugins.  An example is the player Xmms, where you can install a plugin sending the played music irectly to the Streaming server. Another example is Muse software, or software for music production like pure-data.. +In case of various music-playing or music-producing products, the capability to send out the data to a streaming-server is allready built-in or uses the possibillity of plugins.  An example is the player Xmms, for which exists a plugin sending the played music directly to the Streaming server. Another example is Muse software, or software for music production like pure-data.. 
  
-  * Muse http://muse.dyne.org +  * [[http://muse.dyne.org|Muse]] 
-  * SAM2 http://www.spacialaudio.com +  * [[http://www.spacialaudio.com|SAM2]] 
-  * Orban http://www.orban.com/ +  * [[http://www.orban.com/|Orban]] 
-  * freej http://freej.org/ +  * [[http://freej.org/|Freej]] 
-  * Traktor http://www.native-instruments.com +  * [[http://www.native-instruments.com|Traktor]] 
-  * PureData http://pure-data.info+  * [[http://pure-data.info|PureData]]
  
  
Line 109: Line 104:
 === IceCast === === IceCast ===
  
-[[http://icecast.org/|IceCast]] is open-source and distributable under GNU\GPL licence. +[[http://icecast.org/|IceCast]] is open-source and distributable under GNU\GPL licence. It is the most used open-souce streaming server nowadays. It has a nice and simple functionality, is reliable and robust and can stream audio as well as video formats. 
  
  
Line 122: Line 116:
   * [[http://www.xinehq.de|Xine]]   * [[http://www.xinehq.de|Xine]]
   * [[http://www.videolan.org|VLC]]   * [[http://www.videolan.org|VLC]]
 +
 +
 +
  
  
Line 127: Line 124:
 ==== How-To ==== ==== How-To ====
  
-=== Server ===+=== Server Install ===
  
-First of we should have a streaming server allready installed and at our disposal. If true, goto [[linux_streaming#Audio Streaming:how-to:source|here]]. If not, we will install our streaming server now. I chose IceCast.+First of we should have a streaming server allready installed and at our disposal. If true, goto [[linux_streaming#source setup|here]]. If not, we will install our streaming server now. I chose IceCast.
  
-get the new libogg: +get the libogg: 
 <code> <code>
 wget http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz wget http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz
 +</code>
 +
 +get the libvorbis:
 +<code>
 +wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.1.2.tar.gz
 </code> </code>
  
Line 156: Line 158:
  
 edit the configuration file ((the path to the config file can be also different)) edit the configuration file ((the path to the config file can be also different))
-More to the config-file options soonor just [[http://www.icecast.org/docs/icecast-2.3.1/icecast2_config_file.html|RTFM]]+More to the config-file options [[linux_streaming#server config|here]]consult it with the [[http://www.icecast.org/docs/icecast-2.3.1/icecast2_config_file.html| Icecast Documentation]]
 <code> <code>
 vi /usr/local/etc/icecast.xml vi /usr/local/etc/icecast.xml
Line 172: Line 174:
 Icecast is able to stream .ogg streams and also mp3. Newest addistions include the Theora library which is used for streaming video in ogg/theora format. Icecast is able to stream .ogg streams and also mp3. Newest addistions include the Theora library which is used for streaming video in ogg/theora format.
  
-=== Source ===+=== Server config === 
 + 
 +Here is an an example of an icecast configuration file, used for the streaming server of [[http://www.tlis.sk|Tlis Students Radio]] where i work: 
 + 
 +<code> 
 + 
 +<icecast> 
 +    <limits> 
 +        <clients>1000</clients> 
 +        <sources>5</sources> 
 +        <threadpool>8</threadpool> 
 +        <queue-size>262144</queue-size> 
 +        <client-timeout>30</client-timeout> 
 +        <header-timeout>15</header-timeout> 
 +        <source-timeout>10</source-timeout> 
 +        <burst-on-connect>1</burst-on-connect> 
 +        <burst-size>65535</burst-size> 
 +    </limits> 
 + 
 +    <authentication> 
 +        <source-password>*****</source-password> 
 +        <relay-password>******</relay-password> 
 +        <admin-user>*****</admin-user> 
 +        <admin-password>*****</admin-password> 
 +    </authentication> 
 + 
 + 
 +    <directory> 
 +        <yp-url-timeout>15</yp-url-timeout> 
 +        <yp-url>http://dir.xiph.org/cgi-bin/yp-cgi</yp-url> 
 +    </directory> 
 +    <directory> 
 +        <yp-url-timeout>15</yp-url-timeout> 
 +        <yp-url>http://www.oddsock.org/cgi-bin/yp-cgi</yp-url> 
 +    </directory> 
 + 
 +    <hostname>tlis.sk</hostname> 
 + 
 +    <listen-socket> 
 +        <port>8000</port> 
 +    </listen-socket> 
 + 
 +  <fileserve>1</fileserve> 
 + 
 +    <paths> 
 +        <basedir>/opt/icecast</basedir> 
 +        <logdir>/log</logdir> 
 +        <webroot>/share/icecast/web</webroot> 
 +        <adminroot>/share/icecast/admin</adminroot> 
 +        <alias source="/" dest="/status.xsl"/> 
 +    </paths> 
 + 
 +    <logging> 
 +        <accesslog>access.log</accesslog> 
 +        <errorlog>error.log</errorlog> 
 +        <loglevel>4</loglevel> <!-- 4 Debug, 3 Info, 2 Warn, 1 Error --> 
 +    </logging> 
 + 
 +    <security> 
 +        <chroot>1</chroot> 
 +        <changeowner> 
 +            <user>icecast</user> 
 +            <group>nogroup</group> 
 +        </changeowner> 
 +    </security> 
 +</icecast> 
 + 
 +</code> 
 + 
 +=== Source Setup ===
  
-As an stream forwarder we will use darkice.. Its robust, command-line orientated, and fast. We compile darkice from the sources. The we just modify an .conf file, for example /etc/darkice.conf:+As an stream forwarder we will use [[http://darkice.tyrell.hu/|darkice]]. Its robust, command-line orientated, and fast. It can be used to send data to IceCast, Shotcast and Darwin Streaming Server. We compile darkice from the sources. There are some libraries needed. The we just modify an .conf file, for example /etc/darkice.conf:
  
 <code> <code>
Line 228: Line 299:
 </code> </code>
  
-After modification we just run darkice -c /etc.darkice.cfg, and everything we receive in the input device (/dev/dsp) is being forwarded to our streaming server.+After modification we just run darkice -c /etc/darkice.cfg, and everything we receive in the input device (/dev/dsp) is being forwarded to our streaming server. So lets put something into the input device :) The best and easiest way is to run an XMMS and just play some music. If you want to mix it, it is better to try some mixing software, for example [[http://mixxx.sourceforge.net/|mixxx]] ((an open-ource alternative to Traktor)) 
 + 
  
  
Line 234: Line 307:
 ===== Video Streaming ===== ===== Video Streaming =====
  
-Video sreaming under Linux was, for licencing issues a bit weak, until the fabulous libtheora came and with it the OGG/Theora format. This is now something like the flagship of linux video streaming, so we will cover only this option.+Video streaming under Linux was, for licencing issues a bit weak, until [[http://xiph.org|Xiph Foundation]] came with **libtheora**  and with it the OGG/Theora format. As Theora is built upon a free video-codec, which can be fitted into any container. The most used "container" is the OGG format, which when using with Ogg/Vorbis audio, gives a completely free multimedia streaming format. This is now something like the flagship of open-source streaming, so we will cover only this option. 
  
 ==== Structure ==== ==== Structure ====
Line 240: Line 314:
 === Source === === Source ===
  
-various... +  * IEE1394 (FireWire Input), Video4Linux devices, video files 
 +  * [[http://ffmpeg.mplayerhq.hu/|FFMpeg]] - most robust solution 
 +  * [[http://videolan.org|VLC]] - can encode from anything it plays, also from other streams 
 +  * [[http://freej.org/|FreeJ]] - you can mix video inputs and effect them
  
 === Repeater === === Repeater ===
  
-we will use libtheora and libvorbis enabled IceCast streaming server+  * [[http://icecast.org|IceCast Streaming Server]] 
 +  * [[http://www.flumotion.net/|FluMotion]] 
 +  * [[http://videolan.org|VLS]] 
 +  * [[http://www.freecast.org/|FreeCast]]
  
 === Client === === Client ===
  
-various, see above which can playback video..  +  * [[http://videolan.org|VLC]] 
 +  * [[http://www.mplayerhq.hu/|Mplayer]] 
 +  * [[https://player.helixcommunity.org/|Helix Player]] 
 +  * [[http://xinehq.de/|Xine]] 
 +  * etc..
  
  
Line 262: Line 345:
 You need to have either the video on your harddisk, or for live streaming, a FireWire compatible Camera, and firewire enabled in linux. I will not go into this, but it is the main source of problems, when the ieee1394 is not working.  You need to have either the video on your harddisk, or for live streaming, a FireWire compatible Camera, and firewire enabled in linux. I will not go into this, but it is the main source of problems, when the ieee1394 is not working. 
  
-When you have the firewire up & ready, get and install the utikity called [[http://www.v2v.cc/~j/ffmpeg2theora/|ffmpeg2theora]]. Examples how to use it are [[http://www.v2v.cc/~j/ffmpeg2theora/examples.html|here]]+When you have the firewire up & ready, get and install the utility called [[http://www.v2v.cc/~j/ffmpeg2theora/|ffmpeg2theora]]. Examples how to use it are [[http://www.v2v.cc/~j/ffmpeg2theora/examples.html|here]]
  
 We pretend we have ieee1394 running. We should have also installed dvgrab: We pretend we have ieee1394 running. We should have also installed dvgrab:
  
-This grabs the input from firewire, converts it to .ogg and sends output standard out:+This grabs the input from firewire, converts it to .ogg and sends output to standard-out:
 <code> <code>
 dvgrab --format raw - | ffmpeg2theora -a 0 -v 5 -f dv -x 320 -y 240 -o /dev/stdout dvgrab --format raw - | ffmpeg2theora -a 0 -v 5 -f dv -x 320 -y 240 -o /dev/stdout
Line 276: Line 359:
 dvgrab --format raw - | ffmpeg2theora -a 0 -v 5 -f dv -x 320 -y 240 -o /dev/stdout - | oggfwd  icecastserver  8000 pwd /theora.ogg dvgrab --format raw - | ffmpeg2theora -a 0 -v 5 -f dv -x 320 -y 240 -o /dev/stdout - | oggfwd  icecastserver  8000 pwd /theora.ogg
 </code> </code>
-where icecastserver - is the url of our streaming server +**icecastserver** - is the url of our streaming server\\ 
- +**8000** - can be any number for port number of icecast listener\\ 
-8000 - can be any number for port number of icecast listener +**pwd** - password\\ 
- +**/theora.ogg** - mountpoint where we wish to have the video stream accesible
-pwd - password +
- +
-/theora.ogg - mountpoint where we wish to have the video stream accesible+
  
  
 === Server === === Server ===
  
-To use the Ogg/Theora options, we will need an libvorbis and libtheora enabled installation of IceCast Streaming Server. We download the additional libraries (we expect that we have allready installed libogg):  +To use the Ogg/Theora options, we will need an [[http://www.theora.org/|libtheora]] enabled installation of IceCast Streaming Server. We download the additional libraries (we expect that we have allready installed libogg and libvorbis): 
- +
-Get libvorbis: +
-<code> +
-wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.1.2.tar.gz +
-</code>+
  
 Get libtheora: Get libtheora:
Line 303: Line 378:
 ./configure --with-ogg=/usr/local/lib --with-vorbis=/usr/local/lib --with-theora=/usr/local/lib ./configure --with-ogg=/usr/local/lib --with-vorbis=/usr/local/lib --with-theora=/usr/local/lib
 </code> </code>
 +
 +All other options and setup is the same as with Audio. If you allready have IceCast installed, then just recompile, and thats all. 
  
 === Client === === Client ===
 +
 +Setup of the desired player depends on the user ;) If you finally found the player dear to your heart, just open the url: http://ip_of_streaming_server:8000/mount_point.ogg\\
 +
 +Enjoy! :)
  
linux_streaming.txt · Last modified: 2007/04/17 12:58 (external edit)