相关疑难解决方法(0)

SurfaceTexture的onFrameAvailable()方法总是被调用太晚了

我正在尝试使用以下MediaExtractor示例:

http://bigflake.com/mediacodec/ - ExtractMpegFramesTest.java(需要4.1,API 16)

我遇到的问题是outputSurface.awaitNewImage(); 似乎总是抛出RuntimeException("frame wait timed out"),每当mFrameSyncObject.wait(TIMEOUT_MS)调用超时时抛出它.无论我设置什么TIMEOUT_MS,onFrameAvailable()总是在超时发生后立即调用.我尝试了50毫秒和30000毫秒,它是相同的.

似乎onFrameAvailable()在线程繁忙时无法进行调用,并且一旦超时发生并结束线程代码执行,它就可以解析onFrameAvailable()调用.

有没有人设法让这个例子工作,或者知道MediaExtractor应该如何使用GL纹理?

编辑:在使用API​​ 4.4和4.1.1的设备上尝试了这一点,两者都发生了同样的情况.

编辑2:

得益于fadden 4.4.问题是ExtractMpegFramesWrapper.runTest()调用的方法th.join();阻塞了主线程并阻止了onFrameAvailable()调用的处理.一旦我评论th.join();它就适用于4.4.我想也许ExtractMpegFramesWrapper.runTest()本身应该在另一个线程上运行,所以主线程没有被阻止.

4.1.2调用时还有一个小问题codec.configure(),它给出了错误:

A/ACodec(2566): frameworks/av/media/libstagefright/ACodec.cpp:1041 CHECK(def.nBufferSize >= size) failed.
A/libc(2566): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 2625 (CodecLooper)
Run Code Online (Sandbox Code Playgroud)

通过在通话前添加以下内容我解决了这个问题:

format.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, 0);
Run Code Online (Sandbox Code Playgroud)

然而,我现在在4.1.1(Galaxy S2 GT-I9100)和4.1.2(三星Galaxy Tab GT-P3110)上的问题是它们都始终将info.size设置为0以用于所有帧.这是日志输出:

loop
input buffer not available
no output from decoder available
loop
input …
Run Code Online (Sandbox Code Playgroud)

android opengl-es mediacodec mediaextractor

22
推荐指数
1
解决办法
1万
查看次数

使用MediaCodec截断视频

我使用Android MediaCodec库来转码视频文件(主要是在这里更改分辨率示例代码)

我想要实现的另一件事是截断视频 - 仅开始15秒.逻辑是检查videoExtractor.getSampleTime()它是否大于15秒,我只是写一个EOS解码器缓冲区.

但我得到一个例外 Caused by: android.media.MediaCodec$CodecException: Error 0xfffffff3

这是我的代码:

        while ((!videoEncoderDone) || (!audioEncoderDone)) {
        while (!videoExtractorDone
                && (encoderOutputVideoFormat == null || muxing)) {
            int decoderInputBufferIndex = videoDecoder.dequeueInputBuffer(TIMEOUT_USEC);
            if (decoderInputBufferIndex == MediaCodec.INFO_TRY_AGAIN_LATER)
                break;

            ByteBuffer decoderInputBuffer = videoDecoderInputBuffers[decoderInputBufferIndex];
            int size = videoExtractor.readSampleData(decoderInputBuffer, 0);
            long presentationTime = videoExtractor.getSampleTime();

            if (size >= 0) {
                videoDecoder.queueInputBuffer(
                        decoderInputBufferIndex,
                        0,
                        size,
                        presentationTime,
                        videoExtractor.getSampleFlags());
            }
            videoExtractorDone = !videoExtractor.advance();

            if (!videoExtractorDone && videoExtractor.getSampleTime() > mVideoDurationLimit * 1000000) { …
Run Code Online (Sandbox Code Playgroud)

android mediacodec

8
推荐指数
1
解决办法
639
查看次数

调用MediaCodec.configure()时出现非法状态异常

我在MediaCodec.configure()行上得到了IllegalStateException,我正在尝试使用MediaCodec录制音频.这只发生在某些手机上,标签上的一切都很好.这个特殊的崩溃示例来自三星Galaxy S4.异常痕迹:

01-22 17:33:38.379: V/ACodec(16541): [OMX.google.aac.decoder] Now Loaded
01-22 17:33:38.379: V/ACodec(16541): onConfigureComponent
01-22 17:33:38.379: W/ACodec(16541): [OMX.google.aac.decoder] Failed to set standard component role 'audio_encoder.aac'.
01-22 17:33:38.379: E/ACodec(16541): [OMX.google.aac.decoder] configureCodec returning error -2147483648
01-22 17:33:38.379: E/MediaCodec(16541): Codec reported an error. (omx error 0x80001001, internalError -2147483648)
01-22 17:33:38.384: D/AndroidRuntime(16541): Shutting down VM
01-22 17:33:38.384: W/dalvikvm(16541): threadid=1: thread exiting with uncaught exception (group=0x418d0700)
01-22 17:33:38.414: W/BugSenseHandler(16541): Transmitting crash Exception Unable to resolve host "bugsense.appspot.com": No address associated with hostname
01-22 17:33:41.404: E/AndroidRuntime(16541): FATAL EXCEPTION: …
Run Code Online (Sandbox Code Playgroud)

android codec audio-recording mediacodec

7
推荐指数
1
解决办法
9693
查看次数