mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-12-24 00:40:05 +08:00
fix: ffmpeg
This commit is contained in:
parent
dad7245a3a
commit
fc37288827
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
@ -38,6 +38,12 @@ jobs:
|
|||||||
- name: Build NapCat.Shell
|
- name: Build NapCat.Shell
|
||||||
run: |
|
run: |
|
||||||
npm i && cd napcat.webui && npm i && cd .. || exit 1
|
npm i && cd napcat.webui && npm i && cd .. || exit 1
|
||||||
|
curl -sSL https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2025-04-16-12-54/ffmpeg-n7.1.1-6-g48c0f071d4-win64-lgpl-7.1.zip -o ffmpeg.zip
|
||||||
|
unzip -q ffmpeg.zip -d ffmpeg && rm ffmpeg.zip
|
||||||
|
cd ffmpeg
|
||||||
|
mv ffmpeg.exe ../external/ffmpeg/ffmpeg.exe
|
||||||
|
mv ffprobe.exe ../external/ffmpeg/ffprobe.exe
|
||||||
|
cd ..
|
||||||
npm run build:shell && npm run depend || exit 1
|
npm run build:shell && npm run depend || exit 1
|
||||||
rm package-lock.json
|
rm package-lock.json
|
||||||
- name: Upload Artifact
|
- name: Upload Artifact
|
||||||
|
|||||||
@ -1,14 +1,28 @@
|
|||||||
import { readFileSync, statSync, existsSync, mkdirSync } from 'fs';
|
import { readFileSync, statSync, existsSync, mkdirSync } from 'fs';
|
||||||
import { dirname } from 'path';
|
import path, { dirname } from 'path';
|
||||||
import { execFile } from 'child_process';
|
import { execFile } from 'child_process';
|
||||||
import { promisify } from 'util';
|
import { promisify } from 'util';
|
||||||
import type { VideoInfo } from './video';
|
import type { VideoInfo } from './video';
|
||||||
import { fileTypeFromFile } from 'file-type';
|
import { fileTypeFromFile } from 'file-type';
|
||||||
import imageSize from 'image-size';
|
import imageSize from 'image-size';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
const currentPath = dirname(fileURLToPath(import.meta.url));
|
||||||
const execFileAsync = promisify(execFile);
|
const execFileAsync = promisify(execFile);
|
||||||
const FFMPEG_CMD = process.platform === 'win32' ? 'ffmpeg.exe' : 'ffmpeg';
|
const getFFmpegPath = (tool: string): string => {
|
||||||
const FFPROBE_CMD = process.platform === 'win32' ? 'ffprobe.exe' : 'ffprobe';
|
const exeName = `${tool}.exe`;
|
||||||
|
const isLocalExeExists = existsSync(path.join(currentPath, 'ffmpeg', exeName));
|
||||||
|
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
return isLocalExeExists ? path.join(currentPath, 'ffmpeg', exeName) : exeName;
|
||||||
|
}
|
||||||
|
return tool;
|
||||||
|
};
|
||||||
|
|
||||||
|
const FFMPEG_CMD = getFFmpegPath('ffmpeg');
|
||||||
|
const FFPROBE_CMD = getFFmpegPath('ffprobe');
|
||||||
|
|
||||||
|
console.log('[Info] ffmpeg:', FFMPEG_CMD);
|
||||||
|
console.log('[Info] ffprobe:', FFPROBE_CMD);
|
||||||
export class FFmpegService {
|
export class FFmpegService {
|
||||||
// 确保目标目录存在
|
// 确保目标目录存在
|
||||||
private static ensureDirExists(filePath: string): void {
|
private static ensureDirExists(filePath: string): void {
|
||||||
|
|||||||
@ -23,6 +23,7 @@ if (process.env.NAPCAT_BUILDSYS == 'linux') {
|
|||||||
const UniversalBaseConfigPlugin: PluginOption[] = [
|
const UniversalBaseConfigPlugin: PluginOption[] = [
|
||||||
cp({
|
cp({
|
||||||
targets: [
|
targets: [
|
||||||
|
{ src: './external/ffmpeg/', dest: 'dist/ffmpeg', flatten: true },
|
||||||
{ src: './manifest.json', dest: 'dist' },
|
{ src: './manifest.json', dest: 'dist' },
|
||||||
{ src: './src/core/external/napcat.json', dest: 'dist/config/' },
|
{ src: './src/core/external/napcat.json', dest: 'dist/config/' },
|
||||||
{ src: './src/native/packet', dest: 'dist/moehoo', flatten: false },
|
{ src: './src/native/packet', dest: 'dist/moehoo', flatten: false },
|
||||||
@ -46,6 +47,7 @@ const UniversalBaseConfigPlugin: PluginOption[] = [
|
|||||||
const FrameworkBaseConfigPlugin: PluginOption[] = [
|
const FrameworkBaseConfigPlugin: PluginOption[] = [
|
||||||
cp({
|
cp({
|
||||||
targets: [
|
targets: [
|
||||||
|
{ src: './external/ffmpeg/', dest: 'dist/ffmpeg', flatten: true },
|
||||||
{ src: './manifest.json', dest: 'dist' },
|
{ src: './manifest.json', dest: 'dist' },
|
||||||
{ src: './src/core/external/napcat.json', dest: 'dist/config/' },
|
{ src: './src/core/external/napcat.json', dest: 'dist/config/' },
|
||||||
{ src: './src/native/packet', dest: 'dist/moehoo', flatten: false },
|
{ src: './src/native/packet', dest: 'dist/moehoo', flatten: false },
|
||||||
@ -65,6 +67,7 @@ const FrameworkBaseConfigPlugin: PluginOption[] = [
|
|||||||
const ShellBaseConfigPlugin: PluginOption[] = [
|
const ShellBaseConfigPlugin: PluginOption[] = [
|
||||||
cp({
|
cp({
|
||||||
targets: [
|
targets: [
|
||||||
|
{ src: './external/ffmpeg/', dest: 'dist/ffmpeg', flatten: true },
|
||||||
{ src: './src/native/packet', dest: 'dist/moehoo', flatten: false },
|
{ src: './src/native/packet', dest: 'dist/moehoo', flatten: false },
|
||||||
{ src: './src/native/pty', dest: 'dist/pty', flatten: false },
|
{ src: './src/native/pty', dest: 'dist/pty', flatten: false },
|
||||||
{ src: './napcat.webui/dist/', dest: 'dist/static/', flatten: false },
|
{ src: './napcat.webui/dist/', dest: 'dist/static/', flatten: false },
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user