diff --git a/index.js b/index.js index 24a7ace91b4a2e5d07e7acd2dcc67f1e43536419..5a6ee0fec56ef3000f506dbd7b14e37051f3788f 100644 --- a/index.js +++ b/index.js @@ -22,3 +22,28 @@ function getDayOfMonth() { } const dayOfMonth = getDayOfMonth(); console.log(`今天是本月的第 ${dayOfMonth} 天`); + +const { spawn } = require('child_process'); + + +//生成一个 mp4 to wav 视频格式转化器 +// 执行 FFmpeg 命令行工具 +const ffmpeg = spawn('ffmpeg', ['-i', 'input.mp4', 'output.wav']); + +// 监听执行结果 +ffmpeg.on('close', (code) => { + console.log(`子进程退出,退出码 ${code}`); +}); + +ffmpeg.on('error', (err) => { + console.error(`出错了:${err}`); +}); + +ffmpeg.stdout.on('data', (data) => { + console.log(`输出:${data}`); +}); + +ffmpeg.stderr.on('data', (data) => { + console.error(`错误:${data}`); +}); +