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 @item ReadOnlyFile @var{filename}
331 Set the path where the feed file is stored on disk.
333 If not specified, the @file{/tmp/FEED.ffm} is assumed, where
334 @var{FEED} is the feed name.
336 If @option{ReadOnlyFile} is used the file is marked as read-only and
337 it will not be deleted or updated.
340 Truncate the feed file, rather than appending to it. By default
341 @command{ffserver} will append data to the file, until the maximum
342 file size value is reached (see @option{FileMaxSize} option).
344 @item FileMaxSize @var{size}
345 Set maximum size of the feed. 0 means unlimited. The postfixes
346 @code{K}, @code{M}, and @code{G} are recognized.
350 @item Launch @var{args}
351 Launch an @command{ffmpeg} command when creating @command{ffserver}.
353 @var{args} must be a sequence of arguments to be provided to an
354 @command{ffmpeg} instance. The first provided argument is ignored, and
355 it is replaced by a path with the same dirname of the @command{ffserver}
356 instance, followed by the remaining argument and terminated with a
357 path corresponding to the feed.
359 When the launched process exits, @command{ffserver} will launch
360 another program instance.
362 In case you need a more complex @command{ffmpeg} configuration,
363 e.g. if you need to generate multiple FFM feeds with a single
364 @command{ffmpeg} instance, you should launch @command{ffmpeg} by hand.
366 This option is ignored in case the commandline option @option{-n} is
370 Specify the list of IP address which are allowed or denied to write
371 the feed. Multiple ACL options can be specified.
374 @section Stream section
376 A Stream section defines a stream provided by @command{ffserver}, and
377 identified by a single name.
379 The stream is sent when answering a request containing the stream
382 A stream section must be introduced by the line:
387 where @var{STREAM_NAME} specifies the unique name of the stream.
389 The following options are recognized within a Stream section.
391 Encoding options are marked with the @emph{encoding} tag, and they are
392 used to set the encoding parameters, and are mapped to libavcodec
393 encoding options. Not all encoding options are supported, in
394 particular it is not possible to set encoder private options. In order
395 to override the encoding options specified by @command{ffserver}, you
396 can use the @command{ffmpeg} @option{override_ffserver} commandline
399 Only one of the @option{Feed} and @option{File} options should be set.
402 @item Feed @var{feed_name}
403 Set the input feed. @var{feed_name} must correspond to an existing
404 feed defined in a @code{Feed} section.
406 When this option is set, encoding options are used to setup the
407 encoding operated by the remote @command{ffmpeg} process.
409 @item File @var{filename}
410 Set the filename of the pre-recorded input file to stream.
412 When this option is set, encoding options are ignored and the input
413 file content is re-streamed as is.
415 @item Format @var{format_name}
416 Set the format of the output stream.
418 Must be the name of a format recognized by FFmpeg. If set to
419 @samp{status}, it is treated as a status stream.
421 @item InputFormat @var{format_name}
422 Set input format. If not specified, it is automatically guessed.
424 @item Preroll @var{n}
425 Set this to the number of seconds backwards in time to start. Note that
426 most players will buffer 5-10 seconds of video, and also you need to allow
427 for a keyframe to appear in the data stream.
432 Do not send stream until it gets the first key frame. By default
433 @command{ffserver} will send data immediately.
435 @item MaxTime @var{n}
436 Set the number of seconds to run. This value set the maximum duration
437 of the stream a client will be able to receive.
439 A value of 0 means that no limit is set on the stream duration.
442 Set ACL for the stream.
444 @item DynamicACL @var{spec}
446 @item RTSPOption @var{option}
448 @item MulticastAddress @var{address}
450 @item MulticastPort @var{port}
452 @item MulticastTTL @var{integer}
456 @item FaviconURL @var{url}
457 Set favicon (favourite icon) for the server status page. It is ignored
460 @item Author @var{value}
461 @item Comment @var{value}
462 @item Copyright @var{value}
463 @item Title @var{value}
464 Set metadata corresponding to the option.
468 Suppress audio/video.
470 @item AudioCodec @var{codec_name} (@emph{encoding,audio})
473 @item AudioBitRate @var{rate} (@emph{encoding,audio})
474 Set bitrate for the audio stream in kbits per second.
476 @item AudioChannels @var{n} (@emph{encoding,audio})
477 Set number of audio channels.
479 @item AudioSampleRate @var{n} (@emph{encoding,audio})
480 Set sampling frequency for audio. When using low bitrates, you should
481 lower this frequency to 22050 or 11025. The supported frequencies
482 depend on the selected audio codec.
484 @item AVOptionAudio @var{option} @var{value} (@emph{encoding,audio})
485 Set generic option for audio stream.
487 @item AVPresetAudio @var{preset} (@emph{encoding,audio})
488 Set preset for audio stream.
490 @item VideoCodec @var{codec_name} (@emph{encoding,video})
493 @item VideoBitRate @var{n} (@emph{encoding,video})
494 Set bitrate for the video stream in kbits per second.
496 @item VideoBitRateRange @var{range} (@emph{encoding,video})
497 Set video bitrate range.
499 A range must be specified in the form @var{minrate}-@var{maxrate}, and
500 specifies the @option{minrate} and @option{maxrate} encoding options
501 expressed in kbits per second.
503 @item VideoBitRateRangeTolerance @var{n} (@emph{encoding,video})
504 Set video bitrate tolerance in kbits per second.
506 @item PixelFormat @var{pixel_format} (@emph{encoding,video})
507 Set video pixel format.
509 @item Debug @var{integer} (@emph{encoding,video})
510 Set video @option{debug} encoding option.
512 @item Strict @var{integer} (@emph{encoding,video})
513 Set video @option{strict} encoding option.
515 @item VideoBufferSize @var{n} (@emph{encoding,video})
516 Set ratecontrol buffer size, expressed in KB.
518 @item VideoFrameRate @var{n} (@emph{encoding,video})
519 Set number of video frames per second.
521 @item VideoSize (@emph{encoding,video})
522 Set size of the video frame, must be an abbreviation or in the form
523 @var{W}x@var{H}. See @ref{video size syntax,,the Video size section
524 in the ffmpeg-utils(1) manual,ffmpeg-utils}.
526 Default value is @code{160x128}.
528 @item VideoIntraOnly (@emph{encoding,video})
529 Transmit only intra frames (useful for low bitrates, but kills frame rate).
531 @item VideoGopSize @var{n} (@emph{encoding,video})
532 If non-intra only, an intra frame is transmitted every VideoGopSize
533 frames. Video synchronization can only begin at an intra frame.
535 @item VideoTag @var{tag} (@emph{encoding,video})
538 @item VideoHighQuality (@emph{encoding,video})
539 @item Video4MotionVector (@emph{encoding,video})
541 @item BitExact (@emph{encoding,video})
542 Set bitexact encoding flag.
544 @item IdctSimple (@emph{encoding,video})
545 Set simple IDCT algorithm.
547 @item Qscale @var{n} (@emph{encoding,video})
548 Enable constant quality encoding, and set video qscale (quantization
549 scale) value, expressed in @var{n} QP units.
551 @item VideoQMin @var{n} (@emph{encoding,video})
552 @item VideoQMax @var{n} (@emph{encoding,video})
555 @item VideoQDiff @var{integer} (@emph{encoding,video})
556 Set video @option{qdiff} encoding option.
558 @item LumiMask @var{float} (@emph{encoding,video})
559 @item DarkMask @var{float} (@emph{encoding,video})
560 Set @option{lumi_mask}/@option{dark_mask} encoding options.
562 @item AVOptionVideo @var{option} @var{value} (@emph{encoding,video})
563 Set generic option for video stream.
565 @item AVPresetVideo @var{preset} (@emph{encoding,video})
566 Set preset for video stream.
568 @var{preset} must be the path of a preset file.
571 @subsection Server status stream
573 A server status stream is a special stream which is used to show
574 statistics about the @command{ffserver} operations.
576 It must be specified setting the option @option{Format} to
579 @section Redirect section
581 A redirect section specifies where to redirect the requested URL to
584 A redirect section must be introduced by the line:
589 where @var{NAME} is the name of the page which should be redirected.
591 It only accepts the option @option{URL}, which specify the redirection
594 @chapter Stream examples
661 AudioSampleRate 44100
674 AudioSampleRate 44100
680 Real with audio only at 32 kbits
692 Real with audio and video at 64 kbits
706 For stream coming from a file: you only need to set the input filename
707 and optionally a new format.
711 File "/usr/local/httpd/htdocs/tlive.rm"
718 File "/usr/local/httpd/htdocs/test.asf"
721 Copyright "Super MegaCorp"
722 Title "Test stream from disk"
723 Comment "Test comment"
735 @ifset config-avcodec
737 @include bitstream_filters.texi
739 @ifset config-avformat
740 @include formats.texi
741 @include protocols.texi
743 @ifset config-avdevice
744 @include devices.texi
746 @ifset config-swresample
747 @include resampler.texi
749 @ifset config-swscale
752 @ifset config-avfilter
753 @include filters.texi
761 @url{ffserver.html,ffserver},
763 @ifset config-not-all
764 @url{ffserver-all.html,ffserver-all},
766 the @file{doc/ffserver.conf} example,
767 @url{ffmpeg.html,ffmpeg}, @url{ffplay.html,ffplay}, @url{ffprobe.html,ffprobe},
768 @url{ffmpeg-utils.html,ffmpeg-utils},
769 @url{ffmpeg-scaler.html,ffmpeg-scaler},
770 @url{ffmpeg-resampler.html,ffmpeg-resampler},
771 @url{ffmpeg-codecs.html,ffmpeg-codecs},
772 @url{ffmpeg-bitstream-filters.html,ffmpeg-bitstream-filters},
773 @url{ffmpeg-formats.html,ffmpeg-formats},
774 @url{ffmpeg-devices.html,ffmpeg-devices},
775 @url{ffmpeg-protocols.html,ffmpeg-protocols},
776 @url{ffmpeg-filters.html,ffmpeg-filters}
783 @ifset config-not-all
786 the @file{doc/ffserver.conf} example, ffmpeg(1), ffplay(1), ffprobe(1),
787 ffmpeg-utils(1), ffmpeg-scaler(1), ffmpeg-resampler(1),
788 ffmpeg-codecs(1), ffmpeg-bitstream-filters(1), ffmpeg-formats(1),
789 ffmpeg-devices(1), ffmpeg-protocols(1), ffmpeg-filters(1)
792 @include authors.texi
796 @setfilename ffserver
797 @settitle ffserver video server