Skip to content

Commit

Permalink
Fix lint checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasdotcom committed Nov 14, 2024
1 parent a2c9561 commit 1f61be6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
20 changes: 20 additions & 0 deletions server/src/services/media.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,26 @@ describe(MediaService.name, () => {
}),
);
});
it('should not skip intra frames for MTS file', async () => {
mediaMock.probe.mockResolvedValue(probeStub.videoStreamMTS);
assetMock.getById.mockResolvedValue(assetStub.video);
await sut.handleGenerateThumbnails({ id: assetStub.video.id });
expect(mediaMock.transcode).toHaveBeenCalledWith(
'/original/path.ext',
'upload/thumbs/user-id/as/se/asset-id-preview.jpeg',
expect.objectContaining({
inputOptions: ['-sws_flags accurate_rnd+full_chroma_int'],
outputOptions: [
'-fps_mode vfr',
'-frames:v 1',
'-update 1',
'-v verbose',
String.raw`-vf fps=12:eof_action=pass:round=down,thumbnail=12,select=gt(scene\,0.1)-eq(prev_selected_n\,n)+isnan(prev_selected_n)+gt(n\,20),trim=end_frame=2,reverse,scale=-2:1440:flags=lanczos+accurate_rnd+full_chroma_int:out_range=pc`,
],
twoPass: false,
}),
);
});

it('should use scaling divisible by 2 even when using quick sync', async () => {
mediaMock.probe.mockResolvedValue(probeStub.videoStream2160p);
Expand Down
10 changes: 4 additions & 6 deletions server/src/utils/media.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SystemConfigFFmpegDto } from 'src/dtos/system-config.dto';
import { CQMode, ToneMapping, TranscodeHWAccel, TranscodeTarget, VideoCodec, VideoContainer } from 'src/enum';
import { CQMode, ToneMapping, TranscodeHWAccel, TranscodeTarget, VideoCodec } from 'src/enum';
import {
AudioStreamInfo,
BitrateDistribution,
Expand Down Expand Up @@ -384,11 +384,9 @@ export class ThumbnailConfig extends BaseConfig {
}

getBaseInputOptions(videoStream: VideoStreamInfo, format?: VideoFormat): string[] {
if (format?.formatName === 'mpegts') {
return ['-sws_flags accurate_rnd+full_chroma_int'];
} else {
return ['-skip_frame nointra', '-sws_flags accurate_rnd+full_chroma_int'];
}
return format?.formatName === 'mpegts'
? ['-sws_flags accurate_rnd+full_chroma_int']
: ['-skip_frame nointra', '-sws_flags accurate_rnd+full_chroma_int'];
}

getBaseOutputOptions() {
Expand Down
7 changes: 7 additions & 0 deletions server/test/fixtures/media.stub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ export const probeStub = {
...probeStubDefault,
videoStreams: [{ ...probeStubDefaultVideoStream[0], bitrate: 40_000_000 }],
}),
videoStreamMTS: Object.freeze<VideoInfo>({
...probeStubDefault,
format: {
...probeStubDefaultFormat,
formatName: 'mpegts',
},
}),
videoStreamHDR: Object.freeze<VideoInfo>({
...probeStubDefault,
videoStreams: [
Expand Down

0 comments on commit 1f61be6

Please sign in to comment.