<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Web, Technologies, IA, Vidéo... - Analyse, Bidouille, Streaming server, Vidéo</title><link href="https://www.alkannoide.com/" rel="alternate"/><link href="https://www.alkannoide.com/feeds/analyse-bidouille-streaming-server-video.atom.xml" rel="self"/><id>https://www.alkannoide.com/</id><updated>2013-07-04T11:04:00+02:00</updated><entry><title>Play with ffserver - a quick overview</title><link href="https://www.alkannoide.com/2013/07/04/play-with-ffserver-a-quick-overview/" rel="alternate"/><published>2013-07-04T11:04:00+02:00</published><updated>2013-07-04T11:04:00+02:00</updated><author><name>admin</name></author><id>tag:www.alkannoide.com,2013-07-04:/2013/07/04/play-with-ffserver-a-quick-overview/</id><summary type="html">&lt;p&gt;&lt;a href="/images/2012/01/ffmpeg.jpg"&gt;&lt;img src="/images/2012/01/ffmpeg.jpg" class="wp-image-659 alignright" width="154" height="86" alt="ffmpeg" /&gt;&lt;/a&gt;Everybody knows &lt;a href="http://www.ffmpeg.org/"&gt;ffmpeg&lt;/a&gt; the command line encoding tool but do you know ffserver ? &lt;a href="http://www.ffmpeg.org/ffserver.html"&gt;ffserver&lt;/a&gt; is a multimedia streaming server for live broadcasts. With it, you can stream over HTTP, &lt;a href="http://fr.wikipedia.org/wiki/Real-time_Transport_Protocol"&gt;RTP&lt;/a&gt; and &lt;a href="http://fr.wikipedia.org/wiki/Real_Time_Streaming_Protocol"&gt;RSTP&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Quick overview&lt;/h2&gt;
&lt;p&gt;The concept is to use ffmpeg to push content to one server. This server will transcode …&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;a href="/images/2012/01/ffmpeg.jpg"&gt;&lt;img src="/images/2012/01/ffmpeg.jpg" class="wp-image-659 alignright" width="154" height="86" alt="ffmpeg" /&gt;&lt;/a&gt;Everybody knows &lt;a href="http://www.ffmpeg.org/"&gt;ffmpeg&lt;/a&gt; the command line encoding tool but do you know ffserver ? &lt;a href="http://www.ffmpeg.org/ffserver.html"&gt;ffserver&lt;/a&gt; is a multimedia streaming server for live broadcasts. With it, you can stream over HTTP, &lt;a href="http://fr.wikipedia.org/wiki/Real-time_Transport_Protocol"&gt;RTP&lt;/a&gt; and &lt;a href="http://fr.wikipedia.org/wiki/Real_Time_Streaming_Protocol"&gt;RSTP&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Quick overview&lt;/h2&gt;
&lt;p&gt;The concept is to use ffmpeg to push content to one server. This server will transcode streams and deliver to the end-users.&lt;/p&gt;
&lt;p&gt;&lt;a href="/images/2013/07/ffserver_map.png"&gt;&lt;img src="/images/2013/07/ffserver_map.png" class="aligncenter size-full wp-image-1892" width="678" height="426" alt="FFServer map" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Input streams are called feed and for each feed you can have multiple output stream.&lt;/p&gt;
&lt;p&gt;We can manage ffserver via a configuration file. The syntax is close to the one used for Apache server. You can find a example &lt;a href="http://ffmpeg.org/sample.html"&gt;here&lt;/a&gt;. And there are more informations in the &lt;a href="http://ffmpeg.org/trac/ffmpeg/wiki/Streaming%20media%20with%20ffserver"&gt;ffserver wiki&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We will see two examples on how to deliver content via a ffserver. There will be a FLV and a WebM stream.  &lt;/p&gt;
&lt;h2&gt;Stream FLV&lt;/h2&gt;
&lt;p&gt;In this example, we will have one input stream and two output : one in FLV and one WebM.&lt;/p&gt;
&lt;p&gt;Here are the general configuration settings&lt;/p&gt;
&lt;p&gt;[code language="text"]&lt;br&gt;
Port 8090&lt;br&gt;
BindAddress 0.0.0.0&lt;br&gt;
MaxHTTPConnections 2000&lt;br&gt;
MaxClients 1000&lt;br&gt;
MaxBandwidth 1000&lt;br&gt;
CustomLog -&lt;br&gt;
[/code]&lt;/p&gt;
&lt;p&gt;We define a status page.&lt;/p&gt;
&lt;p&gt;[code language="text"]&lt;br&gt;
\&amp;lt;Stream stat.html&amp;gt;&lt;br&gt;
Format status&lt;br&gt;
ACL allow localhost&lt;br&gt;
ACL allow 192.168.0.0 192.168.255.255&lt;br&gt;
\&amp;lt;/Stream&amp;gt;&lt;br&gt;
[/code]&lt;br&gt;
This page will help us to monitor the server. This page is call with this url : http://localhost:8090/stat.html and you will get this page :&lt;/p&gt;
&lt;p&gt;&lt;a href="/images/2013/07/ffserver-status.png"&gt;&lt;img src="/images/2013/07/ffserver-status.png" class="wp-image-1560 aligncenter" width="532" height="365" alt="ffserver-status" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now we set up the feed : storage area, max size and allowed referrers. Remember, feeds are the input of the ffserver.&lt;br&gt;
[code language="text"]&lt;br&gt;
\&amp;lt;Feed feed1.ffm&amp;gt;&lt;br&gt;
File /tmp/feed1.ffm&lt;br&gt;
FileMaxSize 1G&lt;br&gt;
ACL allow 127.0.0.1&lt;br&gt;
\&amp;lt;/Feed&amp;gt;&lt;br&gt;
[/code]&lt;br&gt;
Ok, our configuration file have now a input feed. Now, we will add the first output : the FLV one. The video will be encoded in H264 for video and AAC for audio. This part is divided in 3 part :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;general settings : which feed is used and output format&lt;/li&gt;
&lt;li&gt;settings for video&lt;/li&gt;
&lt;li&gt;settings for audio&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;[code language="text"]&lt;br&gt;
\&amp;lt;Stream live.flv&amp;gt;&lt;br&gt;
Format flv&lt;br&gt;
Feed feed1.ffm&lt;/p&gt;
&lt;p&gt;VideoCodec libx264&lt;br&gt;
VideoFrameRate 30&lt;br&gt;
VideoBitRate 800&lt;br&gt;
VideoSize 720x576&lt;br&gt;
AVOptionVideo crf 23&lt;br&gt;
AVOptionVideo preset medium&lt;br&gt;
AVOptionVideo me_range 16&lt;br&gt;
AVOptionVideo qdiff 4&lt;br&gt;
AVOptionVideo qmin 10&lt;br&gt;
AVOptionVideo qmax 51&lt;br&gt;
AVOptionVideo flags +global_header&lt;/p&gt;
&lt;p&gt;AudioCodec aac&lt;br&gt;
Strict -2&lt;br&gt;
AudioBitRate 128&lt;br&gt;
AudioChannels 2&lt;br&gt;
AudioSampleRate 44100&lt;br&gt;
AVOptionAudio flags +global_header&lt;br&gt;
\&amp;lt;/Stream&amp;gt;&lt;br&gt;
[/code]&lt;/p&gt;
&lt;p&gt;The first part of our server is now configured and saved in a ffserver.conf file. We can test it. Launch the server with this command line :&lt;br&gt;
[code language="bash"]ffserver -f ffserver.conf[/code]&lt;br&gt;
You will have this output :&lt;br&gt;
[code language="bash"] ffserver version 1.2.1 Copyright (c) 2000-2013 the FFmpeg developers&lt;br&gt;
built on Jun 24 2013 10:41:49 with Apple clang version 4.1 (tags/Apple/clang-421.11.65) (based on LLVM 3.1svn)&lt;br&gt;
configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libspeex --enable-libass --enable-libbluray --enable-gnutls --enable-libfreetype --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid --enable-nonfree --enable-libfaac&lt;br&gt;
libavutil 52. 18.100 / 52. 18.100&lt;br&gt;
libavcodec 54. 92.100 / 54. 92.100&lt;br&gt;
libavformat 54. 63.104 / 54. 63.104&lt;br&gt;
libavdevice 54. 3.103 / 54. 3.103&lt;br&gt;
libavfilter 3. 42.103 / 3. 42.103&lt;br&gt;
libswscale 2. 2.100 / 2. 2.100&lt;br&gt;
libswresample 0. 17.102 / 0. 17.102&lt;br&gt;
libpostproc 52. 2.100 / 52. 2.100&lt;br&gt;
Wed Jul 3 14:02:01 2013 FFserver started.&lt;br&gt;
[/code]&lt;br&gt;
Your server is now up and running. We can push our first movie, in my case, I use the &lt;a href="http://www.sintel.org/"&gt;Sintel Movie&lt;/a&gt; trailer. The ffmpeg command line read the video and push it to the feed we configured above.&lt;br&gt;
[code language="bash"][/code]ffmpeg -i sintel.mp4 http://localhost:8090/feed1.ffm[/code]&lt;br&gt;
Now you can launch your preferred player (in my case VLC) and try to stream the content : http://localhost:8090/live.flv ;-)&lt;/p&gt;
&lt;h2&gt;Stream WebM&lt;/h2&gt;
&lt;p&gt;Ok we have now one FLV output stream. We will replace FLV stream by one new output : WebM (with Vorbis and VP6). We will re-used the ffserver.conf file and put this part :&lt;/p&gt;
&lt;p&gt;[code language="text"]&lt;br&gt;
\&amp;lt;Stream live.webm&amp;gt;&lt;br&gt;
Feed feed1.ffm&lt;br&gt;
Format webm&lt;/p&gt;
&lt;p&gt;AudioCodec vorbis&lt;br&gt;
AudioBitRate 64&lt;/p&gt;
&lt;p&gt;VideoCodec libvpx&lt;br&gt;
VideoSize 720x576&lt;br&gt;
VideoFrameRate 25&lt;br&gt;
AVOptionVideo flags +global_header&lt;br&gt;
AVOptionVideo cpu-used 0&lt;br&gt;
AVOptionVideo qmin 10&lt;br&gt;
AVOptionVideo qmax 42&lt;br&gt;
AVOptionVideo quality good&lt;br&gt;
AVOptionAudio flags +global_header&lt;br&gt;
PreRoll 15&lt;br&gt;
StartSendOnKey&lt;br&gt;
VideoBitRate 400&lt;br&gt;
\&amp;lt;/Stream&amp;gt;&lt;br&gt;
[/code]&lt;/p&gt;
&lt;p&gt;Restart the server and push again the content. You can test the movie on Chrome or VLC with this url : http://localhost:8090/live.webm&lt;/p&gt;
&lt;p&gt;Note: with WebM, you can create a kind of live stream if you loop on different ffmpeg command line.&lt;/p&gt;
&lt;p&gt;To conclude, we know ffmpeg as one of the most useful free encoder. Now, ffserver is a very interesting tool and deserve more time to test the different possibility of it.&lt;br&gt;
Have fun with it ! ;-)&lt;/p&gt;</content><category term="Analyse, Bidouille, Streaming server, Vidéo"/><category term="ffmpeg"/><category term="ffserver"/><category term="flv"/><category term="streaming"/><category term="webm"/></entry></feed>