2011-04-29 22 views
0

在解碼圖像文件時,我們使用BitmapFactory,而不是這個,我們可以用於視頻?如何解碼videofile

 public void decodeFile(String filePath) { 
      // Decode image size 

      BitmapFactory.Options o = new BitmapFactory.Options(); 
      o.inJustDecodeBounds = true; 
      BitmapFactory.decodeFile(filePath, o); 

      // The new size we want to scale to 
      //final int REQUIRED_SIZE = 1024; 

      // Find the correct scale value. It should be the power of 2. 
      //int width_tmp = o.outWidth, height_tmp = o.outHeight; 
      int scale = 1; 
      /*while (true) { 
       if (width_tmp <REQUIRED_SIZE && height_tmp < REQUIRED_SIZE) 
        break; 
       width_tmp /= 2; 
       height_tmp /= 2; 
       scale *= 2; 
      }*/ 
      //int scale = 1; 
      // Decode with inSampleSize 
      BitmapFactory.Options o2 = new BitmapFactory.Options(); 

      //o2.inSampleSize = scale; 
      bitmap = BitmapFactory.decodeFile(filePath, o2); 

      //imgView.setImageBitmap(bitmap); 

     } 
+0

這裏我選擇從gallary視頻n獲取特定視頻的SD卡路徑,我將路徑存儲在「filePath」 – Saurabh 2011-04-29 11:25:55

回答

0

有在Android SDK中「解碼」視頻沒有的API,除了進行播放(例如,MediaPlayer)。歡迎您嘗試尋找一些第三方庫,爲您提供您尋求的任何功能。