IOException on watermarking video - Android Studio

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 ?
 

anon(9983233)

Well-known member
Aug 3, 2016
652
1
0
Visit site
You're putting way too much into this while using your android device.. a simple date/time or GPS stamp would do the trick..Just locate an app which allows one to achieve this same stamping. Also there are other options available to you via the Google Play store front.. "water marking videos" would be the key words in this instance.

Lastly and although I've not deviled into any sort or coding or have limited coding skills, I would suggest locating the android Stack Overflow or Stacked Exchange forums for those with a bit more coding experience.
 

Forum statistics

Threads
950,336
Messages
6,946,826
Members
3,161,924
Latest member
ROONALDO