簡體   English   中英

ffmpeg 在 forfiles 循環中調用時覆蓋輸入文件

[英]ffmpeg overwrites input files when called in a forfiles loop

我需要使用 ffmpeg 加入幾個 mp4 和 wav 文件對。

當我運行指定文件名的命令時,它運行良好:

.\ffmpeg.exe -i file01.mp4 -i file01.wav -c:v copy -c:a aac -b:a 96k file01_new.mp4

但是當我將此調用集成到 forfiles 循環中時,源 mp4 文件被覆蓋,並且 output mp4 文件僅包含音頻:

forfiles /M "*.mp4" /C ".\ffmpeg.exe -i @FNAME.mp4 -i @FNAME.wav -c:v copy -c:a aac -b:a 96k @FNAME_new.mp4"

我真的不明白在加入 MP4 和 WAV 文件之前會發生什么。 為什么源 MP4 被覆蓋?

如何編寫此腳本以使其工作? 謝謝您的支持。

讓我推薦使用for而不是forfiles ,因為后者非常慢,並且它用引號來擴展它的@ -variables,這可能是有問題的:

rem // Create sub-directory for resulting files, so resulting files cannot become reprocessed:
2> nul md "result"
rem // Loop through `*.mp4` files:
for %%I in ("*.mp4") do (
    rem /* Process current file, together with the related `*.wav` file,
    rem    and write the result into the new sub-directory: */
    ffmpeg.exe -i "%%~I" -i "%%~nI.wav" -c:v copy -c:a aac -b:a 96k "result\%%~I"
)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM