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.

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