TLDR: VLC or Quicktime won’t open .sdp video stream files generated by ffmpeg, even though ffplay does.
Web development and ffmpeg noob, so apologies if I’m using the wrong terminology:
I’m trying to stream my desktop capture (on OSX) using ffmpeg, sending it out via rtp protocol. As of right now I’m just testing it out by streaming it over a port in my localhost (4000). And trying to play it locally.
The problem is that when I try and open the .sdp file generated by the ffmpeg command, VLC opens it and immediately stops, no errors or anything, and shows that it has a duration of 0:00. Quicktime won’t event open the file in the first place.
ffplay does play the stream and I can see my desktop in the player window (with a significant loss in quality though). Even so there are a ton of warning and errors that show up intermittently (outlined below)
I’m not sure if it’s a problem in the way I start the ffmpeg stream, the command is after a ton of iterations of trying to just make it work, so my options might be way wrong.
command to 'serve' the desktop capture:
./ffmpeg -f avfoundation -s 1920x1080 -r 60 -i "1" -an \
-vcodec libx264 -preset ultrafast -tune zerolatency -pix_fmt yuv420p \
-sdp_file video.sdp -rtsp_transport tcp -f rtp rtp://127.0.0.1:4000
SDP file that’s generated with the ffmpeg command:
SDP:
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 127.0.0.1
t=0 0
a=tool:libavformat 58.29.100
m=video 4000 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1
ffplay command used to play the stream:
./ffplay -probesize 32 -analyzeduration 0 -sync ext \
-fflags nobuffer -fflags discardcorrupt -flags low_delay -framedrop \
-strict experimental -avioflags direct \
-protocol_whitelist file,rtp,udp -I video.sdp
For a while before ffplay starts I see a bunch of these errors repeating (in red):
[h264 @ 0x7ff6b788de00] non-existing PPS 0 referenced
[h264 @ 0x7ff6b788de00] decode_slice_header error
[h264 @ 0x7ff6b788de00] no frame!
then the window seems to 'catch up' to the stream and actually shows the desktop capture, and I get these errors and warnings on a regular interval:
1- in a yellow warning color:
[sdp @ 0x7fc85b830600] RTP: missed 4 packets
[sdp @ 0x7fc85b830600] max delay reached. need to consume packet
2-in a red error color:
[h264 @ 0x7fc85b02aa00] out of range intra chroma pred mode
[h264 @ 0x7fc85b02aa00] error while decoding MB 132 32
(I have a feeling that the above errors have to do with previewing the desktop capture in the desktop I’m capturing and causing pixels in the display to overflow)
Edit: So, I solved the issue soon after posting, but will leave this up in case anyone runs into the same problem.
The solution was to remove the top line in the .sdp file that said SDP: