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.

691 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.
  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{<Stream>} 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, directs log
  153. messages to stdout.
  154. @end table
  155. @chapter Configuration file syntax
  156. @command{ffserver} reads a configuration file containing global
  157. options and settings for each stream and feed.
  158. The configuration file consists of global options and dedicated
  159. sections, which must be introduced by "<@var{SECTION_NAME}
  160. @var{ARGS}>" on a separate line and must be terminated by a line in
  161. the form "</@var{SECTION_NAME}>". @var{ARGS} is optional.
  162. Currently the following sections are recognized: @samp{Feed},
  163. @samp{Stream}, @samp{Redirect}.
  164. A line starting with @code{#} is ignored and treated as a comment.
  165. Name of options and sections are case-insensitive.
  166. @section Global options
  167. @table @option
  168. @item Port @var{port_number}
  169. @item RTSPPort @var{port_number}
  170. Set TCP port number on which the HTTP/RTSP server is listening. You
  171. must select a different port from your standard HTTP web server if it
  172. is running on the same computer.
  173. If not specified, no corresponding server will be created.
  174. @item BindAddress @var{ip_address}
  175. @item RTSPBindAddress @var{ip_address}
  176. Set address on which the HTTP/RTSP server is bound. Only useful if you
  177. have several network interfaces.
  178. @item MaxHTTPConnections @var{n}
  179. Set number of simultaneous HTTP connections that can be handled. It
  180. has to be defined @emph{before} the @option{MaxClients} parameter,
  181. since it defines the @option{MaxClients} maximum limit.
  182. Default value is 2000.
  183. @item MaxClients @var{n}
  184. Set number of simultaneous requests that can be handled. Since
  185. @command{ffserver} is very fast, it is more likely that you will want
  186. to leave this high and use @option{MaxBandwidth}.
  187. Default value is 5.
  188. @item MaxBandwidth @var{kbps}
  189. Set the maximum amount of kbit/sec that you are prepared to consume
  190. when streaming to clients.
  191. Default value is 1000.
  192. @item CustomLog @var{filename}
  193. Set access log file (uses standard Apache log file format).
  194. '-' is the standard output.
  195. @item NoDaemon
  196. Set no-daemon mode. This option is currently ignored since now
  197. @command{ffserver} will work in no-daemon mode, and is deprecated.
  198. @end table
  199. @section ACL syntax
  200. An ACL (Access Control List) specifies the address which are allowed
  201. to access a given stream, or to write a given feed.
  202. It accepts the folling forms
  203. @itemize
  204. @item
  205. Allow/deny access to @var{address}.
  206. @example
  207. ACL ALLOW <address>
  208. ACL DENY <address>
  209. @end example
  210. @item
  211. Allow/deny access to ranges of addresses from @var{first_address} to
  212. @var{last_address}.
  213. @example
  214. ACL ALLOW <first_address> <last_address>
  215. ACL DENY <first_address> <last_address>
  216. @end example
  217. @end itemize
  218. You can repeat the ACL allow/deny as often as you like. It is on a per
  219. stream basis. The first match defines the action. If there are no matches,
  220. then the default is the inverse of the last ACL statement.
  221. Thus 'ACL allow localhost' only allows access from localhost.
  222. 'ACL deny 1.0.0.0 1.255.255.255' would deny the whole of network 1 and
  223. allow everybody else.
  224. @section Feed section
  225. A Feed section defines a feed provided to @command{ffserver}.
  226. Each live feed contains one video and/or audio sequence coming from an
  227. @command{ffmpeg} encoder or another @command{ffserver}. This sequence
  228. may be encoded simultaneously with several codecs at several
  229. resolutions.
  230. A feed instance specification is introduced by a line in the form:
  231. @example
  232. <Feed FEED_FILENAME>
  233. @end example
  234. where @var{FEED_FILENAME} specifies the unique name of the FFM stream.
  235. The following options are recognized within a Feed section.
  236. @table @option
  237. @item File @var{filename}
  238. Set the path where the file is stored on disk.
  239. @item FileMaxSize @var{size}
  240. Set maximum size of the feed. 0 means unlimited.
  241. @item ReadOnlyFile @var{filename}
  242. Mark the file as readonly and it will not be deleted or updated.
  243. @item Launch
  244. @item ACL
  245. Specify the list of IP address which are allowed or denied to write
  246. the feed. Multiple ACL options can be specified.
  247. @end table
  248. @section Stream section
  249. A Stream section defines a stream provided by @command{ffserver}, and
  250. identified by a single name.
  251. The stream is sent when answering a request containing the stream
  252. name.
  253. A stream section must be introduced by the line:
  254. @example
  255. <Stream STREAM_NAME>
  256. @end example
  257. where @var{STREAM_NAME} specifies the unique name of the stream.
  258. The following options are recognized within a Stream section.
  259. @table @option
  260. @item Feed @var{feed_name}
  261. Set the input feed.
  262. Must be specified.
  263. @item Format @var{format_name}
  264. Set the format of the stream.
  265. Must be the name of a format recognized by FFmpeg.
  266. @item AudioBitRate @var{rate}
  267. Set bitrate for the audio stream in KB per second.
  268. @item AudioChannels @var{n}
  269. Set number of audio channels.
  270. @item AudioSampleRate @var{n}
  271. Set sampling frequency for audio. When using low bitrates, you should
  272. lower this frequency to 22050 or 11025. The supported frequencies
  273. depend on the selected audio codec.
  274. @item VideoBitRate @var{n}
  275. Set bitrate for the video stream in KB per second.
  276. @item VideoBitRateRange @var{range}
  277. Set video bitrate range.
  278. @item VideoBitRateRangeTolerance @var{n}
  279. @item PixelFormat
  280. Set video pixel format.
  281. @item VideoBufferSize @var{n}
  282. Set ratecontrol buffer size.
  283. @item VideoFrameRate @var{n}
  284. Set number of video frames per second.
  285. @item VideoSize
  286. Set size of the video frame, must be an abbreviation or in the form
  287. @var{W}x@var{H}. See @ref{video size syntax,,the Video size section
  288. in the ffmpeg-utils(1) manual,ffmpeg-utils}.
  289. Default value is @code{160x128}.
  290. @item VideoIntraOnly
  291. Transmit only intra frames (useful for low bitrates, but kills frame rate).
  292. @item VideoGopSize @var{n}
  293. If non-intra only, an intra frame is transmitted every VideoGopSize
  294. frames. Video synchronization can only begin at an intra frame.
  295. @item VideoHighQuality
  296. @item Video4MotionVector
  297. @item AudioCodec @var{codec_name}
  298. @item VideoCodec @var{codec_name}
  299. Set audio/video codec.
  300. @item NoAudio
  301. @item NoVideo
  302. Suppress audio/video.
  303. @item VideoQMin @var{n}
  304. @item VideoQMax @var{n}
  305. Set video qmin/qmax.
  306. @item AVOptionAudio @var{option} @var{value}
  307. @item AVOptionVideo @var{option} @var{value}
  308. Set generic option for audio/video stream.
  309. @item AVPresetAudio @var{preset}
  310. @item AVOptionVideo @var{preset}
  311. Set preset for audio/video stream.
  312. @var{preset} must be the path of a preset file.
  313. @item Preroll @var{n}
  314. Set this to the number of seconds backwards in time to start. Note that
  315. most players will buffer 5-10 seconds of video, and also you need to allow
  316. for a keyframe to appear in the data stream.
  317. Default value is 0.
  318. @item ACL @var{spec}
  319. Set ACL for the stream.
  320. @item Author @var{value}
  321. @item Comment @var{value}
  322. @item Copyright @var{value}
  323. @item Title @var{value}
  324. Set metadata corresponding to the option.
  325. @item StartSendOnKey
  326. Do not send stream until it gets the first key frame. By default
  327. @command{ffserver} will send data immediately.
  328. @item FaviconURL @var{url}
  329. Set favicon (favourite icon) for the server status page. It is ignored
  330. for regular streams.
  331. @end table
  332. @subsection Server status stream
  333. A server status stream is a special stream which is used to show
  334. statistics about the @command{ffserver} operations.
  335. It must be specified setting the option @option{Format} to
  336. @code{status}.
  337. @section Redirect section
  338. A redirect section specifies where to redirect the requested URL to
  339. another page.
  340. A redirect section must be introduced by the line:
  341. @example
  342. <Redirect NAME>
  343. @end example
  344. where @var{NAME} is the name of the page which should be redirected.
  345. It only accepts the option @option{URL}, which specify the redirection
  346. URL.
  347. @chapter Stream examples
  348. @itemize
  349. @item
  350. Multipart JPEG
  351. @example
  352. <Stream test.mjpg>
  353. Feed feed1.ffm
  354. Format mpjpeg
  355. VideoFrameRate 2
  356. VideoIntraOnly
  357. NoAudio
  358. Strict -1
  359. </Stream>
  360. @end example
  361. @item
  362. Single JPEG
  363. @example
  364. <Stream test.jpg>
  365. Feed feed1.ffm
  366. Format jpeg
  367. VideoFrameRate 2
  368. VideoIntraOnly
  369. #VideoSize 352x240
  370. NoAudio
  371. Strict -1
  372. </Stream>
  373. @end example
  374. @item
  375. Flash
  376. @example
  377. <Stream test.swf>
  378. Feed feed1.ffm
  379. Format swf
  380. VideoFrameRate 2
  381. VideoIntraOnly
  382. NoAudio
  383. </Stream>
  384. @end example
  385. @item
  386. ASF compatible
  387. @example
  388. <Stream test.asf>
  389. Feed feed1.ffm
  390. Format asf
  391. VideoFrameRate 15
  392. VideoSize 352x240
  393. VideoBitRate 256
  394. VideoBufferSize 40
  395. VideoGopSize 30
  396. AudioBitRate 64
  397. StartSendOnKey
  398. </Stream>
  399. @end example
  400. @item
  401. MP3 audio
  402. @example
  403. <Stream test.mp3>
  404. Feed feed1.ffm
  405. Format mp2
  406. AudioCodec mp3
  407. AudioBitRate 64
  408. AudioChannels 1
  409. AudioSampleRate 44100
  410. NoVideo
  411. </Stream>
  412. @end example
  413. @item
  414. Ogg Vorbis audio:
  415. @example
  416. <Stream test.ogg>
  417. Feed feed1.ffm
  418. Title "Stream title"
  419. AudioBitRate 64
  420. AudioChannels 2
  421. AudioSampleRate 44100
  422. NoVideo
  423. </Stream>
  424. @end example
  425. @item
  426. Real with audio only at 32 kbits
  427. @example
  428. <Stream test.ra>
  429. Feed feed1.ffm
  430. Format rm
  431. AudioBitRate 32
  432. NoVideo
  433. NoAudio
  434. </Stream>
  435. @end example
  436. @item
  437. Real with audio and video at 64 kbits
  438. @example
  439. <Stream test.rm>
  440. Feed feed1.ffm
  441. Format rm
  442. AudioBitRate 32
  443. VideoBitRate 128
  444. VideoFrameRate 25
  445. VideoGopSize 25
  446. NoAudio
  447. </Stream>
  448. @end example
  449. @item
  450. For stream coming from a file: you only need to set the input filename
  451. and optionally a new format.
  452. @example
  453. <Stream file.rm>
  454. File "/usr/local/httpd/htdocs/tlive.rm"
  455. NoAudio
  456. </Stream>
  457. @end example
  458. @example
  459. <Stream file.asf>
  460. File "/usr/local/httpd/htdocs/test.asf"
  461. NoAudio
  462. Author "Me"
  463. Copyright "Super MegaCorp"
  464. Title "Test stream from disk"
  465. Comment "Test comment"
  466. </Stream>
  467. @end example
  468. @end itemize
  469. @c man end
  470. @include config.texi
  471. @ifset config-all
  472. @ifset config-avutil
  473. @include utils.texi
  474. @end ifset
  475. @ifset config-avcodec
  476. @include codecs.texi
  477. @include bitstream_filters.texi
  478. @end ifset
  479. @ifset config-avformat
  480. @include formats.texi
  481. @include protocols.texi
  482. @end ifset
  483. @ifset config-avdevice
  484. @include devices.texi
  485. @end ifset
  486. @ifset config-swresample
  487. @include resampler.texi
  488. @end ifset
  489. @ifset config-swscale
  490. @include scaler.texi
  491. @end ifset
  492. @ifset config-avfilter
  493. @include filters.texi
  494. @end ifset
  495. @end ifset
  496. @chapter See Also
  497. @ifhtml
  498. @ifset config-all
  499. @url{ffserver.html,ffserver},
  500. @end ifset
  501. @ifset config-not-all
  502. @url{ffserver-all.html,ffserver-all},
  503. @end ifset
  504. the @file{doc/ffserver.conf} example,
  505. @url{ffmpeg.html,ffmpeg}, @url{ffplay.html,ffplay}, @url{ffprobe.html,ffprobe},
  506. @url{ffmpeg-utils.html,ffmpeg-utils},
  507. @url{ffmpeg-scaler.html,ffmpeg-scaler},
  508. @url{ffmpeg-resampler.html,ffmpeg-resampler},
  509. @url{ffmpeg-codecs.html,ffmpeg-codecs},
  510. @url{ffmpeg-bitstream-filters.html,ffmpeg-bitstream-filters},
  511. @url{ffmpeg-formats.html,ffmpeg-formats},
  512. @url{ffmpeg-devices.html,ffmpeg-devices},
  513. @url{ffmpeg-protocols.html,ffmpeg-protocols},
  514. @url{ffmpeg-filters.html,ffmpeg-filters}
  515. @end ifhtml
  516. @ifnothtml
  517. @ifset config-all
  518. ffserver(1),
  519. @end ifset
  520. @ifset config-not-all
  521. ffserver-all(1),
  522. @end ifset
  523. the @file{doc/ffserver.conf} example, ffmpeg(1), ffplay(1), ffprobe(1),
  524. ffmpeg-utils(1), ffmpeg-scaler(1), ffmpeg-resampler(1),
  525. ffmpeg-codecs(1), ffmpeg-bitstream-filters(1), ffmpeg-formats(1),
  526. ffmpeg-devices(1), ffmpeg-protocols(1), ffmpeg-filters(1)
  527. @end ifnothtml
  528. @include authors.texi
  529. @ignore
  530. @setfilename ffserver
  531. @settitle ffserver video server
  532. @end ignore
  533. @bye