High data rate and packet loss streaming from VLC but ffmpeg is fine with the same file
Posted: 28 May 2020 18:39
I'm afraid I'm a complete noob when it comes to video streaming but, as part of a project I'm working on, I need to stream video to another PC over a LAN. I have control of the server end, and am using VLC, mostly due to the handy remote control interface (which I'm accessing using a socket). The video is a desktop capture - it will be 4k in the end, but I'm testing at 2560x1440 at the moment. It's only 5fps, so the data rate should be manageable.
The basic problem is that I can send the stream using ffmpeg, but not with VLC. It looks like VLC is sending a lot more data than ffmpeg, and I don't understand why In more detail...
The client end is expecting to receive an H264 rtp stream, and is using a simple ffplay command to receive/display:
(where test1.sdp is a local file, created from the debug output of the VLC command below)
I've found that I can stream OK with ffmpeg, but not VLC. These are the commands I am sending the stream with:
I'm puzzled because, if I use ffmpeg, the video plays just fine, although there's a 4-5 second delay at the start. If I stream using VLC, the receiver has a huge number of missed packets, corrupted macroblock, decoding errors etc. The video is unusable, with around 1/3 the screen covered in solid blocks of colour. I tried playing with the caching values in VLC but, while it gave me the same start delay as ffmpeg, it didn't fix the problem. They're both playing the video at the same speed and resolution...
On further investigation, it appears that VLC sends data over the network at around 10x the rate of ffmpeg for the same file (a few Mbps rather than a few hundred kbps). I guess that explains the packet loss, but I don't know why there's such a difference.
Does anyone have an idea how I can reduce the data rate with VLC to match that of ffmpeg? I guess I'm missing some options, or have something wrong on my command line, but don't really know where to start.
I can post the output from VLC/ffplay if necessary, but maybe someone can see the problem with my command line?
Cheers
The basic problem is that I can send the stream using ffmpeg, but not with VLC. It looks like VLC is sending a lot more data than ffmpeg, and I don't understand why In more detail...
The client end is expecting to receive an H264 rtp stream, and is using a simple ffplay command to receive/display:
Code: Select all
ffplay -flags low_delay -probesize 32 -protocol_whitelist file,udp,rtp -i test1.sdp
I've found that I can stream OK with ffmpeg, but not VLC. These are the commands I am sending the stream with:
Code: Select all
ffmpeg -re -i "C:\Temp\Video Replays\192.168.1.1_12344_4\replay.ts" -c:v libx264 -preset ultrafast -tune zerolatency -f rtp rtp://192.168.1.1:12210
vlc "C:\Temp\Video Replays\192.168.1.1_12344_4\replay.ts" --sout-avcodec-codec=libx264 --sout-x264-preset=ultrafast --sout-x264-tune=zerolatency --sout #rtp{dst=192.168.1.1,port=12210}
On further investigation, it appears that VLC sends data over the network at around 10x the rate of ffmpeg for the same file (a few Mbps rather than a few hundred kbps). I guess that explains the packet loss, but I don't know why there's such a difference.
Does anyone have an idea how I can reduce the data rate with VLC to match that of ffmpeg? I guess I'm missing some options, or have something wrong on my command line, but don't really know where to start.
I can post the output from VLC/ffplay if necessary, but maybe someone can see the problem with my command line?
Cheers