keshavdv / unifi-cam-proxy

Enable non-Ubiquiti cameras to work with Unifi NVR
MIT License
1.73k stars 237 forks source link

RTSP for INSTAR IN-9408 2K+ / IN-9008 Full HD not working #384

Closed patrickbussmann closed 3 months ago

patrickbussmann commented 3 months ago

Camera

INSTAR IN-9408 2K+ / IN-9008 Full HD

Firmware version of the camera

3.2.0 [782]

Description

WARNING Previous ffmpeg process for video2 died

So I tried different configurations as you can see on How to reproduce but its failing all the time.

Input #0, rtsp, from 'rtsp://xyz@192.168.178.2:554/12':
  Metadata:
    title           : 11
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0, 28, 1/90000: Video: h264 (Main), 1 reference frame, yuvj420p(pc, bt709, progressive, left), 640x352, 0/1, 12.50 tbr, 90k tbn, 180k tbc
    Stream #0:1, 116, 1/8000: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s
Successfully opened the file.
Parsing a group of options: output url -.
Applying option r (set frame rate (Hz value, fraction or abbreviation)) with argument 12.5.
Applying option c:v (codec name) with argument copy.
Applying option ar (set audio sampling rate (in Hz)) with argument 44100.
Applying option ac (set number of audio channels) with argument 1.
Applying option codec:a (codec name) with argument aac.
Applying option b:a (video bitrate (please use -b:v)) with argument 32k.
Applying option bsf:v (A comma-separated list of bitstream filters) with argument h264_metadata=tick_rate=30000/1001.
Applying option metadata (add metadata) with argument streamname=HESfjUGRtNPQuhIp.
Applying option f (force format) with argument flv.
Successfully parsed a group of options.
Opening an output file: -.
[h264_metadata_bsf @ 0x562aad1cea00] Setting 'tick_rate' to value '30000/1001'
[pipe @ 0x562aad341580] Setting default whitelist 'crypto'
Successfully opened the file.
[AVBSFContext @ 0x562aad357f40] nal_unit_type: 7(SPS), nal_ref_idc: 3
[AVBSFContext @ 0x562aad357f40] nal_unit_type: 8(PPS), nal_ref_idc: 3
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (pcm_alaw (native) -> aac (native))
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
    Last message repeated 1 times
detected 8 logical cores
[graph_0_in_0_1 @ 0x562aad19df40] Setting 'time_base' to value '1/8000'
[graph_0_in_0_1 @ 0x562aad19df40] Setting 'sample_rate' to value '8000'
[graph_0_in_0_1 @ 0x562aad19df40] Setting 'sample_fmt' to value 's16'
[graph_0_in_0_1 @ 0x562aad19df40] Setting 'channel_layout' to value '0x4'
[graph_0_in_0_1 @ 0x562aad19df40] tb:1/8000 samplefmt:s16 samplerate:8000 chlayout:0x4
[format_out_0_1 @ 0x562aad19e780] Setting 'sample_fmts' to value 'fltp'
[format_out_0_1 @ 0x562aad19e780] Setting 'sample_rates' to value '44100'
[format_out_0_1 @ 0x562aad19e780] Setting 'channel_layouts' to value '0x4'
[format_out_0_1 @ 0x562aad19e780] auto-inserting filter 'auto_resampler_0' between the filter 'Parsed_anull_0' and the filter 'format_out_0_1'
[AVFilterGraph @ 0x562aad199b00] query_formats: 4 queried, 6 merged, 3 already done, 0 delayed
[auto_resampler_0 @ 0x562aad19f380] [SWR @ 0x562aad1e3640] Using fltp internally between filters
[auto_resampler_0 @ 0x562aad19f380] ch:1 chl:mono fmt:s16 r:8000Hz -> ch:1 chl:mono fmt:fltp r:44100Hz
Output #0, flv, to 'pipe:':
  Metadata:
    title           : 11
    streamname      : HESfjUGRtNPQuhIp
    encoder         : Lavf58.20.100
    Stream #0:0, 0, 1/1000: Video: h264 (Main), 1 reference frame ([7][0][0][0] / 0x0007), yuvj420p(pc, bt709, progressive, left), 640x352 (0x0), 0/1, q=2-31, 12.50 tbr, 1k tbn, 12.50 tbc
    Stream #0:1, 0, 1/1000: Audio: aac (LC) ([10][0][0][0] / 0x000A), 44100 Hz, mono, fltp, delay 1024, 32 kb/s
    Metadata:
      encoder         : Lavc58.35.100 aac
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
    Last message repeated 9 times
[AVBSFContext @ 0x562aad357f40] nal_unit_type: 7(SPS), nal_ref_idc: 3
[AVBSFContext @ 0x562aad357f40] nal_unit_type: 8(PPS), nal_ref_idc: 3
[AVBSFContext @ 0x562aad357f40] nal_unit_type: 6(SEI), nal_ref_idc: 0
[AVBSFContext @ 0x562aad357f40] nal_unit_type: 5(IDR), nal_ref_idc: 3
[flv @ 0x7f7ede1174c0] 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 @ 0x562aad357f40] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
    Last message repeated 32 times
[AVBSFContext @ 0x562aad357f40] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 311.1kbits/s speed=5.44x    
    Last message repeated 5 times
[AVBSFContext @ 0x562aad357f40] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 302.0kbits/s speed=3.24x    
    Last message repeated 6 times
[AVBSFContext @ 0x562aad357f40] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 398.0kbits/s speed=2.49x    
    Last message repeated 5 times
[AVBSFContext @ 0x562aad357f40] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 390.3kbits/s speed=2.12x    
    Last message repeated 5 times
[AVBSFContext @ 0x562aad357f40] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 385.2kbits/s speed= 1.9x    
    Last message repeated 6 times
[AVBSFContext @ 0x562aad357f40] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 384.9kbits/s speed=1.74x

or also some other infos

[tcp @ 0x7fde3f14de40] Starting connection attempt to 192.168.178.2 port 554
[tcp @ 0x7fde3f14de40] Successfully connected to 192.168.178.2 port 554
ffmpeg version 4.1.6 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 8.3.0 (Alpine 8.3.0)
  configuration: --prefix=/usr --enable-avresample --enable-avfilter --enable-gnutls --enable-gpl --enable-libass --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libxvid --enable-libx264 --enable-libx265 --enable-libtheora --enable-libv4l2 --enable-postproc --enable-pic --enable-pthreads --enable-shared --enable-libxcb --disable-stripping --disable-static --disable-librtmp --enable-vaapi --enable-vdpau --enable-libopus --disable-debug
  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
2024-08-02 22:33:21 40e3f33bd49d RTSPCam[1] INFO Spawning ffmpeg for video3 (2cnuqoH8hNQNNwD1): ffmpeg -nostdin -loglevel error -y -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -stimeout 15000000 -rtsp_transport tcp -i "rtsp://xyz@192.168.178.2:554/12" -loglevel debug -analyzeduration 10000000 -probesize 10000000 -vsync 1 -copyts -r 12.5 -c:v copy -ar 44100 -ac 1 -codec:a aac -b:a 32k -bsf:v "h264_metadata=tick_rate=30000/1001" -metadata streamname=2cnuqoH8hNQNNwD1 -f flv - | /usr/local/bin/python -m unifi.clock_sync | nc 172.16.33.33 7550
2024-08-02 22:33:21 40e3f33bd49d RTSPCam[1] INFO Processing [NetworkStatus] message
2024-08-02 22:33:21 40e3f33bd49d RTSPCam[1] INFO Processing [GetSystemStats] message
Applying option vsync (video sync method) with argument 1.
Applying option copyts (copy timestamps) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url rtsp://xyz@192.168.178.2:554/12.
Successfully parsed a group of options.
Opening an input file: rtsp://xyz@192.168.178.2:554/12.
[tcp @ 0x7f09dcb80e40] No default whitelist set
[tcp @ 0x7f09dcb80e40] Original list of addresses:
[tcp @ 0x7f09dcb80e40] Address 192.168.178.2 port 554
[tcp @ 0x7f09dcb80e40] Interleaved list of addresses:
[tcp @ 0x7f09dcb80e40] Address 192.168.178.2 port 554
[tcp @ 0x7f09dcb80e40] Starting connection attempt to 192.168.178.2 port 554
[tcp @ 0x7f09dcb80e40] Successfully connected to 192.168.178.2 port 554
[rtsp @ 0x7fde3f14d6c0] SDP:
v=0
o=- 38990265062388 38990265062388 IN IP4 192.168.178.2

How to reproduce

services:
  proxy-1:
    restart: unless-stopped
    image: keshavdv/unifi-cam-proxy
    volumes:
      - "./client.pem:/client.pem"
    command: >-
      unifi-cam-proxy
      --host 172.16.33.33
      --mac 'AA:BB:CC:00:11:30'
      --cert /client.pem
      --token cNQgkRCYlFeAv7yGZgNEOWGHYAEDClGO
      --model "UVC G3 Micro"
      rtsp -s rtsp://admin:xyz@192.168.178.4:554/livestream/11
      --ffmpeg-args='-ar 11025'
#      --ffmpeg-args='-c:v copy -ar 32000 -ac 1 -codec:a pcm_alaw -b:a 32k'
  proxy-2:
    restart: unless-stopped
    image: keshavdv/unifi-cam-proxy
    volumes:
      - "./client.pem:/client.pem"
    command: >-
      unifi-cam-proxy
      --host 172.16.33.33
      --mac 'AA:BB:CC:00:11:31'
      --cert /client.pem
      --token RVYJx0pgf8PHlhQx63z73wDTzNkZ0kMu
      --model "UVC G3 Micro"
      rtsp -s rtsp://admin:xyz@192.168.178.3:554/11
      --ffmpeg-args='-c:v copy -ar 22050 -ac 1 -codec:a aac -b:a 32k'
  proxy-3:
    restart: unless-stopped
    image: keshavdv/unifi-cam-proxy
    volumes:
      - "./client.pem:/client.pem"
    environment:
      - TZ=Europe/Berlin
      - DEBUG=1
    command: >-
      unifi-cam-proxy
      --host 172.16.33.33
      --mac 'AA:BB:CC:00:11:32'
      --cert /client.pem
      --token M5AidPbfbv9wyQ0fH6KiX9DbCqNLsXPg
      --model "UVC G3 Micro"
      rtsp -s rtsp://xyz@192.168.178.2:554/12
      --ffmpeg-args='-loglevel debug -analyzeduration 10000000 -probesize 10000000 -vsync 1 -copyts -r 12.5 -c:v copy -ar 44100 -ac 1 -codec:a aac -b:a 32k -bsf:v "h264_metadata=tick_rate=30000/1001"'

Expected behaviour

Video Recording and Watching is working as normal 😇

Screenshots

No response

Additional information

No response

patrickbussmann commented 3 months ago

Working fine with Protect 4.1.39 🥳