You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

708 lines
19KB

  1. \input texinfo @c -*- texinfo -*-
  2. @settitle ffserver Documentation
  3. @titlepage
  4. @center @titlefont{ffserver Documentation}
  5. @end titlepage
  6. @top
  7. @contents
  8. @chapter Synopsis
  9. ffserver [@var{options}]
  10. @chapter Description
  11. @c man begin DESCRIPTION
  12. @command{ffserver} is a streaming server for both audio and video. It
  13. supports several live feeds, streaming from files and time shifting on
  14. live feeds (you can seek to positions in the past on each live feed,
  15. provided you specify a big enough feed storage in
  16. @file{ffserver.conf}).
  17. @command{ffserver} receives prerecorded files or FFM streams from some
  18. @command{ffmpeg} instance as input, then streams them over
  19. RTP/RTSP/HTTP.
  20. An @command{ffserver} instance will listen on some port as specified
  21. in the configuration file. You can launch one or more instances of
  22. @command{ffmpeg} and send one or more FFM streams to the port where
  23. ffserver is expecting to receive them. Alternately, you can make
  24. @command{ffserver} launch such @command{ffmpeg} instances at startup.
  25. Input streams are called feeds, and each one is specified by a
  26. @code{<Feed>} section in the configuration file.
  27. For each feed you can have different output streams in various
  28. formats, each one specified by a @code{<Stream>} section in the
  29. configuration file.
  30. @section Status stream
  31. ffserver supports an HTTP interface which exposes the current status
  32. of the server.
  33. Simply point your browser to the address of the special status stream
  34. specified in the configuration file.
  35. For example if you have:
  36. @example
  37. <Stream status.html>
  38. Format status
  39. # Only allow local people to get the status
  40. ACL allow localhost
  41. ACL allow 192.168.0.0 192.168.255.255
  42. </Stream>
  43. @end example
  44. then the server will post a page with the status information when
  45. the special stream @file{status.html} is requested.
  46. @section What can this do?
  47. When properly configured and running, you can capture video and audio in real
  48. time from a suitable capture card, and stream it out over the Internet to
  49. either Windows Media Player or RealAudio player (with some restrictions).
  50. It can also stream from files, though that is currently broken. Very often, a
  51. web server can be used to serve up the files just as well.
  52. It can stream prerecorded video from .ffm files, though it is somewhat tricky
  53. to make it work correctly.
  54. @section How do I make it work?
  55. First, build the kit. It *really* helps to have installed LAME first. Then when
  56. you run the ffserver ./configure, make sure that you have the
  57. @code{--enable-libmp3lame} flag turned on.
  58. LAME is important as it allows for streaming audio to Windows Media Player.
  59. Don't ask why the other audio types do not work.
  60. As a simple test, just run the following two command lines where INPUTFILE
  61. is some file which you can decode with ffmpeg:
  62. @example
  63. ffserver -f doc/ffserver.conf &
  64. ffmpeg -i INPUTFILE http://localhost:8090/feed1.ffm
  65. @end example
  66. At this point you should be able to go to your Windows machine and fire up
  67. Windows Media Player (WMP). Go to Open URL and enter
  68. @example
  69. http://<linuxbox>:8090/test.asf
  70. @end example
  71. You should (after a short delay) see video and hear audio.
  72. WARNING: trying to stream test1.mpg doesn't work with WMP as it tries to
  73. transfer the entire file before starting to play.
  74. The same is true of AVI files.
  75. @section What happens next?
  76. You should edit the ffserver.conf file to suit your needs (in terms of
  77. frame rates etc). Then install ffserver and ffmpeg, write a script to start
  78. them up, and off you go.
  79. @section Troubleshooting
  80. @subsection The audio and video lose sync after a while.
  81. Yes, they do.
  82. @subsection After a long while, the video update rate goes way down in WMP.
  83. Yes, it does. Who knows why?
  84. @subsection WMP 6.4 behaves differently to WMP 7.
  85. Yes, it does. Any thoughts on this would be gratefully received. These
  86. differences extend to embedding WMP into a web page. [There are two
  87. object IDs that you can use: The old one, which does not play well, and
  88. the new one, which does (both tested on the same system). However,
  89. I suspect that the new one is not available unless you have installed WMP 7].
  90. @section What else can it do?
  91. You can replay video from .ffm files that was recorded earlier.
  92. However, there are a number of caveats, including the fact that the
  93. ffserver parameters must match the original parameters used to record the
  94. file. If they do not, then ffserver deletes the file before recording into it.
  95. (Now that I write this, it seems broken).
  96. You can fiddle with many of the codec choices and encoding parameters, and
  97. there are a bunch more parameters that you cannot control. Post a message
  98. to the mailing list if there are some 'must have' parameters. Look in
  99. ffserver.conf for a list of the currently available controls.
  100. It will automatically generate the ASX or RAM files that are often used
  101. in browsers. These files are actually redirections to the underlying ASF
  102. or RM file. The reason for this is that the browser often fetches the
  103. entire file before starting up the external viewer. The redirection files
  104. are very small and can be transferred quickly. [The stream itself is
  105. often 'infinite' and thus the browser tries to download it and never
  106. finishes.]
  107. @section Tips
  108. * When you connect to a live stream, most players (WMP, RA, etc) want to
  109. buffer a certain number of seconds of material so that they can display the
  110. signal continuously. However, ffserver (by default) starts sending data
  111. in realtime. This means that there is a pause of a few seconds while the
  112. buffering is being done by the player. The good news is that this can be
  113. cured by adding a '?buffer=5' to the end of the URL. This means that the
  114. stream should start 5 seconds in the past -- and so the first 5 seconds
  115. of the stream are sent as fast as the network will allow. It will then
  116. slow down to real time. This noticeably improves the startup experience.
  117. You can also add a 'Preroll 15' statement into the ffserver.conf that will
  118. add the 15 second prebuffering on all requests that do not otherwise
  119. specify a time. In addition, ffserver will skip frames until a key_frame
  120. is found. This further reduces the startup delay by not transferring data
  121. that will be discarded.
  122. * You may want to adjust the MaxBandwidth in the ffserver.conf to limit
  123. the amount of bandwidth consumed by live streams.
  124. @section Why does the ?buffer / Preroll stop working after a time?
  125. It turns out that (on my machine at least) the number of frames successfully
  126. grabbed is marginally less than the number that ought to be grabbed. This
  127. means that the timestamp in the encoded data stream gets behind realtime.
  128. This means that if you say 'Preroll 10', then when the stream gets 10
  129. or more seconds behind, there is no Preroll left.
  130. Fixing this requires a change in the internals of how timestamps are
  131. handled.
  132. @section Does the @code{?date=} stuff work.
  133. Yes (subject to the limitation outlined above). Also note that whenever you
  134. start ffserver, it deletes the ffm file (if any parameters have changed),
  135. thus wiping out what you had recorded before.
  136. The format of the @code{?date=xxxxxx} is fairly flexible. You should use one
  137. of the following formats (the 'T' is literal):
  138. @example
  139. * YYYY-MM-DDTHH:MM:SS (localtime)
  140. * YYYY-MM-DDTHH:MM:SSZ (UTC)
  141. @end example
  142. You can omit the YYYY-MM-DD, and then it refers to the current day. However
  143. note that @samp{?date=16:00:00} refers to 16:00 on the current day -- this
  144. may be in the future and so is unlikely to be useful.
  145. You use this by adding the ?date= to the end of the URL for the stream.
  146. For example: @samp{http://localhost:8080/test.asf?date=2002-07-26T23:05:00}.
  147. @c man end
  148. @section What is FFM, FFM2
  149. FFM and FFM2 are formats used by ffserver. They allow storing a wide variety of
  150. video and audio streams and encoding options, and can store a moving time segment
  151. of an infinite movie or a whole movie.
  152. FFM is version specific, and there is limited compatibility of FFM files
  153. generated by one version of ffmpeg/ffserver and another version of
  154. ffmpeg/ffserver. It may work but it is not guaranteed to work.
  155. FFM2 is extensible while maintaining compatibility and should work between
  156. differing versions of tools. FFM2 is the default.
  157. @chapter Options
  158. @c man begin OPTIONS
  159. @include fftools-common-opts.texi
  160. @section Main options
  161. @table @option
  162. @item -f @var{configfile}
  163. Use @file{configfile} instead of @file{/etc/ffserver.conf}.
  164. @item -n
  165. Enable no-launch mode. This option disables all the Launch directives
  166. within the various <Stream> sections. Since ffserver will not launch
  167. any ffmpeg instances, you will have to launch them manually.
  168. @item -d
  169. Enable debug mode. This option increases log verbosity, directs log
  170. messages to stdout.
  171. @end table
  172. @chapter Configuration file syntax
  173. @command{ffserver} reads a configuration file containing global
  174. options and settings for each stream and feed.
  175. The configuration file consists of global options and dedicated
  176. sections, which must be introduced by "<@var{SECTION_NAME}
  177. @var{ARGS}>" on a separate line and must be terminated by a line in
  178. the form "</@var{SECTION_NAME}>". @var{ARGS} is optional.
  179. Currently the following sections are recognized: @samp{Feed},
  180. @samp{Stream}, @samp{Redirect}.
  181. A line starting with @code{#} is ignored and treated as a comment.
  182. @section Global options
  183. @table @option
  184. @item Port @var{port_number}
  185. @item RTSPPort @var{port_number}
  186. Set TCP port number on which the HTTP/RTSP server is listening. You
  187. must select a different port from your standard HTTP web server if it
  188. is running on the same computer.
  189. If not specified, no corresponding server will be created.
  190. @item BindAddress @var{ip_address}
  191. @item RTSPBindAddress @var{ip_address}
  192. Set address on which the HTTP/RTPS server is bound. Only useful if you
  193. have several network interfaces.
  194. @item MaxHTTPConnections @var{n}
  195. Set number of simultaneous HTTP connections that can be handled. It
  196. has to be defined @emph{before} the @option{MaxClients} parameter,
  197. since it defines the @option{MaxClients} maximum limit.
  198. Default value is 2000.
  199. @item MaxClients @var{n}
  200. Set number of simultaneous requests that can be handled. Since
  201. @command{ffserver} is very fast, it is more likely that you will want
  202. to leave this high and use @option{MaxBandwidth}.
  203. Default value is 5.
  204. @item MaxBandwidth @var{kbps}
  205. Set the maximum amount of kbit/sec that you are prepared to consume
  206. when streaming to clients.
  207. Default value is 1000.
  208. @item CustomLog @var{filename}
  209. Set access log file (uses standard Apache log file format).
  210. '-' is the standard output.
  211. @end table
  212. @section ACL syntax
  213. An ACL (Access Control List) specifies the address which are allowed
  214. to access a given stream, or to write a given feed.
  215. It accepts the folling forms
  216. @itemize
  217. @item
  218. Allow/deny access to @var{address}.
  219. @example
  220. ACL ALLOW <address>
  221. ACL DENY <address>
  222. @end example
  223. @item
  224. Allow/deny access to ranges of addresses from @var{first_address} to
  225. @var{last_address}.
  226. @example
  227. ACL ALLOW <first_address> <last_address>
  228. ACL DENY <first_address> <last_address>
  229. @end example
  230. @end itemize
  231. You can repeat the ACL allow/deny as often as you like. It is on a per
  232. stream basis. The first match defines the action. If there are no matches,
  233. then the default is the inverse of the last ACL statement.
  234. Thus 'ACL allow localhost' only allows access from localhost.
  235. 'ACL deny 1.0.0.0 1.255.255.255' would deny the whole of network 1 and
  236. allow everybody else.
  237. @section Feed section
  238. A Feed section defines a feed provided to @command{ffserver}.
  239. Each live feed contains one video and/or audio sequence coming from an
  240. @command{ffmpeg} encoder or another @command{ffserver}. This sequence
  241. may be encoded simultaneously with several codecs at several
  242. resolutions.
  243. A feed instance specification is introduced by a line in the form:
  244. @example
  245. <Feed FEED_FILENAME>
  246. @end example
  247. where @var{FEED_FILENAME} specifies the unique name of the FFM stream.
  248. The following options are recognized within a Feed section.
  249. @table @option
  250. @item File @var{filename}
  251. Set the path where the file is stored on disk.
  252. @item FileMaxSize @var{size}
  253. Set maximum size of the feed. 0 means unlimited.
  254. @item ReadOnlyFile @var{filename}
  255. Mark the file as readonly and it will not be deleted or updated.
  256. @item Launch
  257. @item ACL
  258. Specify the list of IP address which are allowed or denied to write
  259. the feed. Multiple ACL options can be specified.
  260. @end table
  261. @section Stream section
  262. A Stream section defines a stream provided by @command{ffserver}, and
  263. identified by a single name.
  264. The stream is sent when answering a request containing the stream
  265. name.
  266. A stream section must be introduced by the line:
  267. @example
  268. <Stream STREAM_NAME>
  269. @end example
  270. where @var{STREAM_NAME} specifies the unique name of the stream.
  271. The following options are recognized within a Stream section.
  272. @table @option
  273. @item Feed @var{feed_name}
  274. Set the input feed.
  275. Must be specified.
  276. @item Format @var{format_name}
  277. Set the format of the stream.
  278. Must be the name of a format recognized by FFmpeg.
  279. @item AudioBitRate @var{rate}
  280. Set bitrate for the audio stream in KB per second.
  281. @item AudioChannels @var{n}
  282. Set number of audio channels.
  283. @item AudioSampleRate @var{n}
  284. Set sampling frequency for audio. When using low bitrates, you should
  285. lower this frequency to 22050 or 11025. The supported frequencies
  286. depend on the selected audio codec.
  287. @item VideoBitRate @var{n}
  288. Set bitrate for the video stream in KB per second.
  289. @item VideoBitRateRange @var{range}
  290. Set video bitrate range.
  291. @item VideoBitRateRangeTolerance @var{n}
  292. @item PixelFormat
  293. Set video pixel format.
  294. @item VideoBufferSize @var{n}
  295. Set ratecontrol buffer size.
  296. @item VideoFrameRate @var{n}
  297. Set number of video frames per second.
  298. @item VideoSize
  299. Set size of the video frame, must be an abbreviation or in the form
  300. @var{W}x@var{H}. See @ref{video size syntax,,the Video size section
  301. in the ffmpeg-utils(1) manual,ffmpeg-utils}.
  302. Default value is @code{160x128}.
  303. @item VideoIntraOnly
  304. Transmit only intra frames (useful for low bitrates, but kills frame rate).
  305. @item VideoGopSize @var{n}
  306. If non-intra only, an intra frame is transmitted every VideoGopSize
  307. frames. Video synchronization can only begin at an intra frame.
  308. @item VideoHighQuality
  309. @item Video4MotionVector
  310. @item AudioCodec @var{codec_name}
  311. @item VideoCodec @var{codec_name}
  312. Set audio/video codec.
  313. @item NoAudio
  314. @item NoVideo
  315. Suppress audio/video.
  316. @item VideoQMin @var{n}
  317. @item VideoQMax @var{n}
  318. Set video qmin/qmax.
  319. @item AVOptionAudio @var{option} @var{value}
  320. @item AVOptionVideo @var{option} @var{value}
  321. Set generic option for audio/video stream.
  322. @item AVPresetAudio @var{preset}
  323. @item AVOptionVideo @var{preset}
  324. Set preset for audio/video stream.
  325. @var{preset} must be the path of a preset file.
  326. @item Preroll @var{n}
  327. Set this to the number of seconds backwards in time to start. Note that
  328. most players will buffer 5-10 seconds of video, and also you need to allow
  329. for a keyframe to appear in the data stream.
  330. @item ACL @var{spec}
  331. Set ACL for the stream.
  332. @item Author @var{value}
  333. @item Comment @var{value}
  334. @item Copyright @var{value}
  335. @item Title @var{value}
  336. Set metadata corresponding to the option.
  337. @item StartSendOnKey
  338. Do not send stream until it gets the first key frame. By default
  339. @command{ffserver} will send data immediately.
  340. @item FaviconURL @var{url}
  341. Set favicon (favourite icon) for the server status page. It is ignored
  342. for regular streams.
  343. @end table
  344. @subsection Server status stream
  345. A server status stream is a special stream which is used to show
  346. statistics about the @command{ffserver} operations.
  347. It must be specified setting the option @option{Format} to
  348. @code{status}.
  349. @section Redirect section
  350. A redirect section specifies where to redirect the requested URL to
  351. another page.
  352. A redirect section must be introduced by the line:
  353. @example
  354. <Redirect NAME>
  355. @end example
  356. where @var{NAME} is the name of the page which should be redirected.
  357. It only accepts the option @option{URL}, which specify the redirection
  358. URL.
  359. @chapter Stream examples
  360. @itemize
  361. @item
  362. Multipart JPEG
  363. @example
  364. <Stream test.mjpg>
  365. Feed feed1.ffm
  366. Format mpjpeg
  367. VideoFrameRate 2
  368. VideoIntraOnly
  369. NoAudio
  370. Strict -1
  371. </Stream>
  372. @end example
  373. @item
  374. Single JPEG
  375. @example
  376. <Stream test.jpg>
  377. Feed feed1.ffm
  378. Format jpeg
  379. VideoFrameRate 2
  380. VideoIntraOnly
  381. #VideoSize 352x240
  382. NoAudio
  383. Strict -1
  384. </Stream>
  385. @end example
  386. @item
  387. Flash
  388. @example
  389. <Stream test.swf>
  390. Feed feed1.ffm
  391. Format swf
  392. VideoFrameRate 2
  393. VideoIntraOnly
  394. NoAudio
  395. </Stream>
  396. @end example
  397. @item
  398. ASF compatible
  399. @example
  400. <Stream test.asf>
  401. Feed feed1.ffm
  402. Format asf
  403. VideoFrameRate 15
  404. VideoSize 352x240
  405. VideoBitRate 256
  406. VideoBufferSize 40
  407. VideoGopSize 30
  408. AudioBitRate 64
  409. StartSendOnKey
  410. </Stream>
  411. @end example
  412. @item
  413. MP3 audio
  414. @example
  415. <Stream test.mp3>
  416. Feed feed1.ffm
  417. Format mp2
  418. AudioCodec mp3
  419. AudioBitRate 64
  420. AudioChannels 1
  421. AudioSampleRate 44100
  422. NoVideo
  423. </Stream>
  424. @end example
  425. @item
  426. Ogg Vorbis audio:
  427. @example
  428. <Stream test.ogg>
  429. Feed feed1.ffm
  430. Title "Stream title"
  431. AudioBitRate 64
  432. AudioChannels 2
  433. AudioSampleRate 44100
  434. NoVideo
  435. </Stream>
  436. @end example
  437. @item
  438. Real with audio only at 32 kbits
  439. @example
  440. <Stream test.ra>
  441. Feed feed1.ffm
  442. Format rm
  443. AudioBitRate 32
  444. NoVideo
  445. NoAudio
  446. </Stream>
  447. @end example
  448. @item
  449. Real with audio and video at 64 kbits
  450. @example
  451. <Stream test.rm>
  452. Feed feed1.ffm
  453. Format rm
  454. AudioBitRate 32
  455. VideoBitRate 128
  456. VideoFrameRate 25
  457. VideoGopSize 25
  458. NoAudio
  459. </Stream>
  460. @end example
  461. @item
  462. For stream coming from a file: you only need to set the input filename
  463. and optionally a new format.
  464. @example
  465. <Stream file.rm>
  466. File "/usr/local/httpd/htdocs/tlive.rm"
  467. NoAudio
  468. </Stream>
  469. @end example
  470. @example
  471. <Stream file.asf>
  472. File "/usr/local/httpd/htdocs/test.asf"
  473. NoAudio
  474. Author "Me"
  475. Copyright "Super MegaCorp"
  476. Title "Test stream from disk"
  477. Comment "Test comment"
  478. </Stream>
  479. @end example
  480. @end itemize
  481. @c man end
  482. @include config.texi
  483. @ifset config-all
  484. @ifset config-avutil
  485. @include utils.texi
  486. @end ifset
  487. @ifset config-avcodec
  488. @include codecs.texi
  489. @include bitstream_filters.texi
  490. @end ifset
  491. @ifset config-avformat
  492. @include formats.texi
  493. @include protocols.texi
  494. @end ifset
  495. @ifset config-avdevice
  496. @include devices.texi
  497. @end ifset
  498. @ifset config-swresample
  499. @include resampler.texi
  500. @end ifset
  501. @ifset config-swscale
  502. @include scaler.texi
  503. @end ifset
  504. @ifset config-avfilter
  505. @include filters.texi
  506. @end ifset
  507. @end ifset
  508. @chapter See Also
  509. @ifhtml
  510. @ifset config-all
  511. @url{ffserver.html,ffserver},
  512. @end ifset
  513. @ifset config-not-all
  514. @url{ffserver-all.html,ffserver-all},
  515. @end ifset
  516. the @file{doc/ffserver.conf} example,
  517. @url{ffmpeg.html,ffmpeg}, @url{ffplay.html,ffplay}, @url{ffprobe.html,ffprobe},
  518. @url{ffmpeg-utils.html,ffmpeg-utils},
  519. @url{ffmpeg-scaler.html,ffmpeg-scaler},
  520. @url{ffmpeg-resampler.html,ffmpeg-resampler},
  521. @url{ffmpeg-codecs.html,ffmpeg-codecs},
  522. @url{ffmpeg-bitstream-filters.html,ffmpeg-bitstream-filters},
  523. @url{ffmpeg-formats.html,ffmpeg-formats},
  524. @url{ffmpeg-devices.html,ffmpeg-devices},
  525. @url{ffmpeg-protocols.html,ffmpeg-protocols},
  526. @url{ffmpeg-filters.html,ffmpeg-filters}
  527. @end ifhtml
  528. @ifnothtml
  529. @ifset config-all
  530. ffserver(1),
  531. @end ifset
  532. @ifset config-not-all
  533. ffserver-all(1),
  534. @end ifset
  535. the @file{doc/ffserver.conf} example, ffmpeg(1), ffplay(1), ffprobe(1),
  536. ffmpeg-utils(1), ffmpeg-scaler(1), ffmpeg-resampler(1),
  537. ffmpeg-codecs(1), ffmpeg-bitstream-filters(1), ffmpeg-formats(1),
  538. ffmpeg-devices(1), ffmpeg-protocols(1), ffmpeg-filters(1)
  539. @end ifnothtml
  540. @include authors.texi
  541. @ignore
  542. @setfilename ffserver
  543. @settitle ffserver video server
  544. @end ignore
  545. @bye