fix ffmpeg调用出错

This commit is contained in:
theluyuan 2023-07-01 23:42:23 +08:00
parent 77a3bccc55
commit 64124557c6

View File

@ -1,4 +1,6 @@
const {spawn} = require('child_process'); const {spawn} = require('child_process');
const path = require('path');
const { cwd } = require('process');
function seep(time) { function seep(time) {
@ -19,10 +21,12 @@ function seep(time) {
*/ */
function getVideoSpecifyTimeImage(filePath, seconds, save) { function getVideoSpecifyTimeImage(filePath, seconds, save) {
return new Promise((resolve) => { return new Promise((resolve) => {
console.info(formatSeconds(seconds)) const lux = spawn("ffmpeg", ['-ss',`${formatSeconds(seconds)}`,'-i',filePath,'-vframes','1',save],{
const lux = spawn("./bin/ffmpeg.exe", ['-ss', formatSeconds(seconds), '-i', filePath, '-vframes 1', save]) env:{
path:path.join(cwd(),'./bin/')
}
})
lux.stdout.on('data', (data) => { lux.stdout.on('data', (data) => {
console.log("开始")
console.log(data) console.log(data)
}); });
lux.on('close', (code) => { lux.on('close', (code) => {
@ -30,7 +34,10 @@ function getVideoSpecifyTimeImage(filePath, seconds, save) {
console.log(code.toString()) console.log(code.toString())
resolve(save) resolve(save)
}); });
lux.stderr.on("data",(err)=>{
console.log(String(err))
})
console.log(lux)
}) })
} }
@ -69,7 +76,11 @@ function createTorrent(filePath, save) {
function dow(info, callback) { function dow(info, callback) {
const lux = spawn("./bin/yt-dlp.exe", ['--cookies-from-browser', 'chrome', '-P', info.save, '-o', info.title + '.mp4', info.url]) const lux = spawn("yt-dlp", ['--cookies-from-browser', 'chrome', '-P', info.save, '-o', info.title + '.mp4', info.url],{
env:{
path:path.join(cwd(),'./bin/')
}
})
lux.stdout.on('data', (data) => { lux.stdout.on('data', (data) => {
console.log(String(data)) console.log(String(data))
callback(String(data), false) callback(String(data), false)