]> git.sesse.net Git - ffmpeg/blob - doc/ffserver.texi
Merge commit '25609b63d2e07d26d610f485a22082d32c96c0f5'
[ffmpeg] / doc / ffserver.texi
1 \input texinfo @c -*- texinfo -*-
2
3 @settitle ffserver Documentation
4 @titlepage
5 @center @titlefont{ffserver Documentation}
6 @end titlepage
7
8 @top
9
10 @contents
11
12 @chapter Synopsis
13
14 ffserver [@var{options}]
15
16 @chapter Description
17 @c man begin DESCRIPTION
18
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.
23
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}.
27
28 @command{ffserver} receives prerecorded files or FFM streams from some
29 @command{ffmpeg} instance as input, then streams them over
30 RTP/RTSP/HTTP.
31
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.
37
38 Input streams are called feeds, and each one is specified by a
39 @code{<Feed>} section in the configuration file.
40
41 For each feed you can have different output streams in various
42 formats, each one specified by a @code{<Stream>} section in the
43 configuration file.
44
45 @section Status stream
46
47 @command{ffserver} supports an HTTP interface which exposes the
48 current status of the server.
49
50 Simply point your browser to the address of the special status stream
51 specified in the configuration file.
52
53 For example if you have:
54 @example
55 <Stream status.html>
56 Format status
57
58 # Only allow local people to get the status
59 ACL allow localhost
60 ACL allow 192.168.0.0 192.168.255.255
61 </Stream>
62 @end example
63
64 then the server will post a page with the status information when
65 the special stream @file{status.html} is requested.
66
67 @section How do I make it work?
68
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.
72
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.
75
76 As a simple test, just run the following two command lines where INPUTFILE
77 is some file which you can decode with ffmpeg:
78
79 @example
80 ffserver -f doc/ffserver.conf &
81 ffmpeg -i INPUTFILE http://localhost:8090/feed1.ffm
82 @end example
83
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
86
87 @example
88     http://<linuxbox>:8090/test.asf
89 @end example
90
91 You should (after a short delay) see video and hear audio.
92
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.
96
97 @section What happens next?
98
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.
102
103 @section What else can it do?
104
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).
110
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.
115
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
122 finishes.]
123
124 @section Tips
125
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.
135
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.
141
142 @section Why does the ?buffer / Preroll stop working after a time?
143
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.
149
150 Fixing this requires a change in the internals of how timestamps are
151 handled.
152
153 @section Does the @code{?date=} stuff work.
154
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.
158
159 The format of the @code{?date=xxxxxx} is fairly flexible. You should use one
160 of the following formats (the 'T' is literal):
161
162 @example
163 * YYYY-MM-DDTHH:MM:SS     (localtime)
164 * YYYY-MM-DDTHH:MM:SSZ    (UTC)
165 @end example
166
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.
170
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}.
173 @c man end
174
175 @section What is FFM, FFM2
176
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.
180
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.
184
185 FFM2 is extensible while maintaining compatibility and should work between
186 differing versions of tools. FFM2 is the default.
187
188 @chapter Options
189 @c man begin OPTIONS
190
191 @include fftools-common-opts.texi
192
193 @section Main options
194
195 @table @option
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}.
199
200 @item -n
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.
205
206 @item -d
207 Enable debug mode. This option increases log verbosity, and directs
208 log messages to stdout. When specified, the @option{CustomLog} option
209 is ignored.
210 @end table
211
212 @chapter Configuration file syntax
213
214 @command{ffserver} reads a configuration file containing global
215 options and settings for each stream and feed.
216
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.
221
222 Currently the following sections are recognized: @samp{Feed},
223 @samp{Stream}, @samp{Redirect}.
224
225 A line starting with @code{#} is ignored and treated as a comment.
226
227 Name of options and sections are case-insensitive.
228
229 @section ACL syntax
230 An ACL (Access Control List) specifies the address which are allowed
231 to access a given stream, or to write a given feed.
232
233 It accepts the folling forms
234 @itemize
235 @item
236 Allow/deny access to @var{address}.
237 @example
238 ACL ALLOW <address>
239 ACL DENY <address>
240 @end example
241
242 @item
243 Allow/deny access to ranges of addresses from @var{first_address} to
244 @var{last_address}.
245 @example
246 ACL ALLOW <first_address> <last_address>
247 ACL DENY <first_address> <last_address>
248 @end example
249 @end itemize
250
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.
254
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.
258
259 @section Global options
260 @table @option
261 @item Port @var{port_number}
262 @item RTSPPort @var{port_number}
263
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.
267
268 If not specified, no corresponding server will be created.
269
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.
274
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.
279
280 Default value is 2000.
281
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}.
286
287 Default value is 5.
288
289 @item MaxBandwidth @var{kbps}
290 Set the maximum amount of kbit/sec that you are prepared to consume
291 when streaming to clients.
292
293 Default value is 1000.
294
295 @item CustomLog @var{filename}
296 Set access log file (uses standard Apache log file format). '-' is the
297 standard output.
298
299 If not specified @command{ffserver} will produce no log.
300
301 In case the commandline option @option{-d} is specified this option is
302 ignored, and the log is written to standard output.
303
304 @item NoDaemon
305 Set no-daemon mode. This option is currently ignored since now
306 @command{ffserver} will work in no-daemon mode, and is deprecated.
307
308 @end table
309
310 @section Feed section
311
312 A Feed section defines a feed provided to @command{ffserver}.
313
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
317 resolutions.
318
319 A feed instance specification is introduced by a line in the form:
320 @example
321 <Feed FEED_FILENAME>
322 @end example
323
324 where @var{FEED_FILENAME} specifies the unique name of the FFM stream.
325
326 The following options are recognized within a Feed section.
327
328 @table @option
329 @item File @var{filename}
330 Set the path where the file is stored on disk.
331
332 @item FileMaxSize @var{size}
333 Set maximum size of the feed. 0 means unlimited.
334
335 @item ReadOnlyFile @var{filename}
336 Mark the file as readonly and it will not be deleted or updated.
337
338 @item Launch @var{args}
339 Launch an @command{ffmpeg} command when creating @command{ffserver}.
340
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.
346
347 When the launched process exits, @command{ffserver} will launch
348 another program instance.
349
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.
353
354 This option is ignored in case the commandline option @option{-n} is
355 specified.
356
357 @item ACL
358 Specify the list of IP address which are allowed or denied to write
359 the feed. Multiple ACL options can be specified.
360 @end table
361
362 @section Stream section
363
364 A Stream section defines a stream provided by @command{ffserver}, and
365 identified by a single name.
366
367 The stream is sent when answering a request containing the stream
368 name.
369
370 A stream section must be introduced by the line:
371 @example
372 <Stream STREAM_NAME>
373 @end example
374
375 where @var{STREAM_NAME} specifies the unique name of the stream.
376
377 The following options are recognized within a Stream section.
378
379 @table @option
380 @item Feed @var{feed_name}
381 Set the input feed.
382
383 Must be specified for regular streams.
384
385 @item Format @var{format_name}
386 Set the format of the output stream.
387
388 Must be the name of a format recognized by FFmpeg. If set to
389 @samp{status}, it is treated as a status stream.
390
391 @item InputFormat @var{format_name}
392 Set input format. If not specified, it is automatically guessed.
393
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.
398
399 Default value is 0.
400
401 @item StartSendOnKey
402 Do not send stream until it gets the first key frame. By default
403 @command{ffserver} will send data immediately.
404
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.
408
409 A value of 0 means that no limit is set on the stream duration.
410
411 @item ACL @var{spec}
412 Set ACL for the stream.
413
414 @item DynamicACL @var{spec}
415
416 @item RTSPOtion @var{option}
417
418 @item MulticastAddress @var{address}
419
420 @item MulticastPort @var{port}
421
422 @item MulticastTTL @var{integer}
423
424 @item NoLoop
425
426 @item FaviconURL @var{url}
427 Set favicon (favourite icon) for the server status page. It is ignored
428 for regular streams.
429
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.
435
436 @item NoAudio
437 @item NoVideo
438 Suppress audio/video.
439
440 @item AudioBitRate @var{rate}
441 Set bitrate for the audio stream in kbits per second.
442
443 @item AudioChannels @var{n}
444 Set number of audio channels.
445
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.
450
451 @item VideoBitRate @var{n}
452 Set bitrate for the video stream in kbits per second.
453
454 @item VideoBitRateRange @var{range}
455 Set video bitrate range.
456
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.
460
461 @item VideoBitRateRangeTolerance @var{n}
462 Set video bitrate tolerance in kbits per second.
463
464 @item PixelFormat @var{pixel_format}
465 Set video pixel format.
466
467 @item Debug @var{integer}
468 Set video @option{debug} encoding option.
469
470 @item Strict @var{integer}
471 Set video @option{strict} encoding option.
472
473 @item VideoBufferSize @var{n}
474 Set ratecontrol buffer size, expressed in KB.
475
476 @item VideoFrameRate @var{n}
477 Set number of video frames per second.
478
479 @item VideoSize
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}.
483
484 Default value is @code{160x128}.
485
486 @item VideoIntraOnly
487 Transmit only intra frames (useful for low bitrates, but kills frame rate).
488
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.
492
493 @item VideoTag @var{tag}
494 Set video tag.
495
496 @item VideoHighQuality
497 @item Video4MotionVector
498
499 @item BitExact
500 Set bitexact encoding flag.
501
502 @item IdctSimple
503 Set simple IDCT algorithm.
504
505 @item Qscale @var{n}
506 Enable constant quality encoding, and set video qscale (quantization
507 scale) value, expressed in @var{n} QP units.
508
509 @item VideoQMin @var{n}
510 @item VideoQMax @var{n}
511 Set video qmin/qmax.
512
513 @item VideoQDiff @var{integer}
514 Set video @option{qdiff} encoding option.
515
516 @item LumiMask @var{float}
517 @item DarkMask @var{float}
518 Set @option{lumi_mask}/@option{dark_mask} encoding options.
519
520 @item AudioCodec @var{codec_name}
521 @item VideoCodec @var{codec_name}
522 Set audio/video codec.
523
524 @item AVOptionAudio @var{option} @var{value}
525 @item AVOptionVideo @var{option} @var{value}
526 Set generic option for audio/video stream.
527
528 @item AVPresetAudio @var{preset}
529 @item AVOptionVideo @var{preset}
530 Set preset for audio/video stream.
531
532 @var{preset} must be the path of a preset file.
533 @end table
534
535 @subsection Server status stream
536
537 A server status stream is a special stream which is used to show
538 statistics about the @command{ffserver} operations.
539
540 It must be specified setting the option @option{Format} to
541 @samp{status}.
542
543 @section Redirect section
544
545 A redirect section specifies where to redirect the requested URL to
546 another page.
547
548 A redirect section must be introduced by the line:
549 @example
550 <Redirect NAME>
551 @end example
552
553 where @var{NAME} is the name of the page which should be redirected.
554
555 It only accepts the option @option{URL}, which specify the redirection
556 URL.
557
558 @chapter Stream examples
559
560 @itemize
561 @item
562 Multipart JPEG
563 @example
564 <Stream test.mjpg>
565 Feed feed1.ffm
566 Format mpjpeg
567 VideoFrameRate 2
568 VideoIntraOnly
569 NoAudio
570 Strict -1
571 </Stream>
572 @end example
573
574 @item
575 Single JPEG
576 @example
577 <Stream test.jpg>
578 Feed feed1.ffm
579 Format jpeg
580 VideoFrameRate 2
581 VideoIntraOnly
582 #VideoSize 352x240
583 NoAudio
584 Strict -1
585 </Stream>
586 @end example
587
588 @item
589 Flash
590 @example
591 <Stream test.swf>
592 Feed feed1.ffm
593 Format swf
594 VideoFrameRate 2
595 VideoIntraOnly
596 NoAudio
597 </Stream>
598 @end example
599
600 @item
601 ASF compatible
602 @example
603 <Stream test.asf>
604 Feed feed1.ffm
605 Format asf
606 VideoFrameRate 15
607 VideoSize 352x240
608 VideoBitRate 256
609 VideoBufferSize 40
610 VideoGopSize 30
611 AudioBitRate 64
612 StartSendOnKey
613 </Stream>
614 @end example
615
616 @item
617 MP3 audio
618 @example
619 <Stream test.mp3>
620 Feed feed1.ffm
621 Format mp2
622 AudioCodec mp3
623 AudioBitRate 64
624 AudioChannels 1
625 AudioSampleRate 44100
626 NoVideo
627 </Stream>
628 @end example
629
630 @item
631 Ogg Vorbis audio:
632 @example
633 <Stream test.ogg>
634 Feed feed1.ffm
635 Title "Stream title"
636 AudioBitRate 64
637 AudioChannels 2
638 AudioSampleRate 44100
639 NoVideo
640 </Stream>
641 @end example
642
643 @item
644 Real with audio only at 32 kbits
645 @example
646 <Stream test.ra>
647 Feed feed1.ffm
648 Format rm
649 AudioBitRate 32
650 NoVideo
651 NoAudio
652 </Stream>
653 @end example
654
655 @item
656 Real with audio and video at 64 kbits
657 @example
658 <Stream test.rm>
659 Feed feed1.ffm
660 Format rm
661 AudioBitRate 32
662 VideoBitRate 128
663 VideoFrameRate 25
664 VideoGopSize 25
665 NoAudio
666 </Stream>
667 @end example
668
669 @item
670 For stream coming from a file: you only need to set the input filename
671 and optionally a new format.
672
673 @example
674 <Stream file.rm>
675 File "/usr/local/httpd/htdocs/tlive.rm"
676 NoAudio
677 </Stream>
678 @end example
679
680 @example
681 <Stream file.asf>
682 File "/usr/local/httpd/htdocs/test.asf"
683 NoAudio
684 Author "Me"
685 Copyright "Super MegaCorp"
686 Title "Test stream from disk"
687 Comment "Test comment"
688 </Stream>
689 @end example
690 @end itemize
691
692 @c man end
693
694 @include config.texi
695 @ifset config-all
696 @ifset config-avutil
697 @include utils.texi
698 @end ifset
699 @ifset config-avcodec
700 @include codecs.texi
701 @include bitstream_filters.texi
702 @end ifset
703 @ifset config-avformat
704 @include formats.texi
705 @include protocols.texi
706 @end ifset
707 @ifset config-avdevice
708 @include devices.texi
709 @end ifset
710 @ifset config-swresample
711 @include resampler.texi
712 @end ifset
713 @ifset config-swscale
714 @include scaler.texi
715 @end ifset
716 @ifset config-avfilter
717 @include filters.texi
718 @end ifset
719 @end ifset
720
721 @chapter See Also
722
723 @ifhtml
724 @ifset config-all
725 @url{ffserver.html,ffserver},
726 @end ifset
727 @ifset config-not-all
728 @url{ffserver-all.html,ffserver-all},
729 @end ifset
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}
741 @end ifhtml
742
743 @ifnothtml
744 @ifset config-all
745 ffserver(1),
746 @end ifset
747 @ifset config-not-all
748 ffserver-all(1),
749 @end ifset
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)
754 @end ifnothtml
755
756 @include authors.texi
757
758 @ignore
759
760 @setfilename ffserver
761 @settitle ffserver video server
762
763 @end ignore
764
765 @bye