]> git.sesse.net Git - ffmpeg/blob - doc/ffserver.texi
Merge remote-tracking branch 'qatar/master'
[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 Synopsys
13
14 The generic syntax is:
15
16 @example
17 @c man begin SYNOPSIS
18 ffserver [options]
19 @c man end
20 @end example
21
22 @chapter Description
23 @c man begin DESCRIPTION
24
25 ffserver is a streaming server for both audio and video. It supports
26
27 several live feeds, streaming from files and time shifting on live feeds
28 (you can seek to positions in the past on each live feed, provided you
29 specify a big enough feed storage in ffserver.conf).
30
31 This documentation covers only the streaming aspects of ffserver /
32 ffmpeg. All questions about parameters for ffmpeg, codec questions,
33 etc. are not covered here. Read @file{ffmpeg.html} for more
34 information.
35
36 @section How does it work?
37
38 ffserver receives prerecorded files or FFM streams from some ffmpeg
39 instance as input, then streams them over RTP/RTSP/HTTP.
40
41 An ffserver instance will listen on some port as specified in the
42 configuration file. You can launch one or more instances of ffmpeg and
43 send one or more FFM streams to the port where ffserver is expecting
44 to receive them. Alternately, you can make ffserver launch such ffmpeg
45 instances at startup.
46
47 Input streams are called feeds, and each one is specified by a <Feed>
48 section in the configuration file.
49
50 For each feed you can have different output streams in various
51 formats, each one specified by a <Stream> section in the configuration
52 file.
53
54 @section Status stream
55
56 ffserver supports an HTTP interface which exposes the current status
57 of the server.
58
59 Simply point your browser to the address of the special status stream
60 specified in the configuration file.
61
62 For example if you have:
63 @example
64 <Stream status.html>
65 Format status
66
67 # Only allow local people to get the status
68 ACL allow localhost
69 ACL allow 192.168.0.0 192.168.255.255
70 </Stream>
71 @end example
72
73 then the server will post a page with the status information when
74 the special stream @file{status.html} is requested.
75
76 @section What can this do?
77
78 When properly configured and running, you can capture video and audio in real
79 time from a suitable capture card, and stream it out over the Internet to
80 either Windows Media Player or RealAudio player (with some restrictions).
81
82 It can also stream from files, though that is currently broken. Very often, a
83 web server can be used to serve up the files just as well.
84
85 It can stream prerecorded video from .ffm files, though it is somewhat tricky
86 to make it work correctly.
87
88 @section What do I need?
89
90 I use Linux on a 900 MHz Duron with a cheapo Bt848 based TV capture card. I'm
91 using stock Linux 2.4.17 with the stock drivers. [Actually that isn't true,
92 I needed some special drivers for my motherboard-based sound card.]
93
94 I understand that FreeBSD systems work just fine as well.
95
96 @section How do I make it work?
97
98 First, build the kit. It *really* helps to have installed LAME first. Then when
99 you run the ffserver ./configure, make sure that you have the
100 @code{--enable-libmp3lame} flag turned on.
101
102 LAME is important as it allows for streaming audio to Windows Media Player.
103 Don't ask why the other audio types do not work.
104
105 As a simple test, just run the following two command lines where INPUTFILE
106 is some file which you can decode with ffmpeg:
107
108 @example
109 ffserver -f doc/ffserver.conf &
110 ffmpeg -i INPUTFILE http://localhost:8090/feed1.ffm
111 @end example
112
113 At this point you should be able to go to your Windows machine and fire up
114 Windows Media Player (WMP). Go to Open URL and enter
115
116 @example
117     http://<linuxbox>:8090/test.asf
118 @end example
119
120 You should (after a short delay) see video and hear audio.
121
122 WARNING: trying to stream test1.mpg doesn't work with WMP as it tries to
123 transfer the entire file before starting to play.
124 The same is true of AVI files.
125
126 @section What happens next?
127
128 You should edit the ffserver.conf file to suit your needs (in terms of
129 frame rates etc). Then install ffserver and ffmpeg, write a script to start
130 them up, and off you go.
131
132 @section Troubleshooting
133
134 @subsection I don't hear any audio, but video is fine.
135
136 Maybe you didn't install LAME, or got your ./configure statement wrong. Check
137 the ffmpeg output to see if a line referring to MP3 is present. If not, then
138 your configuration was incorrect. If it is, then maybe your wiring is not
139 set up correctly. Maybe the sound card is not getting data from the right
140 input source. Maybe you have a really awful audio interface (like I do)
141 that only captures in stereo and also requires that one channel be flipped.
142 If you are one of these people, then export 'AUDIO_FLIP_LEFT=1' before
143 starting ffmpeg.
144
145 @subsection The audio and video lose sync after a while.
146
147 Yes, they do.
148
149 @subsection After a long while, the video update rate goes way down in WMP.
150
151 Yes, it does. Who knows why?
152
153 @subsection WMP 6.4 behaves differently to WMP 7.
154
155 Yes, it does. Any thoughts on this would be gratefully received. These
156 differences extend to embedding WMP into a web page. [There are two
157 object IDs that you can use: The old one, which does not play well, and
158 the new one, which does (both tested on the same system). However,
159 I suspect that the new one is not available unless you have installed WMP 7].
160
161 @section What else can it do?
162
163 You can replay video from .ffm files that was recorded earlier.
164 However, there are a number of caveats, including the fact that the
165 ffserver parameters must match the original parameters used to record the
166 file. If they do not, then ffserver deletes the file before recording into it.
167 (Now that I write this, it seems broken).
168
169 You can fiddle with many of the codec choices and encoding parameters, and
170 there are a bunch more parameters that you cannot control. Post a message
171 to the mailing list if there are some 'must have' parameters. Look in
172 ffserver.conf for a list of the currently available controls.
173
174 It will automatically generate the ASX or RAM files that are often used
175 in browsers. These files are actually redirections to the underlying ASF
176 or RM file. The reason for this is that the browser often fetches the
177 entire file before starting up the external viewer. The redirection files
178 are very small and can be transferred quickly. [The stream itself is
179 often 'infinite' and thus the browser tries to download it and never
180 finishes.]
181
182 @section Tips
183
184 * When you connect to a live stream, most players (WMP, RA, etc) want to
185 buffer a certain number of seconds of material so that they can display the
186 signal continuously. However, ffserver (by default) starts sending data
187 in realtime. This means that there is a pause of a few seconds while the
188 buffering is being done by the player. The good news is that this can be
189 cured by adding a '?buffer=5' to the end of the URL. This means that the
190 stream should start 5 seconds in the past -- and so the first 5 seconds
191 of the stream are sent as fast as the network will allow. It will then
192 slow down to real time. This noticeably improves the startup experience.
193
194 You can also add a 'Preroll 15' statement into the ffserver.conf that will
195 add the 15 second prebuffering on all requests that do not otherwise
196 specify a time. In addition, ffserver will skip frames until a key_frame
197 is found. This further reduces the startup delay by not transferring data
198 that will be discarded.
199
200 * You may want to adjust the MaxBandwidth in the ffserver.conf to limit
201 the amount of bandwidth consumed by live streams.
202
203 @section Why does the ?buffer / Preroll stop working after a time?
204
205 It turns out that (on my machine at least) the number of frames successfully
206 grabbed is marginally less than the number that ought to be grabbed. This
207 means that the timestamp in the encoded data stream gets behind realtime.
208 This means that if you say 'Preroll 10', then when the stream gets 10
209 or more seconds behind, there is no Preroll left.
210
211 Fixing this requires a change in the internals of how timestamps are
212 handled.
213
214 @section Does the @code{?date=} stuff work.
215
216 Yes (subject to the limitation outlined above). Also note that whenever you
217 start ffserver, it deletes the ffm file (if any parameters have changed),
218 thus wiping out what you had recorded before.
219
220 The format of the @code{?date=xxxxxx} is fairly flexible. You should use one
221 of the following formats (the 'T' is literal):
222
223 @example
224 * YYYY-MM-DDTHH:MM:SS     (localtime)
225 * YYYY-MM-DDTHH:MM:SSZ    (UTC)
226 @end example
227
228 You can omit the YYYY-MM-DD, and then it refers to the current day. However
229 note that @samp{?date=16:00:00} refers to 16:00 on the current day -- this
230 may be in the future and so is unlikely to be useful.
231
232 You use this by adding the ?date= to the end of the URL for the stream.
233 For example:   @samp{http://localhost:8080/test.asf?date=2002-07-26T23:05:00}.
234 @c man end
235
236 @section What is FFM, FFM2
237
238 FFM and FFM2 are formats used by ffserver. They allow storing a wide varity of
239 video and audio streams and encoding options, and can store a moving time segment
240 of an infinite movie or a whole movie.
241
242 FFM is version specific, and there is limited compatibility of FFM files
243 generated by one version of ffmpeg/ffserver and another version of
244 ffmpeg/ffserver. It may work but its not guaranteed to work.
245
246 FFM2 is extensible while maintaining compatibility and should work between
247 differing versions of tools. FFM2 is the default.
248
249 @chapter Options
250 @c man begin OPTIONS
251
252 @include avtools-common-opts.texi
253
254 @section Main options
255
256 @table @option
257 @item -f @var{configfile}
258 Use @file{configfile} instead of @file{/etc/ffserver.conf}.
259 @item -n
260 Enable no-launch mode. This option disables all the Launch directives
261 within the various <Stream> sections. Since ffserver will not launch
262 any ffmpeg instances, you will have to launch them manually.
263 @item -d
264 Enable debug mode. This option increases log verbosity, directs log
265 messages to stdout.
266 @end table
267 @c man end
268
269 @ignore
270
271 @setfilename ffserver
272 @settitle ffserver video server
273
274 @c man begin SEEALSO
275
276 ffmpeg(1), ffplay(1), ffprobe(1), the @file{ffserver.conf}
277 example and the FFmpeg HTML documentation
278 @c man end
279
280 @c man begin AUTHORS
281 The FFmpeg developers
282 @c man end
283
284 @end ignore
285
286 @bye