You are in Home page » Documentation

Soluzione integrata di telefonia su internet a banda larga.
Search on this site:  

Are you interested to be updated about all things happens to me day by day?
Visit my new blog

Streaming Howto

Abstract:

Short guide to realize a audio/video streaming. This guide has been used to realize the audio/video streaming during the  LinuxDay 2004 event.

This document is work in progress and it could have mistaken. Let me know if you found problems.

Introduction

To produce the streaming it has been used the ffmpeg/ffserver platform

Why?

  1. It's OpenSource

  2. It supports many input and output formats

  3. It practically supports all the client from Mplayer to Windows Media Player

  4. It supports Video4Linux and therefore it adapted with all the acquisition cards video

P.S. The streaming made with VideoLan works alone if also client is VideoLan and has a very very very low number of supported acquisition cards .

I made test on RedHat9, Fedora Core 1, Mandrake 10,0, Slackware 10 platforms and at the end I decided to use Slackware 10 because, as an example, on the test box  (Pentium II 800), in a situation in which the server is an encoder server and a client listen to, on Mandrake the load of the box was of 1.00 while on Slackware, in the same conditions, load was 0.60.

How to implement the system.

The first idea was  to distribute the load on two box, a (Pentium II 800), with acquisition card and ffmpeg that it sends the videoflow , and a Pentium IV 2600, with ffserver, that it recive the flow video in order to redistribute it to clients that they had made request. Unfortunately, in all tests made, except in one case, with two Mandrake boxs, the ffserver went in segfault in the first client request, and so, at the end, it has been decided to put all on a Pentium IV and to make to run ffmpeg and ffserver on the same box, than however, from tests carried out, it always remains under a load of 0.4.

Configuration

As first step, it is necessary to make to work the acquisition card video that, in our case, was an Hauppauge WinTV with chipset BT878.

The module bttv.o is always correctly be loaded in any kernel > 2.4.24 and 2.6.9. The interface has recognized correctly and the card ihas been activated as /dev/video0. Only in the Mandrake distribution it has been necessary to configure by hands  the modprobe bttv command in the modules.conf. Instead in Slackware the hotplug demon found correctly the card but, in this case, it has been necessary to configure in the hotplug blacklist the audio module of the bttv that, otherwise, it was in conflict with the true audio card of server.

In order to configure the WinTV card properties (to select the corrected input, to see what it was looked at, etc.) it has been downloaded and installed XawTV so to select the video source from which to read the flow video, once the source was selected, you can also close this program. It's possible at the same time to hold open XawTV and the ffmpeg acquisition, because it does not be in conflict and neither the first nor the second program lock the video device, ah, the power of Linux: -)

Compile and installe XawTV with these lines:

# /configure
# make; make install

 

Before download ffmpeg, a tip. Some distribution, as Mandrake, already have a package for the ffmpeg. Not trusted, but download and compilate from source. As an example, the standard package with Mandrake has not activated the support for the mp3 audio and therefore only mp2 can be sent with consequent incompatibility with many clients.

Before downloading ffmpeg, to have mp3 audio support, we must download and install the mp3lame linrary.

# wget ttp://puzzle.dl.sourceforge.net/sourceforge/lame/lame-3.96.1.tar.gz
# tar zxvf blades-3.96.1.tar.gz
# cd blades-3.96.1
# /configure -- prefix=/usr
# make
# make install

 

Now we are ready to download and install ffmpeg with the support mp3. I tried, owing to a sigfault, many ffmpeg versions, also the CVS, but the stablest it is the 0.4.8, for which I decided to used this one

# wget http://puzzle.dl.sourceforge.net/sourceforge/ffmpeg/ffmpeg-0.4.8.tar.gz
# tar zxvf ffmpeg-0.4.8.tar.gz
# cd ffmpeg-0.4.8
# /configure -- enable-mp3lame -- prefix=/usr -- enable-pthreads
# make
# make install

 

Ok, now we must create the configuration file in /etc/ffserver.conf.

This is what we used [ comment more options][this is not the definitive one][add comments in more pretty way ]

  • FileMaxSize 10G so to have the complete video of the event for postprocessing and having the events online for future, even after having split them in more files, one for every event.

  • Feed in avi and asf because Windows Media Player does not understand the avi streaming  and therefore, for it required a feed for it. Other clients read all, but it seemed ugly to make the LinuxDay with based only on MS Mpeg4 codec : -)

Port 80
BindAddress 0.0.0.0
MaxClients 1000
MaxBandwidth 2000
CustomLog -
NoDaemon

<Feed ld2004.ffm>
Rows /tmp/ld2004.ffm
FileMaxSize 10G
# Only allow connections from localhost to the feed
ACL allow 127.0.0.1
</Feed>

<Stream ld2004_high.avi>
Feed ld2004.ffm
Format grandfathers
AudioBitRate 64
AudioChannels 1
VideoBitRate 256
VideoFrameRate 15
VideoSize cif
AudioCodec mp3
VideoCodec mpeg4
VideoQMin 3
VideoQMax 31
VideoHighQuality
VideoGopSize 30
</Stream>

<Stream ld2004_low.avi>
Feed ld2004.ffm
Format grandfathers
AudioBitRate 32
AudioChannels 1
VideoBitRate 32
VideoFrameRate 15
VideoSize qcif
AudioCodec mp3
VideoCodec mpeg4
VideoQMin 3
VideoQMax 31
VideoHighQuality
VideoGopSize 30
</Stream >

<Stream ld2004_low.asf>
Feed ld2004.ffm
Format asf
AudioBitRate 32
VideoFrameRate 15
VideoSize qcif
VideoBitRate 32
VideoGopSize 30
VideoCodec msmpeg4v2
AudioCodec mp3
VideoHighQuality
StartSendOnKey
</Stream>

<Stream ld2004_high.asf>
Feed ld2004.ffm
Format asf
AudioBitRate 64
VideoFrameRate 15
VideoSize cif
VideoBitRate 256
VideoGopSize 30
VideoCodec msmpeg4v2
AudioCodec mp3
VideoHighQuality
StartSendOnKey
</Stream>

##################################################################
# Special streams

# Serveur status

< Stream stat.html>
Format status
ACL allow localhost
</Stream>

# Redirect index.html to the appropriated situated

< Redirect index.html>
URL http://www.telug.it/linuxday-2004/streaming.php
</Redirect>

Ok. We completed.

We can make to leave the serveur

# ffserver &

and to start streaming

# ffmpeg - vd /dev/video0 http://localhost/ld2004.ffm JavaScript Menu Courtesy of Milonic.com




 Copyright© 1997-2006 Emiliano Bruni Online from 16/08/1998 with visitors Write me to: