I send the intention to start the camcorder
PackageManager pm = getPackageManager(); if(pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)){ Intent video = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); File tempDir= new File(Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES), "BCA"); if(!tempDir.exists()) { if(!tempDir.mkdir()){ Toast.makeText(this, "Please check SD card! Image shot is impossible!", Toast.LENGTH_SHORT).show(); } } String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss",Locale.US).format(new Date()); File mediaFile = new File(tempDir.getPath() + File.separator + "VIDEO_"+ timeStamp + ".mp4"); Uri videoUri = Uri.fromFile(mediaFile); video.putExtra(MediaStore.EXTRA_OUTPUT, videoUri); video.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); startActivityForResult(video, VIDEO_REQUEST); }else{ Toast.makeText(this, "This device does not have a rear facing camera",Toast.LENGTH_SHORT).show(); }
I take the video and it is stored correctly. When onActivityResult launched, I use the intent to get the uri where it is stored to create a bitmap
this is an example uri file:///storage/emulated/0/Pictures/BCA/VIDEO_20131227_145043.mp4
Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(intent.getDataString(), MediaStore.Video.Thumbnails.MICRO_KIND);
but the bitmap is null every time. Therefore, since the docs say May return null if the video is corrupt or the format is not supported , I check the video in the directory and plays its .mp4 file perfectly, which is supported, so what am I doing wrong here?
tyczj
source share