1
我正在使用我的android应用程序录制视频。当我试图在录制后从路径中读取视频时,我没有获得完整的录制文件。 但经过一段时间我可以阅读完整的文件。我不知道是什么问题? 请帮忙。 这里是我的代码录制的视频无法从文件中立即读取位置?
try { videoFile = getOutputMediaFile(MEDIA_TYPE_VIDEO); videothumb = new File(getOutputMediaThumbFile(MEDIA_TYPE_VIDEO),videoFile.getName()); db.insertFileInfo(videoFile.getName(),0,videoFile.length(),0,“video/mp4”);如果(videoFile == null){ Log.d(“”,“创建媒体文件时出错,检查存储权限:”); safeToTakePicture = true; 返回null; }
videothumb.createNewFile();
videoFile.createNewFile();
Thread.sleep(10000);
upVFile = new File(videoFile.getAbsolutePath());
FileOutputStream fos = new FileOutputStream(videoFile);
FileOutputStream ftos = new FileOutputStream(videothumb);
thumb = Bitmap.createScaledBitmap(bmv, 200, 200, false);
thumb.compress(Bitmap.CompressFormat.JPEG, 90, ftos);
ftos.flush();
ftos.close();
bmv.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.flush();
fos.close();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bmv.compress(Bitmap.CompressFormat.JPEG, 100, baos);
byte[] b = baos.toByteArray();
baos.close();
String encodedImage = new String(Base64.encodeBase64(b));
editor.putString("image_data", encodedImage);
editor.commit();
editor.putString(IMAGE_NAME, videoFile.getName());
editor.commit();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
}