동영상의 모든 프레임을 얻을 수 있습니다. 여기 ffmpeg 라이브러리를 사용하면 작동하는 코드입니다.
의존성에게 Gradle을 여기
private void loadFFMpegBinary() {
try {
if (ffmpeg == null) {
ffmpeg = FFmpeg.getInstance(this);
}
ffmpeg.loadBinary(new LoadBinaryResponseHandler() {
// @Override
// public void onFailure() {
// showUnsupportedExceptionDialog();
// }
@Override
public void onSuccess() {
Log.d(TAG, "ffmpeg : correct Loaded");
}
});
} catch (FFmpegNotSupportedException e) {
} catch (Exception e) {
Log.d(TAG, "EXception : " + e);
}
}
에
compile 'com.writingminds:FFmpegAndroid:0.3.2'
를 추가 이미지 extratct 방법에게있는 경우
public void extractImagesVideo() {
File moviesDir = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES
);
String filePrefix = "extract_picture";
String fileExtn = ".jpg";
String yourRealPath = getPath(Pick_Video.this, DataModel.selectedVideoUri);
Log.d("selected url", "" + DataModel.selectedVideoUri);
File src = new File(yourRealPath).getAbsoluteFile();
File appDir=new File(moviesDir,"/"+app_name+"/");
if(!appDir.exists())
appDir.mkdir();
DataModel.appDir=appDir;
File dir = new File(appDir, "testVideo");
int fileNo = 0;
while (dir.exists()) {
fileNo++;
dir = new File(moviesDir+"/"+app_name+"/", "testVideo" + fileNo);
}
dir.mkdir();
DataModel.dir = dir;
resultList = new ArrayList<String>(256);
filePath = dir.getAbsolutePath();
File dest = new File(dir, filePrefix + "%03d" + fileExtn);
Log.d(TAG, "startTrim: src: " + src.toString());
Log.d(TAG, "startTrim: dest: " + dest.getAbsolutePath());
String[] complexCommand = { "-i",""+src.toString(),"-qscale:v", "2","-vf", "fps=fps=20/1",dest.getAbsolutePath()};
//"-qscale:v", "2","-vf", "fps=fps=20/1",//
//works fine with speed and
execFFmpegBinary(complexCommand);
}
호출 버튼 클릭 이벤트에서이 두 가지 방법
댓글입니다질문.
FFmpeg를 사용하지 않고이를 수행 할 수있는 방법이 있습니까? –
나는 ffmpeg없이 이것을하는 방법에 관하여 아무 아이디어도 없다 그러나 저에게 ffmpeg를 사용하는 제일 방법에 따르면 당신은 ffmpeg로 할 수있는 것의이 유형의 심상의 수 및 qulity를 놓을 수있다 –