brux
brux

Reputation: 3230

getruntime() exec() with double quotes in command

I want to execute an ffmpeg command, the method I am using works with every command on my list except the following one which contains double quotes to set a filter (-vf) parameter

ffmpeg -i 2012-12-27.mp4 -vf "movie=bb.png [movie]; [in] [movie] overlay=0:0 [out]" -vcodec libx264 -acodec copy out.mp4

I have tried changing the quotes for single quotes with no luck. The command works at the android terminal with both single and double quotes.

The app I'm developing uses about 5 ffmpeg commands, all work except this one, is this some bug?

I can't find a concrete solution to this problem, breaking the args into an array and then passing this to runtime().exec() as suggested elsewhere doesn't seem to work, or simply trying to escape the quotes with \" won't work.

Both of the files referenced in the above command are located in the sdcard, I removed the concatenation of the command out so that things don't get messy, rest assured these commands work in a terminal when referencing the full paths to the files. I contatenate the string passed to getRuntime().exec() using a stringbuilder and`getexternalstorageDirectory().getabsolutepath() to get the path to each file like I have been doing with previous commands when using the process class.

I am using Jelly Bean 4.2 in case that is of any significance.

Upvotes: 3

Views: 5310

Answers (2)

323go
323go

Reputation: 14274

Try

getRuntime().exec( new String[] { "ffmpeg", "-i", "2012-12-27.mp4", "-vf", "movie=bb.png [movie]; [in] [movie] overlay=0:0 [out]", "-vcodec", "libx264", "-acodec", "copy", "out.mp4" } );

The parameters belonging together (such as the quoted -vf filter string) need to be in the same array element.

Upvotes: 6

imxylz
imxylz

Reputation: 7937

not working fine with string array?

java.lang.Runtime.exec(String[])
java.lang.Runtime.exec(String[], String[], File)

Runtime.exec(new String[]{"ffmpeg","-i","2012-12-27.mp4","-vf",
    "movie=bb.png [movie]; [in] [movie] overlay=0:0 [out]",
    "-vcodec","libx264","-acodec","copy","out.mp4"});

You should put all arguments into an array.

Upvotes: 2

Related Questions