Merge pull request '生成视频由七牛直接抓取并校验可用性' (#89) from codex/98k-model-expansion-20261116 into main
This commit is contained in:
commit
dff2e22ffd
@ -5,6 +5,7 @@ import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { promisify } from "node:util";
|
||||
import { uploadFile } from "@/lib/storage/service";
|
||||
import { archiveMediaThroughQiniu } from "@/lib/storage/qiniu-image-archive";
|
||||
import { downloadCanvasMedia } from "./download-media";
|
||||
|
||||
const probe = promisify(execFile);
|
||||
@ -15,6 +16,13 @@ export async function archiveCanvasVideo(url: string): Promise<string> {
|
||||
if (existing) return existing;
|
||||
if (pending.size >= 2) throw new Error("视频保存繁忙,请稍后重试");
|
||||
const job = (async () => {
|
||||
const archived = await archiveMediaThroughQiniu(url, randomUUID(), "video");
|
||||
if (archived) {
|
||||
const { stdout } = await probe("ffprobe", ["-v", "error", "-rw_timeout", "15000000", "-protocol_whitelist", "http,https,tcp,tls,crypto", "-format_whitelist", "mov,matroska,webm", "-show_streams", "-show_format", "-of", "json", archived.url], { timeout: 20000, maxBuffer: 1024 * 1024 });
|
||||
const media = JSON.parse(stdout);
|
||||
if (!media.streams?.some((stream: { codec_type: string }) => stream.codec_type === "video") || !(Number(media.format?.duration) > 0)) throw new Error("视频文件不完整");
|
||||
return archived.url;
|
||||
}
|
||||
const dir = await mkdtemp(join(tmpdir(), "canvas-video-archive-"));
|
||||
try {
|
||||
const input = join(dir, "video");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user