KhaosT / homebridge-camera-isight

iSight camera plugin for homebridge
52 stars 14 forks source link

plugin crashes homebridge #4

Closed jocamero closed 8 years ago

jocamero commented 8 years ago

As soon as I open the camera in the Home app it causes homebridge to crash with the following error:

[10/12/2016, 12:09:00 PM] Homebridge is running on port 51826. -re -f avfoundation -r 30 -i 0:0 -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 gGoQLRe1wY/rTaou+bKk5I5tCFMNnKfHMv46iqSF srtp://10.0.1.20:65082?rtcpport=65082&localrtcpport=65082&pkt_size=1378 events.js:141 throw er; // Unhandled 'error' event ^

Error: spawn ffmpeg ENOENT at exports._errnoException (util.js:907:11) at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32) at onErrorNT (internal/child_process.js:344:16) at nextTickCallbackWith2Args (node.js:442:9) at process._tickCallback (node.js:356:17)

KhaosT commented 8 years ago

1. Install ffmpeg on your Mac

ENOENT means there is no ffmpeg installed on your Mac.

jocamero commented 8 years ago

Thanks for the quick response!

I just installed it using:

brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-frei0r --with-libass --with-libvo-aacenc --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools

I'm seeing a static image of my camera in the home app, then homebridge crashes. Do I need to restart or initialize ffmpeg?

KhaosT commented 8 years ago

Are you sure you installed ffmpeg into a path that system is looking for binaries? try to run ffmpeg in terminal and see what it returns.

jocamero commented 8 years ago

ffmpeg version 3.1.4 Copyright (c) 2000-2016 the FFmpeg developers built with Apple LLVM version 8.0.0 (clang-800.0.38) configuration: --prefix=/usr/local/Cellar/ffmpeg/3.1.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-libfreetype --enable-libtheora --enable-libvorbis --enable-libvpx --enable-librtmp --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libass --enable-libspeex --enable-libschroedinger --enable-libfdk-aac --enable-libopus --enable-frei0r --disable-lzma --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/2.1.2/include/openjpeg-2.1 --enable-nonfree --enable-vda libavutil 55. 28.100 / 55. 28.100 libavcodec 57. 48.101 / 57. 48.101 libavformat 57. 41.100 / 57. 41.100 libavdevice 57. 0.101 / 57. 0.101 libavfilter 6. 47.100 / 6. 47.100 libavresample 3. 0. 0 / 3. 0. 0 libswscale 4. 1.100 / 4. 1.100 libswresample 2. 1.100 / 2. 1.100 libpostproc 54. 0.100 / 54. 0.100 Hyper fast Audio and Video encoder usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'

KhaosT commented 8 years ago

And if you run which ffmpeg, what's the location it shows?

jocamero commented 8 years ago

/usr/local/bin/ffmpeg

KhaosT commented 8 years ago

The location is right. If you run homebridge now, does it still crash when trying to start streaming?

jocamero commented 8 years ago

Doesn't appear to crash, now I just get a black window for the video stream.

homebridge log:

-re -f avfoundation -r 30 -i 0:0 -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 t08yjsFQ1y1bBD+MFgCHBepOCp7nJqiknsN23sGy srtp://10.0.1.20:63967?rtcpport=63967&localrtcpport=63967&pkt_size=1378

As a sidenote, now there are several new accessories related to iTunes. Other than this plugin, I only have the Nest plugin installed.

KhaosT commented 8 years ago

If you run ffmpeg -re -f avfoundation -r 30 -i "0:0" -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 t08yjsFQ1y1bBD+MFgCHBepOCp7nJqiknsN23sGy "srtp://10.0.1.20:63967?rtcpport=63967&localrtcpport=63967&pkt_size=1378" in terminal, what do you see?

jocamero commented 8 years ago
 libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 48.101 / 57. 48.101
  libavformat    57. 41.100 / 57. 41.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 47.100 /  6. 47.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
[avfoundation @ 0x7f98d1802c00] Selected pixel format (yuv420p) is not supported by the input device.
[avfoundation @ 0x7f98d1802c00] Supported pixel formats:
[avfoundation @ 0x7f98d1802c00]   uyvy422
[avfoundation @ 0x7f98d1802c00]   yuyv422
[avfoundation @ 0x7f98d1802c00]   nv12
[avfoundation @ 0x7f98d1802c00]   0rgb
[avfoundation @ 0x7f98d1802c00]   bgr0
[avfoundation @ 0x7f98d1802c00] Overriding selected pixel format to use uyvy422 instead.
Input #0, avfoundation, from '0:0':
  Duration: N/A, start: 71498.974800, bitrate: N/A
    Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 320x240, 29.97 tbr, 1000k tbn, 1000k tbc
    Stream #0:1: Audio: pcm_f32le, 96000 Hz, stereo, flt, 6144 kb/s
[libx264 @ 0x7f98d5805800] VBV maxrate unspecified, assuming CBR
[libx264 @ 0x7f98d5805800] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x7f98d5805800] profile High, level 3.1
[rtp @ 0x7f98d5805200] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Output #0, rtp, to 'srtp://10.0.1.20:63967?rtcpport=63967&localrtcpport=63967&pkt_size=1378':
  Metadata:
    encoder         : Lavf57.41.100
    Stream #0:0: Video: h264 (libx264), yuv420p, 1280x720, q=-1--1, 299 kb/s, 30 fps, 90k tbn, 30 tbc
    Metadata:
      encoder         : Lavc57.48.101 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/299000 buffer size: 299000 vbv_delay: -1
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
SDP:
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 10.0.1.20
t=0 0
a=tool:libavformat 57.41.100
m=video 63967 RTP/AVP 99
b=AS:299
a=rtpmap:99 H264/90000
a=fmtp:99 packetization-mode=1
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:t08yjsFQ1y1bBD+MFgCHBepOCp7nJqiknsN23sGy

Press [q] to stop, [?] for help
frame=   17 fps=0.0 q=43.0 size=      17kB time=00:00:00.53 bitrate= 261.7kbits/frame=   22 fps= 22 q=44.0 size=      22kB time=00:00:00.70 bitrate= 252.3kbits/frame=   23 fps= 15 q=44.0 size=      23kB time=00:00:00.73 bitrate= 254.3kbits/frame=   24 fps= 12 q=44.0 size=      24kB time=00:00:00.76 bitrate= 254.5kbits/frame=   24 fps=9.5 q=44.0 size=      24kB time=00:00:00.76 bitrate= 254.5kbits/frame=   25 fps=8.2 q=43.0 size=      25kB time=00:00:00.80 bitrate= 254.9kbits/frame=   26 fps=7.3 q=43.0 size=      26kB time=00:00:00.83 bitrate= 252.3kbits/frame=   27 fps=6.7 q=43.0 size=      27kB time=00:00:00.86 bitrate= 251.2kbits
KhaosT commented 8 years ago

It should work then. When you start stream on iOS side, what does Home app show? Error?

jocamero commented 8 years ago

Rebuilt homebridge odd iTunes accessories are gone but still getting a black screen. The main page in the Home app shows a static accurate preview, but when opening the live view I see the request in the homebridge log, but nothing appears, just a black screen with a spinning wheel. No errors.

KhaosT commented 8 years ago

I don't know then. Based on the log it should work. You can try to get logs from iOS device and see if mediaserverd is complaining anything but other than that I can't think anything else to fix.

jocamero commented 8 years ago

No worries, thanks for your help!