0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-02-11 01:18:24 -05:00

fix(server): encodes iPhone 16 Pro video with unknown audio codec (#13593)

* fix(server): encodes iPhone 16 Pro video with unknown audio codec

* remove white space

* pr feedback + unit test

* remove public method keyword

* test the service

* correcting unit test
This commit is contained in:
Alex 2024-10-19 00:50:08 -05:00 committed by GitHub
parent c9c0212ca9
commit 39b571a95c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 1 deletions

View file

@ -2292,6 +2292,22 @@ describe(MediaService.name, () => {
expect(mediaMock.probe).toHaveBeenCalledWith(assetStub.video.originalPath, { countFrames: false });
});
it('should process unknown audio stream', async () => {
mediaMock.probe.mockResolvedValue(probeStub.audioStreamUnknown);
assetMock.getByIds.mockResolvedValue([assetStub.video]);
await sut.handleVideoConversion({ id: assetStub.video.id });
expect(mediaMock.transcode).toHaveBeenCalledWith(
'/original/path.ext',
'upload/encoded-video/user-id/as/se/asset-id.mp4',
expect.objectContaining({
inputOptions: expect.any(Array),
outputOptions: expect.arrayContaining(['-c:a copy']),
twoPass: false,
}),
);
});
});
describe('isSRGB', () => {

View file

@ -349,7 +349,9 @@ export class MediaService extends BaseService {
}
private getMainStream<T extends VideoStreamInfo | AudioStreamInfo>(streams: T[]): T {
return streams.sort((stream1, stream2) => stream2.frameCount - stream1.frameCount)[0];
return streams
.filter((stream) => stream.codecName !== 'unknown')
.sort((stream1, stream2) => stream2.frameCount - stream1.frameCount)[0];
}
private getTranscodeTarget(

View file

@ -154,6 +154,13 @@ export const probeStub = {
...probeStubDefault,
audioStreams: [{ index: 1, codecName: 'aac', frameCount: 100 }],
}),
audioStreamUnknown: Object.freeze<VideoInfo>({
...probeStubDefault,
audioStreams: [
{ index: 0, codecName: 'aac', frameCount: 100 },
{ index: 1, codecName: 'unknown', frameCount: 200 },
],
}),
matroskaContainer: Object.freeze<VideoInfo>({
...probeStubDefault,
format: {