How to decode video with mime type application/octet-stream using mediaCodec decoder

Viewed 466

I need to decode videos into frames. I am able to do this for mime type video but it doesn't work with application/octet-stream.

for (int i = 0; i < extractor.getTrackCount(); i++) {
                MediaFormat format = extractor.getTrackFormat(i);
                String mime = format.getString(MediaFormat.KEY_MIME);
                System.out.println(mime);
                if (mime.startsWith("application/")) {
                    extractor.selectTrack(i);
                    try {
                        decoder = MediaCodec.createDecoderByType(mime);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    decoder.configure(format, null, null, 0);
                    break;
                }
            }

The error I get is below.

E/libc: Access denied finding property "ro.kirin.product.platform"
W/HwExtendedCodec: The mime is not in hisi extended mime.
W/Thread-3: type=1400 audit(0.0:81515): avc: denied { read } for pid=23409 name="u:object_r:product_platform_prop:s0" dev="tmpfs" ino=15947 scontext=u:r:untrusted_app:s0:c111,c257,c512,c768 tcontext=u:object_r:product_platform_prop:s0 tclass=file permissive=0
W/MediaCodec-JNI: try to release MediaCodec from JMediaCodec::~JMediaCodec()...
    done releasing MediaCodec from JMediaCodec::~JMediaCodec().
I/QarthLog: [PatchStore] createDisableExceptionQarthFile
I/QarthLog: [PatchStore] create disable file for com.example.mp4decoder uid is 10367
E/AndroidRuntime: FATAL EXCEPTION: Thread-3
    Process: com.example.mp4decoder, PID: 23409
    java.lang.IllegalArgumentException: Failed to initialize application/octet-stream, error 0xfffffffe
        at android.media.MediaCodec.native_setup(Native Method)
        at android.media.MediaCodec.<init>(MediaCodec.java:1864)
        at android.media.MediaCodec.createDecoderByType(MediaCodec.java:1809)
        at com.example.mp4decoder.MainActivity$PlayerThread.run(MainActivity.java:108)
1 Answers

As I understand it, MediaCodec just support Audio or Video Format. I do not think "application/octet-stream" is a video format. Video format should start with "video/", like "video/avc","video/hevc" etc. I think you got "application/octet-stream" because the stream is not a video stream or MediaExtractor does not know the stream format.

Related