use totalDuration instead of format.duration

This commit is contained in:
mertalev 2026-04-23 16:00:03 -04:00
parent c38215e0aa
commit c5fb4ac970
No known key found for this signature in database
GPG Key ID: 0603AE056AA39037
2 changed files with 3 additions and 15 deletions

View File

@ -310,16 +310,7 @@ export class MediaRepository {
* Needed for accurate segments, especially when remuxing, seeking and/or VFR is involved.
* Scanning packets for keyframes in JS is much faster than -skip_frame nokey since it avoids decoding the video.
*/
async probePackets(
input: string,
streamIndex: number,
timeBase: number,
formatDuration: number,
): Promise<VideoPacketInfo | null> {
if (formatDuration <= 0) {
return null;
}
async probePackets(input: string, streamIndex: number): Promise<VideoPacketInfo | null> {
const { stdout } = await execFile('ffprobe', [
'-v',
'error',
@ -369,7 +360,7 @@ export class MediaRepository {
return {
totalDuration,
packetCount: postDiscard.length,
outputFrames: this.cfrOutputFrames(postDiscard, postDiscard.length / formatDuration / timeBase),
outputFrames: this.cfrOutputFrames(postDiscard, postDiscard.length / totalDuration),
keyframePts,
keyframeAccDuration,
keyframeOwnDuration,

View File

@ -1080,10 +1080,7 @@ export class MetadataService extends BaseService {
const { videoStreams, audioStreams, format } = await this.mediaRepository.probe(originalPath);
const video = videoStreams[0];
const audio = audioStreams[0];
const packets =
video && video.timeBase
? await this.mediaRepository.probePackets(originalPath, video.index, video.timeBase, format.duration)
: null;
const packets = video?.timeBase ? await this.mediaRepository.probePackets(originalPath, video.index) : null;
const tags: Pick<ImmichTags, 'Duration' | 'Orientation' | 'ImageWidth' | 'ImageHeight'> = {};