Changes between Version 17 and Version 18 of StreamingGuide


Ignore:
Timestamp:
Jul 18, 2012, 7:22:22 PM (4 years ago)
Author:
burek
Comment:

Added several link references and corrected few minor typos

Legend:

Unmodified
Added
Removed
Modified
  • StreamingGuide

    v17 v18  
    11FFmpeg 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 VLC at doing the raw encoding, this can be a useful option compared to doing it all in VLC. 
     2Servers 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. 
    33 
    44How 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]. 
    55 
    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. 
     6NB 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. 
    77 
    88Also 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]. 
    99 
    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. 
     10The 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. 
    1111 
    1212Here's how one guy broadcast a live stream: 
     
    1515$ 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 
    1616 
    17 Here is my ffmpeg preset (libx264-my_ffpreset.ffpreset): 
     17Here is my FFmpeg preset (libx264-my_ffpreset.ffpreset): 
    1818coder=1 
    1919flags2=+wpred+dct8x8 
     
    4545}}}  
    4646 
    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. 
     47NB 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. 
    4848 
    4949== Latency/cpu-usage == 
     
    6161Sometimes 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). 
    6262 
    63 == Streaming a simple RTP audio stream from ffmpeg == 
     63== Streaming a simple RTP audio stream from FFmpeg == 
    6464 
    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]. 
     65FFmpeg 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]. 
    6666 
    6767For example the following command will generate a signal, and will stream it to the port 1234 on localhost: 
     
    7777== Codecs == 
    7878 
    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. 
     79The 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. 
    8080 
    8181== Outputting files == 
    8282 
    83 Ffmpeg supports splitting files (using "-f segment" for the output) into time based chunks, useful for "http live streaming" style file output. 
     83FFmpeg 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.