如何使用google/zx在windows中执行ffmpeg shell?

How to use google/zx to execute ffmpeg shell in windows?

我通过scoop下载了ffmpeg,我可以在powershell中使用ffmpeg

我的脚本如下:

#!/usr/bin/env zx
const filePath = `./abc.mp4`;
const srsServerURL = `192.168.30.100`;
await $`ffmpeg -re -i ${filePath} -c copy -f mp4 -y rtmp://${srsServerURL}/live/livestream`;

但是 zx 告诉我找不到 ffmpeg。

我认为问题可能是 zx 在 WSL 中使用了 bash。假设您也不想在 WSL 中使用 ffmpeg,这是我修复它的方法。

  1. 安装git.
  2. 在已安装的git里面找到bash.exe。就我而言,它位于 C:/Program Files/Git/usr/bin/bash.exe.
  3. 在 shebang 后插入以下行:$.shell = `Location to your bash`。在我的例子中,它是 $.shell = `C:/Program Files/Git/usr/bin/bash.exe`;.

我相当确定这适用于 bash 的其他发行版 Windows,但我没有测试过。