2013-09-26 41 views
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」,但它總是返回空位圖...

問題在哪裏?

三江源

回答

3

這個類有很多問題,我認爲其中之一是從外部源檢索框架。我建議你使用this external library。您只需將其添加到您的項目中,然後像使用mediametadataretriever類一樣使用該類。

希望它有用

相關問題