From c49e3cb648e2bd9e2bb73c2fa3f0b87dd055b23b Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Mon, 18 Mar 2024 13:39:43 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=82=92=E5=87=BA=E5=8A=9B?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/src/core/FileInfoService.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/core/FileInfoService.ts b/packages/backend/src/core/FileInfoService.ts index ab828e5014..fe5e39ac79 100644 --- a/packages/backend/src/core/FileInfoService.ts +++ b/packages/backend/src/core/FileInfoService.ts @@ -19,7 +19,10 @@ import { sharpBmp } from '@misskey-dev/sharp-read-bmp'; import { encode } from 'blurhash'; import { createTempDir } from '@/misc/create-temp.js'; import { AiService } from '@/core/AiService.js'; +import { LoggerService } from '@/core/LoggerService.js'; +import type Logger from '@/logger.js'; import { bindThis } from '@/decorators.js'; +import { sub } from 'date-fns'; export type FileInfo = { size: number; @@ -49,9 +52,13 @@ const TYPE_SVG = { @Injectable() export class FileInfoService { + private logger: Logger; + constructor( private aiService: AiService, + private loggerService: LoggerService, ) { + this.logger = this.loggerService.getLogger('file-info'); } /** @@ -320,19 +327,25 @@ export class FileInfoService { /** * ビデオファイルにビデオトラックがあるかどうかチェック * (ない場合:m4a, webmなど) + * + * @param path ファイルパス + * @returns ビデオトラックがあるかどうか(エラー発生時は常に`true`を返す) */ @bindThis private hasVideoTrackOnVideoFile(path: string): Promise { - return new Promise((resolve, reject) => { + const sublogger = this.logger.createSubLogger('ffprobe'); + return new Promise((resolve) => { try { FFmpeg.ffprobe(path, (err, metadata) => { if (err) { + sublogger.warn(`Could not determine video file. Returns true. File path: ${path}`, err); resolve(true); return; } resolve(metadata.streams.some((stream) => stream.codec_type === 'video')); }); - } catch (e) { + } catch (err) { + sublogger.warn(`Could not determine video file. Returns true. File path: ${path}`, err as Error); resolve(true); } });