Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reolink RLC-520 not working #126

Closed
Fanman03 opened this issue Dec 22, 2021 · 45 comments
Closed

Reolink RLC-520 not working #126

Fanman03 opened this issue Dec 22, 2021 · 45 comments
Labels

Comments

@Fanman03
Copy link

Fanman03 commented Dec 22, 2021

I have some Reolink RLC-520s I would like to use in UniFi Protect, however when I use this proxy they only show snapshots and do not play live video on either the desktop site or the mobile app.
I have tried running both with and without the argument --ffmpeg-args '-c:v copy -vbsf "h264_metadata=tick_rate=60000/1001:fixed_frame_rate_flag=1" -ar 32000 -ac 2 -codec:a aac -b:a 32k'. Is there a known fix for this issue?

Here is my console output
https://i.imgur.com/35pNuE1.png

@keshavdv
Copy link
Owner

I see a lot of respawning of the ffmpeg streams which suggests they might be terminating early for some reason. If you copy one of those ffmpeg lines and run it by hand, do you see any error messages?

@GhostlyCrowd
Copy link
Contributor

GhostlyCrowd commented Dec 23, 2021

I see a lot of respawning of the ffmpeg streams which suggests they might be terminating early for some reason. If you copy one of those ffmpeg lines and run it by hand, do you see any error messages?

I can run the command and output it to a test.flv just fine with no errors, some warnings. it seems the cam proxy is triggering the restart not a ffmpeg error.

$ ffmpeg -loglevel verbose -nostdin -y -stimeout 15000000 -rtsp_transport tcp -i "rtsp://unifiprotect:[email protected]:554//h264Preview_01_main" -c:v copy -vbsf "h264_metadata=tick_rate=60000/1001:fixed_frame_rate_flag=1" -ar 32000 -ac 2 -codec:a aac -b:a 32k -metadata streamname=2J526r7kMJvb0JTf -f flv -t 10 test.flv
ffmpeg version 4.1.8-0+deb10u1 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr --extra-version=0+deb10u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
[tcp @ 0x55612916df00] Starting connection attempt to 192.168.7.100 port 554
[tcp @ 0x55612916df00] Successfully connected to 192.168.7.100 port 554
[rtsp @ 0x55612916ba40] SDP:
v=0
o=- 1639915230479332 1 IN IP4 192.168.7.100
s=Session streamed by "preview"
i=h264Preview_01_main
t=0 0
a=tool:LIVE555 Streaming Media v2013.04.08
a=type:broadcast
a=control:*
a=range:npt=0-
a=x-qt-text-nam:Session streamed by "preview"
a=x-qt-text-inf:h264Preview_01_main
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:500
a=rtpmap:96 H264/90000
a=range:npt=0-
a=fmtp:96 packetization-mode=1;profile-level-id=420032;sprop-parameter-sets=Z0IAMvQBQAeIgA==,aM48gA==
a=control:trackID=1
m=audio 0 RTP/AVP 97
c=IN IP4 0.0.0.0
b=AS:256
a=rtpmap:97 MPEG4-GENERIC/16000
a=fmtp:97 streamtype=5;profile-level-id=15;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1408; profile=1;
a=control:trackID=2

[rtsp @ 0x55612916ba40] setting jitter buffer size to 0
    Last message repeated 1 times
[h264 @ 0x55612916fa00] Reinit context to 2560x1920, pix_fmt: yuv420p
Input #0, rtsp, from 'rtsp://unifiprotect:[email protected]:554//h264Preview_01_main':
  Metadata:
    title           : Session streamed by "preview"
    comment         : h264Preview_01_main
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: h264 (Baseline), 1 reference frame, yuv420p(progressive, left), 2560x1920, 30 tbr, 90k tbn, 180k tbc
    Stream #0:1: Audio: aac (LC), 16000 Hz, mono, fltp
[AVBSFContext @ 0x5561294ac380] Warning: low_delay_hrd_flag does not match inferred value: 1, but should be 0.
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
[graph_0_in_0_1 @ 0x556129199f00] tb:1/16000 samplefmt:fltp samplerate:16000 chlayout:0x4
[format_out_0_1 @ 0x55612919a940] auto-inserting filter 'auto_resampler_0' between the filter 'Parsed_anull_0' and the filter 'format_out_0_1'
[auto_resampler_0 @ 0x5561291a7340] ch:1 chl:mono fmt:fltp r:16000Hz -> ch:2 chl:stereo fmt:fltp r:32000Hz
Output #0, flv, to 'test.flv':
  Metadata:
    title           : Session streamed by "preview"
    comment         : h264Preview_01_main
    streamname      : 2J526r7kMJvb0JTf
    encoder         : Lavf58.20.100
    Stream #0:0: Video: h264 (Baseline), 1 reference frame ([7][0][0][0] / 0x0007), yuv420p(progressive, left), 2560x1920 (0x0), q=2-31, 30 tbr, 1k tbn, 90k tbc
    Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 32000 Hz, stereo, fltp, delay 1024, 32 kb/s
    Metadata:
      encoder         : Lavc58.35.100 aac
[AVBSFContext @ 0x5561294ac380] Warning: low_delay_hrd_flag does not match inferred value: 1, but should be 0.
[flv @ 0x55612918f980] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[AVBSFContext @ 0x5561294ac380] Warning: low_delay_hrd_flag does not match inferred value: 1, but should be 0.
[AVBSFContext @ 0x5561294ac380] Warning: low_delay_hrd_flag does not match inferred value: 1, but should be 0.
[AVBSFContext @ 0x5561294ac380] Warning: low_delay_hrd_flag does not match inferred value: 1, but should be 0.
[AVBSFContext @ 0x5561294ac380] Warning: low_delay_hrd_flag does not match inferred value: 1, but should be 0.
No more output streams to write to, finishing.e=00:00:09.98 bitrate=5669.1kbits/s speed=1.19x
frame=  251 fps= 30 q=-1.0 Lsize=    7131kB time=00:00:10.01 bitrate=5832.7kbits/s speed=1.19x
video:7081kB audio:39kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.148950%
Input file #0 (rtsp://unifiprotect:[email protected]:554//h264Preview_01_main):
  Input stream #0:0 (video): 262 packets read (7387622 bytes);
  Input stream #0:1 (audio): 158 packets read (80896 bytes); 158 frames decoded (161792 samples);
  Total: 420 packets (7468518 bytes) demuxed
Output file #0 (test.flv):
  Output stream #0:0 (video): 251 packets muxed (7251260 bytes);
  Output stream #0:1 (audio): 313 frames encoded (320000 samples); 314 packets muxed (40445 bytes);
  Total: 565 packets (7291705 bytes) muxed
[AVIOContext @ 0x5561291c4240] Statistics: 2 seeks, 30 writeouts
[aac @ 0x5561291905c0] Qavg: 211.247

@GhostlyCrowd
Copy link
Contributor

GhostlyCrowd commented Dec 23, 2021

And another test

$ ffmpeg -loglevel verbose -nostdin -y -stimeout 15000000 -rtsp_transport tcp -i "rtsp://unifiprotect:[email protected]:554//h264Preview_01_main" -c:v copy -vbsf "h264_metadata=tick_rate=60000/1001:fixed_frame_rate_flag=1" -ar 32000 -ac 2 -codec:a aac -b:a 32k -metadata streamname=2J526r7kMJvb0JTf -f flv -t 10 test2.flv
ffmpeg version 4.1.8-0+deb10u1 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr --extra-version=0+deb10u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
[tcp @ 0x5640dad5df00] Starting connection attempt to 192.168.7.100 port 554
[tcp @ 0x5640dad5df00] Successfully connected to 192.168.7.100 port 554
[rtsp @ 0x5640dad5ba40] SDP:
v=0
o=- 1639915230479332 1 IN IP4 192.168.7.100
s=Session streamed by "preview"
i=h264Preview_01_main
t=0 0
a=tool:LIVE555 Streaming Media v2013.04.08
a=type:broadcast
a=control:*
a=range:npt=0-
a=x-qt-text-nam:Session streamed by "preview"
a=x-qt-text-inf:h264Preview_01_main
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:500
a=rtpmap:96 H264/90000
a=range:npt=0-
a=fmtp:96 packetization-mode=1;profile-level-id=420032;sprop-parameter-sets=Z0IAMvQBQAeIgA==,aM48gA==
a=control:trackID=1
m=audio 0 RTP/AVP 97
c=IN IP4 0.0.0.0
b=AS:256
a=rtpmap:97 MPEG4-GENERIC/16000
a=fmtp:97 streamtype=5;profile-level-id=15;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1408; profile=1;
a=control:trackID=2

[rtsp @ 0x5640dad5ba40] setting jitter buffer size to 0
    Last message repeated 1 times
[h264 @ 0x5640dad5fa00] Reinit context to 2560x1920, pix_fmt: yuv420p
Input #0, rtsp, from 'rtsp://unifiprotect:[email protected]:554//h264Preview_01_main':
  Metadata:
    title           : Session streamed by "preview"
    comment         : h264Preview_01_main
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: h264 (Baseline), 1 reference frame, yuv420p(progressive, left), 2560x1920, 30 tbr, 90k tbn, 180k tbc
    Stream #0:1: Audio: aac (LC), 16000 Hz, mono, fltp
[AVBSFContext @ 0x5640db031f00] Warning: low_delay_hrd_flag does not match inferred value: 1, but should be 0.
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
[graph_0_in_0_1 @ 0x5640dad88800] tb:1/16000 samplefmt:fltp samplerate:16000 chlayout:0x4
[format_out_0_1 @ 0x5640dad88d80] auto-inserting filter 'auto_resampler_0' between the filter 'Parsed_anull_0' and the filter 'format_out_0_1'
[auto_resampler_0 @ 0x5640dad74540] ch:1 chl:mono fmt:fltp r:16000Hz -> ch:2 chl:stereo fmt:fltp r:32000Hz
Output #0, flv, to 'test2.flv':
  Metadata:
    title           : Session streamed by "preview"
    comment         : h264Preview_01_main
    streamname      : 2J526r7kMJvb0JTf
    encoder         : Lavf58.20.100
    Stream #0:0: Video: h264 (Baseline), 1 reference frame ([7][0][0][0] / 0x0007), yuv420p(progressive, left), 2560x1920 (0x0), q=2-31, 30 tbr, 1k tbn, 90k tbc
    Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 32000 Hz, stereo, fltp, delay 1024, 32 kb/s
    Metadata:
      encoder         : Lavc58.35.100 aac
[AVBSFContext @ 0x5640db031f00] Warning: low_delay_hrd_flag does not match inferred value: 1, but should be 0.
[flv @ 0x5640dad7f980] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[aac @ 0x5640dad7da40] Queue input is backward in time02.01 bitrate=5201.3kbits/s speed=   4x
[flv @ 0x5640dad7f980] Non-monotonous DTS in output stream 0:1; previous: 2592, current: 2587; changing to 2592. This may result in incorrect timestamps in the output file.
[AVBSFContext @ 0x5640db031f00] Warning: low_delay_hrd_flag does not match inferred value: 1, but should be 0.
[AVBSFContext @ 0x5640db031f00] Warning: low_delay_hrd_flag does not match inferred value: 1, but should be 0.
[AVBSFContext @ 0x5640db031f00] Warning: low_delay_hrd_flag does not match inferred value: 1, but should be 0.
[AVBSFContext @ 0x5640db031f00] Warning: low_delay_hrd_flag does not match inferred value: 1, but should be 0.
No more output streams to write to, finishing.
frame=  241 fps= 28 q=-1.0 Lsize=    7023kB time=00:00:10.01 bitrate=5746.7kbits/s speed=1.15x
video:6973kB audio:40kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.148706%
Input file #0 (rtsp://unifiprotect:[email protected]:554//h264Preview_01_main):
  Input stream #0:0 (video): 242 packets read (7150002 bytes);
  Input stream #0:1 (audio): 161 packets read (82432 bytes); 161 frames decoded (164864 samples);
  Total: 403 packets (7232434 bytes) demuxed
Output file #0 (test2.flv):
  Output stream #0:0 (video): 241 packets muxed (7140082 bytes);
  Output stream #0:1 (audio): 314 frames encoded (321184 samples); 315 packets muxed (40553 bytes);
  Total: 556 packets (7180635 bytes) muxed
[AVIOContext @ 0x5640dad81880] Statistics: 2 seeks, 30 writeouts
[aac @ 0x5640dad7da40] Qavg: 214.419

@GhostlyCrowd
Copy link
Contributor

GhostlyCrowd commented Dec 23, 2021

and the root of the problem might be the broken pipe error trying to send the stream to unifi?

$ ffmpeg -loglevel verbose -nostdin -y -stimeout 15000000 -rtsp_transport tcp -i "rtsp://unifiprotect:[email protected]:554//h264Preview_01_main" -c:v copy -ar 32000 -ac 1 -codec:a aac -b:a 32k -metadata streamname=7VsJj2643J2yVQxv -f flv - | /usr/bin/python3 -m unifi.clock_sync | nc 192.168.7.245 7550
-bash: nc: command not found
ffmpeg version 4.1.8-0+deb10u1 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr --extra-version=0+deb10u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
[tcp @ 0x5612e0436ec0] Starting connection attempt to 192.168.7.100 port 554
[tcp @ 0x5612e0436ec0] Successfully connected to 192.168.7.100 port 554
[rtsp @ 0x5612e0434a40] SDP:
v=0
o=- 1639915230479332 1 IN IP4 192.168.7.100
s=Session streamed by "preview"
i=h264Preview_01_main
t=0 0
a=tool:LIVE555 Streaming Media v2013.04.08
a=type:broadcast
a=control:*
a=range:npt=0-
a=x-qt-text-nam:Session streamed by "preview"
a=x-qt-text-inf:h264Preview_01_main
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:500
a=rtpmap:96 H264/90000
a=range:npt=0-
a=fmtp:96 packetization-mode=1;profile-level-id=420032;sprop-parameter-sets=Z0IAMvQBQAeIgA==,aM48gA==
a=control:trackID=1
m=audio 0 RTP/AVP 97
c=IN IP4 0.0.0.0
b=AS:256
a=rtpmap:97 MPEG4-GENERIC/16000
a=fmtp:97 streamtype=5;profile-level-id=15;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1408; profile=1;
a=control:trackID=2

[rtsp @ 0x5612e0434a40] setting jitter buffer size to 0
    Last message repeated 1 times
[h264 @ 0x5612e04389c0] Reinit context to 2560x1920, pix_fmt: yuv420p
Input #0, rtsp, from 'rtsp://unifiprotect:[email protected]:554//h264Preview_01_main':
  Metadata:
    title           : Session streamed by "preview"
    comment         : h264Preview_01_main
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: h264 (Baseline), 1 reference frame, yuv420p(progressive, left), 2560x1920, 30 tbr, 90k tbn, 180k tbc
    Stream #0:1: Audio: aac (LC), 16000 Hz, mono, fltp
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
[graph_0_in_0_1 @ 0x5612e0755d40] tb:1/16000 samplefmt:fltp samplerate:16000 chlayout:0x4
[format_out_0_1 @ 0x5612e07a9100] auto-inserting filter 'auto_resampler_0' between the filter 'Parsed_anull_0' and the filter 'format_out_0_1'
[auto_resampler_0 @ 0x5612e045d900] ch:1 chl:mono fmt:fltp r:16000Hz -> ch:1 chl:mono fmt:fltp r:32000Hz
Output #0, flv, to 'pipe:':
  Metadata:
    title           : Session streamed by "preview"
    comment         : h264Preview_01_main
    streamname      : 7VsJj2643J2yVQxv
    encoder         : Lavf58.20.100
    Stream #0:0: Video: h264 (Baseline), 1 reference frame ([7][0][0][0] / 0x0007), yuv420p(progressive, left), 2560x1920 (0x0), q=2-31, 30 tbr, 1k tbn, 90k tbc
    Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 32000 Hz, mono, fltp, delay 1024, 32 kb/s
    Metadata:
      encoder         : Lavc58.35.100 aac
[flv @ 0x5612e0458b00] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/DietPi/unifi-cam-proxy/unifi/clock_sync.py", line 167, in <module>
    main()
  File "/home/DietPi/unifi-cam-proxy/unifi/clock_sync.py", line 157, in main
    write(read_bytes(source, payload_size))
  File "/home/DietPi/unifi-cam-proxy/unifi/clock_sync.py", line 87, in write
    sys.stdout.buffer.write(data)
BrokenPipeError: [Errno 32] Broken pipe
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
BrokenPipeError: [Errno 32] Broken pipe
av_interleaved_write_frame(): Broken pipe
No more output streams to write to, finishing.
av_interleaved_write_frame(): Broken pipe
[flv @ 0x5612e0458b00] Failed to update header with correct duration.
[flv @ 0x5612e0458b00] Failed to update header with correct filesize.
Error writing trailer of pipe:: Broken pipe
frame=    5 fps=0.0 q=-1.0 Lsize=     624kB time=00:00:02.08 bitrate=2448.3kbits/s speed=42.5x
video:631kB audio:9kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (rtsp://unifiprotect:[email protected]:554//h264Preview_01_main):
  Input stream #0:0 (video): 5 packets read (646035 bytes);
  Input stream #0:1 (audio): 34 packets read (17408 bytes); 34 frames decoded (34816 samples);
  Total: 39 packets (663443 bytes) demuxed
Output file #0 (pipe:):
  Output stream #0:0 (video): 5 packets muxed (646035 bytes);
  Output stream #0:1 (audio): 67 frames encoded (68608 samples); 67 packets muxed (8757 bytes);
  Total: 72 packets (654792 bytes) muxed
[AVIOContext @ 0x5612e043d580] Statistics: 0 seeks, 85 writeouts
[aac @ 0x5612e0458540] Qavg: 111.714
Conversion failed!

Edit, Apparently i did not have netcat installed, so disregard this noise.

@Fanman03
Copy link
Author

I tried running the command:

ffmpeg -nostdin -y -stimeout 15000000 -rtsp_transport tcp -i "rtsp://unifi:[email protected]:554//h264Preview_01_main" -c:v copy -vbsf "h264_metadata=tick_rate=60000/1001:fixed_frame_rate_flag=1" -ar 32000 -ac 2 -codec:a aac -b:a 32k -metadata streamname=Mb0AWQ1TlWt2GMS8 -f flv -

This was the output:

ffmpeg version 4.3.3-0+deb11u1 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 10 (Debian 10.2.1-6)
  configuration: --prefix=/usr --extra-version=0+deb11u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Input #0, rtsp, from 'rtsp://unifi:[email protected]:554//h264Preview_01_main':
  Metadata:
    title           : Session streamed by "preview"
    comment         : h264Preview_01_main
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: h264 (High), yuv420p(progressive), 2560x1920, 30 tbr, 90k tbn, 180k tbc
    Stream #0:1: Audio: aac (LC), 16000 Hz, mono, fltp
[h264_metadata @ 0x560c5d95ff00] low_delay_hrd_flag does not match inferred value: 1, but should be 0.
[h264_metadata @ 0x560c5d95ff00] Failed to write unit 0 (type 7).
[h264_metadata @ 0x560c5d95ff00] Failed to write extradata.
Error initializing bitstream filter: h264_metadata
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
    Last message repeated 1 times

@GhostlyCrowd
Copy link
Contributor

I tried running the command:

ffmpeg -nostdin -y -stimeout 15000000 -rtsp_transport tcp -i "rtsp://unifi:[email protected]:554//h264Preview_01_main" -c:v copy -vbsf "h264_metadata=tick_rate=60000/1001:fixed_frame_rate_flag=1" -ar 32000 -ac 2 -codec:a aac -b:a 32k -metadata streamname=Mb0AWQ1TlWt2GMS8 -f flv -

This was the output:

ffmpeg version 4.3.3-0+deb11u1 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 10 (Debian 10.2.1-6)
  configuration: --prefix=/usr --extra-version=0+deb11u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Input #0, rtsp, from 'rtsp://unifi:[email protected]:554//h264Preview_01_main':
  Metadata:
    title           : Session streamed by "preview"
    comment         : h264Preview_01_main
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: h264 (High), yuv420p(progressive), 2560x1920, 30 tbr, 90k tbn, 180k tbc
    Stream #0:1: Audio: aac (LC), 16000 Hz, mono, fltp
[h264_metadata @ 0x560c5d95ff00] low_delay_hrd_flag does not match inferred value: 1, but should be 0.
[h264_metadata @ 0x560c5d95ff00] Failed to write unit 0 (type 7).
[h264_metadata @ 0x560c5d95ff00] Failed to write extradata.
Error initializing bitstream filter: h264_metadata
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
    Last message repeated 1 times

ffmpeg 4.3.3 aparently crashes when its sent the modifier for reolink cams

-c:v copy -vbsf "h264_metadata=tick_rate=60000/1001:fixed_frame_rate_flag=1"

Others are reporting. -vbsf is now depreciated the correct flag is -bsf:v.

Others have reported in here that they had to downgrade their ffmpeg.

See #31

and im also working to get these cams working here #127

@Fanman03
Copy link
Author

Fanman03 commented Dec 23, 2021

and im also working to get these cams working here #127

That's great and I hope you can figure something out 😄. I tried running your PR code but it still respawns and closes the process all the time.

I then tried running the command it does which is ffmpeg -nostdin -y -stimeout 15000000 -rtsp_transport tcp -i "rtsp://unifi:[email protected]:554//h264Preview_01_main" -c:v copy -bsf:v "h264_metadata=tick_rate=30000/1001:fixed_frame_rate_flag=1" -ar 32000 -ac 2 -codec:a aac -b:a 32k -metadata streamname=j68ro5Kj5eFMlIdI -f flv -

and I get this error

[h264_metadata @ 0x560b4e725cc0] low_delay_hrd_flag does not match inferred value: 1, but should be 0.
[h264_metadata @ 0x560b4e725cc0] Failed to write unit 0 (type 7).
[h264_metadata @ 0x560b4e725cc0] Failed to write extradata.
Error initializing bitstream filter: h264_metadata

I am using ffmpeg 4.3.3-0+deb11u1 if that matters.

@acortelyou
Copy link
Contributor

I am using ffmpeg 4.3.3-0+deb11u1 if that matters.

Yeah give 4.1.x a try... There are static binaries available for most platforms. This might be a ffmpeg bug or we might need a different bitstream filter for the latest versions.

@GhostlyCrowd
Copy link
Contributor

Error initializing bitstream filter: h264_metadata

what does ffmpeg --list-bsfs output?

@Fanman03
Copy link
Author

Fanman03 commented Dec 23, 2021

what does ffmpeg --list-bsfs output?

ffmpeg version 4.3.3-0+deb11u1 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 10 (Debian 10.2.1-6)
  configuration: --prefix=/usr --extra-version=0+deb11u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Unrecognized option '-list-bsfs'.
Error splitting the argument list: Option not found

ffmpeg -bsfs outputs this:

ffmpeg version 4.3.3-0+deb11u1 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 10 (Debian 10.2.1-6)
  configuration: --prefix=/usr --extra-version=0+deb11u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Bitstream filters:
aac_adtstoasc
av1_frame_merge
av1_frame_split
av1_metadata
chomp
dump_extra
dca_core
eac3_core
extract_extradata
filter_units
h264_metadata
h264_mp4toannexb
h264_redundant_pps
hapqa_extract
hevc_metadata
hevc_mp4toannexb
imxdump
mjpeg2jpeg
mjpegadump
mp3decomp
mpeg2_metadata
mpeg4_unpack_bframes
mov2textsub
noise
null
opus_metadata
pcm_rechunk
prores_metadata
remove_extra
text2movsub
trace_headers
truehd_core
vp9_metadata
vp9_raw_reorder
vp9_superframe
vp9_superframe_split

@GhostlyCrowd
Copy link
Contributor

Hmm either our syntax is wrong for 4.3.3 (something chnaged again) or its a bug. can you try 4.1.X?

@Fanman03
Copy link
Author

Fanman03 commented Dec 24, 2021

can you try 4.1.X?

How do I install that version?

@acortelyou
Copy link
Contributor

How do I install that version?

Put this on your PATH:
https://www.johnvansickle.com/ffmpeg/old-releases/

@Fanman03
Copy link
Author

Put this on your PATH:
https://www.johnvansickle.com/ffmpeg/old-releases/

Thank you so much @GhostlyCrowd and @acortelyou ! Downgrading to 4.1.4 fixed the issue so now live view in both mobile and desktop work, as well as recording.

@GhostlyCrowd
Copy link
Contributor

@acortelyou @Fanman03 @keshavdv REMOVING :fixed_frame_rate_flag=1 from the meta data command resolves Error initializing bitstream filter: h264_metadata on the latest ffmpeg however the stream is laggy to unifi protect. Just as a fyi

@GhostlyCrowd
Copy link
Contributor

@Fanman03 would you be willing to test my pull request for reolink stand alone cameras, could use more people testing it. its a big step in a good direction for reolink cameras. #127

You seem to be active and savvy enough.

@julianpoy
Copy link

@Fanman03 Mind posting the args you're passing? I downgraded to 4.1.4 and am still experiencing ffmpeg crashes.

@burnsy180
Copy link

I have an RLC-520 and trying to get this working via Docker on Unraid. Passing unifi-cam-proxy -H 192.168.1.1 -i 192.168.1.30 -c /cert/client.pem -t <token> reolink -u <user> -p <pass> -s main --ffmpeg-args='-bsf:v "h264_metadata=tick_rate=30000/1001:fixed_frame_rate_flag=1"' gives me the ffmpeg respawning in the log also.
Using the suggested:
unifi-cam-proxy -H 192.168.1.1 -i 192.168.1.30 -c /cert/client.pem -t token reolink -u user -p pass --ffmpeg-args '-c:v copy -vbsf "h264_metadata=tick_rate=60000/1001" -ar 32000 -ac 1 -codec:a aac -b:a 32k'
as per the documentation produces:
unifi-cam-proxy reolink: error: argument --ffmpeg-args/-f: expected one argument

@burnsy180
Copy link

I have an RLC-520 and trying to get this working via Docker on Unraid. Passing unifi-cam-proxy -H 192.168.1.1 -i 192.168.1.30 -c /cert/client.pem -t <token> reolink -u <user> -p <pass> -s main --ffmpeg-args='-bsf:v "h264_metadata=tick_rate=30000/1001:fixed_frame_rate_flag=1"' gives me the ffmpeg respawning in the log also. Using the suggested: unifi-cam-proxy -H 192.168.1.1 -i 192.168.1.30 -c /cert/client.pem -t token reolink -u user -p pass --ffmpeg-args '-c:v copy -vbsf "h264_metadata=tick_rate=60000/1001" -ar 32000 -ac 1 -codec:a aac -b:a 32k' as per the documentation produces: unifi-cam-proxy reolink: error: argument --ffmpeg-args/-f: expected one argument

So have noticed the code referenced in the docs here is missing the '=', causing that error.
However now I get:
[--channel CHANNEL] --substream {main,sub} unifi-cam-proxy reolink: error: the following arguments are required: --substream/-s

@wikrok
Copy link

wikrok commented Jan 12, 2022

I'm having the same ffmpeg restarting issue on an RLC-420 here, too.

Running the ffmpeg commands by hand gives me the same output as @GhostlyCrowd - no errors, just a few warnings about low_delay_hrd_flag.

I've tried a variety of different ffmpeg versions with the same results each time, including on 4.1.4 and on the 4.1.6 the current dev docker image has been changed to.

I see in the console output each ffmpeg restart is immediately preceded by a Reolink[1] INFO Processing [ChangeVideoSettings] message , is it possible this restart is actually being triggered by the proxy somehow?

Thanks

@GhostlyCrowd
Copy link
Contributor

GhostlyCrowd commented Jan 14, 2022

I have an RLC-520 and trying to get this working via Docker on Unraid. Passing unifi-cam-proxy -H 192.168.1.1 -i 192.168.1.30 -c /cert/client.pem -t <token> reolink -u <user> -p <pass> -s main --ffmpeg-args='-bsf:v "h264_metadata=tick_rate=30000/1001:fixed_frame_rate_flag=1"' gives me the ffmpeg respawning in the log also. Using the suggested: unifi-cam-proxy -H 192.168.1.1 -i 192.168.1.30 -c /cert/client.pem -t token reolink -u user -p pass --ffmpeg-args '-c:v copy -vbsf "h264_metadata=tick_rate=60000/1001" -ar 32000 -ac 1 -codec:a aac -b:a 32k' as per the documentation produces: unifi-cam-proxy reolink: error: argument --ffmpeg-args/-f: expected one argument

So have noticed the code referenced in the docs here is missing the '=', causing that error. However now I get: [--channel CHANNEL] --substream {main,sub} unifi-cam-proxy reolink: error: the following arguments are required: --substream/-s

need to choose your cameras strem, -s main or -s sub and yes the = is required for ff args. some of my explanation from my PR didnt make it to the new wiki it seems.

@burnsy180
Copy link

burnsy180 commented Jan 15, 2022

I have an RLC-520 and trying to get this working via Docker on Unraid. Passing unifi-cam-proxy -H 192.168.1.1 -i 192.168.1.30 -c /cert/client.pem -t <token> reolink -u <user> -p <pass> -s main --ffmpeg-args='-bsf:v "h264_metadata=tick_rate=30000/1001:fixed_frame_rate_flag=1"' gives me the ffmpeg respawning in the log also. Using the suggested: unifi-cam-proxy -H 192.168.1.1 -i 192.168.1.30 -c /cert/client.pem -t token reolink -u user -p pass --ffmpeg-args '-c:v copy -vbsf "h264_metadata=tick_rate=60000/1001" -ar 32000 -ac 1 -codec:a aac -b:a 32k' as per the documentation produces: unifi-cam-proxy reolink: error: argument --ffmpeg-args/-f: expected one argument

So have noticed the code referenced in the docs here is missing the '=', causing that error. However now I get: [--channel CHANNEL] --substream {main,sub} unifi-cam-proxy reolink: error: the following arguments are required: --substream/-s

need to choose your cameras strem, -s main or -s sub and yes the = is required for ff args. some of my explanation from my PR didnt make it to the new wiki it seems.

Thanks for the clarification. The docker runs now but once again, plagued with the repeating error in the logs, trying both -s main and sub:

`[AVBSFContext @ 0x149dafab5e40] Codec 'flv1' (21) is not supported by the bitstream filter 'h264_metadata'. Supported codecs are: h264 (27)
Error initializing bitstream filter: h264_metadata

Error initializing output stream 0:0 --

[libmp3lame @ 0x55c09ba93100] 6 frames left in the queue on closing
Conversion failed!


2022-01-15 03:56:54 f31635ffec1b Reolink[1] INFO Spawning ffmpeg for video1 (648gXRLhMJgeUIM5): ffmpeg -nostdin -y -stimeout 15000000 -rtsp_transport tcp -i "rtsp://<user>:<pass>@192.168.1.30:554//h264Preview_01_sub" -bsf:v "h264_metadata=tick_rate=30000/1001" -metadata streamname=648gXRLhMJgeUIM5 -f flv - | /usr/local/bin/python -m unifi.clock_sync | nc 192.168.1.1 7550
2022-01-15 03:56:54 f31635ffec1b Reolink[1] INFO Processing [ChangeVideoSettings] message
2022-01-15 03:56:54 f31635ffec1b Reolink[1] WARNING Stream video3 terminated unexpectedly: ffmpeg version 4.1.6 Copyright (c) 2000-2020 the FFmpeg developers
`

I've heard a few ppl actually have a working stream. Is the args that are working that you can share?
For clarity, i'm using:
unifi-cam-proxy -H 192.168.1.1 -i 192.168.1.30 -c /cert/client.pem -t <token> reolink -u <user> -p <pass> -s main --ffmpeg-args='-bsf:v "h264_metadata=tick_rate=30000/1001"'

@julianpoy
Copy link

I spoke to @Fanman03 and he mentioned that he did not in fact get it working stable and was still encountering issues.

I don't believe there is anyone who has a stable RLC-520 setup.

@keshavdv
Copy link
Owner

keshavdv commented Jan 15, 2022

I don't have a Reolink camera so my debugging abilities are limited. If you can, please privately send me a short 20-30s video file captured from the RTSP output via email or be willing to share access to a device. In the meantime, can you try the latest dev docker image (keshavdv/unifi-can-proxy:dev) with the --verbose flag and include the proxy output in a paste? It should include the output from ffmpeg and have a bit more information about why it keeps crashing. I noticed that the last few command shared in this thread are missing the "copy" part from the recommended args. Can you try it again with the following?

--ffmpeg-args='-c:v copy -vbsf "h264_metadata=tick_rate=60000/1001" -ar 32000 -ac 1 -codec:a aac -b:a 32k'

@GhostlyCrowd
Copy link
Contributor

Today I've discovered that the reolink firmware outputs natively a flv stream. this may be very usefull for these cameras if we can use it. For example i have http://192.168.7.100/flv?port=1935&app=bcs&stream=channel0_main.bcs&token=f48c87c0f105441 streaming steadily in vlc player. there is a python api module for these cameras as well it may be a better way for us to move forward. Since Amcrest and hikvision use a proper api and work very well.

I''m not good enough with python to do this though.

@GhostlyCrowd
Copy link
Contributor

@GhostlyCrowd
Copy link
Contributor

@keshavdv
I have a RLC-522 Sitting on my desk at home I was planning on having a kick at it. I can also give you a video clip, as well as I'm not against putting it on a vlan and giving you access to it. Is there any way we can take advantage of the native flv stream these cameras output and direct feed it to the cam proxy? It actually has the proper video metadata as far as I can tell and the Unifi system should happily take it as long as the system thinks it's from a Unify cam.

There is also beta firmware for many of the Cams that enabled keyframes finally. It seems to have been very beneficial for camera stream recording/quality reliability. I have it flashed to one of my RLC-410-5MP

I started a discussion on some things I've found recently, since it's out of the scope of an issue report. The native FLV stream is the most reliable and stable from these cameras. it also opens up a third substream called External which could be leveraged. I'm not sure what video 1-3 do in this great cam proxy, I assume one is high quality (main) one is low (sub) and the third is for mobile viewing (external/ext) just as the reolink flv streams are used.

@keshavdv
Copy link
Owner

Temporary access to a camera would be best since I imagine this will need quite a few attempts to get right, but video clips are at least a start. The FLV stream generally is just a container for the same h264-encoded video that you can access via RTSP so while it does have flash-level metadata, the inner video stream is still probably missing a few key components. The beta firmware sounds interesting -- the biggest reason Reolink cameras struggle is the lack of certain VUI markers within the h264 stream. Easiest way to know if it fixes anything is to try the RTSP implementation without any ffmpeg-args and see if it streams smoothly in the web viewer.

@GhostlyCrowd
Copy link
Contributor

GhostlyCrowd commented Jan 19, 2022

No such luck running the base RTSP implementation. I can get the camera access set up tonight hopefully for you.

@GhostlyCrowd
Copy link
Contributor

@keshavdv I have the RLC-522 working well on my proxy. what level of access do you want to have so you can work with it and deploy code improvements? just a rtsp port forwarded? do you want the web ui and admin? flv and rtmp ports forwarded? Also best way to contact you privately with the access info?

@keshavdv
Copy link
Owner

Ideally, RTSP and web/admin access would be great since I'm planning to experiment with the more official reolink API if I can. My email is [email protected].

@GhostlyCrowd
Copy link
Contributor

@keshavdv everything you need is sent let me know if you need anything else shoot me an email.

@GhostlyCrowd
Copy link
Contributor

GhostlyCrowd commented Jan 20, 2022

Forgot to mention I've baffled the mic (didn't want to disable it for your work) , so its pretty deaf. mainly because you're just going to hear me at my work pc clacking away on the keyboard, or my cats fighting. there is enough sound to hear you will get something inaudible when there is something to hear, and if you really want to hear something adjust the optical zoom in the Web UI the mic rattle traps when that happens.

@Tr4um4z
Copy link

Tr4um4z commented Jan 24, 2022

installed ffmpeg 4.1.4 but same freezes

with other nvr software i have used a rtmp stream that is more stable for reolink cams

rtmp://ip adress/bcs/channel0_main.bcs?channel=0&stream=0&user=usenam&password=pass

thanks in advance

@julianpoy
Copy link

I can provide remote access to my camera - email me at [email protected] and I'll give you a public address to hit the camera.

@keshavdv
Copy link
Owner

For folks using an RLC-520, does live streaming work on iOS or Android? In my testing, it seems to only be the web player that struggles to handle the Reolink stream. My testing has been with the existing reolink implementation.

@stale
Copy link

stale bot commented Mar 14, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 14, 2022
@burnsy180
Copy link

For folks using an RLC-520, does live streaming work on iOS or Android? In my testing, it seems to only be the web player that struggles to handle the Reolink stream. My testing has been with the existing reolink implementation.

Sorry for the late reply,
I can't get live streaming to work on the web player or via the android protect app. I don't have an iOS device to test. I simply get the last snapshot and it's constantly attempting to load.
My docker log loops through constant:
Error writing trailer of pipe:: Broken pipe
followed by:
2022-03-17 08:32:48 ba05e5d91adb Reolink[1] INFO Spawning ffmpeg for video1 (gPmmgSgOOe32x7kX): ffmpeg -nostdin -loglevel error -y -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -stimeout 15000000 -rtsp_transport tcp -i "rtsp://admin:[email protected]:554//h264Preview_01_main" -c:v copy -vbsf "h264_metadata=tick_rate=60000/1001" -ar 32000 -ac 1 -codec:a aac -b:a 32k -metadata streamname=gPmmgSgOOe32x7kX -f flv - | /usr/local/bin/python -m unifi.clock_sync | nc 192.168.1.1 7550

Has there been any progress on this by anyone?

@stale stale bot removed the stale label Mar 17, 2022
@Fanman03
Copy link
Author

Fanman03 commented Apr 13, 2022

@Fanman03 would you be willing to test my pull request for reolink stand alone cameras, could use more people testing it. its a big step in a good direction for reolink cameras. #127

You seem to be active and savvy enough.

Sorry for the delay, I ended up using Frigate in the meantime since I couldn't get this working properly. I see your commit has been merged into the main repo, and I've tried the latest build via Docker with partial success but there still are some issues. Streaming works fine from the Protect app on mobile, but on Desktop the streaming doesn't work and just endlessly loads. The mobile stream also has lots of artifacting when attempting to view the desktop one.

The console outputs lots of lines of the following:

[rtsp @ 0x7fcef9cfc580] RTP: PT=60: bad cseq 154d expected=1bdf
[rtsp @ 0x7fcef9cfc580] RTP: PT=60: bad cseq e1ab expected=1be0
[rtsp @ 0x7fcef9cfc580] RTP: PT=60: bad cseq 394f expected=1be0
[rtsp @ 0x7fcef9cfc580] RTP: PT=60: bad cseq e1ac expected=1be1
[rtsp @ 0x7fcef9cfc580] RTP: PT=60: bad cseq 154e expected=1be1
[rtsp @ 0x7fcef9cfc580] RTP: PT=60: bad cseq 3950 expected=1be1
[rtsp @ 0x7fcef9cfc580] RTP: PT=60: bad cseq e1ad expected=1be2
[rtsp @ 0x7fcef9cfc580] RTP: PT=60: bad cseq 154f expected=1be2
[rtsp @ 0x7fcef9cfc580] RTP: PT=60: bad cseq 3951 expected=1be2
[rtsp @ 0x7fcef9cfc580] RTP: PT=60: bad cseq 1550 expected=1be3
[rtsp @ 0x7fcef9cfc580] RTP: PT=60: bad cseq e1ae expected=1be4
[rtsp @ 0x7fcef9cfc580] RTP: PT=60: bad cseq 3952 expected=1be4
[rtsp @ 0x7fcef9cfc580] RTP: PT=60: bad cseq e1af expected=1be5
[rtsp @ 0x7fcef9cfc580] RTP: PT=60: bad cseq 1551 expected=1be5

This is my docker-compose.yaml:

version: "3.9"
services:
  driveway:
    restart: unless-stopped
    image: keshavdv/unifi-cam-proxy
    volumes:
      - "/root/unifi-protect/client.pem:/client.pem"
    command: unifi-cam-proxy --host 10.2.0.1 --cert /client.pem --token '4SZbpirU2LJB4B1p1IIU0haleKjxOPjE' --mac 'b4:fb:71:62:6b:16' -i 10.6.0.11 reolink -u 'admin' -p '[REDACTED]' -s "main" --ffmpeg-args='-c:v copy -vbsf "h264_metadata=tick_rate=60000/1001" -ar 32000 -ac 1 -codec:a aac -b:a 32k'

If I can assist the development in any way, please let me know and I'll be happy to provide any additional info.

@Fanman03
Copy link
Author

Fanman03 commented Apr 13, 2022

For folks using an RLC-520, does live streaming work on iOS or Android? In my testing, it seems to only be the web player that struggles to handle the Reolink stream. My testing has been with the existing reolink implementation.

Sorry for the late reply, I can't get live streaming to work on the web player or via the android protect app. I don't have an iOS device to test. I simply get the last snapshot and it's constantly attempting to load. My docker log loops through constant: Error writing trailer of pipe:: Broken pipe followed by: 2022-03-17 08:32:48 ba05e5d91adb Reolink[1] INFO Spawning ffmpeg for video1 (gPmmgSgOOe32x7kX): ffmpeg -nostdin -loglevel error -y -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -stimeout 15000000 -rtsp_transport tcp -i "rtsp://admin:[email protected]:554//h264Preview_01_main" -c:v copy -vbsf "h264_metadata=tick_rate=60000/1001" -ar 32000 -ac 1 -codec:a aac -b:a 32k -metadata streamname=gPmmgSgOOe32x7kX -f flv - | /usr/local/bin/python -m unifi.clock_sync | nc 192.168.1.1 7550

Has there been any progress on this by anyone?

I believe this is unrelated to Reolink and is a general bug. I was able to fix it by downgrading to Protect v1.21.2 by running the following via SSH on the UDM Pro:

unifi-os shell
apt-get update
apt-get install --reinstall --allow-downgrades unifi-protect=1.21.2 -y

@Fanman03
Copy link
Author

Fanman03 commented May 5, 2022

I've installed a beta reolink firmware that is supposed to have fixed RTSP, but now I'm getting this error. I'm on Protect v1.21.2 so I don't think its related to the new FLV format issue.

  File "/usr/local/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/app/unifi/clock_sync.py", line 167, in <module>
    main()
  File "/app/unifi/clock_sync.py", line 157, in main
    write(read_bytes(source, payload_size))
  File "/app/unifi/clock_sync.py", line 87, in write
    sys.stdout.buffer.write(data)
BrokenPipeError: [Errno 32] Broken pipe
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>

This is the command I'm using:

unifi-cam-proxy --host 10.2.0.1 --cert /client.pem --token 'AevlmOs6KPmCe2KryvQ7GAunmxth5PUk' --mac '78:45:58:4a:89:f2' --model 'UVC G4 Dome' -i 10.6.0.11 reolink -u 'admin' -p 'password' -s "main" --ffmpeg-args='-c:v copy -vbsf "h264_metadata=tick_rate=60000/1001" -ar 32000 -ac 1 -codec:a aac -b:a 32k'

@mjn138
Copy link

mjn138 commented Jun 3, 2022

@Fanman03 I'm getting the same error as you with the RLC-510A.

@stale
Copy link

stale bot commented Jul 3, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 3, 2022
@julianpoy
Copy link

Not stale

@stale stale bot removed the stale label Jul 6, 2022
@stale
Copy link

stale bot commented Aug 5, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 5, 2022
@stale stale bot closed this as completed Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants