Ffmpeg settings for streaming to CloudFlare from an RTSP-enabled IP camera (Video Not Found)

Hello! Exciting product.

This is how I’m trying to use it:

ffmpeg -loglevel verbose -rtsp_transport tcp -y -i rtsp://<username>:<password>@<ip-address>/live1s1.sdp -c:a aac -b:a 128k -ar 44100 -f flv rtmps://live.cloudflare.com:443/live/<STREAM KEY>

When I view the stream in Cloudflare it’s detecting input but saying “Video not found”, and it seems like audio isn’t coming through either.

But when I close down the ffmpeg process I see:

Input file #0 (rtsp://<u>:<p>@<ip>/live1s1.sdp):
  Input stream #0:0 (video): 947 packets read (2441506 bytes); 944 frames decoded;
  Input stream #0:1 (audio): 494 packets read (316160 bytes); 494 frames decoded (316160 samples);
  Input stream #0:2 (data): 10 packets read (7749 bytes);
  Total: 1451 packets (2765415 bytes) demuxed
Output file #0 (rtmps://live.cloudflare.com:443/live/4cebe3e57381cffeb5bfbaf5e6b8bad5k70cff2f14e58895f1311910769b96fc8):
  Output stream #0:0 (video): 939 frames encoded; 939 packets muxed (15718745 bytes);
  Output stream #0:1 (audio): 1701 frames encoded (1741824 samples); 1702 packets muxed (440348 bytes);
  Total: 2641 packets (16159093 bytes) muxed
[AVIOContext @ 0x556bdcf99040] Statistics: 0 seeks, 2972 writeouts

And here’s the details on the input stream:

[h264 @ 0x556bdce93400] Reinit context to 2560x1920, pix_fmt: yuvj420p
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, rtsp, from 'rtsp://<snip>/live1s1.sdp':
  Metadata:
    title           : RTSP server
  Duration: N/A, start: 0.077000, bitrate: N/A
    Stream #0:0: Video: h264 (Main), 1 reference frame, yuvj420p(pc, bt470bg/bt470bg/smpte170m, progressive, left), 2560x1920, 24 fps, 29.92 tbr, 90k t
bn, 48 tbc
    Stream #0:1: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s
    Stream #0:2: Data: none

Some additional logging that might be useful:

[h264 @ 0x556bdcf902c0] Reinit context to 2560x1920, pix_fmt: yuvj420p
[graph_1_in_0_1 @ 0x556bdd3182c0] tb:1/8000 samplefmt:s16 samplerate:8000 chlayout:0x4
[format_out_0_1 @ 0x556bdd318d80] auto-inserting filter 'auto_resampler_0' between the filter 'Parsed_anull_0' and the filter 'format_out_0_1'
[auto_resampler_0 @ 0x556bdd31a2c0] ch:1 chl:mono fmt:s16 r:8000Hz -> ch:1 chl:mono fmt:fltp r:44100Hz

[flv @ 0x556bdceb6d00] Non-monotonous DTS in output stream 0:1; previous: 3650, current: 3584; changing to 3650. This may result in incorrect timestamp
s in the output file.

Any help would be much appreciated :slight_smile:

FWIW if I use OBS to read from the camera’s RTSP stream and broadcast to Cloudflare it works perfectly (but we’re running a fleet of medical devices and really don’t want to try to use install OBS and use it programatically, if that’s even possible).

I’ve also tried setting -f h264 to no avail:

ffmpeg -loglevel verbose -rtsp_transport tcp -y -i rtsp://<username>:<password>@<ip-address>/live1s1.sdp -c:a aac -b:a 128k -ar 44100 -f h264 rtmps://live.cloudflare.com:443/live/<STREAM KEY>

Other things I’ve tried:

because the input stream is h264 anyway (with I-frame interval constant at 4s btw):

-c:v copy

Also this:

-force_key_frames 6

And here’s some more debugging info, from when I re-encode into h264:

[libx264 @ 0x55f5fa018100] frame I:4     Avg QP:16.99  size: 57274
[libx264 @ 0x55f5fa018100] frame P:253   Avg QP:21.33  size:  1398
[libx264 @ 0x55f5fa018100] frame B:606   Avg QP:32.10  size:    90
[libx264 @ 0x55f5fa018100] consecutive B-frames:  4.2%  4.4%  6.6% 84.8%
[libx264 @ 0x55f5fa018100] mb I  I16..4: 15.8% 16.0% 68.2%
[libx264 @ 0x55f5fa018100] mb P  I16..4:  0.4%  0.6%  0.4%  P16..4:  5.2%  1.2%  1.0%  0.0%  0.0%    skip:91.2%
[libx264 @ 0x55f5fa018100] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  1.8%  0.1%  0.1%  direct: 0.1%  skip:97.9%  L0:37.0% L1:60.7% BI: 2.3%
[libx264 @ 0x55f5fa018100] 8x8 transform intra:29.1% inter:32.5%
[libx264 @ 0x55f5fa018100] coded y,uvDC,uvAC intra: 76.8% 52.2% 32.9% inter: 1.1% 1.3% 0.2%
[libx264 @ 0x55f5fa018100] i16 v,h,dc,p: 14% 15% 21% 50%
[libx264 @ 0x55f5fa018100] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 39% 21% 16%  4%  3%  4%  3%  5%  4%
[libx264 @ 0x55f5fa018100] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 16% 15%  7%  6%  9%  6%  8%  6%
[libx264 @ 0x55f5fa018100] i8c dc,h,v,p: 49% 17% 23% 11%
[libx264 @ 0x55f5fa018100] Weighted P-Frames: Y:0.4% UV:0.0%
[libx264 @ 0x55f5fa018100] ref P L0: 75.1% 13.6%  9.9%  1.4%  0.0%
[libx264 @ 0x55f5fa018100] ref B L0: 88.6% 10.8%  0.5%
[libx264 @ 0x55f5fa018100] ref B L1: 95.2%  4.8%

Hey! Thanks for the detailed report. I have two questions:

  1. Could you. if possible share the video ID that is causing problems? Maybe we can take a look at the data and try to fix this.
  2. Have you tried encoding the video? For example with -c:v libx264; I’m aware the input is h264 already, just curious if this solves your issue and if so, why