1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| String[] cmdLine = ["ffmpeg","-i",fOriginal.path,"'|'","grep","'Duration'","|","cut","-d","\' \'","-f","4","|","sed s/,// "]
ProcessBuilder pb = new ProcessBuilder(cmdLine)
pb.redirectErrorStream(true)
Process p = null;
try
{
p = pb.start();
logProcessOutputAndErrors(p);
}
catch (Exception ex)
{
logger.warn "Can't create process to convert '${inFileName}'"
p?.destroy();
return false;
}
// wait until the process is finished
try
{
p.waitFor();
}
catch (InterruptedException e)
{
p.destroy();
}
if (p.exitValue() != 0)
{
logger.warn("Error while converting '" + inFileName + "'.");
return false;
} |
Partager