我正在使用ProcessBuilder来运行FFMPEG来转换和标记我的一些MP3文件。
在.bat文件中手动使用以下按预期方式工作:
"E:\Dokumente\workspace\MusicBot\ffmpeg\bin\ffmpeg.exe"
-i "The Glitch Mob - We Can Make The World Stop.mp4"
-metadata author="The Glitch Mob"
-metadata title="We Can Make The World Stop"
-ab 320k "mob.mp3"
现在我想用java的ProcessBuilder
来实现ProcessBuilder pr = new ProcessBuilder(FFMPEG_PATH,
"-i", target.getAbsolutePath(),
"-metadata", "title=\"We Can Make The World Stop\"",
"-metadata", "author=\"The Glitch Mob\"",
"-ab", "320k",
tar.getAbsolutePath());
会产生[NULL @ 000000000032f680] Unable to find a suitable output format for 'Can'
。
但是,使用没有空格的标题和作者可以使用。
答案 0 :(得分:2)
命令行上的双引号用于告诉shell解释器不要将字符串拆分为多个参数。这是为了确保应用程序接收title=We Can Make The World Stop
作为单个参数。
由于ProcessBuilder
显式处理多个命令行参数,因此在调用时不需要转义空格。