在forfiles循环中调用时,ffmpeg覆盖输入文件

亚伯龙修斯教授

我需要使用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文件将被覆盖,而输出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"
)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章