homebridge-plugins / homebridge-camera-ffmpeg

Homebridge Plugin Providing FFmpeg-based Camera Support
https://homebridge-plugins.github.io/homebridge-camera-ffmpeg/
Apache License 2.0
1.09k stars 227 forks source link

D-link DCS-920 live video crashes ffmpeg #612

Closed SkOODaT closed 4 years ago

SkOODaT commented 4 years ago

Describe The Bug: D-link DCS-920 live video crashes ffmpeg Snapshots work perfectly fine

To Reproduce: Browse To The Video Feed

Logs:

[7/6/2020, 5:41:34 PM] [Camera-ffmpeg] FFMPEG: [mjpeg @ 0000026abbc0e780] Opening 'http://admin:XXXXX@192.168.0.44/VIDEO.CGI' for reading
[http @ 0000026abbc0fdc0] Setting default whitelist 'http,https,tls,rtp,tcp,udp,crypto,httpproxy,data'
[7/6/2020, 5:41:34 PM] [Camera-ffmpeg] FFMPEG: [tcp @ 0000026abbc11800] Original list of addresses:
[7/6/2020, 5:41:34 PM] [Camera-ffmpeg] FFMPEG: [tcp @ 0000026abbc11800] Address 192.168.0.44 port 80
[tcp @ 0000026abbc11800] Interleaved list of addresses:
[7/6/2020, 5:41:34 PM] [Camera-ffmpeg] FFMPEG: [tcp @ 0000026abbc11800] Address 192.168.0.44 port 80
[tcp @ 0000026abbc11800] Starting connection attempt to 192.168.0.44 port 80
[7/6/2020, 5:41:34 PM] [Camera-ffmpeg] FFMPEG: [tcp @ 0000026abbc11800] Successfully connected to 192.168.0.44 port 80
[http @ 0000026abbc0fdc0] request: GET /VIDEO.CGI HTTP/1.1
User-Agent: Lavf/58.38.101
Accept: */*
Range: bytes=0-
Connection: close
Host: 192.168.0.44
Icy-MetaData: 1
[7/6/2020, 5:41:34 PM] [Camera-ffmpeg] FFMPEG: http://admin:XXXXX@192.168.0.44/VIDEO.CGI: End of file
[7/6/2020, 5:41:34 PM] [Camera-ffmpeg] [FFMPEG] ffmpeg exited with code: 1 and signal: null (error)
[7/6/2020, 5:41:34 PM] [Camera-ffmpeg] Stopped DCS-920 video stream!

Homebridge Config:

                     "manufacturer": "D-Link",
                     "model": "DCS-920",
                     "videoConfig": {
                        "source": "-re -f mjpeg -i http://admin:XXXXX@192.168.0.44/VIDEO.CGI",
                        "stillImageSource": "-f mjpeg -i http://admin:XXXXX@192.168.0.44/image.jpg",
                        "maxFPS": 30,
                        "audio": false,
                        "debug": true
                    }

or ive tried

                            "source": "-re -i http://admin:XXXXX@192.168.0.44/video/mjpg.cgi",
                            "stillImageSource": "-i http://admin:XXXXX@192.168.0.44/image.jpg",

same error.... I've verified the links in browser i can see a feed

Environment: Latest Setup, Up To Date

if any info from the camera is needed, let me know :)

b2un0 commented 4 years ago

is http://admin:XXXXX@192.168.0.44/VIDEO.CGI really only the video feed?

does the URL works in VLC?

did you try another URLs for your camera from here http://www.camera-sdk.com/p_162-how-to-connect-to-your-d-link-ip-camera-onvif.html or here https://www.ispyconnect.com/man.aspx?n=d-link&page=15

SkOODaT commented 4 years ago

i have tried a ton of urls i have found for the 920, they ALL work in VLC and i can browse directly to them in a browser and see a feed but as soon as ffmpeg trys to do anything it crashes with the end of file error, I've even tried ffmpeg standalone from the plugin i have a feeling its something to do with the headers in the stream ffmpeg isnt reading them correctly

donavanbecker commented 4 years ago

Environment: Latest Setup, Up To Date

if any info from the camera is needed, let me know :)

What is your actual environment setup?

SkOODaT commented 4 years ago

node --version v12.18.0

+-- homebridge@1.1.1
| +-- chalk@4.1.0
| +-- commander@5.1.0
| +-- hap-nodejs@0.7.6
| +-- node-persist@0.0.11
| +-- qrcode-terminal@0.12.0
| +-- semver@7.3.2
| `-- source-map-support@0.5.19
+-- homebridge-camera-ffmpeg@2.1.0
| +-- debug@4.1.1
| +-- ffmpeg-for-homebridge@0.0.6
| `-- ip@1.1.5

windows 10 system

donavanbecker commented 4 years ago

Closing to bring into #631, to see if it fixes your issues.

SkOODaT commented 4 years ago

[7/10/2020, 11:49:48 AM] [Camera-ffmpeg] FFMPEG:   configuration: --pkg-config=pkg-config --pkg-config-flags=--static --extra-version=ffmpeg-windows-build-helpers --enable-version3 --disable-debug --disable-w32threads --arch=x86_64 --target-os=mingw32 --cross-prefix=/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/bin/x86_64-w64-mingw32- --enable-libcaca --enable-gray --enable-libtesseract --enable-fontconfig --enable-gmp --enable-gnutls --enable-libass --enable-libbluray --enable-libbs2b --enable-libflite --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libvorbis --enable-libwebp --enable-libzimg --enable-libzvbi --enable-libmysofa --enable-libopenjpeg --enable-libopenh264 --enable-liblensfun --enable-libvmaf --enable-libsrt --enable-demuxer=dash --enable-libxml2 --enable-opengl --enable-libdav1d --enable-libsvthevc --enable-libaom --enable-libvpx --enable-nvenc --enable-nvdec --extra-libs=-lharfbuzz --extra-libs=-lm --extra-libs=-lpthread --extra-cflags=-DLIBTWOLAME_STATIC --extra-cflags=-DMODPLUG_STATIC --extra-cflags=-DCACA_STATIC --enable-amf --enable-libmfx --enable-gpl --enable-avisynth --enable-frei0r --enable-filter=frei0r --enable-librubberband --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxvid --enable-libxavs --enable-avresample --extra-cflags='-mtune=generic' --extra-cflags=-O3 --enable-static --disable-shared --prefix=/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32 --enable-nonfree --enable-decklink --enable-libfdk-aac
  libavutil      56. 41.100 / 56. 41.100
  libavcodec     58. 70.100 / 58. 70.100
  libavformat    58. 38.101 / 58. 38.101
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 76.100 /  7. 76.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Splitting the commandline.
Reading option '-re' ... matched as option 're' (read input at native frame rate) with argument '1'.
Reading option '-i' ... matched as input url with argument 'http://admin:XXXXX@192.168.0.43/video/mjpg.cgi'.
Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '0:0'.
Reading option '-vcodec' ... matched as option 'vcodec' (force video codec ('copy' to copy stream)) with argument 'libx264'.
Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel format) with argument 'yuv420p'.
Reading option '-r' ... matched as option 'r' (set frame rate (Hz value, fraction or abbreviation)) with argument '10'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'rawvideo'.
Reading option '-preset' ...
[7/10/2020, 11:49:48 AM] [Camera-ffmpeg] FFMPEG:  matched as AVOption 'preset' with argument 'ultrafast'.
Reading option '-tune' ...
[7/10/2020, 11:49:48 AM] [Camera-ffmpeg] FFMPEG:  matched as AVOption 'tune' with argument 'zerolatency'.
Reading option '-vf' ... matched as option 'vf' (set video filters) with argument 'scale=640:480'.
[7/10/2020, 11:49:48 AM] [Camera-ffmpeg] FFMPEG: Reading option '-b:v' ... matched as option 'b' (video bitrate (please use -b:v)) with argument '299k'.
Reading option '-bufsize' ...
[7/10/2020, 11:49:48 AM] [Camera-ffmpeg] FFMPEG:  matched as AVOption 'bufsize' with argument '598k'.
Reading option '-maxrate' ...
[7/10/2020, 11:49:48 AM] [Camera-ffmpeg] FFMPEG:  matched as AVOption 'maxrate' with argument '299k'.
Reading option '-payload_type' ...
[7/10/2020, 11:49:48 AM] [Camera-ffmpeg] FFMPEG:  matched as AVOption 'payload_type' with argument '99'.
Reading option '-ssrc' ...
[7/10/2020, 11:49:48 AM] [Camera-ffmpeg] FFMPEG:  matched as AVOption 'ssrc' with argument '12198308'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'rtp'.
[7/10/2020, 11:49:48 AM] [Camera-ffmpeg] FFMPEG: Reading option '-srtp_out_suite' ...
[7/10/2020, 11:49:48 AM] [Camera-ffmpeg] FFMPEG:  matched as AVOption 'srtp_out_suite' with argument 'AES_CM_128_HMAC_SHA1_80'.
Reading option '-srtp_out_params' ...
[7/10/2020, 11:49:48 AM] [Camera-ffmpeg] FFMPEG:  matched as AVOption 'srtp_out_params' with argument '0gJRFyJQUQBDDE8uDk/cPXyiLOgbNKGXJB7XRJ0w'.
Reading option 'srtp://192.168.0.107:54650?rtcpport=54650&localrtcpport=54650&pkt_size=1316' ... matched as output url.
[7/10/2020, 11:49:48 AM] [Camera-ffmpeg] FFMPEG: Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Finished splitting the commandline.
[7/10/2020, 11:49:48 AM] [Camera-ffmpeg] FFMPEG: Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
[7/10/2020, 11:49:48 AM] [Camera-ffmpeg] FFMPEG: Parsing a group of options: input url http://admin:anvil@192.168.0.43/video/mjpg.cgi.
Applying option re (read input at native frame rate) with argument 1.
Successfully parsed a group of options.
Opening an input file: http://admin:XXXXX@192.168.0.43/video/mjpg.cgi.
[7/10/2020, 11:49:48 AM] [Camera-ffmpeg] FFMPEG: [NULL @ 0000020f1d97ea80] Opening 'http://admin:XXXXX@192.168.0.43/video/mjpg.cgi' for reading
[http @ 0000020f1d9800c0] Setting default whitelist 'http,https,tls,rtp,tcp,udp,crypto,httpproxy,data'
[7/10/2020, 11:49:48 AM] [Camera-ffmpeg] FFMPEG: [tcp @ 0000020f1d981ac0] Original list of addresses:
[7/10/2020, 11:49:48 AM] [Camera-ffmpeg] FFMPEG: [tcp @ 0000020f1d981ac0] Address 192.168.0.43 port 80
[tcp @ 0000020f1d981ac0] Interleaved list of addresses:
[7/10/2020, 11:49:48 AM] [Camera-ffmpeg] FFMPEG: [tcp @ 0000020f1d981ac0] Address 192.168.0.43 port 80
[tcp @ 0000020f1d981ac0] Starting connection attempt to 192.168.0.43 port 80
[7/10/2020, 11:49:48 AM] [Camera-ffmpeg] FFMPEG: [tcp @ 0000020f1d981ac0] Successfully connected to 192.168.0.43 port 80
[7/10/2020, 11:49:48 AM] [Camera-ffmpeg] FFMPEG: [http @ 0000020f1d9800c0] request: GET /video/mjpg.cgi HTTP/1.1
User-Agent: Lavf/58.38.101
Accept: */*
Range: bytes=0-
Connection: close
Host: 192.168.0.43
Icy-MetaData: 1
[7/10/2020, 11:52:52 AM] [Camera-ffmpeg] FFMPEG: http://admin:XXXX@192.168.0.43/video/mjpg.cgi: End of file
[7/10/2020, 11:52:52 AM] [Camera-ffmpeg] [FFMPEG] ffmpeg exited with code: 1 and signal: null (error)
[7/10/2020, 11:52:52 AM] [Camera-ffmpeg] Stopped DCS-920 1 video stream!

homebridge-camera-ffmpeg v2.1.1

julien94800 commented 4 years ago

Hello, With same camera and config below from my side everything is ok. Audio is deactivated on my config. I do not know if it can help you

cameras": [ { "name": "Camera Home", "manufacturer": "D-Link", "model": "DCS-932L", "serialNumber": "28.xx.XX.xx.Xx.10", "firmwareRevision": "1.14", "motion": true, "switches": true, "videoConfig": { "source": "-re -f mjpeg -i http://XX:xxxxx@192.168.0.xx/mjpeg.cgi -i http://xxxxx:xxxxxx@192.168.0.xx/audio.cgi", "stillImageSource": "-f mjpeg -i http://xxxx:xxxxx@192.168.0.xx/mjpeg.cgi", "maxStreams": 2, "maxWidth": 640, "maxHeight": 480, "maxFPS": 30, "audio": false, "debug": false }

SkOODaT commented 4 years ago

ill try but i dont think its going to help, ty tho im trying his PR right now, i think its something with the video header not being recognized correctly thus exit codeing ffmpeg lol mines a 920 not a 932L

Sunoo commented 4 years ago

@SkOODaT Looks like FFmpeg thinks it's reached the end of your video file, so it closes. If you try to view the video URL you have configured in VLC, does it work for you?

Also, I see that @julien94800 has posted a different URL for that camera than either of the ones you mentioned. Have you tried the one they posted: http://XX:xxxxx@192.168.0.xx/mjpeg.cgi

SkOODaT commented 4 years ago

ive tried a bunch of URLs and i can get them all working in VLC or a browser but ffmpeg always "end of file" even on latest as of today 2.2.1

[7/11/2020, 1:39:25 PM] [Camera-ffmpeg] Starting DCS-920 2 video stream (640x480, 10 fps, 299 kbps, 1316 mtu)...debug enabled
[7/11/2020, 1:39:25 PM] [Camera-ffmpeg] FFMPEG command: ffmpeg -re -i http://admin:anvil@192.168.0.44/mjpeg.cgi -map 0:0 -vcodec libx264 -pix_fmt yuv420p -r 10 -f rawvideo -preset ultrafast -tune zerolatency -vf scale=640:480 -b:v 299k -bufsize 598k -maxrate 299k -payload_type 99 -ssrc 7933518 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params q/uyrxhDoPHNpt1x3nPY42YMAXXeNnK/A3xVAStX srtp://192.168.0.107:51592?rtcpport=51592&localrtcpport=51592&pkt_size=1316 -loglevel debug
[7/11/2020, 1:39:25 PM] [Camera-ffmpeg] FFMPEG: received first frame
[7/11/2020, 1:39:25 PM] [Camera-ffmpeg] FFMPEG: ffmpeg version N-96777-gebee808595-ffmpeg-windows-build-helpers
[7/11/2020, 1:39:25 PM] [Camera-ffmpeg] FFMPEG:  Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 8.3.0 (GCC)
  configuration: --pkg-config=pkg-config --pkg-config-flags=--static --extra-version=ffmpeg-windows-build-helpers --enable-version3 --disable-debug --disable-w32threads --arch=x86_64 --target-os=mingw32 --cross-prefix=/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/bin/x86_64-w64-mingw32- --enable-libcaca --enable-gray --enable-libtesseract --enable-fontconfig --enable-gmp --enable-gnutls --enable-libass --enable-libbluray --enable-libbs2b --enable-libflite --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libvorbis --enable-libwebp --enable-libzimg --enable-libzvbi --enable-libmysofa --enable-libopenjpeg --enable-libopenh264 --enable-liblensfun --enable-libvmaf --enable-libsrt --enable-demuxer=dash --enable-libxml2 --enable-opengl --enable-libdav1d --enable-libsvthevc --enable-libaom --enable-libvpx --enable-nvenc --enable-nvdec --extra-libs=-lharfbuzz --extra-libs=-lm --extra-libs=-lpthread --extra-cflags=-DLIBTWOLAME_STATIC --extra-cflags=-DMODPLUG_STATIC --extra-cflags=-DCACA_STATIC --enable-amf --enable-libmfx --enable-gpl --enable-avisynth --enable-frei0r --enable-filter=frei0r --enable-librubberband --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxvid --enable-libxavs --enable-avresample --extra-cflags='-mtune=generic' --extra-cflags=-O3 --enable-static --disable-shared --prefix=/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32 --enable-nonfree --enable-decklink --enable-libfdk-aac
  libavutil      56. 41.100 / 56. 41.100
  libavcodec     58. 70.100 / 58. 70.100
  libavformat    58. 38.101 / 58. 38.101
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 76.100 /  7. 76.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Splitting the commandline.
Reading option '-re' ... matched as option 're' (read input at native frame rate) with argument '1'.
Reading option '-i' ... matched as input url with argument 'http://admin:anvil@192.168.0.44/mjpeg.cgi'.
Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '0:0'.
Reading option '-vcodec' ... matched as option 'vcodec' (force video codec ('copy' to copy stream)) with argument 'libx264'.
Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel format) with argument 'yuv420p'.
Reading option '-r' ... matched as option 'r' (set frame rate (Hz value, fraction or abbreviation)) with argument '10'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'rawvideo'.
Reading option '-preset' ...
[7/11/2020, 1:39:25 PM] [Camera-ffmpeg] FFMPEG:  matched as AVOption 'preset' with argument 'ultrafast'.
Reading option '-tune' ...
[7/11/2020, 1:39:25 PM] [Camera-ffmpeg] FFMPEG:  matched as AVOption 'tune' with argument 'zerolatency'.
Reading option '-vf' ... matched as option 'vf' (set video filters) with argument 'scale=640:480'.
[7/11/2020, 1:39:25 PM] [Camera-ffmpeg] FFMPEG: Reading option '-b:v' ... matched as option 'b' (video bitrate (please use -b:v)) with argument '299k'.
Reading option '-bufsize' ...
[7/11/2020, 1:39:25 PM] [Camera-ffmpeg] FFMPEG:  matched as AVOption 'bufsize' with argument '598k'.
Reading option '-maxrate' ...
[7/11/2020, 1:39:25 PM] [Camera-ffmpeg] FFMPEG:  matched as AVOption 'maxrate' with argument '299k'.
Reading option '-payload_type' ...
[7/11/2020, 1:39:25 PM] [Camera-ffmpeg] FFMPEG:  matched as AVOption 'payload_type' with argument '99'.
Reading option '-ssrc' ...
[7/11/2020, 1:39:25 PM] [Camera-ffmpeg] FFMPEG:  matched as AVOption 'ssrc' with argument '7933518'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'rtp'.
Reading option '-srtp_out_suite' ...
[7/11/2020, 1:39:25 PM] [Camera-ffmpeg] FFMPEG:  matched as AVOption 'srtp_out_suite' with argument 'AES_CM_128_HMAC_SHA1_80'.
Reading option '-srtp_out_params' ...
[7/11/2020, 1:39:25 PM] [Camera-ffmpeg] FFMPEG:  matched as AVOption 'srtp_out_params' with argument 'q/uyrxhDoPHNpt1x3nPY42YMAXXeNnK/A3xVAStX'.
Reading option 'srtp://192.168.0.107:51592?rtcpport=51592&localrtcpport=51592&pkt_size=1316' ... matched as output url.
[7/11/2020, 1:39:25 PM] [Camera-ffmpeg] FFMPEG: Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input url http://admin:XXX@192.168.0.44/mjpeg.cgi.
Applying option re (read input at native frame rate) with argument 1.
Successfully parsed a group of options.
Opening an input file: http://admin:XXX@192.168.0.44/mjpeg.cgi.
[7/11/2020, 1:39:25 PM] [Camera-ffmpeg] FFMPEG: [NULL @ 000001ec6465f400] Opening 'http://admin:XXX@192.168.0.44/mjpeg.cgi' for reading
[http @ 000001ec6465fb00] Setting default whitelist 'http,https,tls,rtp,tcp,udp,crypto,httpproxy,data'
[7/11/2020, 1:39:25 PM] [Camera-ffmpeg] FFMPEG: [tcp @ 000001ec64661540] Original list of addresses:
[7/11/2020, 1:39:25 PM] [Camera-ffmpeg] FFMPEG: [tcp @ 000001ec64661540] Address 192.168.0.44 port 80
[tcp @ 000001ec64661540] Interleaved list of addresses:
[tcp @ 000001ec64661540]
[7/11/2020, 1:39:25 PM] [Camera-ffmpeg] FFMPEG:  Address 192.168.0.44 port 80
[tcp @ 000001ec64661540] Starting connection attempt to 192.168.0.44 port 80
[7/11/2020, 1:39:25 PM] [Camera-ffmpeg] FFMPEG: [tcp @ 000001ec64661540] Successfully connected to 192.168.0.44 port 80
[7/11/2020, 1:39:25 PM] [Camera-ffmpeg] FFMPEG: [http @ 000001ec6465fb00] request: GET /mjpeg.cgi HTTP/1.1
User-Agent: Lavf/58.38.101
Accept: */*
Range: bytes=0-
Connection: close
Host: 192.168.0.44
Icy-MetaData: 1
[7/11/2020, 1:39:26 PM] [Camera-ffmpeg] FFMPEG: http://admin:XXX@192.168.0.44/mjpeg.cgi: End of file
[7/11/2020, 1:39:26 PM] [Camera-ffmpeg] [FFMPEG] ffmpeg exited with code: 1 and signal: null (error)
[7/11/2020, 1:39:26 PM] [Camera-ffmpeg] Stopped DCS-920 2 video stream!
Sunoo commented 4 years ago

Interesting. This could be a tough one to resolve without access to the camera. I'm not sure why FFmpeg would be behaving like that if the video feed works correctly in VLC.

SkOODaT commented 4 years ago

i can dig for whatever information you may need from it etc..... i think its the mjpeg headers something in them ffmpeg doesn't like its like it receives the first frame but then just goes end of file no other frames, their really shitty dlink cams lol

Sunoo commented 4 years ago

It's very likely to be something like that, just odd that it would be working with other cameras in the same line. Why would D-Link bother to use two different codebases, one of which potentially spits out corrupt data?

SkOODaT commented 4 years ago

i think their dlinks first try at cameras lol

http://www.dlink.lt/en/products/1433/822.html

AdamDempsey commented 4 years ago

Not sure if it helps but I have a couple of D-Link 935s and the config below works for them

{
     "name": "DoorCam",
     "manufacturer": "D-Link",
     "model": "DCS-935LA1",
     "serialNumber": "S36I2FA000022",
     "firmwareRevision": "1.12.101",
     "motion": true,
     "videoConfig": {
          "source": "-re -i rtsp://user:**********@192.168.1.241:554/play1.sdp",
          "stillImageSource": "-i http://user:**********@192.168.1.241/cgi/jpg/image.cgi",
          "maxStreams": 2,
          "maxWidth": 1280,
          "maxHeight": 720,
          "vcodec": "h264_omx",
          "packetSize": 188,
          "maxFPS": 30
     }
}
SkOODaT commented 4 years ago

thier is no rtsp stream :(

Untitadadled

How do i go about getting full header information? above is what postman spits out

SkOODaT commented 4 years ago
import cv2
import requests
import numpy as np

r = requests.get('http://192.168.0.44/VIDEO.CGI', auth=('admin', 'XXX'), stream=True)
if(r.status_code == 200):
    bytes = bytes()

        for chunk in r.iter_content(chunk_size=1024):
        bytes += chunk
        #print(bytes)
        a = bytes.find(b'\xff\xd8')
        b = bytes.find(b'\xff\xd9')
        if a != -1 and b != -1:
            jpg = bytes[a:b+2]
            bytes = bytes[b+2:]
            i = cv2.imdecode(np.frombuffer(jpg, dtype=np.uint8), cv2.IMREAD_COLOR)
            contents = bytes.decode('ISO-8859-1')
            print(contents)
            cv2.imshow('i', i)
            if cv2.waitKey(1) == 27:
                exit(0)
else:
    print("Received unexpected status code {}".format(r.status_code))

this python code appears to work aswell, not sure if that helps tho ~

--video boundary--
Content-length: 42133
Content-type: image/jpeg

                        W !1AQa"2q#BRb3r$CS%&'(5678DEFGHTUVWXcdefghstuvwx             W !1A"Qa2q#B3R$Cb%4&'(5678DEFGHTUVWXcdefghstuvwx C 


 



$&##%&$$#$ C:  :{RFR{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ !    ? EdTR;P(PtBUm|F/WK)׃FU\}Kȵ
1?_      ͮb#P3ur;C6"2O&QzW

i think theirs garbage in header it doesn't understand trying to decode the bytes~

--video boundary--
Content-length: 36891
Content-type: image/jpeg

ÿØÿÄ                ÿÄ •   W !1AQa"2q‘#BRb¡±3rÁÑ$CS‚4’¢áñ%&'(5678DEFGHTUVWXcdefghstuvwxƒ„…†‡ˆ“”•–—˜£¤¥¦§¨²³´µ¶·¸ÂÃÄÅÆÇÈÒÓÔÕÖ×Øâãäåæçèòóôõö÷øÿÄ              ÿÄ •   W !1A"Qa2q#B3R‘¡±ðÁÑá$Cbñ%4Sr‚&'(5678DEFGHTUVWXcdefghstuvwxƒ„…†‡ˆ“”•–—˜¢£¤¥¦§¨²³´µ¶·¸ÂÃÄÅÆÇÈÒÓÔÕÖ×Øâãäåæçèòóôõö÷øÿÛ C 


 



$&##%&$$#$ÿÛ C:  :{RFR{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ÿÀ à€! ÿÚ   ? üzu’“*€u*Ô[j: tèE
LoWÔð¶WOâÔÆé/ùk@¤ë5Úð’¸Cÿ ¸oýÚµQ잍ð##Xd]‡p+ù¡ûká²xGøŽ¦Si”è~õëiìgsÌxwúÅ«ô
Üè塖q1š¥…v‘ÕôdƒÖa|i¦Ë$ª†Ú^úû«G‰x
W`\fñ҉‹[¸«<30ÔÄhÊÏBøVdÖâ¹L×]jG¬ðü7VÌ}‡Àü7Ñ«d'—ª¹V]5ÿ Q[ÃR?Ø¿(ÀÛ
M¹ŠþiáåÂûÒ­“¯ã×ä÷ÈW
ãǟqÿ ¨z?ë

@Sunoo not sure if any of that helps, what information do you need for me to gather? or can we setup a way to talk privately and ill give you temp access to the camera if needed, id love to fully use these things i have 2 lmao

SkOODaT commented 4 years ago

here i finally got a dump using curl curl -o stream http://admin:XXX@192.168.0.44/VIDEO.CGI

stream.txt

also tried ffmpeg again directly and got info on the image.jpg

Input #0, image2, from 'http://admin:XXX@192.168.0.44/image.jpg':
  Duration: 00:00:00.04, start: 0.000000, bitrate: 8284 kb/s
    Stream #0:0: Video: mjpeg (Baseline), yuvj422p(pc, bt470bg/unknown/unknown), 640x480, 25 tbr, 25 tbn, 25 tbc
Output #0, image2, to 'frame%d.jpg':
  Metadata:
    encoder         : Lavf58.47.100
    Stream #0:0: Video: mjpeg (Baseline), yuvj422p(pc, bt470bg/unknown/unknown), 640x480, q=2-31, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=    1 fps=0.0 q=-1.0 Lsize=N/A time=00:00:00.04 bitrate=N/A speed=  10x
video:40kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

could --video boundary--Content-length: 39619 being all on 1 line be the issue? it looks like the first bit of data is always like that arrrrg i wish i knew C stuff better id compile my own and debug

Sunoo commented 4 years ago

I was busy most of the afternoon, let me take some time to look into everything you sent to see if I can figure out what's going on.

SkOODaT commented 4 years ago

np, i figure an alternative is to use node or python... something and reformat/rehost the cam if absolutely needed ... ill give ya time to check things over tho :) thank you

Sunoo commented 4 years ago

Yea, if the mjpeg feed from the camera is actually malformed, that may be the best approach. I'll hopefully have some thoughts to share soon.

I have a working mjpeg-based camera here, so at least that is something I can compare your data against.

Sunoo commented 4 years ago

I did some poking around your saved stream and the stream from my working mjpeg camera, and the only real difference I could spot was Content Length being on the same line on line 1, but I'm really not sure that's the issue. I was also able to recover several jpeg frames from your file, and they all seemed to be good.

If I had access to the camera I could write something to sit between the camera and this plugin to see if I could rewrite that part (or maybe play with some others if that didn't work). But I'm kinda at a loss as to what next to try from here.

Sunoo commented 4 years ago

So I wrote the world's most basic proxy quickly in NodeJS for testing, and now I'm able to get your camera's feed running. Not sure why FFmpeg in particular is having trouble handling the feed. You should be able to use this as a base to get your stuff working.

I may eventually make a tweak to this plugin to prevent needing to use this, but I'd have to give how best to handle that some more thought.

proxy.js:

const http = require('http');
const https = require('https');

const server = http.createServer();
server.listen(6666);
server.on('request', (req, res) => {
    res.writeHead(200);
    https.get('https://USER:PASS@HOST/VIDEO.CGI', (feed) => {
        feed.on('data', (chunk) => {
            res.write(chunk);
        });

        feed.on('end', () => {
            res.end();
        });
    });
});

Homebridge config:

        {
            "cameras": [
                {
                    "name": "Test Cam",
                    "manufacturer": "D-Link",
                    "model": "DCS-920",
                    "videoConfig": {
                        "source": "-f mjpeg -i http://localhost:6666/VIDEO.CGI",
                        "stillImageSource": "-i https://USER:PASS@HOST/image.jpg",
                        "maxFPS": 30,
                        "audio": false,
                        "debug": true
                    }
                }
            ],
            "platform": "Camera-ffmpeg"
        }

Then as long as you have nodejs proxy.js running, your camera should work.

SkOODaT commented 4 years ago

awesome thank you so much, hopefully this might help others with similar issues in the future... hopefully you figure out a perm fix eventually :) ill give it a try now :)

SkOODaT commented 4 years ago

working perfect now :) thank you so much again

djpoohbizzle commented 1 year ago

Hey guys, I'm having the same issue with the dcs-920. Snapshots are fine but no live feed.. And drink no longer cares to show any support for this outdated product. Can anyone explain the script given in the previous posts of solutions. Unfortunately I am unfamiliar of what has been posted. Please and thank you