mirror of
https://github.com/immich-app/immich.git
synced 2025-05-31 04:05:39 -04: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
@ -2292,6 +2292,22 @@ describe(MediaService.name, () => {
|
|||||||
|
|
||||||
expect(mediaMock.probe).toHaveBeenCalledWith(assetStub.video.originalPath, { countFrames: false });
|
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', () => {
|
describe('isSRGB', () => {
|
||||||
|
@ -349,7 +349,9 @@ export class MediaService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getMainStream<T extends VideoStreamInfo | AudioStreamInfo>(streams: T[]): T {
|
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(
|
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,
|
...probeStubDefault,
|
||||||
audioStreams: [{ index: 1, codecName: 'aac', frameCount: 100 }],
|
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>({
|
matroskaContainer: Object.freeze<VideoInfo>({
|
||||||
...probeStubDefault,
|
...probeStubDefault,
|
||||||
format: {
|
format: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user