45clouds / homebridge-ip-camera

IP camera plugin for homebridge
50 stars 7 forks source link

Not able to work with RTSP stream from WansView camera #14

Open mkloock opened 7 years ago

mkloock commented 7 years ago

Hello,

So far, I enjoyed the plugin and I have already gotten one camera (camera A) working which streams MJPEG over http. This camera is a motionpie setup on a raspberry. The quality in the Home app is medium, not great.

So I went and added another commercial WansView 1080p camera which streams as RTSP. I was hoping that this might product better quality.

My Homebridge is running in a Debian 9 (Stretch) installation. ffmpeg is installed (and working with the MJPEG camera).

Unfortunately, I am not able to stream from rtsp. The ffmpeg connection gets initiated like this, similar to the MJPEG connection over http.

-re -i rtsp://192.168.1.21:554/live/ch1 -threads 0 -vcodec libx264 -an -pix_fmt yuv420p -r 30 -f rawvideo -tune zerolatency -vf scale=1280:720 -b:v 299k -bufsize 299k -payload_type 99 -ssrc 1 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params qnD98F94ccl0+w35ZmNnrBEvCIRHDZHDHondaudl srtp://192.168.1.17:65372?rtcpport=65372&localrtcpport=65372&pkt_size=1378

Unfortunately, no video stream is never received.

I verified with several apps (VLC and LiveCams Pro) to retrieve the video stream with the same URL and it works (authentication is off so that is not the issue).

running ffmpeg -re -i rtsp://192.168.1.21:554/live/ch1 test.mp4 yields the following:

[rtsp @ 0x55bb4c670d00] UDP timeout, retrying with TCP
[rtsp @ 0x55bb4c670d00] Could not find codec parameters for stream 0 (Video: h264, none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, rtsp, from 'rtsp://192.168.1.21:554/live/ch1':
  Metadata:
    title           : hysxrtpsion
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: h264, none, 90k tbr, 90k tbn, 180k tbc
    Stream #0:1: Audio: aac, 16000 Hz, mono, fltp
    Stream #0:2: Data: none
Output #0, mp4, to 'test.mp4':
  Metadata:
    title           : hysxrtpsion
    encoder         : Lavf57.56.101
    Stream #0:0: Audio: aac (LC) ([64][0][0][0] / 0x0040), 16000 Hz, mono, fltp, 69 kb/s
    Metadata:
      encoder         : Lavc57.64.101 aac
Stream mapping:
  Stream #0:1 -> #0:0 (aac (native) -> aac (native))
Press [q] to stop, [?] for help

Thanks for any suggestions or help!

Martin

45clouds commented 7 years ago

Martin,

Please recheck ffmpeg flags during when you compile program from source. ffmget has to understand the stream that is coming from camera. My setup is:

ffmpeg version 3.3.4 Copyright (c) 2000-2017 the FFmpeg developers built with gcc 6.3.0 (Debian 6.3.0-18) 20170516 configuration: --disable-decoder=amrnb --disable-decoder=libopenjpeg --disable-mips32r2 --disable-mips32r6 --disable-mips64r6 --disable-mipsdsp --disable-mipsdspr2 --disable-mipsfpu --disable-msa --disable-libopencv --disable-podpages --disable-stripping --enable-avfilter --enable-avresample --enable-gcrypt --enable-gnutls --enable-gpl --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libilbc --enable-libkvazaar --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx265 --enable-libxvid --enable-libzvbi --enable-nonfree --enable-opengl --enable-openssl --enable-postproc --enable-pthreads --enable-shared --enable-version3 --incdir=/usr/include/arm-linux-gnueabihf --libdir=/usr/lib/arm-linux-gnueabihf --prefix=/usr --toolchain=hardened --enable-frei0r --enable-chromaprint ---enable-libx264 --enable-libiec61883 --enable-libdc1394 --disable-altivec --shlibdir=/usr/lib/arm-linux-gnueabihf

Very important flags are: --enable-libopenh264 --enable-libx264

mkloock commented 7 years ago

Thank you. I was hoping to avoid a compile, especially since ffmpeg seems to work fine with my jpeg camera. But I might have to... will take me a while to figure out.

If you know of any step by step guide for ffmpeg, that would be great.

I used this compiled version that has omg enabled: https://www.npmjs.com/package/homebridge-camera-ffmpeg-omx sudo wget goo.gl/gMGA81 -O ffmpeg.deb sudo dpkg -i ffmpeg.deb

Cheers, Martin

45clouds commented 7 years ago

Hi Martin,

If you are working with Debian please try to use:

deb http://www.deb-multimedia.org stretch main non-free

as additional repo (watch instruction on their page to add proper repo). First uninstall existing ffmpeg package. Then issue apt-get update && apt-get install ffmpeg. Their version works on my RPI.

mkloock commented 7 years ago

thank you for your responses! Yes - I had moved to Debian from Raspberry Pi but had the same problem there.

So in general, you think the issue is with ffmpeg? If so, I will do my digging there - not an expert in ffmpeg but maybe this is the time to become one…

Cheers, Martin

On Oct 23, 2017, at 7:53 AM, 45clouds notifications@github.com wrote:

Hi Martin,

If you are working with Debian please try to use:

deb http://www.deb-multimedia.org http://www.deb-multimedia.org/ stretch main non-free

as additional repo (watch instruction on their page to add proper repo). First uninstall existing ffmpeg package. Then issue apt-get update && apt-get install ffmpeg. Their version works on my RPI.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/45clouds/homebridge-ip-camera/issues/14#issuecomment-338685570, or mute the thread https://github.com/notifications/unsubscribe-auth/ADBqZKhhTloEKksUvUYPHBgNdG1vorPRks5svKh8gaJpZM4P__pj.

45clouds commented 7 years ago

Yes. I'm almost sure that is has something with ffmpeg (not an expert too). I run this setup on RPI, Synology DS416, pure Debian on PC, on OSX and didn't have any problems with homebridge and configuration. The only important part is correct ffmpeg.