1
0
mirror of https://github.com/immich-app/immich.git synced 2025-07-17 15:47:54 +02:00

fix(server): select main stream according to bitrate (#18375)

* fix main stream

* update unit tests

---------

Co-authored-by: mertalev <101130780+mertalev@users.noreply.github.com>
This commit is contained in:
Daimolean
2025-05-20 05:33:28 +08:00
committed by GitHub
parent 00a77c2d6a
commit dc8962f2bc
5 changed files with 58 additions and 19 deletions

View File

@ -21,7 +21,7 @@ const probeStubDefaultVideoStream: VideoStreamInfo[] = [
},
];
const probeStubDefaultAudioStream: AudioStreamInfo[] = [{ index: 1, codecName: 'mp3', frameCount: 100 }];
const probeStubDefaultAudioStream: AudioStreamInfo[] = [{ index: 3, codecName: 'mp3', bitrate: 100 }];
const probeStubDefault: VideoInfo = {
format: probeStubDefaultFormat,
@ -40,23 +40,42 @@ export const probeStub = {
height: 1080,
width: 400,
codecName: 'hevc',
frameCount: 100,
frameCount: 1,
rotation: 0,
isHDR: false,
bitrate: 0,
bitrate: 100,
pixelFormat: 'yuv420p',
},
{
index: 1,
height: 1080,
width: 400,
codecName: 'h7000',
frameCount: 99,
codecName: 'hevc',
frameCount: 2,
rotation: 0,
isHDR: false,
bitrate: 0,
bitrate: 101,
pixelFormat: 'yuv420p',
},
{
index: 2,
height: 1080,
width: 400,
codecName: 'h7000',
frameCount: 3,
rotation: 0,
isHDR: false,
bitrate: 99,
pixelFormat: 'yuv420p',
},
],
}),
multipleAudioStreams: Object.freeze<VideoInfo>({
...probeStubDefault,
audioStreams: [
{ index: 0, codecName: 'mp3', bitrate: 100 },
{ index: 1, codecName: 'mp3', bitrate: 101 },
{ index: 2, codecName: 'mp3', bitrate: 102 },
],
}),
noHeight: Object.freeze<VideoInfo>({
@ -200,13 +219,13 @@ export const probeStub = {
}),
audioStreamAac: Object.freeze<VideoInfo>({
...probeStubDefault,
audioStreams: [{ index: 1, codecName: 'aac', frameCount: 100 }],
audioStreams: [{ index: 1, codecName: 'aac', bitrate: 100 }],
}),
audioStreamUnknown: Object.freeze<VideoInfo>({
...probeStubDefault,
audioStreams: [
{ index: 0, codecName: 'aac', frameCount: 100 },
{ index: 1, codecName: 'unknown', frameCount: 200 },
{ index: 0, codecName: 'aac', bitrate: 100 },
{ index: 1, codecName: 'unknown', bitrate: 200 },
],
}),
matroskaContainer: Object.freeze<VideoInfo>({