如何在不使用 Ctrl + C 的情况下以编程方式停止 FFmpeg 进程?

问题描述 投票:0回答:1
const shell = require("shelljs");

const processShell = shell.exec(
  `ffmpeg -i "https://pull-hls-l1-va01.tiktokcdn.com/game/stream-2998227837016342624_or4/playlist.m3u8?expire=1728613179&session_id=000-20240927021937E401758EF5D00A0AC325&sign=7aeab541c3ef8072d52a9fe799f8692b" -movflags use_metadata_tags -map_metadata 0 -metadata title="Chill chill kiếm kèo Warthunder" -metadata artist="bacgaucam" -metadata year="2024" -c copy "downloads/bacgaucam-927202491939.mp4" -n -stats -hide_banner -loglevel error`,
  { async: true }
);

setTimeout(() => {
  // processShell.kill();
  process.exit();
}, 20000);

我的视频仅在我使用 Ctrl+C 停止时才有效。我尝试过使用

process.exit()
.kill(pid, "SIGINT")
.kill()
参考文献中的
shell.exec()
方法,但它们都不起作用

有人可以帮忙吗?谢谢!

javascript ffmpeg process-management shelljs
1个回答
0
投票
const shell = require("shelljs");

shell.exec(
  `ffmpeg -i "https://pull-hls-l1-va01.tiktokcdn.com/game/stream-2998227837016342624_or4/playlist.m3u8?expire=1728613179&session_id=000-20240927021937E401758EF5D00A0AC325&sign=7aeab541c3ef8072d52a9fe799f8692b" -movflags use_metadata_tags -map_metadata 0 -metadata title="Chill chill kiếm kèo Warthunder" -metadata artist="bacgaucam" -metadata year="2024" -c copy "downloads/bacgaucam-927202491939.mp4" -n -stats -hide_banner -loglevel error`,
  { async: true }
);

setTimeout(() => {
  shell.exit(1);
}, 20000);
© www.soinside.com 2019 - 2024. All rights reserved.