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.

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