mirror of
https://github.com/koush/scrypted.git
synced 2026-02-12 18:12:04 +00:00
rebroadcast/homekit: better h264 oddity handling
This commit is contained in:
4
plugins/homekit/package-lock.json
generated
4
plugins/homekit/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/homekit",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.4",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/homekit",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.4",
|
||||
"dependencies": {
|
||||
"@koush/qrcode-terminal": "^0.12.0",
|
||||
"@koush/werift-src": "file:../../external/werift",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scrypted/homekit",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.4",
|
||||
"description": "HomeKit Plugin for Scrypted",
|
||||
"scripts": {
|
||||
"prepublishOnly": "NODE_ENV=production scrypted-webpack",
|
||||
|
||||
@@ -192,17 +192,21 @@ export function createCameraStreamingDelegate(device: ScryptedDevice & VideoCame
|
||||
} = await getStreamingConfiguration(device, forceLowBandwidth, storage, request)
|
||||
|
||||
const isHomeHub = homekitPlugin.storageSettings.values.lastKnownHomeHub?.includes(session.prepareRequest.targetAddress);
|
||||
if (isHomeHub)
|
||||
console.log('Streaming request is coming from the active HomeHub. Will wait for initial RTCP packet.');
|
||||
const hasHomeHub = !!homekitPlugin.storageSettings.values.lastKnownHomeHub;
|
||||
if (!hasHomeHub)
|
||||
console.log('HomeHub currently unknown. Will wait for initial RTCP packet.');
|
||||
|
||||
const videoReturnRtcpReady = !isHomeHub && !isLowBandwidth && hasHomeHub
|
||||
? undefined
|
||||
: timeoutPromise(1000, once(session.videoReturn, 'message')).catch(() => {
|
||||
console.warn('Video RTCP Packet timed out. There may be a network (routing/firewall) issue preventing the Apple device sending UDP packets back to Scrypted.');
|
||||
const waitRtcp = isHomeHub || isLowBandwidth || !hasHomeHub;
|
||||
if (waitRtcp) {
|
||||
console.log('Will wait for initial RTCP packet.', {
|
||||
isHomeHub,
|
||||
isLowBandwidth,
|
||||
hasHomeHub,
|
||||
});
|
||||
}
|
||||
|
||||
const videoReturnRtcpReady = waitRtcp
|
||||
? timeoutPromise(1000, once(session.videoReturn, 'message')).catch(() => {
|
||||
console.warn('Video RTCP Packet timed out. There may be a network (routing/firewall) issue preventing the Apple device sending UDP packets back to Scrypted.');
|
||||
})
|
||||
: undefined;
|
||||
session.videoReturnRtcpReady = videoReturnRtcpReady;
|
||||
|
||||
console.log({
|
||||
|
||||
4
plugins/prebuffer-mixin/package-lock.json
generated
4
plugins/prebuffer-mixin/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/prebuffer-mixin",
|
||||
"version": "0.9.2",
|
||||
"version": "0.9.4",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/prebuffer-mixin",
|
||||
"version": "0.9.2",
|
||||
"version": "0.9.4",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@scrypted/common": "file:../../common",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scrypted/prebuffer-mixin",
|
||||
"version": "0.9.2",
|
||||
"version": "0.9.4",
|
||||
"description": "Video Stream Rebroadcast, Prebuffer, and Management Plugin for Scrypted.",
|
||||
"author": "Scrypted",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -699,16 +699,16 @@ class PrebufferSession {
|
||||
let { parser, isDefault } = this.getParser(rtspMode, sessionMso);
|
||||
this.usingScryptedParser = parser === SCRYPTED_PARSER_TCP || parser === SCRYPTED_PARSER_UDP;
|
||||
|
||||
// if (isDefault && this.usingScryptedParser && h264Oddities) {
|
||||
// if (sessionMso.tool === 'scrypted') {
|
||||
// this.console.warn('H264 oddities were detected in video stream, but stream is marked safe by Scrypted. The Default Scrypted RTSP Parser will be used. This can be overriden by setting the RTSP Parser to Scrypted.');
|
||||
// }
|
||||
// else {
|
||||
// this.console.warn('H264 oddities were detected in video stream, the Default Scrypted RTSP Parser will not be used. Falling back to FFmpeg. This can be overriden by setting the RTSP Parser to Scrypted.');
|
||||
// this.usingScryptedParser = false;
|
||||
// parser = FFMPEG_PARSER_TCP;
|
||||
// }
|
||||
// }
|
||||
// prefer ffmpeg if this is a prebuffered stream.
|
||||
if (isDefault
|
||||
&& this.usingScryptedParser
|
||||
&& h264Oddities
|
||||
&& !this.stopInactive
|
||||
&& sessionMso.tool === 'scrypted') {
|
||||
this.console.warn('H264 oddities were detected in prebuffered video stream, the Default Scrypted RTSP Parser will not be used. Falling back to FFmpeg. This can be overriden by setting the RTSP Parser to Scrypted.');
|
||||
this.usingScryptedParser = false;
|
||||
parser = FFMPEG_PARSER_TCP;
|
||||
}
|
||||
|
||||
if (this.usingScryptedParser) {
|
||||
session = await startRtspSession(this.console, ffmpegInput.url, ffmpegInput.mediaStreamOptions, {
|
||||
@@ -761,14 +761,14 @@ class PrebufferSession {
|
||||
return;
|
||||
}
|
||||
|
||||
// if (!this.inactivityTimeout) {
|
||||
// this.console.warn('Oddity in prebuffered stream. Restarting rebroadcast to use FFmpeg instead.');
|
||||
// session.kill(new Error('restarting due to H264 oddity detection'));
|
||||
// this.storage.setItem(this.lastH264ProbeKey, JSON.stringify(h264Probe));
|
||||
// removeOddityProbe();
|
||||
// this.startPrebufferSession();
|
||||
// return;
|
||||
// }
|
||||
if (!this.stopInactive) {
|
||||
this.console.warn('Oddity in prebuffered stream. Restarting rebroadcast to use FFmpeg instead.');
|
||||
session.kill(new Error('restarting due to H264 oddity detection'));
|
||||
this.storage.setItem(this.lastH264ProbeKey, JSON.stringify(h264Probe));
|
||||
removeOddityProbe();
|
||||
this.startPrebufferSession();
|
||||
return;
|
||||
}
|
||||
|
||||
// this.console.warn('Oddity in non prebuffered stream. Next restart will use FFmpeg instead.');
|
||||
}
|
||||
@@ -979,7 +979,8 @@ class PrebufferSession {
|
||||
// may be worth considering playing with a few other things to avoid this:
|
||||
// mpeg-ts as a container (would need to write a muxer)
|
||||
// specifying the buffer before the sync frame with probesize.
|
||||
if (container !== 'rtsp' || !options.findSyncFrame) {
|
||||
// If h264 oddities are detected, assume ffmpeg will be used.
|
||||
if (container !== 'rtsp' || !options.findSyncFrame || this.getLastH264Oddities()) {
|
||||
for (const chunk of prebufferContainer) {
|
||||
if (chunk.time < now - requestedPrebuffer)
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user