1
我正在製作和Android應用程序,從外部來源流視頻,並顯示它在我的活動視頻視圖。 流正常工作,但我無法保存我的SD卡上的幀。這是我的代碼,其中VV是videoview:如何從外部設備使用setVideoURI流從android 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";
我嘗試設置viewSourc像鏈接到我的視頻mediametadataretriver的「的setDataSource」,但它總是返回空位圖...
問題在哪裏?
三江源