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

Streaming issue #1

Closed
andyjhall opened this issue May 14, 2020 · 6 comments
Closed

Streaming issue #1

andyjhall opened this issue May 14, 2020 · 6 comments
Labels
question Further information is requested

Comments

@andyjhall
Copy link

Describe Your Problem:
Streaming of a camera just shows the "loading" symbol forever, even though the homebridge logs suggest the stream is being sent. The tile in the home app is however updated every 10 seconds.

Logs:


[5/14/2020, 12:47:36 PM] [Camera-Swann] Snapshot from: Test Cam @ 480:270
ffmpeg -rtsp_transport tcp -i rtsp://admin:password@192.168.0.210:554/ch01/0 -t 1 -vf scale=480:270 -f image2 -
[NULL @ 0x555b9203a540] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0

[rtp @ 0x555b920517c0] Sending NAL 2 of len 31267 M=1
[rtp @ 0x555b920517c0] NAL size 31267 > 1352

[NULL @ 0x555b9203a540] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0

[rtp @ 0x555b920517c0] Sending NAL 2 of len 22390 M=1
[rtp @ 0x555b920517c0] NAL size 22390 > 1352

[NULL @ 0x555b9203a540] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0

[rtp @ 0x555b920517c0] Sending NAL 2 of len 51154 M=1
[rtp @ 0x555b920517c0] NAL size 51154 > 1352

[NULL @ 0x555b9203a540] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0

[rtp @ 0x555b920517c0] Sending NAL 2 of len 28582 M=1
[rtp @ 0x555b920517c0] NAL size 28582 > 1352

[NULL @ 0x555b9203a540] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0

[rtp @ 0x555b920517c0] Sending NAL 2 of len 29941 M=1
[rtp @ 0x555b920517c0] NAL size 29941 > 1352

[NULL @ 0x555b9203a540] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0

[rtp @ 0x555b920517c0] Sending NAL 2 of len 30405 M=1
[rtp @ 0x555b920517c0] NAL size 30405 > 1352

frame=   30 fps=0.0 q=-1.0 size=    1462kB time=00:00:01.93 bitrate=6190.4kbits/s speed=3.71x
[NULL @ 0x555b9203a540] nal_unit_type: 32(VPS), nuh_layer_id: 0, temporal_id: 0
[NULL @ 0x555b9203a540] nal_unit_type: 33(SPS), nuh_layer_id: 0, temporal_id: 0
[NULL @ 0x555b9203a540] nal_unit_type: 34(PPS), nuh_layer_id: 0, temporal_id: 0
[NULL @ 0x555b9203a540] nal_unit_type: 39(SEI_PREFIX), nuh_layer_id: 0, temporal_id: 0

[NULL @ 0x555b9203a540] nal_unit_type: 19(IDR_W_RADL), nuh_layer_id: 0, temporal_id: 0
[NULL @ 0x555b9203a540] Decoding VPS
[NULL @ 0x555b9203a540] Main profile bitstream
[NULL @ 0x555b9203a540] Decoding SPS
[NULL @ 0x555b9203a540] Main profile bitstream
[NULL @ 0x555b9203a540] Decoding VUI
[NULL @ 0x555b9203a540] Decoding PPS

[NULL @ 0x555b9203a540] Decoding SEI
[NULL @ 0x555b9203a540] Skipped PREFIX SEI 229

[rtp @ 0x555b920517c0] Sending NAL 0 of len 23 M=0
[rtp @ 0x555b920517c0] Sending NAL 2 of len 35 M=0
[rtp @ 0x555b920517c0] Sending NAL 4 of len 7 M=0
[rtp @ 0x555b920517c0] Sending NAL e of len 9 M=0

[rtp @ 0x555b920517c0] Sending NAL 6 of len 575670 M=1

[rtp @ 0x555b920517c0] NAL size 575670 > 1352

[NULL @ 0x555b9203a540] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0

[rtp @ 0x555b920517c0] Sending NAL 2 of len 31061 M=1
[rtp @ 0x555b920517c0] NAL size 31061 > 1352

[NULL @ 0x555b9203a540] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[rtp @ 0x555b920517c0]
Sending NAL 2 of len 48430 M=1
[rtp @ 0x555b920517c0] NAL size 48430 > 1352

[NULL @ 0x555b9203a540] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0

[rtp @ 0x555b920517c0] Sending NAL 2 of len 22380 M=1
[rtp @ 0x555b920517c0] NAL size 22380 > 1352

[NULL @ 0x555b9203a540] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0

[rtp @ 0x555b920517c0] Sending NAL 2 of len 42580 M=1
[rtp @ 0x555b920517c0] NAL size 42580 > 1352

[NULL @ 0x555b9203a540] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0

[rtp @ 0x555b920517c0] Sending NAL 2 of len 52714 M=1
[rtp @ 0x555b920517c0] NAL size 52714 > 1352

[NULL @ 0x555b9203a540] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[rtp @ 0x555b920517c0]
Sending NAL 2 of len 30711 M=1
[rtp @ 0x555b920517c0] NAL size 30711 > 1352

[libfdk_aac @ 0x555b92056740] Trying to remove 224 more samples than there are in the queue

frame=   37 fps= 35 q=-1.0 Lsize=    2256kB time=00:00:02.51 bitrate=7362.3kbits/s speed=2.36x
video:2231kB audio:8kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.774995%
Input file #0 (rtsp://admin:password@192.168.0.210:554/ch01/0):
  Input stream #0:0 (video): 37 packets read (2284418 bytes);
  Input stream #0:1 (audio): 42 packets read (20160 bytes); 42 frames decoded (20160 samples);
  Total: 79 packets (2304578 bytes) demuxed
Output file #0 (srtp://192.168.0.132:53772?rtcpport=53772&localrtcpport=53772&pkt_size=1378):
  Output stream #0:0 (video): 37 packets muxed (2284418 bytes);
  Total: 37 packets (2284418 bytes) muxed
Output file #1 (srtp://192.168.0.132:51152?rtcpport=51152&localrtcpport=51152&pkt_size=188):
  Output stream #1:0 (audio): 78 frames encoded (39936 samples)
; 79 packets muxed (7725 bytes);
  Total: 79 packets (7725 bytes) muxed
42 frames successfully decoded, 0 decoding errors

[AVIOContext @ 0x555b9214bb80] Statistics: 0 seeks, 1712 writeouts

[AVIOContext @ 0x555b9216d6c0] Statistics: 0 seeks, 80 writeouts

Exiting normally, received signal 15.

[5/14/2020, 12:47:36 PM] [Camera-Swann] Stopped streaming
[5/14/2020, 12:47:46 PM] [Camera-Swann] Snapshot from: Test Cam @ 480:270
ffmpeg -rtsp_transport tcp -i rtsp://admin:password@192.168.0.210:554/ch01/0 -t 1 -vf scale=480:270 -f image2 -
[5/14/2020, 12:47:58 PM] [Camera-Swann] Snapshot from: Test Cam @ 480:270
ffmpeg -rtsp_transport tcp -i rtsp://admin:password@192.168.0.210:554/ch01/0 -t 1 -vf scale=480:270 -f image2 -
[5/14/2020, 12:48:10 PM] [Camera-Swann] Snapshot from: Test Cam @ 480:270
ffmpeg -rtsp_transport tcp -i rtsp://admin:password@192.168.0.210:554/ch01/0 -t 1 -vf scale=480:270 -f image2 -

Homebridge Config:

 "platforms": [
        {
            "cameras": [
                {
                    "name": "Test Cam",
                    "manufacturer": "Swann",
                    "model": "NVR-123",
                    "serialNumber": "1234",
                    "firmwareRevision": "V8.1.0",
                    "videoConfig": {
                        "mainStream": "-rtsp_transport tcp -i rtsp://admin:password@192.168.0.210:554/ch01/0",
                        "subStream": "-rtsp_transport tcp -i rtsp://admin:password@192.168.0.210:554/ch01/1",
                        "maxStreams": 1,
                        "bitrateThreshold": 299,
                        "videoPacketSize": 1378,
                        "audioPacketSize": 188,
                        "mapvideo": "0:v",
                        "mapaudio": "0:a",
                        "audio": true,
                        "debug": true
                    }
                }
            ],
            "platform": "Camera-Swann"
        }
    ]

Environment:
onzu docker container

@andyjhall andyjhall added the question Further information is requested label May 14, 2020
@SupImDos
Copy link
Owner

Hi @andyjhall

Would you be able to share a screenshot of the "Recording" section of your Swann NVR/DVR?

e.g.
16AEFE98-D87E-46D5-80C6-5EA4E86EC83F
14B54EDB-2D5E-4D3A-9BDD-F04FB7A975BD

Thanks!

@andyjhall
Copy link
Author

Please see below, happy to give it ago with changing the stream to match your screenshots if that might fix it?
mainstream
substream

@SupImDos
Copy link
Owner

@andyjhall

In order for this specific plugin to work, the streams must be set to h264 rather than h265 as per your mainstream screenshot (HomeKit only accepts h264).

On a separate note, you may also experience some stuttering at high resolutions and bitrates (especially 4K @ 6kbps, but you may as well try it first).

You might be able to play around with the settings, and find what is suitable for your network/setup, while still being an appropriately high quality (in case you actually need to use the stored footage from the NVR).

Alternatively, if you can't compromise the high quality for smooth playback in HomeKit, you might be able to look at using the homebridge-camera-ffmpeg plugin to transcode your high quality stream, but this would cost a large amount of cpu usage (which is the main advantage of this plugin - directly copying the h264 stream instead of transcoding it).

Hope some of this info was useful.

Thanks!

@andyjhall
Copy link
Author

andyjhall commented May 14, 2020 via email

@SupImDos
Copy link
Owner

@andyjhall

I'm not 100% sure about much to do with a Docker setup, sorry.

In terms of incoming traffic, the RTSP stream is on port 554.

For outgoing traffic, the SRTP video and audio streams are on separate ports, but are chosen differently each time by HomeKit.

As shown in your example log above:

Output file #0 (srtp://192.168.0.132:53772?rtcpport=53772&localrtcpport=53772&pkt_size=1378):
 Output stream #0:0 (video): 37 packets muxed (2284418 bytes);
 Total: 37 packets (2284418 bytes) muxed
Output file #1 (srtp://192.168.0.132:51152?rtcpport=51152&localrtcpport=51152&pkt_size=188):

The ports were 53772 and 51152 in that particular request. I'm sure it would be possible to find the range of ports it can select somewhere in the HAP specifications though.

@andyjhall
Copy link
Author

Ok tried changing the streams to match your screenshots and that doesnt work, also made the docker container host mode so it can use any port it likes. Seems like an issue with my setup rather than the plugin so Im going to close this and deal with it on my side.

Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants