Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UDP Streaming with ffmpeg - overrun_nonfatal option

I'm working on a software which uses FFMPEG C++ libs to make an acquisition from an UDP streaming.

FFMPEG (1.2) is implemented and running but I get some errors (acquisition crashes and restarts). The log displays the following message:

*Circular buffer overrun. To avoid, increase fifo_size URL option. To survive in such case, use overrun_nonfatal option*

I searched online for documentation about how to use this option, but I only got informations about how to use when running directly ffmpeg executable.

Would someone know how to set the correct option in my C++ code to: - increase fifo_size - use overrun_nonfatal option

Thanks

like image 968
Julien Greard Avatar asked Jun 05 '13 15:06

Julien Greard


2 Answers

The same option works from command line or C++ libraries, you need to modify your UDP URL as follows: If you original URL looks like this:

udp://@239.1.1.7:5107

Add the fifo_size and overrun parameters like this:

"udp://@239.1.1.7:5107?overrun_nonfatal=1&fifo_size=50000000"

Remember to escape the URL with quotes.

overrun_nonfatal=1 prevents ffmpeg from exiting, it can recover in most circumstances.

fifo_size=50000000 uses a 50MB udp input buffer (default 5MB)

The only documentation is in the source code: http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavformat/udp.c;h=5b5c7cb7dfc1aed3f71ea0c3e980be54757d3c62;hb=dd0a9b78db0eeea72183bd3f5bc5fe51a5d3f537

like image 173
Grant Avatar answered Sep 17 '22 23:09

Grant


I don't have enough reputation to comment the other answer, but if I did I would say that studying the source linked in the answer:

  • fifo_size is measured as multiples of 188 Byte (packets) according to the line:

    s->circular_buffer_size = strtol(buf, NULL, 10)*188;

  • so whilst Grant is roughly correct that "default 5MB", because of the line:

    s->circular_buffer_size = 7*188*4096;

If you want a circular buffer of 50MB you should really set the fifo_size parameter to something closer to 50*1024*1024/188 otherwise 50000000 will give 50000000*188 bytes which is closer to 8965MB!

like image 39
derke Avatar answered Sep 20 '22 23:09

derke