dgreif / ring

Unofficial packages for Ring Doorbells, Cameras, Alarm System, and Smart Lighting
MIT License
1.17k stars 155 forks source link

Trouble recording video to file or live streaming on an M1 Mac Mini #1389

Closed skykosiner closed 5 months ago

skykosiner commented 5 months ago

Streaming Issue

Hiya, I've been trying to get my cameras to record to a file on motion, and no matter what I try I keep on running into errors. But the odd thing is if I run the exact same code on Linux but just change where my server is mounted it runs fine. I'm going to amuse it's some sort of M1 issue. I do have roseate installed so I'm not too sure what could be causing it.

if (noti.action === PushNotificationAction.Motion) {
  console.log("motion deceted on", camera.name);
    try {
      const filePath = path.join("/Volumes/Files/ring/cameras", `camera-${Date.now()}.mp4`);
      await camera.recordToFile(filePath, 10);
    } catch (err) {
       console.error(err);
    }
}

the console.log is runing so it's finding when there is motion, but then it just errors on the record to file section.

Proposed Solution

Make sure that the ffmpeg process's run correctly on arm chips.

Environment

Other (ring-client-api)

What operating system are you on?

Mac

Relevant log output

Error: spawn Unknown system error -8
    at ChildProcess.spawn (node:internal/child_process:421:11)
    at spawn (node:child_process:761:9)
    at new FfmpegProcess (/Users/skykosiner/personal/ring-save-cameras/node_modules/@homebridge/camera-utils/lib/ffmpeg-process.js:14:45)
    at StreamingSession.startTranscoding (/Users/skykosiner/personal/ring-save-cameras/node_modules/ring-client-api/lib/streaming/streaming-session.js:88:67)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async RingCamera.streamVideo (/Users/skykosiner/personal/ring-save-cameras/node_modules/ring-client-api/lib/ring-camera.js:408:9)
    at async RingCamera.recordToFile (/Users/skykosiner/personal/ring-save-cameras/node_modules/ring-client-api/lib/ring-camera.js:401:26) {
  errno: -8,
  code: 'Unknown system error -8',
  syscall: 'spawn'
}

Honesty Time

tsightler commented 5 months ago

You didn't provide your macOS version, but note that ring-client-api doesn't provide it's own ffmpeg, but rather depends on the ffmpeg-for-homebridge package which has full support for Apple Silicon, however, recent builds support only macOS 13.0 (Ventura) and newer, so if you happen to be on an earlier build of macOS that is the most likely issue.

Also, you can just test if the ffmpeg binary will run from the command line and it's totally possible to just provide your own OS version of ffmpeg by leveraging the ffmpegPath parameter to tell ring-client-api what ffmpeg binary to use.

tsightler commented 5 months ago

BTW, I believe that -8 error is ENOEXEC, which normally indicates that the binary is not for the platform. As Apple Silicon is fully supported, you need to make sure that you are running all the correct versions for your arch. Perhaps simply remove the dependencies and re-install and then make sure that the ffmpeg binary is the same arch as your node binaries.

skykosiner commented 5 months ago

Seems I just needed to point ffmpeg to a different path to where it was looking. Thank you for the help!