webrtc: fixup h265 keyframe hunting

This commit is contained in:
Koushik Dutta
2025-03-21 23:51:24 -07:00
parent 1fa5f66b44
commit 1a33384115
5 changed files with 13 additions and 16 deletions

View File

@@ -96,6 +96,8 @@ export const H265_NAL_TYPE_PPS = 34;
export const H265_NAL_TYPE_IDR_N = 19;
export const H265_NAL_TYPE_IDR_W = 20;
export const H265_NAL_TYPE_FU = 49;
export const H265_NAL_TYPE_SEI_PREFIX = 39;
export const H265_NAL_TYPE_SEI_SUFFIX = 40;
export function findH264NaluType(streamChunk: StreamChunk, naluType: number) {
if (streamChunk.type !== 'h264')

View File

@@ -383,17 +383,9 @@ export function getSpsPpsVps(
const pps = parameters['sprop-pps'];
const vps = parameters['sprop-vps'];
if (!sps || !pps || !vps) {
return {
sps: undefined,
pps: undefined,
vps: undefined,
};
}
return {
vps: Buffer.from(vps, 'base64'),
sps: Buffer.from(sps, 'base64'),
pps: Buffer.from(pps, 'base64'),
sps: sps ? Buffer.from(sps, 'base64') : undefined,
pps: pps ? Buffer.from(pps, 'base64') : undefined,
vps: vps ? Buffer.from(vps, 'base64') : undefined,
}
}

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/webrtc",
"version": "0.2.66",
"version": "0.2.67",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/webrtc",
"version": "0.2.66",
"version": "0.2.67",
"dependencies": {
"@scrypted/common": "file:../../common",
"@scrypted/sdk": "file:../../sdk",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/webrtc",
"version": "0.2.66",
"version": "0.2.67",
"scripts": {
"scrypted-setup-project": "scrypted-setup-project",
"prescrypted-setup-project": "scrypted-package-json",

View File

@@ -430,10 +430,13 @@ export class H265Repacketizer {
return;
}
if (!this.codecInfo?.vps || !this.codecInfo?.sps || !this.codecInfo?.pps)
// vps is not required.
if (!this.codecInfo?.sps || !this.codecInfo?.pps)
return;
const agg = [this.codecInfo.vps, this.codecInfo.sps, this.codecInfo.pps];
const agg = [this.codecInfo.sps, this.codecInfo.pps];
if (this.codecInfo.vps)
agg.unshift(this.codecInfo.vps);
if (this.codecInfo?.sei)
agg.push(this.codecInfo.sei);