Powershell批次從視訊檔案提取音訊命令

Powershell批次從視訊檔案提取音訊命令

我有一個有效的 bash 命令來提取當前資料夾中視訊的所有音軌而不重新編碼並將它們放入子資料夾中:

for f in *.mp4; do ffmpeg -i "$f" -vn -c:a copy ./audio/"${f%.*}".m4a; done

我一直在嘗試尋找 PS 的等效命令。我怎樣才能做到這一點?當我嘗試以下操作:

ls *.mp4|foreach{
    ffmpeg -i $_ -vn -c:a copy $_.name.replace("mp4", "m4a")
}

我在某些帶有 opus 音訊的文件上收到此錯誤:

[ipod @ 00000000005719c0] Could not find tag for codec opus in stream #0, codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 --

有什麼方法可以提取視訊檔案中任何格式的音訊嗎?模仿 PS 中 bash 指令的工作方式。

謝謝!

相關內容