MediaExtractor.setDataSource抛出IOException异常"未能实例提取" [英] MediaExtractor.setDataSource throws IOException "failed to instantiate extractor"

查看:2564
本文介绍了MediaExtractor.setDataSource抛出IOException异常"未能实例提取"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android 4.2和呼叫MediaExtractor.setDataSource,它的有时的抛出的失败实例提取一个IOException。我发现这哪里是从C ++实现抛出,但它并没有帮助。

I'm on Android 4.2 and calling MediaExtractor.setDataSource, and it sometimes throws an IOException of "failed to instantiate extractor". I've found where this is thrown from the C++ implementation, but it hasn't helped.

同样的问题,要么没有答案或者回答别人不帮我是:

Other people with the same problem and either no answer or an answer which doesn't help me are:

<一个href=\"http://stackoverflow.com/questions/14527797/android-media-mediaextractor-anyone-got-this-beast-to-work-failed-to-instanti\">android.media.MediaExtractor.任何人都得到这畜生工作? &QUOT;无法实例提取&QUOT;例外

<一个href=\"http://stackoverflow.com/questions/12671989/media-extractor-show-failed-to-instantiate-extractor\">media提取秀&QUOT;未能实例提取器QUOT;

<一个href=\"http://stackoverflow.com/questions/17398111/failed-to-instantiate-mediaextractor-when-using-setdatasource\">Failed使用的setDataSource当实例mediaextractor()

在拼命想出解决办法,我写最小的小应用程序,我可以这表明它:

In a desperate attempt to figure this out I've written the smallest little app I could which demonstrates it:

public class MainActivity extends Activity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
  }
  public boolean doStuff(View view) {
    File f = getExternalFilesDir(null);
    File[] files = f.listFiles();
    for (File file : files) {
      if (file.isFile()) {
        Log.e("Andy", "trying file [" + file.getName() + "]");
        startExtractor(file);
      }
    }
    return true;
  }
  private void startExtractor(File f) {
    MediaExtractor extractor = new MediaExtractor();
    try {
      extractor.setDataSource(f.getAbsolutePath());
    } catch (IOException e) {
      Log.e("Andy", "splat " + e.getMessage());
    }
    extractor.release();
  }
}

为这个应用程序的活动有一个按钮,它调用doStuff。输出看起来是这样的:

The activity for this app has a single button, which calls "doStuff". The output looks like this:

05-12 15:27:42.639: E/Andy(18757): trying file [aaitn.mp4]
05-12 15:27:42.689: E/Andy(18757): splat Failed to instantiate extractor.
05-12 15:27:42.689: E/Andy(18757): trying file [unusual aspect.mp4]
05-12 15:27:42.709: E/Andy(18757): trying file [test.mp4]
05-12 15:27:55.039: E/Andy(18757): trying file [aaitn.mp4]
05-12 15:27:55.119: E/Andy(18757): trying file [unusual aspect.mp4]
05-12 15:27:55.149: E/Andy(18757): trying file [test.mp4]
05-12 15:28:03.209: E/Andy(18757): trying file [aaitn.mp4]
05-12 15:28:03.259: E/Andy(18757): splat Failed to instantiate extractor.
05-12 15:28:03.259: E/Andy(18757): trying file [unusual aspect.mp4]
05-12 15:28:03.279: E/Andy(18757): trying file [test.mp4]
05-12 15:28:12.289: E/Andy(18757): trying file [aaitn.mp4]
05-12 15:28:12.379: E/Andy(18757): trying file [unusual aspect.mp4]
05-12 15:28:12.419: E/Andy(18757): trying file [test.mp4]
05-12 15:28:17.879: E/Andy(18757): trying file [aaitn.mp4]
05-12 15:28:17.929: E/Andy(18757): trying file [unusual aspect.mp4]
05-12 15:28:17.949: E/Andy(18757): splat Failed to instantiate extractor.
05-12 15:28:17.949: E/Andy(18757): trying file [test.mp4]

这是在几个计数混乱。


  • 有时工作,有时不

  • 它失败的第一个尝试。

现在,我相当肯定,其他人都在使用这个接口,它是为他们工作,这意味着要么我使用已经打破​​固件的设备(MK808s),或有一招我缺少做可靠。没有人有任何想法?

Now, I'm fairly sure that other people are using this interface and it is working for them, which either means the devices I'm using (MK808s) have broken firmware, or there's a trick I'm missing to make it reliable. Does anyone have any ideas?

在logcat的是,除了当GC踢,和GC时间不相关的问题非常的清晰。

The logcat is amazingly clear except when the GC kicks in, and the GC timing doesn't correlate to the problem.

我改变了我的按钮,将推出其在所有三个文件循环1000次线程。它一路跑,没有烦恼。很多挠头。我发现的如果我扭动鼠标而线程运行时它开始出现问题的,但将立即开始工作了,因为我放手。运行另一个线程,只是周围的食堂做数学一段时间的没有的原因吧。在现实世界中应用这个来自,取出鼠标不会使问题消失,但它是一个大的应用程序,并做了很多其他的东西了。

I changed my button so that it would launch a thread which loops 1000 times over all three files. It ran all the way, no trouble. Much head scratching. I have found that if I wiggle the mouse while that thread is running it starts failing, but it starts working again as soon as I let go. Running yet another thread that just messes around doing maths for a while didn't cause it. In the real world app this came from, removing the mouse doesn't make the problem go away, but it's a big app and does a lot of other stuff too.

推荐答案

这样看来,如果不是要求它从文件中提取,我打开文件我自己,得到一个输入流,从输入获得的FileDescriptor流,然后要求其从文件描述符中提取,它屡试不爽。即使我扭动鼠标!

It would appear that if, instead of asking it to extract from a file, I open the file myself, get an input stream, get the FileDescriptor from the input stream, and then ask it to extract from the file descriptor, it works every time. Even if I wiggle the mouse!

我会粉笔高达Android的一个bug,去回答用这个复制粘贴一些其他人的问题。不知道这是正确的协议在这种情况下?

I'll chalk that up to a bug in android and go answer some other peoples questions with a copy paste of this. Not sure if that is the correct protocol in this case?

这篇关于MediaExtractor.setDataSource抛出IOException异常&QUOT;未能实例提取&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆