Skip to content

Commit 04ad345

Browse files
committed
feat: vite build error
1 parent 6f8b09d commit 04ad345

File tree

2 files changed

+3
-58
lines changed

2 files changed

+3
-58
lines changed

src/lib/ffmpeg.ts

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -599,61 +599,3 @@ export async function ffmpegConcatVideos(videos: string[]): Promise<string> {
599599
});
600600
return output;
601601
}
602-
603-
export const ffmpegVideoNormal = async (input: string, option: {
604-
widthMax?: number;
605-
heightMax?: number;
606-
fps?: number;
607-
durationMax?: number;
608-
}): Promise<string> => {
609-
option = Object.assign({
610-
widthMax: 1920,
611-
heightMax: 1920,
612-
fps: 25,
613-
durationMax: -1,
614-
});
615-
const ext = await $mapi.file.ext(input);
616-
const output = await $mapi.file.temp(ext);
617-
const {width, height, duration, fps} = await ffprobeVideoInfo(input);
618-
let scaleFilter = "";
619-
let targetWidth = width;
620-
let targetHeight = height;
621-
let targetFps = fps;
622-
if (option.widthMax && width > option.widthMax) {
623-
targetWidth = option.widthMax;
624-
targetHeight = Math.round((option.widthMax / width) * height);
625-
}
626-
if (option.heightMax && targetHeight > option.heightMax) {
627-
targetHeight = option.heightMax;
628-
targetWidth = Math.round((option.heightMax / height) * targetWidth);
629-
}
630-
if (targetWidth !== width || targetHeight !== height) {
631-
scaleFilter = `scale=${targetWidth}:${targetHeight}`;
632-
}
633-
if (option.fps && fps > option.fps) {
634-
targetFps = option.fps;
635-
scaleFilter += (scaleFilter ? "," : "") + `fps=${targetFps}`;
636-
}
637-
if (option.durationMax && option.durationMax > 0 && duration > option.durationMax) {
638-
scaleFilter += (scaleFilter ? "," : "") + `trim=duration=${option.durationMax},setpts=PTS-STARTPTS`;
639-
}
640-
const args = [
641-
"-i",
642-
input,
643-
"-vf",
644-
scaleFilter || "null",
645-
"-r",
646-
targetFps.toString(),
647-
"-preset",
648-
"fast",
649-
"-y",
650-
output,
651-
];
652-
// console.log("FFmpeg videoNormal args:", args.join(" "));
653-
await $mapi.app.spawnBinary("ffmpeg", args);
654-
if (!(await $mapi.file.exists(output))) {
655-
throw "视频处理失败,请检查视频文件是否存在或ffmpeg是否正常工作";
656-
}
657-
return output;
658-
}
659-

vite.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ export default defineConfig(({command}) => {
7171
];
7272
files.forEach(f => {
7373
const p = path.resolve(__dirname, "dist", f);
74+
if(!fs.existsSync(p)) {
75+
return;
76+
}
7477
let html = fs.readFileSync(p, "utf-8");
7578
for (const key in AppConfig) {
7679
html = html.replace(new RegExp(`%${key}%`, "g"), AppConfig[key]);

0 commit comments

Comments
 (0)