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:
parent
c9c0212ca9
commit
39b571a95c
3 changed files with 26 additions and 1 deletions
|
@ -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', () => {
|
||||
|
|
|
@ -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(
|
||||
|
|
7
server/test/fixtures/media.stub.ts
vendored
7
server/test/fixtures/media.stub.ts
vendored
|
@ -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: {
|
||||
|
|
Loading…
Add table
Reference in a new issue