Changes between Version 17 and Version 18 of StreamingGuide
- Timestamp:
- Jul 18, 2012, 4:22:22 PM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
StreamingGuide
v17 v18 1 1 FFmpeg can basically stream through one of two ways: It either streams to a some "other server", which restreams for it, or it can stream via UDP directly to some destination host, or possibly multicast destination. 2 Servers which can receive from ffmpeg (to restream) include [http://ffmpeg.org/ffserver.html ffserver] (linux only, though cygwin might work), or wowza, or flash media server. Even VLC can pick up the stream, then redistribute it, acting as server. Since ffmpeg is sometimes more efficient than VLCat doing the raw encoding, this can be a useful option compared to doing it all in VLC.2 Servers which can receive from FFmpeg (to restream) include [http://ffmpeg.org/ffserver.html ffserver] (linux only, though cygwin might work), or [http://en.wikipedia.org/wiki/Wowza_Media_Server Wowza Media Server], or [http://en.wikipedia.org/wiki/Adobe_Flash_Media_Server Flash Media Server]. Even [http://en.wikipedia.org/wiki/VLC_media_player VLC] can pick up the stream, then redistribute it, acting as a server. Since FFmpeg is sometimes more efficient than VLC, at doing the raw encoding, this can be a useful option compared to doing it all in VLC. 3 3 4 4 How to stream with several different simultaneous bitrates is described [http://sonnati.wordpress.com/2011/08/30/ffmpeg-%E2%80%93-the-swiss-army-knife-of-internet-streaming-%E2%80%93-part-iv/ here]. 5 5 6 NB that when you are testing your streams, you may want to test them with both VLC and ffplay, as ffplay sometimes introduces its own artifacts when it is scaled (it has poor quality scaling). Don't use ffplay as your baseline for determining quality.6 NB that when you are testing your streams, you may want to test them with both VLC and [http://ffmpeg.org/ffplay.html FFplay], as FFplay sometimes introduces its own artifacts when it is scaled (it has poor quality scaling). Don't use ffplay as your baseline for determining quality. 7 7 8 8 Also note that encoding it to the x264 "baseline" is basically for older iOS devices or the like, see [http://sonnati.wordpress.com/2011/08/30/ffmpeg-%E2%80%93-the-swiss-army-knife-of-internet-streaming-%E2%80%93-part-iv/ here]. 9 9 10 The ffmpeg "-re" flag means to "Read input at native frame rate. Mainly used to simulate a grab device." i.e. if you want to play a video file, but at realtime, then use this.My guess is you typically don't want this flag when streaming from a live device.10 The FFmpeg's "-re" flag means to "Read input at native frame rate. Mainly used to simulate a grab device." i.e. if you want to play a video file, but at realtime, then use this. My guess is you typically don't want this flag when streaming from a live device. 11 11 12 12 Here's how one guy broadcast a live stream: … … 15 15 $ ffmpeg -y -loglevel warning -f dshow -i video="screen-capture-recorder" -vf crop=690:388:136:0 -r 30 -s 962x388 -threads 2 -vcodec libx264 -vpre baseline -vpre my_ffpreset -f flv rtmp:///live/myStream.sdp 16 16 17 Here is my ffmpeg preset (libx264-my_ffpreset.ffpreset):17 Here is my FFmpeg preset (libx264-my_ffpreset.ffpreset): 18 18 coder=1 19 19 flags2=+wpred+dct8x8 … … 45 45 }}} 46 46 47 NB that they also had to adjust the rtbufsize in that example. I'm also not entirely sure which presets are "best" or what the available options are. Also note that newer version of ffmpeg may need a different syntax for specifying preset/tune.47 NB that they also had to adjust the rtbufsize in that example. I'm also not entirely sure which presets are "best" or what the available options are. Also note that newer version of FFmpeg may need a different syntax for specifying preset/tune. 48 48 49 49 == Latency/cpu-usage == … … 61 61 Sometimes you can change the "pixel formats" somehow, like using rgb16 instead of rgb24, to save space (or yuv420 instead of yuv444 or the like, since 420 stores less information it can compress better). 62 62 63 == Streaming a simple RTP audio stream from ffmpeg ==63 == Streaming a simple RTP audio stream from FFmpeg == 64 64 65 FFmpeg can stream a single stream using the RTP protocol. In order to avoid buffering problems on the other hand, the streaming should be done through the -re option, which means that the stream will be streamed in real-time (i.e. it slows it down to simulate a live streaming [http://ffmpeg.org/ffmpeg.html source].65 FFmpeg can stream a single stream using the [http://en.wikipedia.org/wiki/Real-time_Transport_Protocol RTP protocol]. In order to avoid buffering problems on the other hand, the streaming should be done through the -re option, which means that the stream will be streamed in real-time (i.e. it slows it down to simulate a live streaming [http://ffmpeg.org/ffmpeg.html source]. 66 66 67 67 For example the following command will generate a signal, and will stream it to the port 1234 on localhost: … … 77 77 == Codecs == 78 78 79 The most popular streaming codec is probably libx264, though if you're streaming to a device which requires a "crippled" baseline h264 implementation, some have argued that the mp4 video codec is [http://forums.macrumors.com/showthread.php?t=398016 better]. You can also use mpeg2video, or really any other video codec you want, typically, as long as your receiver can decode it, and it suits your needs.79 The most popular streaming codec is probably [http://www.videolan.org/developers/x264.html libx264], though if you're streaming to a device which requires a "crippled" baseline h264 implementation, some have argued that the mp4 video codec is [http://forums.macrumors.com/showthread.php?t=398016 better]. You can also use mpeg2video, or really any other video codec you want, typically, as long as your receiver can decode it, and it suits your needs. 80 80 81 81 == Outputting files == 82 82 83 F fmpeg supports splitting files (using "-f segment" for the output) into time based chunks, useful for "http live streaming"style file output.83 FFmpeg supports splitting files (using "-f segment" for the output, see [http://ffmpeg.org/ffmpeg.html#segment_002c-stream_005fsegment_002c-ssegment segment muxer]) into time based chunks, useful for [http://en.wikipedia.org/wiki/HTTP_Live_Streaming HTTP live streaming] style file output.
