简体   繁体   English

除了这个命令(合并)之外,ffmpeg大部分时间在java中工作正常,这个命令在终端中工作正常

[英]ffmpeg works fine most of the time in java except for this command (merging), and this command works fine directly in terminal

When I run this from the command line it works (merges two videos side by side): 当我从命令行运行它时,它可以工作(并排合并两个视频):

/usr/local/bin/ffmpeg -i /Users/ron/Dropbox/JAMR/Technology/workspace/JAMR/sandbox/test.mov -i /Users/ron/Dropbox/JAMR/Technology/workspace/JAMR/sandbox/test1.mov -filter_complex "[0:v:0]pad=iw*2:ih[bg]; [bg][1:v:0]overlay=w" /Users/ron/Dropbox/JAMR/Technology/workspace/JAMR/sandbox/merged.mov

However, when I run it in java, I get this from the console: 但是,当我在java中运行它时,我从控制台得到它:

[AVFilterGraph @ 0x7fd44ad00440] No such filter: '"'
Error configuring filters.

here is the text I am returning (copied directly) which is what I am sending to be executed. 这是我要返回的文本(直接复制),这是我要发送的文件。 It is exactly the same, except I use the escape character before the quote symbol, so a " becomes \\": 它完全相同,除了我在引号之前使用转义字符,所以“变成\\”:

"/usr/local/bin/ffmpeg -i /Users/ron/Dropbox/JAMR/Technology/workspace/JAMR/sandbox/test.mov -i /Users/ron/Dropbox/JAMR/Technology/workspace/JAMR/sandbox/test1.mov -filter_complex \"[0:v:0]pad=iw*2:ih[bg]; [bg][1:v:0]overlay=w\" /Users/ron/Dropbox/JAMR/Technology/workspace/JAMR/sandbox/merged.mov";

All other ffmpeg tests have worked except this.... (the only one where I use a " character) 所有其他的ffmpeg测试都有用,除了这....(我使用“字符”的唯一一个)

Can anyone figure it out? 任何人都可以搞清楚吗?

you should split your command in Java into a String array and then pass it to getRuntime().exec(String[]) 您应该将Java中的命令拆分为String数组,然后将其传递给getRuntime()。exec(String [])

Short example: 简短的例子:

String cmd[] = new String[]{
                "ffmpeg",
                "-r", String.valueOf(20/30f), 
                "-i", "assets/IMAG0054_BURST%03d.jpg",
                "-i","assets/logo.png",
                "-i","assets/guitar_tuning.wav","-r", "24", "-codec:a", "mp3",
                "-filter_complex","[0:v][1:v]overlay=main_w-overlay_w-10:main_h-overlay_h-10,"+
                "drawtext=fontfile=assets/OpenSans-Regular.ttf:text=1st scene:x=0:y=0:fontsize=100:fontcolor=white:enable='between(t,0.5,2.5)'," +
                "drawtext=enable='between(t,2.6,5.5)':fontfile=assets/OpenSans-Regular.ttf:text=2nd scene:x=0:y=0:fontsize=100:fontcolor=white," +
                "drawtext=enable='between(t,5.6,8.8)':fontfile=assets/OpenSans-Regular.ttf:text=3rd scene:x=0:y=0:fontsize=100:fontcolor=white," +
                "drawtext=enable='between(t,8.9,30)':fontfile=assets/OpenSans-Regular.ttf:text=4rd scene:x=0:y=0:fontsize=100:fontcolor=white" +
                "[out]",
                "-map", "[out]", "-map", "2:0",
                "-acodec","mp3",
                //"-shortest " +
                "simple_lapse.mp4"};

Process ffmpeg = Runtime.getRuntime().exec(cmd);

Hope it helps 希望能帮助到你

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从Java执行时,MYSQL命令给出错误。 相同的命令在Linux Terminal上可以正常工作。 可能是什么原因? - MYSQL command gives error while being executed from java. Same command works fine on Linux Terminal. What can be the reason? Java setShape()方法在命令提示符下给出错误,但在Eclipse上工作正常 - Java setShape() method giving error on command prompt but works fine on eclipse Java应用程序可以从netbeans正常运行,但不能从命令行或.jar文件运行 - Java application works fine from netbeans but not the command line or a .jar file java 命令在 linux 中抛出错误,但在 windows 中运行良好 - java command throwing an error in linux although works fine in windows AppleScript 命令在终端中有效,但在 Java 中无效 - AppleScript Command Works in Terminal but not in Java 为什么Java Processbuilder不能在其自己的目录中运行PMCMD(informatica命令),但可以在命令提示符下正常运行 - Why PMCMD (informatica command) is not run by Java Processbuilder from its own directory while it works fine with command prompt mysqldump从java运行时返回代码6,但同样的命令从命令行运行正常 - mysqldump returns code 6 when run from java, but the same command works fine from command line Java Applet在Eclipse中工作正常,但在终端机(Appletviewer)中不正确 - Java Applet works fine in Eclipse but in terminal(Appletviewer) not correctly Java在Eclipse中运行良好,但无法在终端中正常运行 - Java works fine in Eclipse, but cannot run normally in Terminal 命令适用于终端,但不适用于 Kotlin - Command works on terminal but not with Kotlin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM