mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-09 16:53:47 +02:00
Merge branch 'main' into hls
This commit is contained in:
@@ -99,6 +99,8 @@ type ElementaryStream = {
|
||||
colorSpace: VideoColorSpaceInit;
|
||||
width: number;
|
||||
height: number;
|
||||
squarePixelWidth: number;
|
||||
squarePixelHeight: number;
|
||||
reorderSize: number;
|
||||
} | {
|
||||
type: 'audio';
|
||||
@@ -328,6 +330,8 @@ export class MpegTsDemuxer extends Demuxer {
|
||||
},
|
||||
width: -1,
|
||||
height: -1,
|
||||
squarePixelWidth: -1,
|
||||
squarePixelHeight: -1,
|
||||
reorderSize: -1,
|
||||
};
|
||||
}; break;
|
||||
@@ -447,8 +451,8 @@ export class MpegTsDemuxer extends Demuxer {
|
||||
if (elementaryStream.info.type === 'video') {
|
||||
// We loop because in some files, the video parameters are not in the first packet
|
||||
while (true) {
|
||||
const contextAlias = context;
|
||||
contextAlias.suppliedPacket = null; // TyyyyypeScript 😩
|
||||
const contextAlias = context; // TyyyyypeScript 😩
|
||||
contextAlias.suppliedPacket = null;
|
||||
await context.markNextPacket();
|
||||
|
||||
if (elementaryStream.info.codec === 'avc') {
|
||||
@@ -472,6 +476,20 @@ export class MpegTsDemuxer extends Demuxer {
|
||||
|
||||
elementaryStream.info.width = spsInfo.displayWidth;
|
||||
elementaryStream.info.height = spsInfo.displayHeight;
|
||||
if (spsInfo.pixelAspectRatio.num > spsInfo.pixelAspectRatio.den) {
|
||||
elementaryStream.info.squarePixelWidth = Math.round(
|
||||
elementaryStream.info.width
|
||||
* spsInfo.pixelAspectRatio.num / spsInfo.pixelAspectRatio.den,
|
||||
);
|
||||
elementaryStream.info.squarePixelHeight = elementaryStream.info.height;
|
||||
} else {
|
||||
elementaryStream.info.squarePixelWidth = elementaryStream.info.width;
|
||||
elementaryStream.info.squarePixelHeight = Math.round(
|
||||
elementaryStream.info.height
|
||||
* spsInfo.pixelAspectRatio.den / spsInfo.pixelAspectRatio.num,
|
||||
);
|
||||
}
|
||||
|
||||
elementaryStream.info.colorSpace = {
|
||||
primaries:
|
||||
COLOR_PRIMARIES_MAP_INVERSE[spsInfo.colourPrimaries] as
|
||||
@@ -511,6 +529,20 @@ export class MpegTsDemuxer extends Demuxer {
|
||||
|
||||
elementaryStream.info.width = spsInfo.displayWidth;
|
||||
elementaryStream.info.height = spsInfo.displayHeight;
|
||||
if (spsInfo.pixelAspectRatio.num > spsInfo.pixelAspectRatio.den) {
|
||||
elementaryStream.info.squarePixelWidth = Math.round(
|
||||
elementaryStream.info.width
|
||||
* spsInfo.pixelAspectRatio.num / spsInfo.pixelAspectRatio.den,
|
||||
);
|
||||
elementaryStream.info.squarePixelHeight = elementaryStream.info.height;
|
||||
} else {
|
||||
elementaryStream.info.squarePixelWidth = elementaryStream.info.width;
|
||||
elementaryStream.info.squarePixelHeight = Math.round(
|
||||
elementaryStream.info.height
|
||||
* spsInfo.pixelAspectRatio.den / spsInfo.pixelAspectRatio.num,
|
||||
);
|
||||
}
|
||||
|
||||
elementaryStream.info.colorSpace = {
|
||||
primaries:
|
||||
COLOR_PRIMARIES_MAP_INVERSE[spsInfo.colourPrimaries] as
|
||||
@@ -546,6 +578,8 @@ export class MpegTsDemuxer extends Demuxer {
|
||||
}),
|
||||
codedWidth: elementaryStream.info.width,
|
||||
codedHeight: elementaryStream.info.height,
|
||||
displayAspectWidth: elementaryStream.info.squarePixelWidth,
|
||||
displayAspectHeight: elementaryStream.info.squarePixelHeight,
|
||||
colorSpace: elementaryStream.info.colorSpace,
|
||||
};
|
||||
elementaryStream.initialized = true;
|
||||
@@ -1598,6 +1632,14 @@ class MpegTsVideoTrackBacking extends MpegTsTrackBacking implements InputVideoTr
|
||||
return this.elementaryStream.info.height;
|
||||
}
|
||||
|
||||
getSquarePixelWidth() {
|
||||
return this.elementaryStream.info.squarePixelWidth;
|
||||
}
|
||||
|
||||
getSquarePixelHeight() {
|
||||
return this.elementaryStream.info.squarePixelHeight;
|
||||
}
|
||||
|
||||
getRotation(): Rotation {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user