1 \input texinfo @c -*- texinfo -*-
3 @settitle ffserver Documentation
5 @center @titlefont{ffserver Documentation}
14 ffserver [@var{options}]
17 @c man begin DESCRIPTION
19 @command{ffserver} is a streaming server for both audio and video.
20 It supports several live feeds, streaming from files and time shifting
21 on live feeds. You can seek to positions in the past on each live
22 feed, provided you specify a big enough feed storage.
24 @command{ffserver} is configured through a configuration file, which
25 is read at startup. If not explicitly specified, it will read from
26 @file{/etc/ffserver.conf}.
28 @command{ffserver} receives prerecorded files or FFM streams from some
29 @command{ffmpeg} instance as input, then streams them over
32 An @command{ffserver} instance will listen on some port as specified
33 in the configuration file. You can launch one or more instances of
34 @command{ffmpeg} and send one or more FFM streams to the port where
35 ffserver is expecting to receive them. Alternately, you can make
36 @command{ffserver} launch such @command{ffmpeg} instances at startup.
38 Input streams are called feeds, and each one is specified by a
39 @code{<Feed>} section in the configuration file.
41 For each feed you can have different output streams in various
42 formats, each one specified by a @code{<Stream>} section in the
45 @section Status stream
47 @command{ffserver} supports an HTTP interface which exposes the
48 current status of the server.
50 Simply point your browser to the address of the special status stream
51 specified in the configuration file.
53 For example if you have:
58 # Only allow local people to get the status
60 ACL allow 192.168.0.0 192.168.255.255
64 then the server will post a page with the status information when
65 the special stream @file{status.html} is requested.
67 @section How do I make it work?
69 First, build the kit. It *really* helps to have installed LAME first. Then when
70 you run the ffserver ./configure, make sure that you have the
71 @code{--enable-libmp3lame} flag turned on.
73 LAME is important as it allows for streaming audio to Windows Media Player.
74 Don't ask why the other audio types do not work.
76 As a simple test, just run the following two command lines where INPUTFILE
77 is some file which you can decode with ffmpeg:
80 ffserver -f doc/ffserver.conf &
81 ffmpeg -i INPUTFILE http://localhost:8090/feed1.ffm
84 At this point you should be able to go to your Windows machine and fire up
85 Windows Media Player (WMP). Go to Open URL and enter
88 http://<linuxbox>:8090/test.asf
91 You should (after a short delay) see video and hear audio.
93 WARNING: trying to stream test1.mpg doesn't work with WMP as it tries to
94 transfer the entire file before starting to play.
95 The same is true of AVI files.
97 @section What happens next?
99 You should edit the ffserver.conf file to suit your needs (in terms of
100 frame rates etc). Then install ffserver and ffmpeg, write a script to start
101 them up, and off you go.
103 @section What else can it do?
105 You can replay video from .ffm files that was recorded earlier.
106 However, there are a number of caveats, including the fact that the
107 ffserver parameters must match the original parameters used to record the
108 file. If they do not, then ffserver deletes the file before recording into it.
109 (Now that I write this, it seems broken).
111 You can fiddle with many of the codec choices and encoding parameters, and
112 there are a bunch more parameters that you cannot control. Post a message
113 to the mailing list if there are some 'must have' parameters. Look in
114 ffserver.conf for a list of the currently available controls.
116 It will automatically generate the ASX or RAM files that are often used
117 in browsers. These files are actually redirections to the underlying ASF
118 or RM file. The reason for this is that the browser often fetches the
119 entire file before starting up the external viewer. The redirection files
120 are very small and can be transferred quickly. [The stream itself is
121 often 'infinite' and thus the browser tries to download it and never
126 * When you connect to a live stream, most players (WMP, RA, etc) want to
127 buffer a certain number of seconds of material so that they can display the
128 signal continuously. However, ffserver (by default) starts sending data
129 in realtime. This means that there is a pause of a few seconds while the
130 buffering is being done by the player. The good news is that this can be
131 cured by adding a '?buffer=5' to the end of the URL. This means that the
132 stream should start 5 seconds in the past -- and so the first 5 seconds
133 of the stream are sent as fast as the network will allow. It will then
134 slow down to real time. This noticeably improves the startup experience.
136 You can also add a 'Preroll 15' statement into the ffserver.conf that will
137 add the 15 second prebuffering on all requests that do not otherwise
138 specify a time. In addition, ffserver will skip frames until a key_frame
139 is found. This further reduces the startup delay by not transferring data
140 that will be discarded.
142 @section Why does the ?buffer / Preroll stop working after a time?
144 It turns out that (on my machine at least) the number of frames successfully
145 grabbed is marginally less than the number that ought to be grabbed. This
146 means that the timestamp in the encoded data stream gets behind realtime.
147 This means that if you say 'Preroll 10', then when the stream gets 10
148 or more seconds behind, there is no Preroll left.
150 Fixing this requires a change in the internals of how timestamps are
153 @section Does the @code{?date=} stuff work.
155 Yes (subject to the limitation outlined above). Also note that whenever you
156 start ffserver, it deletes the ffm file (if any parameters have changed),
157 thus wiping out what you had recorded before.
159 The format of the @code{?date=xxxxxx} is fairly flexible. You should use one
160 of the following formats (the 'T' is literal):
163 * YYYY-MM-DDTHH:MM:SS (localtime)
164 * YYYY-MM-DDTHH:MM:SSZ (UTC)
167 You can omit the YYYY-MM-DD, and then it refers to the current day. However
168 note that @samp{?date=16:00:00} refers to 16:00 on the current day -- this
169 may be in the future and so is unlikely to be useful.
171 You use this by adding the ?date= to the end of the URL for the stream.
172 For example: @samp{http://localhost:8080/test.asf?date=2002-07-26T23:05:00}.
175 @section What is FFM, FFM2
177 FFM and FFM2 are formats used by ffserver. They allow storing a wide variety of
178 video and audio streams and encoding options, and can store a moving time segment
179 of an infinite movie or a whole movie.
181 FFM is version specific, and there is limited compatibility of FFM files
182 generated by one version of ffmpeg/ffserver and another version of
183 ffmpeg/ffserver. It may work but it is not guaranteed to work.
185 FFM2 is extensible while maintaining compatibility and should work between
186 differing versions of tools. FFM2 is the default.
191 @include fftools-common-opts.texi
193 @section Main options
196 @item -f @var{configfile}
197 Read configuration file @file{configfile}. If not specified it will
198 read by default from @file{/etc/ffserver.conf}.
201 Enable no-launch mode. This option disables all the @code{Launch}
202 directives within the various @code{<Feed>} sections. Since
203 @command{ffserver} will not launch any @command{ffmpeg} instances, you
204 will have to launch them manually.
207 Enable debug mode. This option increases log verbosity, and directs
208 log messages to stdout. When specified, the @option{CustomLog} option
212 @chapter Configuration file syntax
214 @command{ffserver} reads a configuration file containing global
215 options and settings for each stream and feed.
217 The configuration file consists of global options and dedicated
218 sections, which must be introduced by "<@var{SECTION_NAME}
219 @var{ARGS}>" on a separate line and must be terminated by a line in
220 the form "</@var{SECTION_NAME}>". @var{ARGS} is optional.
222 Currently the following sections are recognized: @samp{Feed},
223 @samp{Stream}, @samp{Redirect}.
225 A line starting with @code{#} is ignored and treated as a comment.
227 Name of options and sections are case-insensitive.
230 An ACL (Access Control List) specifies the address which are allowed
231 to access a given stream, or to write a given feed.
233 It accepts the folling forms
236 Allow/deny access to @var{address}.
243 Allow/deny access to ranges of addresses from @var{first_address} to
246 ACL ALLOW <first_address> <last_address>
247 ACL DENY <first_address> <last_address>
251 You can repeat the ACL allow/deny as often as you like. It is on a per
252 stream basis. The first match defines the action. If there are no matches,
253 then the default is the inverse of the last ACL statement.
255 Thus 'ACL allow localhost' only allows access from localhost.
256 'ACL deny 1.0.0.0 1.255.255.255' would deny the whole of network 1 and
257 allow everybody else.
259 @section Global options
261 @item Port @var{port_number}
262 @item RTSPPort @var{port_number}
264 Set TCP port number on which the HTTP/RTSP server is listening. You
265 must select a different port from your standard HTTP web server if it
266 is running on the same computer.
268 If not specified, no corresponding server will be created.
270 @item BindAddress @var{ip_address}
271 @item RTSPBindAddress @var{ip_address}
272 Set address on which the HTTP/RTSP server is bound. Only useful if you
273 have several network interfaces.
275 @item MaxHTTPConnections @var{n}
276 Set number of simultaneous HTTP connections that can be handled. It
277 has to be defined @emph{before} the @option{MaxClients} parameter,
278 since it defines the @option{MaxClients} maximum limit.
280 Default value is 2000.
282 @item MaxClients @var{n}
283 Set number of simultaneous requests that can be handled. Since
284 @command{ffserver} is very fast, it is more likely that you will want
285 to leave this high and use @option{MaxBandwidth}.
289 @item MaxBandwidth @var{kbps}
290 Set the maximum amount of kbit/sec that you are prepared to consume
291 when streaming to clients.
293 Default value is 1000.
295 @item CustomLog @var{filename}
296 Set access log file (uses standard Apache log file format). '-' is the
299 If not specified @command{ffserver} will produce no log.
301 In case the commandline option @option{-d} is specified this option is
302 ignored, and the log is written to standard output.
305 Set no-daemon mode. This option is currently ignored since now
306 @command{ffserver} will work in no-daemon mode, and is deprecated.
310 @section Feed section
312 A Feed section defines a feed provided to @command{ffserver}.
314 Each live feed contains one video and/or audio sequence coming from an
315 @command{ffmpeg} encoder or another @command{ffserver}. This sequence
316 may be encoded simultaneously with several codecs at several
319 A feed instance specification is introduced by a line in the form:
324 where @var{FEED_FILENAME} specifies the unique name of the FFM stream.
326 The following options are recognized within a Feed section.
329 @item File @var{filename}
330 Set the path where the file is stored on disk.
332 @item FileMaxSize @var{size}
333 Set maximum size of the feed. 0 means unlimited.
335 @item ReadOnlyFile @var{filename}
336 Mark the file as readonly and it will not be deleted or updated.
338 @item Launch @var{args}
339 Launch an @command{ffmpeg} command when creating @command{ffserver}.
341 @var{args} must be a sequence of arguments to be provided to an
342 @command{ffmpeg} instance. The first provided argument is ignored, and
343 it is replaced by a path with the same dirname of the @command{ffserver}
344 instance, followed by the remaining argument and terminated with a
345 path corresponding to the feed.
347 When the launched process exits, @command{ffserver} will launch
348 another program instance.
350 In case you need a more complex @command{ffmpeg} configuration,
351 e.g. if you need to generate multiple FFM feeds with a single
352 @command{ffmpeg} instance, you should launch @command{ffmpeg} by hand.
354 This option is ignored in case the commandline option @option{-n} is
358 Specify the list of IP address which are allowed or denied to write
359 the feed. Multiple ACL options can be specified.
362 @section Stream section
364 A Stream section defines a stream provided by @command{ffserver}, and
365 identified by a single name.
367 The stream is sent when answering a request containing the stream
370 A stream section must be introduced by the line:
375 where @var{STREAM_NAME} specifies the unique name of the stream.
377 The following options are recognized within a Stream section.
380 @item Feed @var{feed_name}
383 Must be specified for regular streams.
385 @item Format @var{format_name}
386 Set the format of the output stream.
388 Must be the name of a format recognized by FFmpeg. If set to
389 @samp{status}, it is treated as a status stream.
391 @item InputFormat @var{format_name}
392 Set input format. If not specified, it is automatically guessed.
394 @item Preroll @var{n}
395 Set this to the number of seconds backwards in time to start. Note that
396 most players will buffer 5-10 seconds of video, and also you need to allow
397 for a keyframe to appear in the data stream.
402 Do not send stream until it gets the first key frame. By default
403 @command{ffserver} will send data immediately.
405 @item MaxTime @var{n}
406 Set the number of seconds to run. This value set the maximum duration
407 of the stream a client will be able to receive.
409 A value of 0 means that no limit is set on the stream duration.
412 Set ACL for the stream.
414 @item DynamicACL @var{spec}
416 @item RTSPOtion @var{option}
418 @item MulticastAddress @var{address}
420 @item MulticastPort @var{port}
422 @item MulticastTTL @var{integer}
426 @item FaviconURL @var{url}
427 Set favicon (favourite icon) for the server status page. It is ignored
430 @item Author @var{value}
431 @item Comment @var{value}
432 @item Copyright @var{value}
433 @item Title @var{value}
434 Set metadata corresponding to the option.
438 Suppress audio/video.
440 @item AudioBitRate @var{rate}
441 Set bitrate for the audio stream in kbits per second.
443 @item AudioChannels @var{n}
444 Set number of audio channels.
446 @item AudioSampleRate @var{n}
447 Set sampling frequency for audio. When using low bitrates, you should
448 lower this frequency to 22050 or 11025. The supported frequencies
449 depend on the selected audio codec.
451 @item VideoBitRate @var{n}
452 Set bitrate for the video stream in kbits per second.
454 @item VideoBitRateRange @var{range}
455 Set video bitrate range.
457 A range must be specified in the form @var{minrate}-@var{maxrate}, and
458 specifies the @option{minrate} and @option{maxrate} encoding options
459 expressed in kbits per second.
461 @item VideoBitRateRangeTolerance @var{n}
462 Set video bitrate tolerance in kbits per second.
464 @item PixelFormat @var{pixel_format}
465 Set video pixel format.
467 @item Debug @var{integer}
468 Set video @option{debug} encoding option.
470 @item Strict @var{integer}
471 Set video @option{strict} encoding option.
473 @item VideoBufferSize @var{n}
474 Set ratecontrol buffer size, expressed in KB.
476 @item VideoFrameRate @var{n}
477 Set number of video frames per second.
480 Set size of the video frame, must be an abbreviation or in the form
481 @var{W}x@var{H}. See @ref{video size syntax,,the Video size section
482 in the ffmpeg-utils(1) manual,ffmpeg-utils}.
484 Default value is @code{160x128}.
487 Transmit only intra frames (useful for low bitrates, but kills frame rate).
489 @item VideoGopSize @var{n}
490 If non-intra only, an intra frame is transmitted every VideoGopSize
491 frames. Video synchronization can only begin at an intra frame.
493 @item VideoTag @var{tag}
496 @item VideoHighQuality
497 @item Video4MotionVector
500 Set bitexact encoding flag.
503 Set simple IDCT algorithm.
506 Enable constant quality encoding, and set video qscale (quantization
507 scale) value, expressed in @var{n} QP units.
509 @item VideoQMin @var{n}
510 @item VideoQMax @var{n}
513 @item VideoQDiff @var{integer}
514 Set video @option{qdiff} encoding option.
516 @item LumiMask @var{float}
517 @item DarkMask @var{float}
518 Set @option{lumi_mask}/@option{dark_mask} encoding options.
520 @item AudioCodec @var{codec_name}
521 @item VideoCodec @var{codec_name}
522 Set audio/video codec.
524 @item AVOptionAudio @var{option} @var{value}
525 @item AVOptionVideo @var{option} @var{value}
526 Set generic option for audio/video stream.
528 @item AVPresetAudio @var{preset}
529 @item AVOptionVideo @var{preset}
530 Set preset for audio/video stream.
532 @var{preset} must be the path of a preset file.
535 @subsection Server status stream
537 A server status stream is a special stream which is used to show
538 statistics about the @command{ffserver} operations.
540 It must be specified setting the option @option{Format} to
543 @section Redirect section
545 A redirect section specifies where to redirect the requested URL to
548 A redirect section must be introduced by the line:
553 where @var{NAME} is the name of the page which should be redirected.
555 It only accepts the option @option{URL}, which specify the redirection
558 @chapter Stream examples
625 AudioSampleRate 44100
638 AudioSampleRate 44100
644 Real with audio only at 32 kbits
656 Real with audio and video at 64 kbits
670 For stream coming from a file: you only need to set the input filename
671 and optionally a new format.
675 File "/usr/local/httpd/htdocs/tlive.rm"
682 File "/usr/local/httpd/htdocs/test.asf"
685 Copyright "Super MegaCorp"
686 Title "Test stream from disk"
687 Comment "Test comment"
699 @ifset config-avcodec
701 @include bitstream_filters.texi
703 @ifset config-avformat
704 @include formats.texi
705 @include protocols.texi
707 @ifset config-avdevice
708 @include devices.texi
710 @ifset config-swresample
711 @include resampler.texi
713 @ifset config-swscale
716 @ifset config-avfilter
717 @include filters.texi
725 @url{ffserver.html,ffserver},
727 @ifset config-not-all
728 @url{ffserver-all.html,ffserver-all},
730 the @file{doc/ffserver.conf} example,
731 @url{ffmpeg.html,ffmpeg}, @url{ffplay.html,ffplay}, @url{ffprobe.html,ffprobe},
732 @url{ffmpeg-utils.html,ffmpeg-utils},
733 @url{ffmpeg-scaler.html,ffmpeg-scaler},
734 @url{ffmpeg-resampler.html,ffmpeg-resampler},
735 @url{ffmpeg-codecs.html,ffmpeg-codecs},
736 @url{ffmpeg-bitstream-filters.html,ffmpeg-bitstream-filters},
737 @url{ffmpeg-formats.html,ffmpeg-formats},
738 @url{ffmpeg-devices.html,ffmpeg-devices},
739 @url{ffmpeg-protocols.html,ffmpeg-protocols},
740 @url{ffmpeg-filters.html,ffmpeg-filters}
747 @ifset config-not-all
750 the @file{doc/ffserver.conf} example, ffmpeg(1), ffplay(1), ffprobe(1),
751 ffmpeg-utils(1), ffmpeg-scaler(1), ffmpeg-resampler(1),
752 ffmpeg-codecs(1), ffmpeg-bitstream-filters(1), ffmpeg-formats(1),
753 ffmpeg-devices(1), ffmpeg-protocols(1), ffmpeg-filters(1)
756 @include authors.texi
760 @setfilename ffserver
761 @settitle ffserver video server