ログを出力するように
This commit is contained in:
parent
29ac5e3c0f
commit
c49e3cb648
|
@ -19,7 +19,10 @@ import { sharpBmp } from '@misskey-dev/sharp-read-bmp';
|
||||||
import { encode } from 'blurhash';
|
import { encode } from 'blurhash';
|
||||||
import { createTempDir } from '@/misc/create-temp.js';
|
import { createTempDir } from '@/misc/create-temp.js';
|
||||||
import { AiService } from '@/core/AiService.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 { bindThis } from '@/decorators.js';
|
||||||
|
import { sub } from 'date-fns';
|
||||||
|
|
||||||
export type FileInfo = {
|
export type FileInfo = {
|
||||||
size: number;
|
size: number;
|
||||||
|
@ -49,9 +52,13 @@ const TYPE_SVG = {
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class FileInfoService {
|
export class FileInfoService {
|
||||||
|
private logger: Logger;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private aiService: AiService,
|
private aiService: AiService,
|
||||||
|
private loggerService: LoggerService,
|
||||||
) {
|
) {
|
||||||
|
this.logger = this.loggerService.getLogger('file-info');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -320,19 +327,25 @@ export class FileInfoService {
|
||||||
/**
|
/**
|
||||||
* ビデオファイルにビデオトラックがあるかどうかチェック
|
* ビデオファイルにビデオトラックがあるかどうかチェック
|
||||||
* (ない場合:m4a, webmなど)
|
* (ない場合:m4a, webmなど)
|
||||||
|
*
|
||||||
|
* @param path ファイルパス
|
||||||
|
* @returns ビデオトラックがあるかどうか(エラー発生時は常に`true`を返す)
|
||||||
*/
|
*/
|
||||||
@bindThis
|
@bindThis
|
||||||
private hasVideoTrackOnVideoFile(path: string): Promise<boolean> {
|
private hasVideoTrackOnVideoFile(path: string): Promise<boolean> {
|
||||||
return new Promise((resolve, reject) => {
|
const sublogger = this.logger.createSubLogger('ffprobe');
|
||||||
|
return new Promise((resolve) => {
|
||||||
try {
|
try {
|
||||||
FFmpeg.ffprobe(path, (err, metadata) => {
|
FFmpeg.ffprobe(path, (err, metadata) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
sublogger.warn(`Could not determine video file. Returns true. File path: ${path}`, err);
|
||||||
resolve(true);
|
resolve(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
resolve(metadata.streams.some((stream) => stream.codec_type === 'video'));
|
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);
|
resolve(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue