A
AC Question
Hey guys,
I am trying to programmatically watermark a video in Android using WritingMinds' Ffmpeg library from Github.
I did all they said in their documentation and imported the library in Android Studio.
Still, it gives me an IOExeption with "No such file or directory".
CODE
public class MainActivity extends Activity {
Button btn;
Context context;
String str;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn = (Button) findViewById(R.id.button);
context = this;
str = "ffmpeg -i /storage/extSdCard/DCIM/Camera/video.avi -i /storage/extSdCard/DCIM/Camera/logo.png -filter_complex 'overlay=10:main_h-overlay_h-10' /storage/extSdCard/DCIM/Camera/watermarked.avi";
String[] strArr = new String[str.length()];
for (int i = 0; i < str.length(); i++) {
strArr = String.valueOf(str.charAt(i));
final String[] finality = strArr;
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
doFfmpeg(str.split(" "));
}
});
}
}
public void doFfmpeg(String[] loc){
FFmpeg ffmpeg = FFmpeg.getInstance(context);
try {
// to execute "ffmpeg -version" command you just need to pass "-version"
ffmpeg.execute(loc, new ExecuteBinaryResponseHandler() {
@Override
public void onStart() {
}
@Override
public void onProgress(String message) {
}
@Override
public void onFailure(String message) {
}
@Override
public void onSuccess(String message) {
Toast.makeText(getApplicationContext(), "Success !", Toast.LENGTH_LONG).show();
}
@Override
public void onFinish() {
}
});
} catch (FFmpegCommandAlreadyRunningException e) {
// Handle if FFmpeg is already running
} catch (Exception e){
}
}
}
LOGS
691 5092-5311/com.app.watermark.watermark E/FFmpeg: Exception while trying to run: [Ljava.lang.String;@338dbc60
java.io.IOException: Error running exec(). Command: [/data/data/com.app.watermark.watermark/files/ffmpeg, -i, /storage/extSdCard/DCIM/Camera/video.avi, -i, /storage/extSdCard/DCIM/Camera/logo.png, -filter_complex, 'overlay=10:main_h-overlay_h-10', /storage/extSdCard/DCIM/Camera/watermarked.avi] Working Directory: null Environment: null
at java.lang.ProcessManager.exec(ProcessManager.java:211)
at java.lang.Runtime.exec(Runtime.java:173)
at java.lang.Runtime.exec(Runtime.java:128)
at com.github.hiteshsondhi88.libffmpeg.ShellCommand.run(ShellCommand.java:10)
at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(FFmpegExecuteAsyncTask.java:38)
at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(FFmpegExecuteAsyncTask.java:10)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.io.IOException: No such file or directory
at java.lang.ProcessManager.exec(Native Method)
at java.lang.ProcessManager.exec(ProcessManager.java:209)
at java.lang.Runtime.exec(Runtime.java:173)
at java.lang.Runtime.exec(Runtime.java:128)
at com.github.hiteshsondhi88.libffmpeg.ShellCommand.run(ShellCommand.java:10)
at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(FFmpegExecuteAsyncTask.java:38)
at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(FFmpegExecuteAsyncTask.java:10)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
How can I make this work ?
I am trying to programmatically watermark a video in Android using WritingMinds' Ffmpeg library from Github.
I did all they said in their documentation and imported the library in Android Studio.
Still, it gives me an IOExeption with "No such file or directory".
CODE
public class MainActivity extends Activity {
Button btn;
Context context;
String str;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn = (Button) findViewById(R.id.button);
context = this;
str = "ffmpeg -i /storage/extSdCard/DCIM/Camera/video.avi -i /storage/extSdCard/DCIM/Camera/logo.png -filter_complex 'overlay=10:main_h-overlay_h-10' /storage/extSdCard/DCIM/Camera/watermarked.avi";
String[] strArr = new String[str.length()];
for (int i = 0; i < str.length(); i++) {
strArr = String.valueOf(str.charAt(i));
final String[] finality = strArr;
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
doFfmpeg(str.split(" "));
}
});
}
}
public void doFfmpeg(String[] loc){
FFmpeg ffmpeg = FFmpeg.getInstance(context);
try {
// to execute "ffmpeg -version" command you just need to pass "-version"
ffmpeg.execute(loc, new ExecuteBinaryResponseHandler() {
@Override
public void onStart() {
}
@Override
public void onProgress(String message) {
}
@Override
public void onFailure(String message) {
}
@Override
public void onSuccess(String message) {
Toast.makeText(getApplicationContext(), "Success !", Toast.LENGTH_LONG).show();
}
@Override
public void onFinish() {
}
});
} catch (FFmpegCommandAlreadyRunningException e) {
// Handle if FFmpeg is already running
} catch (Exception e){
}
}
}
LOGS
691 5092-5311/com.app.watermark.watermark E/FFmpeg: Exception while trying to run: [Ljava.lang.String;@338dbc60
java.io.IOException: Error running exec(). Command: [/data/data/com.app.watermark.watermark/files/ffmpeg, -i, /storage/extSdCard/DCIM/Camera/video.avi, -i, /storage/extSdCard/DCIM/Camera/logo.png, -filter_complex, 'overlay=10:main_h-overlay_h-10', /storage/extSdCard/DCIM/Camera/watermarked.avi] Working Directory: null Environment: null
at java.lang.ProcessManager.exec(ProcessManager.java:211)
at java.lang.Runtime.exec(Runtime.java:173)
at java.lang.Runtime.exec(Runtime.java:128)
at com.github.hiteshsondhi88.libffmpeg.ShellCommand.run(ShellCommand.java:10)
at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(FFmpegExecuteAsyncTask.java:38)
at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(FFmpegExecuteAsyncTask.java:10)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.io.IOException: No such file or directory
at java.lang.ProcessManager.exec(Native Method)
at java.lang.ProcessManager.exec(ProcessManager.java:209)
at java.lang.Runtime.exec(Runtime.java:173)
at java.lang.Runtime.exec(Runtime.java:128)
at com.github.hiteshsondhi88.libffmpeg.ShellCommand.run(ShellCommand.java:10)
at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(FFmpegExecuteAsyncTask.java:38)
at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(FFmpegExecuteAsyncTask.java:10)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
How can I make this work ?