commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: Commons Exec not producing the same result as the command line
Date Tue, 13 Apr 2010 23:18:00 GMT
On 13/04/2010, Daniel Wamara <daolwin@hotmail.com> wrote:
> Good evening all,
>
>  I am trying to call ffmpeg via the command exec in order to transcode some files and
the strange thing happening is that the files produced are not the same as the one I can create
when calling the same command via the command line.
>
>  This is how I am calling fmpeg and I get a file with a particular codec in it (strangely
not the right one) although launching in the command line exactly what I have in the sb.toString()
which is the command to be executed, the file created has a correct codec. So to say, the
same command started via Exec and the one started via the command line have not the same result.
Anyone has an idea?
>
>  Thanks.
>  Daniel Wamara
>
>  StringBuilder sb = new StringBuilder("/home/ect/scripts/transcoding.sh ");
>
>  sb.append(" " + source.getAbsolutePath());
>
>  sb.append(" " + attributes.getCodec());
>
>  sb.append(" " + String.valueOf(attributes.getSamplingRate().intValue()));
>
>  sb.append(" " + target.getAbsolutePath());
>
>
>  logDebug("command --> " + sb.toString());
>
>
>  CommandLine commandLine = CommandLine.parse(sb.toString());

Why do you build up the command-line and then parse it?

Much safer to add the arguments one at a time, see:

http://commons.apache.org/exec/tutorial.html

under the heading "Build the Command Line Incrementally"


>  DefaultExecutor executor = new DefaultExecutor();
>
>  executor.execute(commandLine);
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message