01-22 11:59:15.498: E/OMXCodec(38): [OMX.Google.h264.decoder] Timed out waiting for output buffers: 0/001-22 11:59:15.598: E/MetadataRetrIEverClIEnt(38): Failed to capture a vIDeo frame01-22 11:59:15.598: E/MediaMetadataRetrIEverJNI(572): getFrameatTime: vIDeoFrame is a NulL pointer01-22 11:59:15.598: D/AndroIDRuntime(572): Shutting down VM01-22 11:59:15.598: W/dalvikvm(572): threadID=1: thread exiting with uncaught exception (group=0x409961f8)01-22 11:59:15.608: E/AndroIDRuntime(572): FATAL EXCEPTION: main01-22 11:59:15.608: E/AndroIDRuntime(572): java.lang.NullPointerException
这是我正在使用的代码:
file vIDeoPath = new file(Environment.getExternalStorageDirectory(),"test.mp4");String vIDeo = vIDeoPath.getabsolutePath();MediaMetadataRetrIEver vIDfile = new MediaMetadataRetrIEver();vIDfile.setDataSource(vIDeo);//Create folder to store imagesString storageFolder = "/Storage";String extStorageDirectory = Environment.getExternalStorageDirectory().toString();file newFolder = new file(extStorageDirectory + storageFolder);newFolder.mkdir();String value = vIDfile.extractMetadata(MediaMetadataRetrIEver.MetaDATA_KEY_DURATION);long vIDLength = (Long.parseLong(value)/1000); //Returns milliseconds - divIDe by 1,000//VIDeo length = 30037ms - result is 30.037sfor(int i = 0; i <= 10*vIDLength; i++,image++) //10*vIDLength since I'm getting frames every 1/10th sec{ Bitmap bmp = vIDfile.getFrameatTime(100000*i,MediaMetadataRetrIEver.OPTION_CLOSEST); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.PNG,100,bytes); String imagename = String.format(Locale.ENGliSH,"%03d",image); file f = new file(Environment.getExternalStorageDirectory() + storageFolder + file.separator + imagename + ".png"); f.createNewfile(); fileOutputStream fo = new fileOutputStream(f); fo.write(bytes.toByteArray()); fo.close(); //Don't seem to make a difference one way or the other bytes.flush(); bytes.close(); }
就像我说的,它应该得到~300帧,但只能设法在崩溃前提取19帧,但我不明白为什么会发生NulL指针错误.
提前致谢
解决方法 您是否尝试过使用 FFmpegMediaMetadataRetriever lib而不是MediaMetadataRetrIEver?另外,从logcat上的这一行:
01-22 11:59:15.598: E/MediaMetadataRetrIEverJNI(572): getFrameatTime:
vIDeoFrame is a NulL pointer
我会尝试记录for循环的每一行,如Log.d(“MyApp”,“Param of getFrameatTime”(100000 * i));
我知道你已经知道哪个帧是问题(19/20),但只是看看在变成空指针之前该变量会发生什么(也许你可以使用Long i而不是int i?).
另外,您是否尝试使用上述建议来使用MediaMetadataRetrIEver.OPTION_CLOSEST_SYNC而不是OPTION_CLOSEST?
总结以上是内存溢出为你收集整理的android – MediaMetadataRetriever .getFrameAtTime(long,option)崩溃全部内容,希望文章能够帮你解决android – MediaMetadataRetriever .getFrameAtTime(long,option)崩溃所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)