Running ExtractDecodeEditEncodeMuxTest outside of testcase on Android

[亡魂溺海] 提交于 2019-12-02 08:29:21

问题


I am trying to add functionality to extract, decode, edit, encode and mux a video on Android. Therefore, I found some very useful implementation, which is part of the Android CTS ExtractDecodeEditEncodeMuxTest. Unfortunately, the code only works if it is executed as part of the testcase. I tried to execute it from a normal activity and get:

E/ExtractDecodeEditEncodeMuxTest (18781): java.lang.IllegalStateException: Failed to stop the muxer

W/System.err(18781): java.lang.RuntimeException: Surface frame wait timed out W/System.err(18781): at ...OutputSurface.awaitNewImage(OutputSurface.java:216)

Any ideas, why the output surface does not receive the frames?

UPDATE: Here are the log files for the working test case and the non-working implementation. The code for both is exactly the same. The only difference is that the working one is an AndroidTestCase and the other one is running in the application within an IntentService.

It seems that the whole thing stops extracting and decoding after about 6 frames. Any ideas?

Working Testcase Logoutput

Non-Working Log Output


回答1:


morelikely you need to run it in separate thread

    public static void runTest(ExtractDecodeEditEncodeMuxTest test) throws Throwable {
        test.setOutputFile();
        TestWrapper wrapper = new TestWrapper(test);
        Thread th = new Thread(wrapper, "codec test");
        th.start();
        th.join();
        if (wrapper.mThrowable != null) {
            throw wrapper.mThrowable;
        }
    }



回答2:


Thank's to fadden, I was able to resolve this issue. I am using an intent service now and start a thread without looper there, which works fine.

For running the code in an Android service, this means that the wrapping thread has to be started from a custom thread. Starting a thread within a thread is probably not the very best solution, but it actually solves the problem.



来源:https://stackoverflow.com/questions/24733805/running-extractdecodeeditencodemuxtest-outside-of-testcase-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!