如何解码视频文件

时间:2011-04-29 11:24:15

标签: android video decoding

在图像文件的解码中我们使用BitmapFactory而不是我们可以用于视频的那个?

       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);

        }

1 个答案:

答案 0 :(得分:0)

Android SDK中没有用于“解码”视频的API,除了播放它之外(例如MediaPlayer)。欢迎您尝试找到一些第三方库,为您提供所需的任何功能。