Difference between revisions of "Simple video streaming with ffserver"

From Organic Design wiki
(video streaming details)
 
(P2P Video Streaming book)
Line 2: Line 2:
  
 
''ffserver'' is part of the ''ffmpeg'' package.  
 
''ffserver'' is part of the ''ffmpeg'' package.  
apt-get -y install ffmpeg
+
{{code|<pre>apt-get -y install ffmpeg</pre>}}
  
ffserver creates a network socket that is available from client machines to view the video. Once started, you attach an ffmpeg process to the server to do the encoding. Configuration of ffserver is done via the ''/etc/ffserver.conf'' file.
+
 
 +
''ffserver'' creates a network socket that is available from client machines to view the video. Once started, you attach an ''ffmpeg'' process to the server to do the encoding. Configuration of ffserver is done via the ''/etc/ffserver.conf'' file.
  
 
Typical ffserver.conf file
 
Typical ffserver.conf file
<pre>
+
{{code|<pre>
 
Port 8090  
 
Port 8090  
 
# bind to all IPs aliased or not  
 
# bind to all IPs aliased or not  
Line 36: Line 37:
 
Noaudio
 
Noaudio
 
</Stream>
 
</Stream>
</pre>
+
</pre>}}
 +
 
  
 
To get things going, start the server
 
To get things going, start the server
ffserver &
+
{{code|<pre>ffserver &</pre>}}
 +
 
 +
 
 
Attach the ffmpeg process to do the encoding. This is done via a loopback socket.
 
Attach the ffmpeg process to do the encoding. This is done via a loopback socket.
ffmpeg -r 25 -s 352x288 -f video4linux -i /dev/video0 http://localhost:8090/feed1.ffm
+
{{code|<pre>ffmpeg -r 25 -s 352x288 -f video4linux -i /dev/video0 http://localhost:8090/feed1.ffm</pre>}}
 +
 
 +
 
 
Parameters are  
 
Parameters are  
 
*-r - rate in frames per second
 
*-r - rate in frames per second
Line 52: Line 58:
 
*http://localhost/test.swf
 
*http://localhost/test.swf
 
The name of the file will be as defined in the <Stream> section above.
 
The name of the file will be as defined in the <Stream> section above.
 +
 +
== See also ==
 +
*[http://www.bookdepository.co.uk/book/9780387741147/Peer-to-peer-Video-Streaming P2P Video Streaming] ''- A book by Eric Setton and Bernd Girod, free delivery''
  
 
[[Category:Rob]]
 
[[Category:Rob]]

Revision as of 02:07, 16 May 2010

In this example we use the Logitech QuickCam Express web camera to stream video to web page using ffserver

ffserver is part of the ffmpeg package.

apt-get -y install ffmpeg


ffserver creates a network socket that is available from client machines to view the video. Once started, you attach an ffmpeg process to the server to do the encoding. Configuration of ffserver is done via the /etc/ffserver.conf file.

Typical ffserver.conf file

Port 8090 
# bind to all IPs aliased or not 
BindAddress 0.0.0.0 
# max number of simultaneous clients 
MaxClients 1000 
# max bandwidth per-client (kb/s) 
MaxBandwidth 10000 
# Suppress that if you want to launch ffserver as a daemon. 
NoDaemon 

<Feed feed1.ffm> 
File /tmp/feed1.ffm 
FileMaxSize 5M 
</Feed> 

<Stream test.swf>
Feed feed1.ffm
Format swf
VideoCodec flv
VideoFrameRate 15
VideoBufferSize 80000
VideoBitRate 100
VideoQMin 1
VideoQMax 5
VideoSize 352x288
PreRoll 0
Noaudio
</Stream>


To get things going, start the server

ffserver &


Attach the ffmpeg process to do the encoding. This is done via a loopback socket.

ffmpeg -r 25 -s 352x288 -f video4linux -i /dev/video0 http://localhost:8090/feed1.ffm


Parameters are

  • -r - rate in frames per second
  • -s size in pixels width x height (width must be a multiple of 16) and should match the values in the above config file.
  • -f gets input from the video4linux driver
  • -i is the v4l device (if this is not present refer to Logitech QuickCam Express)
  • Lastly the loopback socket

Now you should be able to browse to the server address (or localhost if it's the same machine) and see some live video.

The name of the file will be as defined in the <Stream> section above.

See also