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 @chapter Detailed description
47 @command{ffserver} works by forwarding streams encoded by
48 @command{ffmpeg}, or pre-recorded streams which are read from disk.
50 Precisely, @command{ffserver} acts as an HTTP server, accepting POST
51 requests from @command{ffmpeg} to acquire the stream to publish, and
52 serving HTTP clients GET requests with the stream media content.
54 A feed is an @ref{FFM} stream created by @command{ffmpeg}, and sent to
55 a port where @command{ffserver} is listening.
57 Each feed is identified by a unique name, corresponding to the name
58 of the resource published on @command{ffserver}, and is configured by
59 a dedicated @code{Feed} section in the configuration file.
61 The feed publish URL is given by:
63 http://@var{ffserver_ip_address}:@var{http_port}/@var{feed_name}
66 where @var{ffserver_ip_address} is the IP address of the machine where
67 @command{ffserver} is installed, @var{http_port} is the port number of
68 the HTTP server (configured through the @option{Port} option), and
69 @var{feed_name} is the name of the corresponding feed defined in the
72 Each feed is associated to a file which is stored on disk. This stored
73 file is used to allow to send pre-recorded data to a player as fast as
74 possible when new content is added in real-time to the stream.
76 A "live-stream" or "stream" is a resource published by
77 @command{ffserver}, and made accessible through the HTTP protocol to
80 A stream can be connected to a feed, or to a file. In the first case,
81 the published stream is forwarded from the corresponding feed
82 generated by a running instance of @command{ffmpeg}, in the second
83 case the stream is read from a pre-recorded file.
85 Each stream is identified by a unique name, corresponding to the name
86 of the resource served by @command{ffserver}, and is configured by
87 a dedicated @code{Stream} section in the configuration file.
89 The stream access URL is given by:
91 http://@var{ffserver_ip_address}:@var{http_port}/@var{stream_name}[@var{options}]
94 @var{stream_name} is the name of the corresponding stream defined in
95 the configuration file. @var{options} is a list of options specified
96 after the URL which affects how the stream is served by
99 In case the stream is associated to a feed, the encoding parameters
100 must be configured in the stream configuration. They are sent to
101 @command{ffmpeg} when setting up the encoding. This allows
102 @command{ffserver} to define the encoding parameters used by
103 the @command{ffmpeg} encoders.
105 The @command{ffmpeg} @option{override_ffserver} commandline option
106 allows to override the encoding parameters set by the server.
108 Multiple streams can be connected to the same feed.
110 For example, you can have a situation described by the following
115 ffmpeg 1 -----| feed 1 |-----| stream 1 |
116 \ |_________|\ |__________|
123 \ _________ __________
125 \| feed 2 |-----| stream 3 |
126 |_________| |__________|
130 ffmpeg 2 -----| feed 3 |-----| stream 4 |
131 |_________| |__________|
135 | file 1 |-----| stream 5 |
136 |_________| |__________|
140 @section FFM, FFM2 formats
142 FFM and FFM2 are formats used by ffserver. They allow storing a wide variety of
143 video and audio streams and encoding options, and can store a moving time segment
144 of an infinite movie or a whole movie.
146 FFM is version specific, and there is limited compatibility of FFM files
147 generated by one version of ffmpeg/ffserver and another version of
148 ffmpeg/ffserver. It may work but it is not guaranteed to work.
150 FFM2 is extensible while maintaining compatibility and should work between
151 differing versions of tools. FFM2 is the default.
153 @section Status stream
155 @command{ffserver} supports an HTTP interface which exposes the
156 current status of the server.
158 Simply point your browser to the address of the special status stream
159 specified in the configuration file.
161 For example if you have:
166 # Only allow local people to get the status
168 ACL allow 192.168.0.0 192.168.255.255
172 then the server will post a page with the status information when
173 the special stream @file{status.html} is requested.
175 @section How do I make it work?
177 As a simple test, just run the following two command lines where INPUTFILE
178 is some file which you can decode with ffmpeg:
181 ffserver -f doc/ffserver.conf &
182 ffmpeg -i INPUTFILE http://localhost:8090/feed1.ffm
185 At this point you should be able to go to your Windows machine and fire up
186 Windows Media Player (WMP). Go to Open URL and enter
189 http://<linuxbox>:8090/test.asf
192 You should (after a short delay) see video and hear audio.
194 WARNING: trying to stream test1.mpg doesn't work with WMP as it tries to
195 transfer the entire file before starting to play.
196 The same is true of AVI files.
198 @section What happens next?
200 You should edit the ffserver.conf file to suit your needs (in terms of
201 frame rates etc). Then install ffserver and ffmpeg, write a script to start
202 them up, and off you go.
204 @section What else can it do?
206 You can replay video from .ffm files that was recorded earlier.
207 However, there are a number of caveats, including the fact that the
208 ffserver parameters must match the original parameters used to record the
209 file. If they do not, then ffserver deletes the file before recording into it.
210 (Now that I write this, it seems broken).
212 You can fiddle with many of the codec choices and encoding parameters, and
213 there are a bunch more parameters that you cannot control. Post a message
214 to the mailing list if there are some 'must have' parameters. Look in
215 ffserver.conf for a list of the currently available controls.
217 It will automatically generate the ASX or RAM files that are often used
218 in browsers. These files are actually redirections to the underlying ASF
219 or RM file. The reason for this is that the browser often fetches the
220 entire file before starting up the external viewer. The redirection files
221 are very small and can be transferred quickly. [The stream itself is
222 often 'infinite' and thus the browser tries to download it and never
227 * When you connect to a live stream, most players (WMP, RA, etc) want to
228 buffer a certain number of seconds of material so that they can display the
229 signal continuously. However, ffserver (by default) starts sending data
230 in realtime. This means that there is a pause of a few seconds while the
231 buffering is being done by the player. The good news is that this can be
232 cured by adding a '?buffer=5' to the end of the URL. This means that the
233 stream should start 5 seconds in the past -- and so the first 5 seconds
234 of the stream are sent as fast as the network will allow. It will then
235 slow down to real time. This noticeably improves the startup experience.
237 You can also add a 'Preroll 15' statement into the ffserver.conf that will
238 add the 15 second prebuffering on all requests that do not otherwise
239 specify a time. In addition, ffserver will skip frames until a key_frame
240 is found. This further reduces the startup delay by not transferring data
241 that will be discarded.
243 @section Why does the ?buffer / Preroll stop working after a time?
245 It turns out that (on my machine at least) the number of frames successfully
246 grabbed is marginally less than the number that ought to be grabbed. This
247 means that the timestamp in the encoded data stream gets behind realtime.
248 This means that if you say 'Preroll 10', then when the stream gets 10
249 or more seconds behind, there is no Preroll left.
251 Fixing this requires a change in the internals of how timestamps are
254 @section Does the @code{?date=} stuff work.
256 Yes (subject to the limitation outlined above). Also note that whenever you
257 start ffserver, it deletes the ffm file (if any parameters have changed),
258 thus wiping out what you had recorded before.
260 The format of the @code{?date=xxxxxx} is fairly flexible. You should use one
261 of the following formats (the 'T' is literal):
264 * YYYY-MM-DDTHH:MM:SS (localtime)
265 * YYYY-MM-DDTHH:MM:SSZ (UTC)
268 You can omit the YYYY-MM-DD, and then it refers to the current day. However
269 note that @samp{?date=16:00:00} refers to 16:00 on the current day -- this
270 may be in the future and so is unlikely to be useful.
272 You use this by adding the ?date= to the end of the URL for the stream.
273 For example: @samp{http://localhost:8080/test.asf?date=2002-07-26T23:05:00}.
279 @include fftools-common-opts.texi
281 @section Main options
284 @item -f @var{configfile}
285 Read configuration file @file{configfile}. If not specified it will
286 read by default from @file{/etc/ffserver.conf}.
289 Enable no-launch mode. This option disables all the @code{Launch}
290 directives within the various @code{<Feed>} sections. Since
291 @command{ffserver} will not launch any @command{ffmpeg} instances, you
292 will have to launch them manually.
295 Enable debug mode. This option increases log verbosity, and directs
296 log messages to stdout. When specified, the @option{CustomLog} option
300 @chapter Configuration file syntax
302 @command{ffserver} reads a configuration file containing global
303 options and settings for each stream and feed.
305 The configuration file consists of global options and dedicated
306 sections, which must be introduced by "<@var{SECTION_NAME}
307 @var{ARGS}>" on a separate line and must be terminated by a line in
308 the form "</@var{SECTION_NAME}>". @var{ARGS} is optional.
310 Currently the following sections are recognized: @samp{Feed},
311 @samp{Stream}, @samp{Redirect}.
313 A line starting with @code{#} is ignored and treated as a comment.
315 Name of options and sections are case-insensitive.
318 An ACL (Access Control List) specifies the address which are allowed
319 to access a given stream, or to write a given feed.
321 It accepts the folling forms
324 Allow/deny access to @var{address}.
331 Allow/deny access to ranges of addresses from @var{first_address} to
334 ACL ALLOW <first_address> <last_address>
335 ACL DENY <first_address> <last_address>
339 You can repeat the ACL allow/deny as often as you like. It is on a per
340 stream basis. The first match defines the action. If there are no matches,
341 then the default is the inverse of the last ACL statement.
343 Thus 'ACL allow localhost' only allows access from localhost.
344 'ACL deny 1.0.0.0 1.255.255.255' would deny the whole of network 1 and
345 allow everybody else.
347 @section Global options
349 @item Port @var{port_number}
350 @item RTSPPort @var{port_number}
352 Set TCP port number on which the HTTP/RTSP server is listening. You
353 must select a different port from your standard HTTP web server if it
354 is running on the same computer.
356 If not specified, no corresponding server will be created.
358 @item BindAddress @var{ip_address}
359 @item RTSPBindAddress @var{ip_address}
360 Set address on which the HTTP/RTSP server is bound. Only useful if you
361 have several network interfaces.
363 @item MaxHTTPConnections @var{n}
364 Set number of simultaneous HTTP connections that can be handled. It
365 has to be defined @emph{before} the @option{MaxClients} parameter,
366 since it defines the @option{MaxClients} maximum limit.
368 Default value is 2000.
370 @item MaxClients @var{n}
371 Set number of simultaneous requests that can be handled. Since
372 @command{ffserver} is very fast, it is more likely that you will want
373 to leave this high and use @option{MaxBandwidth}.
377 @item MaxBandwidth @var{kbps}
378 Set the maximum amount of kbit/sec that you are prepared to consume
379 when streaming to clients.
381 Default value is 1000.
383 @item CustomLog @var{filename}
384 Set access log file (uses standard Apache log file format). '-' is the
387 If not specified @command{ffserver} will produce no log.
389 In case the commandline option @option{-d} is specified this option is
390 ignored, and the log is written to standard output.
393 Set no-daemon mode. This option is currently ignored since now
394 @command{ffserver} will always work in no-daemon mode, and is
398 @section Feed section
400 A Feed section defines a feed provided to @command{ffserver}.
402 Each live feed contains one video and/or audio sequence coming from an
403 @command{ffmpeg} encoder or another @command{ffserver}. This sequence
404 may be encoded simultaneously with several codecs at several
407 A feed instance specification is introduced by a line in the form:
412 where @var{FEED_FILENAME} specifies the unique name of the FFM stream.
414 The following options are recognized within a Feed section.
417 @item File @var{filename}
418 @item ReadOnlyFile @var{filename}
419 Set the path where the feed file is stored on disk.
421 If not specified, the @file{/tmp/FEED.ffm} is assumed, where
422 @var{FEED} is the feed name.
424 If @option{ReadOnlyFile} is used the file is marked as read-only and
425 it will not be deleted or updated.
428 Truncate the feed file, rather than appending to it. By default
429 @command{ffserver} will append data to the file, until the maximum
430 file size value is reached (see @option{FileMaxSize} option).
432 @item FileMaxSize @var{size}
433 Set maximum size of the feed file in bytes. 0 means unlimited. The
434 postfixes @code{K} (2^10), @code{M} (2^20), and @code{G} (2^30) are
439 @item Launch @var{args}
440 Launch an @command{ffmpeg} command when creating @command{ffserver}.
442 @var{args} must be a sequence of arguments to be provided to an
443 @command{ffmpeg} instance. The first provided argument is ignored, and
444 it is replaced by a path with the same dirname of the @command{ffserver}
445 instance, followed by the remaining argument and terminated with a
446 path corresponding to the feed.
448 When the launched process exits, @command{ffserver} will launch
449 another program instance.
451 In case you need a more complex @command{ffmpeg} configuration,
452 e.g. if you need to generate multiple FFM feeds with a single
453 @command{ffmpeg} instance, you should launch @command{ffmpeg} by hand.
455 This option is ignored in case the commandline option @option{-n} is
459 Specify the list of IP address which are allowed or denied to write
460 the feed. Multiple ACL options can be specified.
463 @section Stream section
465 A Stream section defines a stream provided by @command{ffserver}, and
466 identified by a single name.
468 The stream is sent when answering a request containing the stream
471 A stream section must be introduced by the line:
476 where @var{STREAM_NAME} specifies the unique name of the stream.
478 The following options are recognized within a Stream section.
480 Encoding options are marked with the @emph{encoding} tag, and they are
481 used to set the encoding parameters, and are mapped to libavcodec
482 encoding options. Not all encoding options are supported, in
483 particular it is not possible to set encoder private options. In order
484 to override the encoding options specified by @command{ffserver}, you
485 can use the @command{ffmpeg} @option{override_ffserver} commandline
488 Only one of the @option{Feed} and @option{File} options should be set.
491 @item Feed @var{feed_name}
492 Set the input feed. @var{feed_name} must correspond to an existing
493 feed defined in a @code{Feed} section.
495 When this option is set, encoding options are used to setup the
496 encoding operated by the remote @command{ffmpeg} process.
498 @item File @var{filename}
499 Set the filename of the pre-recorded input file to stream.
501 When this option is set, encoding options are ignored and the input
502 file content is re-streamed as is.
504 @item Format @var{format_name}
505 Set the format of the output stream.
507 Must be the name of a format recognized by FFmpeg. If set to
508 @samp{status}, it is treated as a status stream.
510 @item InputFormat @var{format_name}
511 Set input format. If not specified, it is automatically guessed.
513 @item Preroll @var{n}
514 Set this to the number of seconds backwards in time to start. Note that
515 most players will buffer 5-10 seconds of video, and also you need to allow
516 for a keyframe to appear in the data stream.
521 Do not send stream until it gets the first key frame. By default
522 @command{ffserver} will send data immediately.
524 @item MaxTime @var{n}
525 Set the number of seconds to run. This value set the maximum duration
526 of the stream a client will be able to receive.
528 A value of 0 means that no limit is set on the stream duration.
531 Set ACL for the stream.
533 @item DynamicACL @var{spec}
535 @item RTSPOption @var{option}
537 @item MulticastAddress @var{address}
539 @item MulticastPort @var{port}
541 @item MulticastTTL @var{integer}
545 @item FaviconURL @var{url}
546 Set favicon (favourite icon) for the server status page. It is ignored
549 @item Author @var{value}
550 @item Comment @var{value}
551 @item Copyright @var{value}
552 @item Title @var{value}
553 Set metadata corresponding to the option. All these options are
554 deprecated in favor of @option{Metadata}.
556 @item Metadata @var{key} @var{value}
557 Set metadata value on the output stream.
561 Suppress audio/video.
563 @item AudioCodec @var{codec_name} (@emph{encoding,audio})
566 @item AudioBitRate @var{rate} (@emph{encoding,audio})
567 Set bitrate for the audio stream in kbits per second.
569 @item AudioChannels @var{n} (@emph{encoding,audio})
570 Set number of audio channels.
572 @item AudioSampleRate @var{n} (@emph{encoding,audio})
573 Set sampling frequency for audio. When using low bitrates, you should
574 lower this frequency to 22050 or 11025. The supported frequencies
575 depend on the selected audio codec.
577 @item AVOptionAudio @var{option} @var{value} (@emph{encoding,audio})
578 Set generic option for audio stream.
580 @item AVPresetAudio @var{preset} (@emph{encoding,audio})
581 Set preset for audio stream.
583 @item VideoCodec @var{codec_name} (@emph{encoding,video})
586 @item VideoBitRate @var{n} (@emph{encoding,video})
587 Set bitrate for the video stream in kbits per second.
589 @item VideoBitRateRange @var{range} (@emph{encoding,video})
590 Set video bitrate range.
592 A range must be specified in the form @var{minrate}-@var{maxrate}, and
593 specifies the @option{minrate} and @option{maxrate} encoding options
594 expressed in kbits per second.
596 @item VideoBitRateRangeTolerance @var{n} (@emph{encoding,video})
597 Set video bitrate tolerance in kbits per second.
599 @item PixelFormat @var{pixel_format} (@emph{encoding,video})
600 Set video pixel format.
602 @item Debug @var{integer} (@emph{encoding,video})
603 Set video @option{debug} encoding option.
605 @item Strict @var{integer} (@emph{encoding,video})
606 Set video @option{strict} encoding option.
608 @item VideoBufferSize @var{n} (@emph{encoding,video})
609 Set ratecontrol buffer size, expressed in KB.
611 @item VideoFrameRate @var{n} (@emph{encoding,video})
612 Set number of video frames per second.
614 @item VideoSize (@emph{encoding,video})
615 Set size of the video frame, must be an abbreviation or in the form
616 @var{W}x@var{H}. See @ref{video size syntax,,the Video size section
617 in the ffmpeg-utils(1) manual,ffmpeg-utils}.
619 Default value is @code{160x128}.
621 @item VideoIntraOnly (@emph{encoding,video})
622 Transmit only intra frames (useful for low bitrates, but kills frame rate).
624 @item VideoGopSize @var{n} (@emph{encoding,video})
625 If non-intra only, an intra frame is transmitted every VideoGopSize
626 frames. Video synchronization can only begin at an intra frame.
628 @item VideoTag @var{tag} (@emph{encoding,video})
631 @item VideoHighQuality (@emph{encoding,video})
632 @item Video4MotionVector (@emph{encoding,video})
634 @item BitExact (@emph{encoding,video})
635 Set bitexact encoding flag.
637 @item IdctSimple (@emph{encoding,video})
638 Set simple IDCT algorithm.
640 @item Qscale @var{n} (@emph{encoding,video})
641 Enable constant quality encoding, and set video qscale (quantization
642 scale) value, expressed in @var{n} QP units.
644 @item VideoQMin @var{n} (@emph{encoding,video})
645 @item VideoQMax @var{n} (@emph{encoding,video})
648 @item VideoQDiff @var{integer} (@emph{encoding,video})
649 Set video @option{qdiff} encoding option.
651 @item LumiMask @var{float} (@emph{encoding,video})
652 @item DarkMask @var{float} (@emph{encoding,video})
653 Set @option{lumi_mask}/@option{dark_mask} encoding options.
655 @item AVOptionVideo @var{option} @var{value} (@emph{encoding,video})
656 Set generic option for video stream.
658 @item AVPresetVideo @var{preset} (@emph{encoding,video})
659 Set preset for video stream.
661 @var{preset} must be the path of a preset file.
664 @subsection Server status stream
666 A server status stream is a special stream which is used to show
667 statistics about the @command{ffserver} operations.
669 It must be specified setting the option @option{Format} to
672 @section Redirect section
674 A redirect section specifies where to redirect the requested URL to
677 A redirect section must be introduced by the line:
682 where @var{NAME} is the name of the page which should be redirected.
684 It only accepts the option @option{URL}, which specify the redirection
687 @chapter Stream examples
754 AudioSampleRate 44100
764 Metadata title "Stream title"
767 AudioSampleRate 44100
773 Real with audio only at 32 kbits
784 Real with audio and video at 64 kbits
797 For stream coming from a file: you only need to set the input filename
798 and optionally a new format.
802 File "/usr/local/httpd/htdocs/tlive.rm"
809 File "/usr/local/httpd/htdocs/test.asf"
812 Metadata copyright "Super MegaCorp"
813 Metadata title "Test stream from disk"
814 Metadata comment "Test comment"
826 @ifset config-avcodec
828 @include bitstream_filters.texi
830 @ifset config-avformat
831 @include formats.texi
832 @include protocols.texi
834 @ifset config-avdevice
835 @include devices.texi
837 @ifset config-swresample
838 @include resampler.texi
840 @ifset config-swscale
843 @ifset config-avfilter
844 @include filters.texi
852 @url{ffserver.html,ffserver},
854 @ifset config-not-all
855 @url{ffserver-all.html,ffserver-all},
857 the @file{doc/ffserver.conf} example,
858 @url{ffmpeg.html,ffmpeg}, @url{ffplay.html,ffplay}, @url{ffprobe.html,ffprobe},
859 @url{ffmpeg-utils.html,ffmpeg-utils},
860 @url{ffmpeg-scaler.html,ffmpeg-scaler},
861 @url{ffmpeg-resampler.html,ffmpeg-resampler},
862 @url{ffmpeg-codecs.html,ffmpeg-codecs},
863 @url{ffmpeg-bitstream-filters.html,ffmpeg-bitstream-filters},
864 @url{ffmpeg-formats.html,ffmpeg-formats},
865 @url{ffmpeg-devices.html,ffmpeg-devices},
866 @url{ffmpeg-protocols.html,ffmpeg-protocols},
867 @url{ffmpeg-filters.html,ffmpeg-filters}
874 @ifset config-not-all
877 the @file{doc/ffserver.conf} example, ffmpeg(1), ffplay(1), ffprobe(1),
878 ffmpeg-utils(1), ffmpeg-scaler(1), ffmpeg-resampler(1),
879 ffmpeg-codecs(1), ffmpeg-bitstream-filters(1), ffmpeg-formats(1),
880 ffmpeg-devices(1), ffmpeg-protocols(1), ffmpeg-filters(1)
883 @include authors.texi
887 @setfilename ffserver
888 @settitle ffserver video server