From efafa02f6820a31df5dded620cf0f6ef30454e0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=93=E3=81=8B=E3=82=8A?= <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sun, 31 Mar 2024 12:43:39 +0900 Subject: [PATCH] =?UTF-8?q?enhance(backend):=20=E3=83=93=E3=83=87=E3=82=AA?= =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=81=AB=E3=83=93=E3=83=87?= =?UTF-8?q?=E3=82=AA=E3=83=88=E3=83=A9=E3=83=83=E3=82=AF=E3=81=8C=E3=81=82?= =?UTF-8?q?=E3=82=8B=E3=81=8B=E3=82=92=E7=A2=BA=E8=AA=8D=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=20(#13568)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * enhance(backend): ビデオファイルにビデオトラックがあるかを確認するように (cherry picked from commit 23d38a2d6492a2b24e9b2c031d66c3e8a5d382ef) * Update Changelog * Update Changelog * Revert "Update Changelog" This reverts commit 93fd996932b87ef550c38b48bd0678060f3ed1af. * fix(test) ffmpegをインストールするように * 入れる方間違えた * fix test * 拡張子変わらなかったのでそのまま行く * ログを出力するように * msg * remove unused import * add log * attempt to fix test error * Revert "attempt to fix test error" This reverts commit d9d6524cadd655e6d8e9398b26fdfef332f30f4d. * Update FileInfoService.ts * oggも検査の対象にする --- .github/workflows/test-backend.yml | 2 + CHANGELOG.md | 1 + packages/backend/src/core/FileInfoService.ts | 49 +++++++++++++++++- .../backend/test/resources/kick_gaba7.m4a | Bin 0 -> 9817 bytes packages/backend/test/unit/FileInfoService.ts | 27 ++++++++-- 5 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 packages/backend/test/resources/kick_gaba7.m4a diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml index 49a6a39805..a803db4508 100644 --- a/.github/workflows/test-backend.yml +++ b/.github/workflows/test-backend.yml @@ -45,6 +45,8 @@ jobs: with: version: 8 run_install: false + - name: Install FFmpeg + uses: FedericoCarboni/setup-ffmpeg@v3 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4.0.2 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index 390639bd69..f6b9cf0939 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ (Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/440) - Fix: エンドポイント`notes/translate`のエラーを改善 - Fix: CleanRemoteFilesProcessorService report progress from 100% (#13632) +- Fix: 一部の音声ファイルが映像ファイルとして扱われる問題を修正 ## 2024.3.1 diff --git a/packages/backend/src/core/FileInfoService.ts b/packages/backend/src/core/FileInfoService.ts index b8babcb3a7..169285f033 100644 --- a/packages/backend/src/core/FileInfoService.ts +++ b/packages/backend/src/core/FileInfoService.ts @@ -14,11 +14,12 @@ import FFmpeg from 'fluent-ffmpeg'; import isSvg from 'is-svg'; import probeImageSize from 'probe-image-size'; import { type predictionType } from 'nsfwjs'; -import sharp from 'sharp'; 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'; export type FileInfo = { @@ -49,9 +50,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'); } /** @@ -317,6 +322,34 @@ export class FileInfoService { return mime; } + /** + * ビデオファイルにビデオトラックがあるかどうかチェック + * (ない場合:m4a, webmなど) + * + * @param path ファイルパス + * @returns ビデオトラックがあるかどうか(エラー発生時は常に`true`を返す) + */ + @bindThis + private hasVideoTrackOnVideoFile(path: string): Promise { + const sublogger = this.logger.createSubLogger('ffprobe'); + sublogger.info(`Checking the video file. File path: ${path}`); + return new Promise((resolve) => { + try { + FFmpeg.ffprobe(path, (err, metadata) => { + if (err) { + sublogger.warn(`Could not check the video file. Returns true. File path: ${path}`, err); + resolve(true); + return; + } + resolve(metadata.streams.some((stream) => stream.codec_type === 'video')); + }); + } catch (err) { + sublogger.warn(`Could not check the video file. Returns true. File path: ${path}`, err as Error); + resolve(true); + } + }); + } + /** * Detect MIME Type and extension */ @@ -339,6 +372,20 @@ export class FileInfoService { return TYPE_SVG; } + if ((type.mime.startsWith('video') || type.mime === 'application/ogg') && !(await this.hasVideoTrackOnVideoFile(path))) { + const newMime = `audio/${type.mime.split('/')[1]}`; + if (newMime === 'audio/mp4') { + return { + mime: 'audio/mp4', + ext: 'm4a', + }; + } + return { + mime: newMime, + ext: type.ext, + }; + } + return { mime: this.fixMime(type.mime), ext: type.ext, diff --git a/packages/backend/test/resources/kick_gaba7.m4a b/packages/backend/test/resources/kick_gaba7.m4a new file mode 100644 index 0000000000000000000000000000000000000000..321df6349f016358b24b7bac2df8273ec5c448e5 GIT binary patch literal 9817 zcmeHtWmFtZ^Y1Pm+?`}`C%6P#+}%A3i@SS(1%d<%0fGj1cPF?8cTJGsK?5WNxyvK> z{onW8ulL)nGry_o?wYFVuAZ4beHs7&P+EETy4boqI|2X*fF}+Ix1$R$7XSc2vvRYv z1ORB(9ib2pYCIVLp*m3Z@f_Xo|I@!CU~&K>Z1{gf9n>uGj{wx?$EQ9nIjK-y+*pKd zY{U0)O676m&q&e1P4bF2Vw=CwtyyEz;*|Tkdu|`bwtiy+m&shW1n*x$jy%1be*aiF zyvs!>2{i^wJPcL&4IQ8Xq){|cC6IDLLI;RncYzd9n7$IPc`xbMzwfYQkYh zT#o_p=4;!Zc-G)FY!xMj#ET&LpuR_()Z=*lKM{N4zz4N0?=Tx-_gORm6kQXUY6-i$ zNo4zH_CwI-IbQy!?51!%@AWh?3sbZPmMs%sTF1w$k#V0sYEI&{ zkMY)iOi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SV6Bp`b>&7EKgdLVmD5j%r%NV*08ER9}5i)gb#gzA-}n%P^5g9Gg?i)*t+Ixb0G zbNlh-GCV~urO}fgkSM3L8aneM6$dW9<57DQXXbBszHszI72CplFHJ3Ih}B0;!p zq|28+F1~ZRU-V*5g?{26Up4v`KfU|ifsU5uC671}@i`jWpS6HjmC4chcVf@Qda1hs z07QL9XJ;>Xgbt2gHc&VRY!RbUKLOsh4?h(10ssU&UH_r~qX4h|uQK>Qn*TQm0d5oK z;RdmXHyV4`|K$_$KR*Ap2KW0P0{-RVzx@2G`L7!IU*T^~X9@Lihl`Y!4(=ZRG{G$Z z&*0~J{)riQ>j<@lz}rBM(Esjxg){(Q60Fnz*OTlvPzSevYyjMyJ)QoQpSTvh43&pC zK^-igbby79woX=X0oUE}Z=+92aH50$T~7&hvwUiQqNgrldb&A){+5BZ?jGh2aM{}3 z!~L&h{9O;wgP%xx3iOGdp81;)0Ju-WQ>bv_v2=$%br^sc92`soS3`nxLNL)&6#~%e z3GiQ2Faka<3Y-Dqc>sXiJ^mV_zf|Bi5&!_{Nrt-s2E#ceJPeDc3OGHveFEt}+yma` z2bcdPcs&sA9(WA*#s=qOaP-0v3r9K}d2qlFSpi{ic*6l70^n;n;NAU8HimOkI1J!` zz+nxC9USnv38aKOd72M|?j9D-|2TY#1?~qx?r!Y@eJZ#)JHTzhPjSH?czlH4Dc#Mj zUEuuRmj4;OxhK>E?ge1zX!#d^QltK#S%%LHH;9YNlg0l{?6!YTCHhhi=ch2J;K#zA Vj64|zC_}ug_yjq)IN=xP{{mAaTcH2| literal 0 HcmV?d00001 diff --git a/packages/backend/test/unit/FileInfoService.ts b/packages/backend/test/unit/FileInfoService.ts index 2eec80d763..40d187f5a8 100644 --- a/packages/backend/test/unit/FileInfoService.ts +++ b/packages/backend/test/unit/FileInfoService.ts @@ -15,6 +15,7 @@ import { GlobalModule } from '@/GlobalModule.js'; import { FileInfoService } from '@/core/FileInfoService.js'; //import { DI } from '@/di-symbols.js'; import { AiService } from '@/core/AiService.js'; +import { LoggerService } from '@/core/LoggerService.js'; import type { TestingModule } from '@nestjs/testing'; import type { MockFunctionMetadata } from 'jest-mock'; @@ -35,6 +36,7 @@ describe('FileInfoService', () => { ], providers: [ AiService, + LoggerService, FileInfoService, ], }) @@ -323,8 +325,26 @@ describe('FileInfoService', () => { }); }); - /* - * video/webmとして検出されてしまう + test('MPEG-4 AUDIO (M4A)', async () => { + const path = `${resources}/kick_gaba7.m4a`; + const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as any; + delete info.warnings; + delete info.blurhash; + delete info.sensitive; + delete info.porn; + delete info.width; + delete info.height; + delete info.orientation; + assert.deepStrictEqual(info, { + size: 9817, + md5: '74c9279a4abe98789565f1dc1a541a42', + type: { + mime: 'audio/mp4', + ext: 'm4a', + }, + }); + }); + test('WEBM AUDIO', async () => { const path = `${resources}/kick_gaba7.webm`; const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as any; @@ -337,13 +357,12 @@ describe('FileInfoService', () => { delete info.orientation; assert.deepStrictEqual(info, { size: 8879, - md5: '3350083dec312419cfdc06c16413aca7', + md5: '53bc1adcb6acbbda67ff9bd484896438', type: { mime: 'audio/webm', ext: 'webm', }, }); }); - */ }); });