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.

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