How to minimize the delay in a live streaming with ffmpeg

ffmpeg rtp streaming
ffmpeg rtsp streaming example
ffmpeg multicast
ffmpeg point to point streaming
ffmpeg zerolatency
ffmpeg stream webcam
ffmpeg rtsp to http
ffmpeg low latency streaming

i have a problem. I would to do a live streaming with ffmpeg from my webcam.

  1. I launch the ffserver and it works.
  2. From another terminal I launch ffmpeg to stream with this command and it works:

    sudo ffmpeg -re -f video4linux2 -i /dev/video0 -fflags nobuffer -an http://localhost:8090/feed1.ffm
    
  3. In my configuration file I have this stream:

    <Stream test.webm>
    Feed feed1.ffm
    Format webm
     NoAudio
     VideoCodec libvpx
     VideoSize 720x576
     VideoFrameRate 25
     # Video settings
        VideoCodec libvpx
        VideoSize 720x576           # Video resolution
        VideoFrameRate 25           # Video FPS
        AVOptionVideo flags +global_header  # Parameters passed to encoder 
                                        # (same as ffmpeg command-line parameters)
        AVOptionVideo cpu-used 0
        AVOptionVideo qmin 10
        AVOptionVideo qmax 42
        #AVOptionVideo quality good
        PreRoll 5
         StartSendOnKey
        VideoBitRate 400            # Video bitrate
     </Stream>
    
  4. I launch the stream with

    ffplay http://192.168.1.2:8090/test.webm It works but I have a delay of 4 seconds and I would to minimize this delay because is essential for my application. Thanks

How to reduce latency on FFmpeg video streaming?, Add the option ffmpeg with -tune zerolatency and best option using x265 codec, reduce VideoSize 640x480 to VideoSize 320x240. Lastly, change your player� So a quite long delay is to be expected with HLS. Use shorter segments, but it will never be low-latency. 10-15 seconds is probably the best you can get. Also, this is not a bug, please use the ffmpeg-user mailing list for questions in the future.

FFMpeg's streaming guide has a specific section on how to reduce latency. I haven't tried all their suggestions yet. http://ffmpeg.org/trac/ffmpeg/wiki/StreamingGuide#Latency

They make a particular note about latency ffplay introduces:

By default, ffplay introduces a small latency of its own, Also useful is mplayer with its -nocache for testing latency (or -benchmark). Using the SDL out is also said to view frames with minimal latency: ffmpeg ... -f sdl -

Reduce the delay while live streaming when pushing the rtsp stream , I am using Wowza Streaming Engine Cloud with the low-latency for live streaming the rtsp stream which is pushed through ffmpeg over tcp. Here I� Reduce the delay while live streaming when pushing the rtsp stream through ffmpeg over tcp by using Wowza Streaming Engine with h.264 video encoder. Hi Guys, I am using Wowza Streaming Engine Cloud with the low-latency for live streaming the rtsp stream which is pushed through ffmpeg over tcp.

Try set flags of AVFormatContext to AVFMT_FLAG_NOBUFFER | AVFMT_FLAG_FLUSH_PACKETS

AVFormatContext *ctx;
...
ctx->flags = AVFMT_FLAG_NOBUFFER | AVFMT_FLAG_FLUSH_PACKETS;

Then try to set decoder thread to 1. It seems like more thread will cause more latency.

AVCodecContext *ctx;
...
ctx->thread_count = 1;

StreamingGuide – FFmpeg, You can also live stream to online redistribution servers like own3d.tv or You can also decrease latency by tuning any broadcast server you� Since you're doing a transcode, that will add some latency to this process, not much, but it could account for 1-2 seconds of latency. If you can do a -c copy in ffmpeg, this will help reduce that latency, but your bitrate would be whatever the rtsp stream is currently at. That may be too much for your viewers.

Ffmpeg low latency hls, Low-Latency Live Streaming for your Desktop using ffmpeg and netcat: The shorter the <SegmentDuration>, the lower latency can be streamed, but it is less � How to reduce delay on ffserver. Hi I'm using ffmpeg and ffserver to stream video from my webcam. The streaming is made in http, to computers on my LAN, so network speed is not a problem.

Reduce lag / delay during live streaming with HLS + fMP4 segments , Description I'm using ffmpeg to ingest an RTSP video/audio stream, and perform real-time encoding to HLS + fMP4 segments (chunks). The file� Network lag in streaming means that there may not be enough bandwidth for you to stream smoothly. Your connection may drop, causing your stream to go offline, or you may be unable to stream in a high quality. For streamers who want their viewers to see how they are playing or performing in real-time, reducing lag is important. What is Graphics Lag?

How to reduce the live delay � Issue #18 � illuspas/Node-Media , I'm using ffmpeg with a live h.264 stream input, transcoding back to h.264 with a lower bandwidth. I'm seeing about 4-6 seconds of latency on LAN. Latency� You could try using OBS streaming software (which is free), and then check out this tutorial for how to add delay to your stream. Basically you go into the advanced settings of OBS and go to the delay settings. There you can choose to add a delay of your choosing. You can also record from the software too.

Comments
  • You can try to reduce the value of probesize: ffplay -probesize 500000 http://192.168.1.2:8090/test.webm (to 500 Kb, experiment with this value, default value is 5Mb if I'm not mistaken.)
  • ok thanks. Now I have to watch the stream in a mobile browser and so I cannot use ffplay. I need some suggest to optimize the configuration file.
  • Reading ffmpeg.org/sample.html I can imagine that you can try with VideoBufferSize or reducing the GOP (it increase the bandwidth usage).
  • Did you manage to find a solution ?
  • None of this had any effect in my teting. Using SDL preview with ffmpeg (not ffplay) was the only option to reduce delay (but the lack of sound is an obvious drawback).
  • thanks, ffplay -probesize 32 -sync ext INPUT from the link did the trick for me!
  • What latency did you achieve? I need more than 100 ms streaming latency . Is it possible ?
  • I didn't measure the final delay but it looked close to live on a monitor in person with the sound which was going through a sound booth, so was good enough for me.