1

why my code is not working in marshmallows and lollipop devices. or any idea how to use FFMPEG in that versions. any help.

import android.os.Bundle; import android.os.Environment; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.Toast; import com.kru.ffmpeglibs.FFmpeg; import com.kru.ffmpeglibs.FFmpegExecuteResponseHandler; import com.kru.ffmpeglibs.FFmpegLoadBinaryResponseHandler; import com.kru.ffmpeglibs.exceptions.FFmpegCommandAlreadyRunningException; import com.kru.ffmpeglibs.exceptions.FFmpegNotSupportedException; public class CommandsActivity extends AppCompatActivity { private FFmpeg fFmpeg; private Button btnGenerate; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); fFmpeg = FFmpeg.getInstance(CommandsActivity.this); executeBinary(); btnGenerate = (Button) findViewById(R.id.btnGenerate); btnGenerate.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { try { String[] ffmpegCommand = { "-i " + Environment.getExternalStorageDirectory() .getPath() + "/vid.mp4" + " -r 10 " + Environment.getExternalStorageDirectory() .getPath() + "/com.mobvcasting.mjpegffmpeg/frame_%05d.jpg" }; executeCommand(ffmpegCommand); } catch (FFmpegCommandAlreadyRunningException e) { e.printStackTrace(); } } }); } private void executeCommand(String[] cmd) throws FFmpegCommandAlreadyRunningException { fFmpeg.execute(cmd, new FFmpegExecuteResponseHandler() { @Override public void onSuccess(String message) { Toast.makeText(CommandsActivity.this, "Sucesses..", Toast.LENGTH_SHORT).show(); System.out.println(message); } @Override public void onProgress(String message) { // Toast.makeText(MainActivity.this, "On Process", // Toast.LENGTH_SHORT).show(); System.out.println(message); } @Override public void onFailure(String message) { Toast.makeText(CommandsActivity.this, "Fail this", Toast.LENGTH_SHORT).show(); System.out.println(message); } @Override public void onStart() { } @Override public void onFinish() { Toast.makeText(CommandsActivity.this, "Finish", Toast.LENGTH_SHORT).show(); } }); } private void executeBinary() { try { fFmpeg.loadBinary(new FFmpegLoadBinaryResponseHandler() { @Override public void onFailure() { } @Override public void onSuccess() { } @Override public void onStart() { } @Override public void onFinish() { } }); } catch (FFmpegNotSupportedException e) { e.printStackTrace(); } } } 

Here is my code but it still not working. please tell me what is wrong in the code The exception i got is something like this.

02-22 11:18:41.469: E/AndroidRuntime(27839): FATAL EXCEPTION: main 02-22 11:18:41.469: E/AndroidRuntime(27839): java.lang.UnsatisfiedLinkError: Native method not found: com.kru.ffmpeglibs.ArmArchHelper.cpuArchFromJNI:()Ljava/lang/String; 02-22 11:18:41.469: E/AndroidRuntime(27839): at com.kru.ffmpeglibs.ArmArchHelper.cpuArchFromJNI(Native Method) 02-22 11:18:41.469: E/AndroidRuntime(27839): at com.kru.ffmpeglibs.CpuArchHelper.getCpuArch(CpuArchHelper.java:61) 02-22 11:18:41.469: E/AndroidRuntime(27839): at com.kru.ffmpeglibs.FFmpeg.loadBinary(FFmpeg.java:40) 02-22 11:18:41.469: E/AndroidRuntime(27839): at com.kru.sampleffmpeg.MainActivity.loadFFMpegBinary(MainActivity.java:68) 02-22 11:18:41.469: E/AndroidRuntime(27839): at com.kru.sampleffmpeg.MainActivity.onCreate(MainActivity.java:36) 02-22 11:18:41.469: E/AndroidRuntime(27839): at android.app.Activity.performCreate(Activity.java:5372) 02-22 11:18:41.469: E/AndroidRuntime(27839): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104) 02-22 11:18:41.469: E/AndroidRuntime(27839): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257) 02-22 11:18:41.469: E/AndroidRuntime(27839): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349) 02-22 11:18:41.469: E/AndroidRuntime(27839): at android.app.ActivityThread.access$700(ActivityThread.java:159) 02-22 11:18:41.469: E/AndroidRuntime(27839): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316) 02-22 11:18:41.469: E/AndroidRuntime(27839): at android.os.Handler.dispatchMessage(Handler.java:99) 02-22 11:18:41.469: E/AndroidRuntime(27839): at android.os.Looper.loop(Looper.java:176) 02-22 11:18:41.469: E/AndroidRuntime(27839): at android.app.ActivityThread.main(ActivityThread.java:5419) 02-22 11:18:41.469: E/AndroidRuntime(27839): at java.lang.reflect.Method.invokeNative(Native Method) 02-22 11:18:41.469: E/AndroidRuntime(27839): at java.lang.reflect.Method.invoke(Method.java:525) 02-22 11:18:41.469: E/AndroidRuntime(27839): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046) 02-22 11:18:41.469: E/AndroidRuntime(27839): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862) 02-22 11:18:41.469: E/AndroidRuntime(27839): at dalvik.system.NativeStart.main(Native Method) 
6
  • working on other version? Commented Feb 19, 2016 at 7:03
  • yes its working on other version perfectly Commented Feb 19, 2016 at 7:04
  • I need to add so other command as like reverse video and slow motion video Commented Feb 19, 2016 at 7:23
  • you have get any solution for that? @Andy Developer Commented Feb 19, 2016 at 12:06
  • stackoverflow.com/a/14444952/5068931 Commented Feb 22, 2016 at 6:12

1 Answer 1

2

Lets see FFmpeg setup in onther way just you have to put compile 'com.github.hiteshsondhi88.libffmpeg:FFmpegAndroid:0.2.5' in your gradle. Now Follow step using this link, now you have must to call ffmpeg.loadBinary(new LoadBinaryResponseHandler() {, before use of execute command. Other wise get problem. Now see below code and Sceenshot

MainActivity.java

public class MainActivity extends AppCompatActivity { EditText editText; Button click; FFmpeg fFmpeg; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); fFmpeg = FFmpeg.getInstance(MainActivity.this); executeBinary(); click = (Button) findViewById(R.id.btnChk); editText=(EditText)findViewById(R.id.editText); Log.e("Log",Environment.getExternalStorageDirectory().getAbsolutePath().toString()); click.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { String cmd=editText.getText().toString(); // frameCount.mp4 executeCommand(cmd); } catch (FFmpegCommandAlreadyRunningException e) { e.printStackTrace(); } } }); } private void executeCommand(String cmd) throws FFmpegCommandAlreadyRunningException { fFmpeg.execute(cmd, new FFmpegExecuteResponseHandler() { @Override public void onSuccess(String message) { Toast.makeText(MainActivity.this, "Sucesses..", Toast.LENGTH_SHORT).show(); System.out.println(message); } @Override public void onProgress(String message) { // Toast.makeText(MainActivity.this, "On Process", Toast.LENGTH_SHORT).show(); System.out.println(message); } @Override public void onFailure(String message) { Toast.makeText(MainActivity.this, "Fail this", Toast.LENGTH_SHORT).show(); System.out.println(message); } @Override public void onStart() { } @Override public void onFinish() { Toast.makeText(MainActivity.this, "Finish", Toast.LENGTH_SHORT).show(); } }); } private void executeBinary() { try { fFmpeg.loadBinary(new FFmpegLoadBinaryResponseHandler() { @Override public void onFailure() { } @Override public void onSuccess() { } @Override public void onStart() { } @Override public void onFinish() { } }); } catch (FFmpegNotSupportedException e) { e.printStackTrace(); } } } 

See Below Image use your command in EditText as input -i /storage/emulated/0/frameCount.mp4 -r 7 /storage/emulated/0/frame%03d.jpg

Images

Sign up to request clarification or add additional context in comments.

6 Comments

I was implement the link you given but I got the exception. : FATAL EXCEPTION: main : java.lang.UnsatisfiedLinkError: Native method not found: com.kru.ffmpeglibs.ArmArchHelper.cpuArchFromJNI:()Ljava/lang/String; : at com.kru.ffmpeglibs.ArmArchHelper.cpuArchFromJNI(Native Method) :at com.kru.ffmpeglibs.CpuArchHelper.getCpuArch(CpuArchHelper.java:15) : at com.kru.ffmpeglibs.FFmpeg.loadBinary(FFmpeg.java:40) : at com.kru.sampleffmpeg.MainActivity.loadFFMpegBinary(MainActivity.java:67)
have you impliment above code ? make new project and test my code. that work for me.
see my updated answer i do the same but it still give me the error in 6.0 also in 4.2 devices. not check any other devices yet
chat.stackoverflow.com come at we discuss about that
@Android I tried - ffmpeg -loop 1 -i image.jpg -i audio.mp3 -c:v libx264 -tune stillimage -c:a aac -strict experimental -b:a 192k -pix_fmt yuv420p -shortest out.mp4 command using your mentioned code, but that seemed failed. Can you plz tell, whats wrong in that command, as the same command is already working, when tried using Ubuntu terminal
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.