Stefan Ionescu Freelancing Ответов: 1

Ioexception на видео водяных знаков на android


Я пытаюсь программно добавить водяные знаки на видео в библиотеку ffmpeg Android с помощью WritingMinds' с GitHub :

https://github.com/WritingMinds/ffmpeg-android-java

Я сделал все, что они сказали в своей документации, и импортировал библиотеку в Android Studio.

Тем не менее, это дает мне IOExeption с "No such file or directory".

КОД

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";

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){

}

 }
}



БРЕВНА

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) 


Как я могу заставить это работать ?

Что я уже пробовал:

Пробовал искать проблемы с зависимостями, пробовал переписывать команду ffmpeg.

1 Ответов

Рейтинг:
0

Umesh_dmt

make sure all the files available on path which you provide on script.

Follow the below example

-y -i /storage/emulated/0/Pictures/HelloCamera/VID_TESTING_20190123_124845.mp4 -i /storage/3636-3861/ic_launcher_incode.png -filter_complex [0][1]overlay=10:main_h-overlay_h-10 /storage/emulated/0/Mitwa_OnRecording.mp4