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.

690 lines
18KB

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