fix: ffmpeg path for video.ts

This commit is contained in:
linyuchen 2024-04-20 08:21:48 +08:00
parent b2831c0a19
commit a5e34645c5

View File

@ -16,8 +16,7 @@ export async function getVideoInfo(filePath: string) {
size: number, size: number,
filePath: string filePath: string
}>((resolve, reject) => { }>((resolve, reject) => {
// todo: 从配置文件中读取ffmpeg路径 const ffmpegPath = process.env.FFMPEG_PATH;
const ffmpegPath = './ffmpeg';
ffmpegPath && ffmpeg.setFfmpegPath(ffmpegPath); ffmpegPath && ffmpeg.setFfmpegPath(ffmpegPath);
ffmpeg(filePath).ffprobe((err: any, metadata: any) => { ffmpeg(filePath).ffprobe((err: any, metadata: any) => {
if (err) { if (err) {
@ -27,7 +26,7 @@ export async function getVideoInfo(filePath: string) {
if (videoStream) { if (videoStream) {
console.log(`视频尺寸: ${videoStream.width}x${videoStream.height}`); console.log(`视频尺寸: ${videoStream.width}x${videoStream.height}`);
} else { } else {
console.log('未找到视频流信息。'); return reject('未找到视频流信息。');
} }
resolve({ resolve({
width: videoStream.width, height: videoStream.height, width: videoStream.width, height: videoStream.height,
@ -85,4 +84,4 @@ export function checkFfmpeg(newPath: string | null = null): Promise<boolean> {
resolve(false); resolve(false);
} }
}); });
} }