fix: add audio stream#21
Conversation
|
Thank you for your contribution, can you please fix the PR removing the code that changed the version of the package to 0.2.2 |
Thank you, removed. |
Code ReviewThe Good
Problems1. Half the diff is a whitespace reformat — do not merge this. Every 2. // device-utils.ts
ScryptedInterface.Intercom, // Added to all devicesNot every Eufy camera has a microphone or supports talkback. There is zero capability check here. Scrypted will show a "Talk" button on every camera including sensors and solo cameras that will just fail when pressed. 3. const profile = 2; // AAC-LC
const freqIndex = 8; // 16000 Hz — hardcoded
const channels = 1; // mono — hardcodedThis assumes every Eufy camera streams 16 kHz mono AAC-LC. The metadata received in the audio event is ignored entirely when wrapping. If any camera uses 8 kHz (freqIndex 11) or 44.1 kHz (freqIndex 4), you'll produce a broken ADTS header and the muxer will silently ingest garbage audio. 4. remove = this.wsClient.addEventListener(
eventType as any,
(() => { ... }) as any, // two casts on one call
...
);If the event type system can't handle this without 5. private muxerStreams = new Map<
net.Socket,
{ muxer: any; duplex: Duplex } // `any` on a central data structure
>();JMuxer ships with TypeScript definitions. Use them. 6. /**
* @deprecated Audio is now muxed in-process via JMuxer. The dedicated
* audio TCP server was removed. Kept for API compatibility; always
* returns undefined.
*/
getAudioPort(): number | undefined {
return undefined;
}This method was added to the 7. The 8. No tests for any of the intercom code.
9. Emojis in log messages. this.logger.info(`🔊 Captured audio metadata: ...`);
this.logger.info(`🔀 Muxed client attached ...`);The rest of the codebase doesn't use emojis in log messages. Pick a style and stick to it. 10. If JMuxer doesn't have a 11. const status = await this.api.isLivestreaming();
if (!status.livestreaming) { ... }If this throws (network error, device offline), the exception propagates with no cleanup. At minimum wrap it in a try/catch or let it propagate with a clear error message. SummaryThe core idea is sound and the implementation is mostly correct where it matters (event ordering, fallback path, livestream lifecycle). But this PR isn't ready: the whitespace reformat must be stripped out, the hardcoded audio assumptions need to use the actual metadata, the unconditional |
thank you for the feedback. I hope I got all of the comments |
|
@acerbetti |
|
100% agree, just added a script
|
I've vibe coded a solution for adding audio. Main pain was some weirdness found with AAC format comming from either my camera or eufy-security-ws so we have to mux it
to matroska to make it work.I checked the code and the logic as far as my knowledge goes and I tried it with my Eufy camera(https://www.eufy.com/gr-en/products/t8400?variant=39620917592216) which seems to be working as expected.
Talkback I couldn't make it to work and I don't know if it's related to my camera, code issue or eufy-security-ws or eufy-security-client.Any sugesstions are welcome
EDIT: Talkback works with the latests changes too
EDIT 2: added JMuxer to improve performance as it was dropping some frames