Video Streaming395
Video Streaming395
Table of Contents
Introduction................................................................................................................................................1 We need CPU for compression .................................................................................................................2 We need bandwidth for distribution ........................................................................................................2 We need harddisk space for storage.........................................................................................................3 Distribution of video archives ...................................................................................................................4 Embedded solutions...................................................................................................................................6 Streaming video software..........................................................................................................................8 About the author of this document ........................................................................................................10 Video streaming terms glossary..............................................................................................................11
Introduction
Given the vast panorama of video technologies available nowadays, this research could ll up way too much paper in the attempt of covering every aspect of this eld, instead ill just try to narrow the focus to certain advanced aspects of streaming video, also trying to give a quick reference guide to the usage of selected free software. So lets rst dene the eld in which well move: streaming video provides a continuous digital video and/or audio signal across a data network. As a viewer, you typically make a web browser-based player connection to a streaming server to receive a webcast (live program) or video-on-demand (previously recorded program). The program is sent from the server to your player in a continuous way, as opposed to having the entire program downloaded before viewing can begin. In fact streaming makes the fruition of content immediate, no copy of the entire program needs to be stored on the computer being used for viewing, it is just about a stream of data being interpreted while received. The aim of this research is to highlight affordable and reliable compression technologies, transport protocols, software and hardware setups for video streaming. Emphasis is put on efcient resource allocation in terms of hardware and network usage: in any case this document will privilege the use of older technologies as it is the authors interest to recycle hardware which is often declared obsolete (marketing lie) by proprietary software employed on it.
Video streaming The computer architecture mostly taken in consideration in this research is the PC ix86 (manufactured by Intel, AMD, Transmeta and VIA among the others) for two main reasons: the Apple platform offers a non free and less exible platform for anything different from desktop publishing (still its video cutting applications are state of the art, but thats not about video streaming) while it is way less affordable and available in the south of the world, where the author comes from. Now, given the assumption that professional quality can be achieved using free software, as of the denition given by the Free Software Foundation1, the main concerns are image quality, audio/video synchronization, efcient network usage, end-user access and exibility. An up to date version of this document is made available at the internet address korova.dyne.org/video_streaming2 and is downloadable in PDF format from korova.dyne.org/video_streaming.pdf3.
1. http://www.gnu.org 2. http://korova.dyne.org/video_streaming 3. http://korova.dyne.org/video_streaming.pdf 4. on the PC, the SSE and SSE2 instruction sets can be considered as an evolution of the MMX set, also implementing accelerated 64bit oating point instructions, see the documentation on tommesani.com/Docs.html
Video streaming
here is how some of the above calculations are done: 1. 2GigaBytes of stored video /60 mins /60 secs = 596523 bytes per sec a. 2. 596523 bytes per sec /1024 = 582 KB/s (Kylobytes per sec)
596523 bytes per sec *8 = 4772184 bits per sec a. 4772184 bits per sec /1024 /1024 = 4 Mb/s (Megabits per sec)
Full quality encoding it is often meaning a bitrate of 6Mbit per second (768KB/s), which walking back thru the above calculus leads to a compression/storage ratio of 2.6Gbytes per hour on your harddisk. As we can see the bitrate is directly proportional to the space required to store the video stream. Lets focus now to the aspect of storing the video we are going to stream, or which is in turn streamed to us.
Video streaming
Video streaming
here is a diagram of our high quality video network In such a situation we distinguish 3 fundamental components of this workow: the Storage, the Encoder and the Players. The Storage is where all the recorded video is stored, it is capable of streaming on demand its "static" les to Players and it offers write access to its storage for the Encoder. The Encoder can get input from other audio/video devices and will transform it into MPEG2 format, perfect for high quality streaming and storage; the result of the transformation can be saved in the Storage and/or streamed to Players. The Players can connect to a live stream on the Encoder or play a le from the Storage, thus being able to show archived videos as well videos which are not stored but realtime converted into a playable format. This setup eager the displaced reproduction of videos on a local network, keeping all the videos stored in a central server, thus simplifying the backup of the stored videos. Last but not least it offers a wide range of possibilities to customize and automatize the playback of the Players for applications like distributed video jukebox and kiosks for browsing digital video biblioteques, being also a scalable solution for Storages which are likely to grow in future. Free software implementing the Storage and Player functions is already available: videolan is the video streaming client/server framework which should be used on every component of our setup, in order to let the MPEG2 video being streamed to Players across the network. But its still missing a software to implement some of the Encoder functionalities: a way to remote control its actions and to send the
Embedded solutions
Dynebolic GNU/Linux bootable CD
Dynebolic GNU/Linux is an operating system working directly from the CD, without the need to install or change anything on harddisk. It is an embedded solution which can easily adapt any PC computer to be a fully congured workstation ready to achieve most of the tasks being discussed here and equipped with most of the software we are going to mention in the next chapters. This operating system focuses on multimedia production, offering tools for audio and video recording, editing, playing and live manipulation; being all compiled from scratch, it takes advantage of specic binary optimizations to achieve superior performance over other generic purpose GNU/Linux distributions, often resulting in smoother processing and responsiveness on older hardware. In fact, keeping our focus on the practice of reciclyng hardware, dynebolic has a basic requirement of a PC with 200Mhz CPU and a IDE CDROM player: on such a setup it can be easily used as a comfortable surf station. When runned on a 400Mhz CPU it can be a perfect stream box for the encoding and broadcasting of a internet radio station; while it can turn a 800Mhz CPU machine into a perfect MPEG4 audio/video streaming box. All the above tasks can be solved using dynebolic without requiring any particular technical knowledge and using a low prole setup: devices for acquisition of audio and video for the tasks mentioned above range from cheap webcams and TV cards to normal audio cards with mic/line input. Being GNU GPL free software, dynebolic is free to be redistributed and is made available for internet download (as a burnable ISO raw cd image le) from its website dynebolic.org8 along with detailed documentation. You are very welcome to join and share your experience with the enthusiastic community of users and developers around it, gathered together in the [email protected] mailinglist.
Video streaming
The documentation on how to setup this card in GNU/Linux is fairly extended, the best and most direct tips are found on the IVTV wiki pages20, both for PAL and NTSC setup of the card. Example 1. setup for PAL video input MPEG2 encoding compile and install the ivtv kernel module, then copy the following lines in your /etc/modules.conf
alias char-major-81 videodev alias char-major-81-0 ivtv alias /dev/v4l ivtv options ivtv debug=0 ivtv_pal=1 options tuner type=5 pal=1 options saa7127 enable_output=1 output_select=0 pal=1 options msp3400 once=1 simple=1 add below ivtv msp3400 saa7115 saa7127 tuner add above ivtv ivtv-fb
then load the module with a simple modprobe ivtv, the /dev/video0 device will give out encoded video with a simple "cat" command, while the /dev/fb0 device will be decoding MPEG2 and can also be used as an addictional framebuffer display device.
Internet Protocol TV http://www.aminocom.com/products/aminet110.html Specs: MIPS 350 CPU with Flash memory, 10/100Eth, MPEG2 8Mb/s decoder, composite video out to 4:3 and 16:9 formats. http://ivtv.sf.net/tiki/tiki-index?page=SupportedHardware most probably the IVTV driver will be included in the 2.6 series Linux kernel. http://mythtv.sf.net http://www.videolan.org http://ivtv.writeme.ch/tiki-index.php
Video streaming The PVR price oats around 240EU while they have many of the features of other expensive competitors. The compressed video can be acquired either from live video plugged into the card (composite or s-video) or from memory mmap. 21
Video streaming Mpeg4Ip can be recommended for its stability and easy employement, being a simple yet powerful tool to produce MPEG4 streams that can be served by the popular Darwin Streaming Server distributed by Apple. It provides an intuitive graphical user interface and can record on harddisk while stream at the same time, the produced streams can be played on most platforms by commonly found players, while mpeg4ip itself provides players for multiple platforms. A remarkable feature is also the complete support for RTP/RTSP and Multicast protocol.
VideoLan
The VideoLAN project targets multimedia streaming of MPEG-1, MPEG-2, MPEG-4 and DivX les, DVDs, digital satellite channels, digital terrestial television channels and live videos on a high-bandwidth IPv4 or IPv6 network in unicast or multicast under many OSes. VideoLAN also features a cross-plaform multimedia player, VLC, which can be used to read the stream from the network or display video read locally on the computer under all GNU/Linux avours, all BSD avours, Windows, Mac OS X, BeOS, Solaris, QNX, Familiar Linux... The latter feature is one of the most important points for VideoLan, being in fact the only free software being able to ll the gaps between video and audio formats on different platforms, while its even supporting ARM and MIPS based handeld devices, being ready to be integrated in consumer-grade embedded solutions. VideoLan supports the functionalities offered by the IVTV driver, taking advantage of hardware encoding on a growing number of cards 24. It is basically made out of two software components: VideoLanClient (VLC) and VideoLanServer (VLS). VLC is a multipurpose streaming a/v client and source: it can play streams as well it can capture and send a stream to another VLC or VLS. VLS is just a server which has no visualization output for the streams it handles, its fully capable of capturing and streaming from the local machine, as well reect streams coming from other VLC/VLS nodes. The way VideoLan distributes functionalities among its nodes is therefore very exible and permits to easily build streaming topologies to distribute realtime audio/video streams for various needs.
Video streaming (pass-through) or PCM audio. More le formats and codecs for audio/video import are supported by the avile library import module (capable of using WIN32 codecs directly from .dll), the ffmpeg codec library (MPEG4, DivX family codecs, Real) while limited Quicktime export support and DVD subtitle rendering is also avaliable. In particular it can be useful for MPEG4 compression, realized thru the FFMpeg module. It supports various m$mpeg and divx formats, as well H.263. While unfortunately is still lacking support for the H.264 video codec and the AAC audio codec, due to patent pending. Honestly enough, i think that even if more efcient than other codecs, those proprietary solutions will have less and less ground for consumer grade diffusion if they will not open their policies: right now its only possible to play H.264/AAC encoded MPEG4 les on Mircosoft Windlows platform. Example 2. commandline video format conversion convert videos from MPEG2 to MPEG4, resizing to half-PAL size, encode with MP3 64Kbit/s audio and WindowsMediaPlayer compatible 300Kbit/s video:
~ #transcode -i mpeg2/video.mpg \
-y -Z -V -o
special care has to be taken with the -Z resizing ag, which has to preserve the screen size ratio in order to avoid interlaced movements in the transcoded video. More information can be obtained by reading the transcode --help | more and the man transcode help and manual page; useful is also the GTranscode26 graphical interface to Transcode which helps to form commandline formulas by schematizing the wide range of possibilities being offered.
Transcode was originally written by Thomas Oetreich and is now mantained by Tilmann Bitterberg, it links several different libraries and includes code contributed by many different researchers and programmers since june 2001.
10
Video streaming All his productions, and further informations about him, are available on his homepage RASTASOFT.org32. This document was commissioned by the Nederlands Instituut vor Mediakunst / Montevideo Time Based Arts in 2003, during a period of artistical residence in its facilities, and its being mantained and made available at the address korova.dyne.org/video_streaming33. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with the Invariant Section being the Front-Cover Text. A copy of the license is made available on the gnu.org website at the address: http://www.gnu.org/licenses/fdl.html
MPEG-1 a codec designed for near-VHS quality video. MPEG-1 is primarily designed for CD-ROM delivery of content through various media.
MPEG-2 a codec designed for high-quality video. MPEG-2 is primarily used for DVD disc encoding and other high-quality archival solutions, but can be streamed over high-bandwidth connections, such as Internet2. MPEG-2 playback often requires additional software and/or hardware.
MP3 a codec designed for audio. MP3 is the most popular standard used for distribution on the Internet and in portable music players, such as Apples iPod. Note that MP3 stands for MPEG Audio Layer 3, not MPEG-3 (there is no MPEG-3).
11
Video streaming MPEG-4 a "codec container" built around free and proprietary codecs, MPEG-4 excels at multi-architecture compatibility and efcient compression for low bandwidth streaming. Being a cross-platform container, its existance makes reduntant other platform specic container protocols: as of QuickTime, Real and WindowsMedia. The best audio/video codec tuples for MPEG4 are MP3/H.263 (widely supported on most players) and AAC/H.264 (highest efciency).
QuickTime built around several non-proprietary codecs, QuickTime excels at medium to high bandwidth clips. It supports MPEG-4.
Real built around proprietary RealNetworks codecs, Real format excels at low to medium bandwidth clips. It supports MPEG-4. Producers can use the SMIL markup language to add interactivity.
WindowsMedia build around proprietary Microsoft codecs, Windows Media excels at medium bandwidth clips. It does not correctly support the MPEG-4, but a modied version of it (MSMPEGv.3).
12