测试ffmpeg编译
This commit is contained in:
@ -8,6 +8,8 @@ const FFMPEG_TAG = "release/7.1"
|
||||
const FFMPEG_SOURCE_DIR = path.join(__dirname, "_source/FFmpeg");
|
||||
const FFMPEG_INSTALL_DIR = path.join(__dirname, "FFmpeg");
|
||||
|
||||
const isWindows = os.platform() == "win32";
|
||||
|
||||
function checkEnv() {
|
||||
if (!process.env.MSYSTEM_PREFIX) throw new Error("Please use msys2 environment to run this script");
|
||||
const bash = process.env.SHELL;
|
||||
@ -26,14 +28,17 @@ function build() {
|
||||
//configure
|
||||
if (!fs.existsSync(path.join(FFMPEG_SOURCE_DIR, "ffbuild/config.mak"))) {
|
||||
console.log("Configuring ffmpeg...");
|
||||
if (0 != spawnSync(process.env.SHELL, [
|
||||
path.join(FFMPEG_SOURCE_DIR, "configure"),
|
||||
const args = [
|
||||
`--prefix=${FFMPEG_INSTALL_DIR}`,
|
||||
"--enable-static",
|
||||
"--enable-small",
|
||||
"--toolchain=msvc",
|
||||
"--disable-programs",
|
||||
], { stdio: "inherit", cwd: FFMPEG_SOURCE_DIR }).status) throw new Error("Failed to configure ffmpeg");
|
||||
];
|
||||
const configureFile = path.join(FFMPEG_SOURCE_DIR, "configure");
|
||||
if (isWindows) args.unshift(configureFile);
|
||||
|
||||
if (0 != spawnSync(isWindows ? process.env.SHELL : configureFile, args, { stdio: "inherit", cwd: FFMPEG_SOURCE_DIR }).status) throw new Error("Failed to configure ffmpeg");
|
||||
}
|
||||
//make
|
||||
if (0 != spawnSync("make", [
|
||||
@ -51,7 +56,7 @@ function resolve() {
|
||||
for (const file of fs.readdirSync(path.join(FFMPEG_INSTALL_DIR, "lib"))) {
|
||||
if (path.extname(file) == ".a") {
|
||||
const libName = file.replace(/\.a$/, "").replace(/^lib/, "");
|
||||
fs.renameSync(path.join(FFMPEG_INSTALL_DIR, "lib", file), path.join(FFMPEG_INSTALL_DIR, "lib", libName + ".lib"));
|
||||
if (isWindows) fs.renameSync(path.join(FFMPEG_INSTALL_DIR, "lib", file), path.join(FFMPEG_INSTALL_DIR, "lib", libName + ".lib"));
|
||||
libs.push(libName);
|
||||
}
|
||||
}
|
||||
@ -68,7 +73,7 @@ async function main() {
|
||||
fs.mkdirSync(path.dirname(FFMPEG_SOURCE_DIR), { recursive: true });
|
||||
fs.mkdirSync(path.dirname(FFMPEG_INSTALL_DIR), { recursive: true });
|
||||
|
||||
checkEnv();
|
||||
if (isWindows) checkEnv();
|
||||
|
||||
if (!fs.existsSync(path.join(FFMPEG_SOURCE_DIR, "configure"))) download();
|
||||
if (!fs.existsSync(path.join(FFMPEG_INSTALL_DIR, "config.cmake"))) {
|
Reference in New Issue
Block a user