Total Pageviews

Sunday 29 April 2012

streaming with ffmpeg

In this article I want to explain how to install ffserver for streaming with libx264 and mp3lame on ubuntu 11.04 with clean process.

1) Download FFMpeg ( ffmpeg-0.6.3 )

2) Install libx264-dev, libmp3lame-dev, libasound2-dev from distribution repository

3) ./configure --enable-gpl --enable-libx264 --enable-libmp3lame and make

4) Use this as config file for ffserver and put it into doc directory as ffserver.conf

Port 9090
BindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 10000
CustomLog -
NoDaemon

File /tmp/feed1.ffm
FileMaxSize 100M
ACL allow 127.0.0.1

Feed feed1.ffm
Format flv

#audio AudioBitRate 64
AudioChannels 1
AudioSampleRate 11025
AVOptionAudio flags +global_header

#video
VideoBitRate 256
VideoBufferSize 400
VideoFrameRate 25
VideoBitRateTolerance 100
VideoSize 704x480
VideoGopSize 12
AudioCodec libmp3lame
VideoCodec libx264
AVOptionVideo coder 0
AVOptionVideo bf 0
AVOptionVideo flags2 +mixed_refs+fastpskip
AVOptionVideo flags +loop
AVOptionVideo cmp +chroma
AVOptionVideo partitions +parti8x8+parti4x4+partp8x8+partb8x8
AVOptionVideo me_method hex
AVOptionVideo subq 7
AVOptionVideo me_range 16
AVOptionVideo g 250
AVOptionVideo keyint_min 10
AVOptionVideo sc_threshold 40
AVOptionVideo i_qfactor 0.71
AVOptionVideo b_strategy 1
AVOptionVideo qcomp 0.6
AVOptionVideo qmin 10
AVOptionVideo qmax 51
AVOptionVideo qdiff 4
AVOptionVideo refs 3
AVOptionVideo directpred 1
AVOptionVideo trellis 1
AVOptionVideo wpredp 0
AVOptionVideo flags +global_header
#NoAudio
#NoVideo
#VideoQMin 1
#VideoQMax 31
#Preroll 5
StartSendOnKey

Feed feed1.ffm
Format swf

#audio
AudioBitRate 64
AudioChannels 1
AudioSampleRate 11025
AVOptionAudio flags +global_header

#video
VideoBitRate 256
VideoBufferSize 400
VideoFrameRate 25
VideoBitRateTolerance 100
VideoSize 704x480
VideoGopSize 12
#NoAudio
#NoVideo
#VideoQMin 1
#VideoQMax 31
#Preroll 5
StartSendOnKey

Format status

# Only allow local people to get the status
ACL allow localhost
ACL allow 192.168.0.0 192.168.255.255
# Redirect index.html to the appropriate site

URL http://www.ffmpeg.org/

#this permit to obtain 2 streams, one for flv streaming (h264+mp3) and the other for swf streaming (flv+mp3)

5) Run ./ffserver -f doc/ffserver.conf

6) Now the source
  • Axis camera 232D+: use './ffmpeg -i rtsp://192.168.0.35/mpeg4/media.amp -f alsa -ac 2 -i hw:0,0 http://127.0.0.1:9090/feed1.ffm' command line for connect ffserver with axis camera video using pc sound card as sound input
  • Axis camera M-1031W: use './ffmpeg -i rtsp://192.168.0.95/axis-media/media.amp http://127.0.0.1:9090/feed1.ffm' command line for connect ffserver with axis camera video/sound
  • File: use this command line for streaming a file live './ffmpeg -i /home/dexmac/record.avi http://127.0.0.1:9090/feed1.ffm'
7) For live view use videolan (install it from ubuntu repository) with address http://127.0.0.1:9090/test1.flv or test1.swf, if you well done, you may see your stream

8) If you want to put this on line use flowplayer and follow my "streaming with flowplayer and ffserver" how-to.
from http://www.dexmac.com/index.php/how-to/74-streaming-with-ffserver
-------------------------------------------------------------------
With "Streaming with FFServer" i explain how to setup a streaming server with FFServer,
now, in this article, i explain how to setup a web page containing FlowPlayer connected to an FFServer (with the same previous setup).

1)Download flowplayer-3.2.5.zip and unzip it.

2)On your Apache htdocs create a new folder called videos.

3)Put flowplayer.controls-3.2.3.swf, flowplayer-3.2.5.swf style.css here.
4)Save flowplayer.html and put it into videos folder.

5)Execute ffserver and ffmpeg and as explained in my how-to, open you browser with this file and you will view live streaming.
from http://www.dexmac.com/index.php/how-to/75-flowplayer-with-ffserver