I am executing the below ffmpeg
command for trimming videos.The issue I am having is that if filepath contains spaces then the command fails.I tried many ways to handle spaces but none of them worked except moving file to a path that doesn't have space and then executing the command with new file path as source.
Below is the command-
execFFmpegBinary("-i " + filepath + " -ss " + startMs / 1000 + " -to " + endMs / 1000 + " -strict -2 -async 1 " + dest.getAbsolutePath());
private void execFFmpegBinary(final String command) {
try {
ffmpeg.execute(command, new ExecuteBinaryResponseHandler() {
@Override
public void onFailure(String s) {
Log.e("Previewragment", "FAILED with output : " + s);
}
@Override
public void onSuccess(String s) {
Log.e("Previewragment", "SUCCESS with output : " + s);
}
@Override
public void onProgress(String s) {
Log.e("Previewragment", "Started command : ffmpeg " + command);
Log.e("Previewragment", "progress : " + s);
}
@Override
public void onStart() {
Log.e("Previewragment", "Started command : ffmpeg " + command);
}
@Override
public void onFinish() {
}
});
} catch (FFmpegCommandAlreadyRunningException e) {
// do nothing for now
}
}
I saw this answer and tried
String addQuotes(String in ) {
return "\"" + in + "\"";
}
execFFmpegBinary("-i " + addQuotes(filepath) + " -ss " + startMs / 1000 + " -to " + endMs / 1000 + " -strict -2 -async 1 " + dest.getAbsolutePath())
;