0

我正在使用意图服务使用FFMPEG库压缩少量视频文件,压缩后,使用 FTP 将这些文件存储在服务器上。所以,我启动了一个线程来等待FFPEG execute()方法,直到它成功完成。

然后,我使用 FTP 将这些文件存储在服务器上。工作正确完成,但最终返回illegalStateException

MessageQueue: Handler (android.view.ViewRootImpl$ViewRootHandler) {8895619} 在死线程上向 Handler 发送消息

如果我有 10 个文件,则此异常返回 10 次。此异常的原因可能是什么以及如何避免它。

这是我正在使用的处理程序:

            fFmpeg.execute(command, new ExecuteBinaryResponseHandler() {
            @Override
            public void onFailure(String s) {
                System.out.println(idx + "----------Failure: \n" + s.toString());
            }

            @Override
            public void onSuccess(String s) {
                System.out.println(idx+ "----------Success: \n" + s.toString());
            }

            @Override
            public void onProgress(String s) {
            }

            @Override
            public void onStart() {
                System.out.println(idx+ " started");
            }

            @Override
            public void onFinish() {
                totalProcessedFileCount++;
                System.out.println(idx + "*****************Finished "+ totalProcessedFileCount);
            }
        });
4

1 回答 1

0

您可以尝试在单独的线程上运行处理程序。

HandlerThread handlerThread = new HandlerThread();
handlerThread.start();

并将处理程序附加到新线程

new ExecuteBinaryResponseHandler(mHandlerThread.getLooper());
于 2017-01-20T14:21:04.970 回答