如何在android中创建.ts视频文件的图像?

时间:2015-10-21 07:25:49

标签: java android bitmap mediametadataretriever

我收到此错误“getFrameAtTime:videoFrame是一个NULL指针”下面是我的代码。任何修复此错误的建议

 ImageView img = (ImageView) findViewById(R.id.picutre);

  try {

       MediaMetadataRetriever retriever = new MediaMetadataRetriever();
       retriever.setDataSource("/storage/sdcard0/download/videos/kamran.ts");
       Bitmap bMap = retriever.getFrameAtTime(0,MediaMetadataRetriever.OPTION_CLOSEST_SYNC);

       img.setImageBitmap(bMap);

    }
    catch(Exception e){
       Log.d("File","Error Creating image",e);
    }

我也试过这两种方法,但得到相同的错误信息(getFrameAtTime:videoFrame是一个NULL指针)

Bitmap bMap = ThumbnailUtils.createVideoThumbnail("/storage/sdcard0/download/videos/kamran.ts", MediaStore.Video.Thumbnails.MICRO_KIND);


Bitmap bMap = ThumbnailUtils.createVideoThumbnail("/storage/sdcard0/download/videos/kamran.ts", Thumbnails.FULL_SCREEN_KIND);

0 个答案:

没有答案