Skip to content

Commit

Permalink
Adding vcodec and description
Browse files Browse the repository at this point in the history
  • Loading branch information
kopiro committed Oct 3, 2024
1 parent b841674 commit 1cc987b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 13 deletions.
44 changes: 33 additions & 11 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,37 +136,59 @@
"videoMaxWidth": {
"title": "Video Max Width",
"type": "integer",
"description": "Maximum width of the video stream",
"placeholder": 1280
"placeholder": 1280,
"multipleOf": 2,
"minimum": 0,
"description": "The maximum width used for video streamed to HomeKit. If set to 0, the resolution of the source is used. If not set, will use any size HomeKit requests."
},
"videoMaxHeight": {
"title": "Video Max Height",
"type": "integer",
"description": "Maximum height of the video stream",
"placeholder": 720
"placeholder": 720,
"multipleOf": 2,
"minimum": 0,
"description": "The maximum height used for video streamed to HomeKit. If set to 0, the resolution of the source is used. If not set, will use any size HomeKit requests."
},
"videoMaxFPS": {
"title": "Video Max FPS",
"type": "integer",
"description": "Maximum frames per second of the video stream",
"placeholder": 30
"placeholder": 30,
"minimum": 0,
"description": "The maximum frame rate used for video streamed to HomeKit. If set to 0, the framerate of the source is used. If not set, will use any framerate HomeKit requests."
},
"videoMaxBitrate": {
"title": "Video Max Bitrate",
"type": "integer",
"description": "Maximum bitrate of the video stream",
"placeholder": 300
"placeholder": 299,
"minimum": 0,
"description": "The maximum bitrate used for video streamed to HomeKit, in kbit/s. If not set, will use any bitrate HomeKit requests."
},
"videoPacketSize": {
"title": "Video Packet Size",
"type": "integer",
"description": "Size of the video packets",
"placeholder": 1316
"placeholder": 1316,
"multipleOf": 188,
"minimum": 188,
"description": "If audio or video is choppy try a smaller value."
},
"videoForceMax": {
"title": "Force Max Video",
"type": "boolean",
"description": "Force the video stream to use the maximum values, instead of the one provided by the Homekit request. Most likely you don't want this"
"description": "If set, the settings requested by HomeKit will be overridden with any 'maximum' values defined in this config."
},
"videoCodec": {
"title": "Video Codec",
"type": "string",
"placeholder": "libx264",
"typeahead": {
"source": [
"libx264",
"h264_omx",
"h264_videotoolbox",
"copy"
]
},
"description": "Set the codec used for encoding video sent to HomeKit, must be H.264-based. You can change to a hardware accelerated video codec with this option, if one is available. *By default, we set 'copy' to avoid any video processing happening on the Homebridge server, but this also means possibly sending more bits to your device than necessary. Also, consider that setting 'copy' will discard all of the following options: videoMaxWidth, videoMaxHeight, videoMaxFPS, videoMaxBirate and videoPacketSize*"
}
}
}
Expand Down
12 changes: 10 additions & 2 deletions src/cameraAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type CameraConfig = {
videoForceMax?: boolean;
videoMaxBirate?: number;
videoPacketSize?: number;
videoCodec?: string;

videoConfig?: VideoConfig;

Expand Down Expand Up @@ -170,11 +171,18 @@ export class CameraAccessory {
Boolean(this.config.lowQuality)
);

const vcodec = this.config.videoCodec ?? "copy";

if (vcodec === "copy") {
this.log.warn(
"You're using the default 'copy' codec. This means that any maximum resolution, FPS, or bitrate you set will be ignored, and you're pushing the camera's native stream directly to HomeKit. This can cause issues if the camera's native stream is not compatible with HomeKit. If you're experiencing issues, try setting a custom codec."
);
}

const config: VideoConfig = {
source: `-i ${streamUrl}`,
audio: true,
videoFilter: "none",
vcodec: "copy",
vcodec: vcodec,
maxWidth: this.config.videoMaxWidth,
maxHeight: this.config.videoMaxHeight,
maxFPS: this.config.videoMaxFPS,
Expand Down

0 comments on commit 1cc987b

Please sign in to comment.