|
|
@ -8,6 +8,7 @@ import android.content.Intent; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.os.Environment; |
|
|
|
import android.os.Environment; |
|
|
|
import android.os.Looper; |
|
|
|
import android.os.Looper; |
|
|
|
|
|
|
|
import android.util.Log; |
|
|
|
import android.view.View; |
|
|
|
import android.view.View; |
|
|
|
import android.widget.Toast; |
|
|
|
import android.widget.Toast; |
|
|
|
|
|
|
|
|
|
|
@ -19,6 +20,7 @@ public class FFmpegTestActivity extends AppCompatActivity { |
|
|
|
private ProgressDialog mProgressDialog; |
|
|
|
private ProgressDialog mProgressDialog; |
|
|
|
|
|
|
|
|
|
|
|
private String videoPath = "/storage/emulated/0/DCIM/Camera/fb639313f7f3d58cc793f20095439c88.mp4"; |
|
|
|
private String videoPath = "/storage/emulated/0/DCIM/Camera/fb639313f7f3d58cc793f20095439c88.mp4"; |
|
|
|
|
|
|
|
private String videoPath2 = "/storage/emulated/0/4399YouPai/Record/LYL_20200316_155722.mp4"; |
|
|
|
|
|
|
|
|
|
|
|
private FFmpegInvoker.Callback mCallback = new FFmpegInvoker.Callback() { |
|
|
|
private FFmpegInvoker.Callback mCallback = new FFmpegInvoker.Callback() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -38,8 +40,8 @@ public class FFmpegTestActivity extends AppCompatActivity { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onProgress(float progress) { |
|
|
|
public void onProgress(float percent) { |
|
|
|
updateProgress((int) progress); |
|
|
|
updateProgress(percent); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -77,22 +79,22 @@ public class FFmpegTestActivity extends AppCompatActivity { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void updateProgress(int percent) { |
|
|
|
private void updateProgress(float percent) { |
|
|
|
mProgressDialog.setProgress(percent); |
|
|
|
mProgressDialog.setProgress((int) (percent * mProgressDialog.getMax())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void cutVideo(View view) { |
|
|
|
public void cutVideo(View view) { |
|
|
|
showProgress(); |
|
|
|
showProgress(); |
|
|
|
String savePath = getSaveDir() + "out.mp4"; |
|
|
|
String savePath = getSaveDir() + "out.mp4"; |
|
|
|
String cmd = "ffmpeg -y -ss 1 -t 300 -accurate_seek -i " + videoPath + " -codec copy " + savePath; |
|
|
|
String cmd = "ffmpeg -y -ss 1 -t 500 -accurate_seek -i " + videoPath2 + " -codec copy " + savePath; |
|
|
|
FFmpegInvoker.exec(cmd.split(" "), 100, mCallback); |
|
|
|
FFmpegInvoker.exec(cmd.split(" "), mCallback); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void extractFrame(View view) { |
|
|
|
public void extractFrame(View view) { |
|
|
|
showProgress(); |
|
|
|
showProgress(); |
|
|
|
String savePath = getSaveDir() + "out.png"; |
|
|
|
String savePath = getSaveDir() + "out.png"; |
|
|
|
String cmd = "ffmpeg -ss 10 -i " + videoPath + " -vframes 1 -y " + savePath; |
|
|
|
String cmd = "ffmpeg -ss 10 -i " + videoPath + " -vframes 1 -y " + savePath; |
|
|
|
FFmpegInvoker.exec(cmd.split(" "), 100, mCallback); |
|
|
|
FFmpegInvoker.exec(cmd.split(" "), mCallback); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static String getSaveDir() { |
|
|
|
public static String getSaveDir() { |
|
|
|