This shows you the differences between two versions of the page.
linux_streaming [2006/12/13 11:57] admin |
linux_streaming [2007/04/17 12:58] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== 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. | ||
- | [[http:// | ||
- | |||
- | ===== What is Streaming ===== | ||
- | |||
- | 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, | ||
- | 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' | ||
- | 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:// | ||
- | |||
- | ==== 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. | ||
- | |||
- | |||
- | === Source === | ||
- | |||
- | * Any sound or video input (through Alsa, Jack, Oss, IEE1394, V4l) | ||
- | * Any internal player (xmms, mp123, VLC) | ||
- | * Source " | ||
- | |||
- | === 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, | ||
- | |||
- | |||
- | ===== Audio Streaming ===== | ||
- | |||
- | 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, | ||
- | |||
- | |||
- | ==== 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 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: | ||
- | |||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | |||
- | |||
- | === Built-in stream-forwarder === | ||
- | |||
- | 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. | ||
- | |||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | |||
- | |||
- | |||
- | ==== Repeater ==== | ||
- | |||
- | === Darwin Streaming Server === | ||
- | |||
- | [[http:// | ||
- | |||
- | === Shoutcast === | ||
- | |||
- | [[http:// | ||
- | |||
- | < | ||
- | 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, | ||
- | 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, | ||
- | 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. | ||
- | </ | ||
- | [[http:// | ||
- | |||
- | === IceCast === | ||
- | |||
- | [[http:// | ||
- | |||
- | |||
- | ==== Clients ==== | ||
- | |||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | ==== How-To ==== | ||
- | |||
- | === Server Install === | ||
- | |||
- | First of we should have a streaming server allready installed and at our disposal. If true, goto [[linux_streaming# | ||
- | |||
- | get the new libogg: | ||
- | < | ||
- | wget http:// | ||
- | </ | ||
- | |||
- | decompress: | ||
- | < | ||
- | tar -xzvf icecast-2.3.1.tar.gz | ||
- | </ | ||
- | |||
- | configure && make. The path to libogg can be different on your system, and depends on YOUR settings. | ||
- | < | ||
- | ./configure --with-ogg=/ | ||
- | </ | ||
- | |||
- | < | ||
- | make | ||
- | </ | ||
- | |||
- | Install: | ||
- | < | ||
- | make install | ||
- | </ | ||
- | |||
- | edit the configuration file ((the path to the config file can be also different)) | ||
- | More to the config-file options [[linux_streaming# | ||
- | < | ||
- | vi / | ||
- | </ | ||
- | |||
- | Now just run icecast | ||
- | < | ||
- | icecast -c / | ||
- | </ | ||
- | |||
- | Depends on settings but the admin interface is on http:// | ||
- | |||
- | source "puts up" the data, with a password, then mounts it on some mountpoint. The mountpoint is accessible through: http:// | ||
- | |||
- | 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 is an an example of an icecast configuration file, used for the streaming server of [[http:// | ||
- | |||
- | < | ||
- | |||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | </ | ||
- | |||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | </ | ||
- | |||
- | |||
- | < | ||
- | < | ||
- | < | ||
- | </ | ||
- | < | ||
- | < | ||
- | < | ||
- | </ | ||
- | |||
- | < | ||
- | |||
- | < | ||
- | < | ||
- | </ | ||
- | |||
- | < | ||
- | |||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | <alias source="/" | ||
- | </ | ||
- | |||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | </ | ||
- | |||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | </ | ||
- | </ | ||
- | </ | ||
- | |||
- | </ | ||
- | |||
- | === Source Setup === | ||
- | |||
- | As an stream forwarder we will use [[http:// | ||
- | |||
- | < | ||
- | # this section describes general aspects of the live streaming session | ||
- | [general] | ||
- | duration | ||
- | bufferSecs | ||
- | |||
- | # this section describes the audio input that will be streamed | ||
- | [input] | ||
- | device | ||
- | sampleRate | ||
- | bitsPerSample | ||
- | channel | ||
- | |||
- | # 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 | ||
- | format | ||
- | bitrate | ||
- | quality | ||
- | # | ||
- | server | ||
- | port = 8000 # port of the IceCast2 server, usually 8000 | ||
- | username | ||
- | password | ||
- | mountPoint | ||
- | name = IRS TLIS LIVE | ||
- | description | ||
- | url = http:// | ||
- | genre = Mixed # genre of the stream | ||
- | public | ||
- | |||
- | [icecast2-1] | ||
- | bitrateMode | ||
- | format | ||
- | bitrate | ||
- | quality | ||
- | # | ||
- | server | ||
- | port = 8000 # port of the IceCast2 server, usually 8000 | ||
- | username | ||
- | password | ||
- | mountPoint | ||
- | name = IRS TLIS LIVE | ||
- | description | ||
- | url = http:// | ||
- | genre = Mixed # genre of the stream | ||
- | public | ||
- | |||
- | </ | ||
- | |||
- | After modification we just run darkice -c / | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | ===== Video Streaming ===== | ||
- | |||
- | Video streaming under Linux was, for licencing issues a bit weak, until [[http:// | ||
- | |||
- | |||
- | ==== Structure ==== | ||
- | |||
- | === Source === | ||
- | |||
- | * IEE1394 (FireWire Input), Video4Linux devices, video files | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | |||
- | === Repeater === | ||
- | |||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | |||
- | === Client === | ||
- | |||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[https:// | ||
- | * [[http:// | ||
- | * etc.. | ||
- | |||
- | |||
- | |||
- | ==== 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 utility called [[http:// | ||
- | |||
- | 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 to standard-out: | ||
- | < | ||
- | dvgrab --format raw - | ffmpeg2theora -a 0 -v 5 -f dv -x 320 -y 240 -o /dev/stdout | ||
- | </ | ||
- | |||
- | We install another utility called [[http:// | ||
- | |||
- | < | ||
- | dvgrab --format raw - | ffmpeg2theora -a 0 -v 5 -f dv -x 320 -y 240 -o /dev/stdout - | oggfwd | ||
- | </ | ||
- | where **icecastserver** - is the url of our streaming server\\ | ||
- | **8000** - can be any number for port number of icecast listener\\ | ||
- | **pwd** - password\\ | ||
- | **/ | ||
- | |||
- | |||
- | === Server === | ||
- | |||
- | To use the Ogg/Theora options, we will need an [[http:// | ||
- | |||
- | Get libtheora: | ||
- | < | ||
- | wget http:// | ||
- | </ | ||
- | |||
- | then recompile icecast with these options (the exact location of the libs depends on YOUR settings) | ||
- | < | ||
- | ./configure --with-ogg=/ | ||
- | </ | ||
- | |||
- | === Client === | ||