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
linux_streaming [2006/12/07 01:01]
admin
linux_streaming [2007/04/17 12:58] (current)
Line 1: Line 1:
-====== Linux Streaming ====== +[[http://smecnet.itchybit.org/wiki/gnd/linux_streaming|moved here]]
- +
-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.  +
-[[http://www.yolinux.com/TUTORIALS/LinuxTutorialAudioStreaming.html|Here]] is one simillar, but older article on audio streaming. +
- +
-===== What is Streaming ===== +
- +
-Streaming is a way how to produce and process media so that they can be seen during downloading.  +
- +
- +
- +
- +
- +
- +
- +
-==== Architecture ==== +
- +
-=== Source === +
- +
-  * Any sound input (through Alsa, Jack, OSS) +
-  * Any internal player (xmms, mp123) +
-  * Source "pushes up" the data to the repeater (darkice, oggfwd, plugins for players, etc) +
- +
-=== Repeater === +
- +
-  * Provides content for the clients +
-  * Can serve more streams at once - mountpoints +
-  * Can be in relation to other repeaters +
-  * Can be the same machine then source +
- +
- +
- +
-=== Client === +
-  +
-  * Client receives stream, decompresses, then playback +
- +
- +
- +
- +
- +
- +
- +
- +
-===== 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)). +
- +
- +
-==== Source ==== +
- +
-Any sound-input routed into the soundcard. Controllable through ALSA or OSS. Possible to steer audio in Jack. Can be also a XMMS player. There two main alternatives:  +
- +
-  * External stream-forwarder +
-  * Plugin, built-in forwarding functionality +
- +
-=== 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:  +
- +
-  * ices http://www.icecast.org/ices.php +
-  * Oddcast http://www.oddsock.org/tools +
-  * Darkice http://darkice.sourceforge.net/ +
-  * ezstream http://www.icecast.org/ezstream.php +
-  * Nicecast http://www.rogueamoeba.com/nicecast/ +
-  * IceGenerator http://sourceforge.net/projects/icegenerator +
- +
- +
-=== 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..  +
- +
-  * Muse http://muse.dyne.org +
-  * SAM2 http://www.spacialaudio.com +
-  * Orban http://www.orban.com/ +
-  * freej http://freej.org/ +
-  * Traktor http://www.native-instruments.com +
-  * PureData http://pure-data.info +
- +
- +
- +
-==== Repeater ==== +
- +
-=== Darwin Streaming Server === +
- +
-[[http://developer.apple.com/opensource/server/streaming/index.html|Darwin Streaming Server]] is a free streaming server from Apple. It should run under under Linux - from the link you can download ((to skip signing in just use [[http://www.bugmenot.com/view/daw.apple.com|bugmenot]])) the source code or packages for Fedora Core. Ill try to make it run here, then i report.  +
- +
-=== Shoutcast === +
- +
-[[http://www.shoutcast.com/download/serve.phtml|Shoutcast]] is runnable under Linux, but has a weird licence, and you get a precompiled binary. Shoutcast is able to stream only data in .mp3 format, which in itself is problematic under linux. There is no licence needed for using mp3 format for uncommercial purposes: +
- +
-<code> +
-Do I need a license to stream mp3, mp3PRO or mp3surround encoded content over the Internet? +
- +
-Yes. A license is needed for commercial (i.e., revenue-generating) use  +
-of mp3/mp3PRO in broadcast systems (terrestrial, satellite, cable and/or  +
-other distribution channels), streaming applications (via Internet,  +
-intranets and/or other networks), other content distribution systems  +
-(pay-audio or audio-on-demand applications and the like) or for use  +
-of mp3/mp3PRO on physical media (compact discs, digital versatile  +
-discs, semiconductor chips, hard drives, memory cards and the like).  +
- +
-However, no license is needed for private, non-commercial activities  +
-(e.g., home-entertainment, receiving broadcasts and creating a personal  +
-music library), not generating revenue or other consideration of any  +
-kind or for entities with associated annual gross revenue less than  +
-US$ 100 000.00.  +
-</code> +
-[[http://www.mp3licensing.com/help/index.html|source]] +
- +
-=== IceCast === +
- +
-[[http://icecast.org/|IceCast]] is open-source and distributable under GNU\GPL licence. +
- +
- +
- +
-==== Clients ==== +
- +
-  * [[http://www.foobar2000.org|foobar2000]] +
-  * [[http://www.winamp.com|winamp 2.x, 5.x]] +
-  * [[http://www.xmms.org|XMMS]] +
-  * [[http://zinf.sourceforge.net|Zinf]] +
-  * [[http://www.mplayerhq.hu|Mplayer]] +
-  * [[http://www.xinehq.de|Xine]] +
-  * [[http://www.videolan.org|VLC]] +
- +
- +
- +
- +
- +
-==== How-To ==== +
- +
-=== Server Install === +
- +
-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:  +
-<code> +
-wget http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz +
-</code> +
- +
-decompress: +
-<code> +
-tar -xzvf icecast-2.3.1.tar.gz +
-</code> +
- +
-configure && make. The path to libogg can be different on your system, and depends on YOUR settings. +
-<code> +
-./configure --with-ogg=/usr/local/lib +
-</code> +
- +
-<code> +
-make  +
-</code> +
- +
-Install: +
-<code> +
-make install +
-</code> +
- +
-edit the configuration file ((the path to the config file can be also different)) +
-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> +
-vi /usr/local/etc/icecast.xml +
-</code> +
- +
-Now just run icecast +
-<code> +
-icecast -c /usr/local/etc/icecast.xml +
-</code> +
- +
-Depends on settings but the admin interface is on http://ip-of-server:8000/admin/ +
- +
-source "puts up" the data, with a password, then mounts it on some mountpoint. The mountpoint is accessible through: http://ip-of=server:8000/mountpoint_name +
- +
-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. +
- +
-=== Server config === +
- +
-Here you can see the icecast config of [[http://www.tlis.sk|Tlis Students Radio]] that we use: +
- +
-<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: +
- +
-<code> +
-# this section describes general aspects of the live streaming session +
-[general] +
-duration        = 0        # duration of encoding, in seconds. 0 means forever +
-bufferSecs      = 5         # size of internal slip buffer, in seconds +
- +
-# this section describes the audio input that will be streamed +
-[input] +
-device          = /dev/dsp  # OSS DSP soundcard device for the audio input +
-sampleRate      = 44100    # sample rate in Hz. try 11025, 22050 or 44100 +
-bitsPerSample   = 16        # bits per sample. try 16 +
-channel         = 1         # channels. 1 = mono, 2 = stereo +
- +
-# this section describes a streaming connection to an IceCast2 server +
-# there may be up to 8 of these sections, named [icecast2-0] ... [icecast2-7] +
-# these can be mixed with [icecast-x] and [shoutcast-x] sections +
-[icecast2-0] +
-bitrateMode     = abr       # average bit rate +
-format          = vorbis    # format of the stream: ogg vorbis +
-bitrate         = 48       # bitrate of the stream sent to the server +
-quality         = 0.9 +
-#sampleRate     = 16000 +
-server          = tlis.sk +
-port            = 8000      # port of the IceCast2 server, usually 8000 +
-username        = source +
-password        = ******    # source password to the IceCast2 server +
-mountPoint      = live.ogg  # mount point of this stream on the IceCast2 server +
-name            = IRS TLIS LIVE +
-description     = College Radio Bratislava, Slovakia >> www.tlis.sk +
-url             = http://www.tlis.sk/ +
-genre           = Mixed    # genre of the stream +
-public          = yes       # advertise this stream? +
- +
-[icecast2-1] +
-bitrateMode     = abr       # average bit rate +
-format          = vorbis    # format of the stream: ogg vorbis +
-bitrate         = 128        # bitrate of the stream sent to the server +
-quality         = 0.9 +
-#sampleRate     = 16000 +
-server          = tlis.sk +
-port            = 8000      # port of the IceCast2 server, usually 8000 +
-username        = source +
-password        = *******    # source password to the IceCast2 server +
-mountPoint      = live_128.ogg  # mount point of this stream on the IceCast2 server +
-name            = IRS TLIS LIVE +
-description     = College Radio Bratislava, Slovakia >> www.tlis.sk +
-url             = http://www.tlis.sk/ +
-genre           = Mixed    # genre of the stream +
-public          = yes       # advertise this stream? +
- +
-</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. 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)) +
- +
- +
- +
-===== 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. +
- +
-==== Structure ==== +
- +
-=== Source === +
- +
-various...  +
- +
-=== Repeater === +
- +
-we will use libtheora and libvorbis enabled IceCast streaming server +
- +
-=== Client === +
- +
-various, see above which can playback video..  +
- +
- +
- +
- +
- +
- +
-==== How-to ==== +
- +
- +
-=== Source === +
- +
-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]] +
- +
-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: +
-<code> +
-dvgrab --format raw - | ffmpeg2theora -a 0 -v 5 -f dv -x 320 -y 240 -o /dev/stdout +
-</code> +
- +
-We install another utility called [[http://www.v2v.cc/~j/ffmpeg2theora/oggfwd/|oggfwd]] and send the stdout to theora-enabled icecast server: +
- +
-<code> +
-dvgrab --format raw - | ffmpeg2theora -a 0 -v 5 -f dv -x 320 -y 240 -o /dev/stdout - | oggfwd  icecastserver  8000 pwd /theora.ogg +
-</code> +
-where icecastserver - is the url of our streaming server +
- +
-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 +
- +
- +
-=== 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):  +
- +
-Get libvorbis: +
-<code> +
-wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.1.2.tar.gz +
-</code> +
- +
-Get libtheora: +
-<code> +
-wget http://downloads.xiph.org/releases/theora/libtheora-1.0alpha7.tar.gz +
-</code> +
- +
-then recompile icecast with these options (the exact location of the libs depends on YOUR settings) +
-<code> +
-./configure --with-ogg=/usr/local/lib --with-vorbis=/usr/local/lib --with-theora=/usr/local/lib +
-</code> +
- +
-=== Client === +
linux_streaming.1165449717.txt.gz · Last modified: 2007/04/17 12:58 (external edit)