휴대 전화에 로컬로 저장된 비디오를 재생하는 VideoView에서 비디오 프레임을 캡처하는 방법을 알 수있었습니다. 비디오가 VideoView에서 IP를 통해 스트리밍되는 경우 스크린 샷/이미지/비디오 프레임을 캡처하는 것이 매우 어려워 보입니다. 나는이 문제에 대한 해결책을 고맙게 생각한다.Android에서 비디오를 스트리밍 할 때 VideoView의 캡쳐 화면을 캡처하는 방법
public static Bitmap captureVideoFrame(Activity activity, VideoView vv, String viewSource, int currPosInMs)
{
MediaMetadataRetriever mmRetriever = new MediaMetadataRetriever();
mmRetriever.setDataSource(viewSource);
Bitmap bmFrame = mmRetriever.getFrameAtTime(currPosInMs * 1000); // unit in microsecond
if(bmFrame == null){
Toast.makeText(activity.getApplicationContext(), "Bitmap is null! Curr Position: " + currPosInMs, Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(activity.getApplicationContext(), "Bitmap is not null! Curr Position: " + currPosInMs, Toast.LENGTH_SHORT).show();
// Save file
String mPath = Environment.getExternalStorageDirectory().toString() + "/" + SCREENSHOT_DIRECTORY + "myScreenshot.png";
OutputStream fout = null;
File imageFile = new File(mPath);
try {
fout = new FileOutputStream(imageFile);
bmFrame.compress(Bitmap.CompressFormat.JPEG, 100, fout);
fout.flush();
fout.close();
Toast.makeText(activity.getApplicationContext(), "Saved file successfully!", Toast.LENGTH_SHORT).show();
}
catch(Exception e){
}
}
return bmFrame;
}
: 여기
How to capture a frame from video in android?
(비디오는 휴대 전화에 저장되어있는 경우 ONLY) 비디오 프레임을 캡쳐하는 용액이다 : 여기
는 응답을받지 못한 유사한 질문은