From 4dafc74223066afb816b072d5e8c2bcf2bd543eb Mon Sep 17 00:00:00 2001 From: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com> Date: Thu, 23 Mar 2023 15:27:29 +0100 Subject: [PATCH] fix(server): invalid video duration format (#2058) --- .../src/processors/metadata-extraction.processor.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/server/apps/microservices/src/processors/metadata-extraction.processor.ts b/server/apps/microservices/src/processors/metadata-extraction.processor.ts index afa8721b1e..095fc2206e 100644 --- a/server/apps/microservices/src/processors/metadata-extraction.processor.ts +++ b/server/apps/microservices/src/processors/metadata-extraction.processor.ts @@ -20,6 +20,7 @@ import { ExifDateTime, exiftool, Tags } from 'exiftool-vendored'; import ffmpeg, { FfprobeData } from 'fluent-ffmpeg'; import { getName } from 'i18n-iso-countries'; import geocoder, { InitOptions } from 'local-reverse-geocoder'; +import { Duration } from 'luxon'; import fs from 'node:fs'; import path from 'path'; import sharp from 'sharp'; @@ -386,10 +387,6 @@ export class MetadataExtractionProcessor { return null; } - const hours = Math.floor(videoDurationInSecond / 3600); - const minutes = Math.floor((videoDurationInSecond - hours * 3600) / 60); - const seconds = videoDurationInSecond - hours * 3600 - minutes * 60; - - return `${hours}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}.000000`; + return Duration.fromObject({ seconds: videoDurationInSecond }).toFormat('hh:mm:ss.SSS'); } }