나는 각이 100ms textureview에 MediaPlayer를 비디오에서 프레임과 비트 맵의 색상 설정의 스크린 샷 (비트 맵) 내가 onSurfaceTextureUpdated 내가 mediaplayer.seekTo (기간)를 호출 할 때마다이라고 생각 ARGB_8888MediaPlayer.seekTo() 및 onSurfaceTextureUpdated()가 루프 내부에서 작동하지 않는 이유는 무엇입니까?
해야려고하고있어 거기에 비트 맵을 얻을 수 있습니다.
그래서 나는 곳 textureview 활동에 버튼을 생성하고,이 같은 활동에 클릭 방식에 적용 :
public void onViewClicked() {
float begin = starttimeframe; // starting point of analysis in timeframe
float end = endtimeframe; // ending point of analysis in timeframe
int f = round(begin);
status = 2;
while (f < round(end)) {
mediaplayer.seekTo(f);
currenttimeframe = f;
f += 100; // forward to next frame (100ms interval)
}
Toast.makeText(Extractor2Activity.this, "Done!", Toast.LENGTH_SHORT).show();
}
그리고 surfacetexture는 다음과 같이 업데이트 할 때 textureview을 캡처 코드를 추가 :
public void onSurfaceTextureUpdated(SurfaceTexture surface) {
Bitmap bitmap = Bitmap.createBitmap(tvWidth, tvHeight, Bitmap.Config.ARGB_8888);
textureView.getBitmap(bitmap);
File file = new File(Environment.getExternalStorageDirectory().toString(), "capture" + current timeframe + ".jpg");
OutputStream fout = null;
try {
fout = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fout);
fout.flush();
fout.close();
MediaStore.Images.Media.insertImage(this.getContentResolver(), file.getAbsolutePath(), file.getName(), file.getName());
} catch (IOException e) {
e.printStackTrace();
}
}
문제는 textureview의 비디오가 변경되지 않고 onSurfaceTextureUpdated가 반복 중에 호출되지 않는다는 것입니다.
onSurfaceTextureUpdated()는 표시된 토스트 메시지 이후에 한 번만 호출됩니다.
나는 해결책이 있어야한다고 생각하지만 안드로이드 프로그래밍에 능숙하지 않으며 이것을 해결하는 방법을 모른다.
루핑하는 동안 seekTo 및 onSurfaceTextureUpdated를 올바르게 작성하는 방법은 무엇입니까? 내가 시도 무엇
: MediaMetadataRetriever.getFrameAtTime를 사용
를, 그것은 원하는 루프 내부 프레임하지만 인수 비트 맵의 색상 설정은 기본적으로 RGB565되고에서 ARGB_8888의 설정의 이미지를 얻을하는 방법을 모르는를 포착하는 것이 가능 getFrameAtTime.
프레임이 버퍼를 기다린 다음 각 seekTo() 호출 후에 렌더링됩니다. – Abbas
@Abbas, 빠른 의견에 감사드립니다! 당신이 친절하게 나에게 어떻게 할 수있는 몇 가지 예제 코드를 제공해 주시겠습니까? –