Sarfraz Ahmed
Sarfraz Ahmed

Reputation: 1399

Exception thrown when calling MediaExtractor.setDataSource()

I placed my raw H264 stream in a file and put it on internal storage. when I access the file using File class it works fine but when I use following code it gives exception

W/System.err: java.io.IOException: Failed to instantiate extractor.

String filePath = Environment.getExternalStorageDirectory() + "/Videos/Video_30.h264";
    try
    {
      extractor = new MediaExtractor();  
      extractor.setDataSource(FilePath);
    }catch(IOException e)
    {
      e.printStackTrace();
    }

I also used Filedescriptor instead of filePath but it also did not work. How can I solve this? Thanks

Edit: File permissions are added in manifest file so there is no permission issue.

Upvotes: 1

Views: 1700

Answers (1)

Sarfraz Ahmed
Sarfraz Ahmed

Reputation: 1399

My "Video_30.h264" is raw h264 stream that is not inside any container. while MediaExtractor.setDataSource(source) expects Stream inside supported containers like mp4, etc. I put my raw stream in mp4 container and it worked fine. hope this would help.

Upvotes: 2

Related Questions