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