mirror of
https://github.com/immich-app/immich.git
synced 2026-04-30 21:10:40 -04:00
earlier duration check
This commit is contained in:
parent
1b414b341c
commit
164f0aa331
@ -315,7 +315,11 @@ export class MediaRepository {
|
||||
streamIndex: number,
|
||||
timeBase: number,
|
||||
formatDuration: number,
|
||||
): Promise<VideoPacketInfo> {
|
||||
): Promise<VideoPacketInfo | null> {
|
||||
if (formatDuration <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { stdout } = await execFile('ffprobe', [
|
||||
'-v',
|
||||
'error',
|
||||
@ -356,18 +360,20 @@ export class MediaRepository {
|
||||
}
|
||||
}
|
||||
|
||||
if (packetCount === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
postDiscard.sort((a, b) => a.pts - b.pts);
|
||||
const firstPts = postDiscard[0].pts;
|
||||
const slotsPerTick = packetCount / formatDuration / timeBase;
|
||||
let outputFrames = 0;
|
||||
if (packetCount > 0 && formatDuration > 0) {
|
||||
postDiscard.sort((a, b) => a.pts - b.pts);
|
||||
const firstPts = postDiscard[0].pts;
|
||||
const slotsPerTick = packetCount / formatDuration / timeBase;
|
||||
let nextPts = 0;
|
||||
for (const pkt of postDiscard) {
|
||||
const delta = (pkt.pts - firstPts) * slotsPerTick - nextPts + pkt.duration * slotsPerTick;
|
||||
const nb = delta < -1.1 ? 0 : delta > 1.1 ? Math.round(delta) : 1;
|
||||
outputFrames += nb;
|
||||
nextPts += nb;
|
||||
}
|
||||
let nextPts = 0;
|
||||
for (const pkt of postDiscard) {
|
||||
const delta = (pkt.pts - firstPts) * slotsPerTick - nextPts + pkt.duration * slotsPerTick;
|
||||
const nb = delta < -1.1 ? 0 : delta > 1.1 ? Math.round(delta) : 1;
|
||||
outputFrames += nb;
|
||||
nextPts += nb;
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@ -1086,7 +1086,7 @@ export class MetadataService extends BaseService {
|
||||
const packets =
|
||||
video && video.timeBase
|
||||
? await this.mediaRepository.probePackets(originalPath, video.index, video.timeBase, format.duration)
|
||||
: undefined;
|
||||
: null;
|
||||
|
||||
const tags: Pick<ImmichTags, 'Duration' | 'Orientation' | 'ImageWidth' | 'ImageHeight'> = {};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user