我正在制作一个从外部源流式传输视频并将其显示在我活动中的视频视图中的 android 应用程序。流工作正常,但我无法在我的 SD 卡上保存帧。这是我的代码,其中 vv 是 videoview:
int currentPosition = vv.getCurrentPosition(); //in millisecond
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
mediaMetadataRetriever.setDataSource(viewSource);
Bitmap bmFrame = mediaMetadataRetriever.getFrameAtTime(currentPosition * 1000); //unit in microsecond
if(bmFrame == null){
Toast.makeText(MainActivity.this,
"bmFrame == null!",
Toast.LENGTH_LONG).show();
}else{
AlertDialog.Builder myCaptureDialog =
new AlertDialog.Builder(MainActivity.this);
ImageView capturedImageView = new ImageView(MainActivity.this);
capturedImageView.setImageBitmap(bmFrame);
LayoutParams capturedImageViewLayoutParams =
new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
capturedImageView.setLayoutParams(capturedImageViewLayoutParams);
myCaptureDialog.setView(capturedImageView);
myCaptureDialog.show();
这是我的视频测试网址:
public String viewSource = "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov";
我尝试为 mediametadataretriver 的“setdatasource”设置 viewSourc,就像我的视频的网址一样,但它总是返回空位图...
问题出在哪里?
谢谢