Reputation: 175
I'm attempting to using the libav libraries with Qt to decode h.264 UDP video streams, but when I use avformat_open_file, I get the following error message:
[udp @ 0x102b5bee0] Part of datagram lost due to insufficient buffer size
The message appears about 10 times and then the attempt fails. I'm trying to decode 4 different UDP streams simultaneously, each stream with a frame rate of 25fps. Wireshark indicates that the packets are between 3000 and 10000 bytes.
Here is my call to avformat_open_input:
avformat_open_input(&formatContext, udpUrl.toStdString().c_str(), NULL, NULL)
formatContext is NULL at the time that this call is made, and udpUrl is in the format "udp://ipaddress:port".
If someone could shed some light on this issue for me it would be greatly appreciated!
Upvotes: 2
Views: 4407
Reputation: 998
Make sure you set the buffer_size
and pkt_size
options to be big enough.
udp
, as any other protocols (e.g. tcp
, sctp
) can deliver generic formats (so mpegts
, nut
, mkv
) or you can use rtp
and rtsp
and the respectively coupled formats.
Upvotes: 0
Reputation: 175
After digging around a bit more it looks like FFMPEG expects you to first encode the stream to MPEGTS when streaming raw H.264 over UDP. Sure enough, encoding the output stream to MPEGTS did the trick.
Upvotes: 1
Reputation: 19052
That error happens when you try to read a UDP datagram into a buffer that is too small. Since UDP does not guarantee delivery, this packet simply gets truncated (or dropped) depending on the implementation.
From a quick look at the documentation, it looks like you can specify the datagram size as an option on your URL (See section 6.16 UDP).
Try changing your URL to something like: udp://ipaddress:port?buffer_size=10240
Upvotes: 1