问题
I'm trying to use the Live Camera Recording ( With Opengl ) from the Sample Code Grafika. Every things works fine on my Moto G but i try in my other device (Galaxy Tab 2 with Cyanogendmod 11) it's seems the method : signalEndofInputStream() is not working and the Encoder never stop. It's there a way to send the signal to the MediaCodec in an other way ?
Sorry for bad English.
回答1:
You can work around it.
If you look at DecodeEditEncodeTest, you can see a mysterious boolean called WORK_AROUND_BUGS
. It's used like this:
if (WORK_AROUND_BUGS) {
// Might drop a frame, but at least we won't crash mediaserver.
try { Thread.sleep(500); } catch (InterruptedException ie) {}
outputDone = true;
} else {
encoder.signalEndOfInputStream();
}
This was used during the development of the CTS tests, when the vendor-specific code wasn't yet working well with the end-of-stream signal. It was added so we could exercise other features while the vendors worked on patches. The flag was disabled before the tests shipped in 4.3. You're probably running into unpatched codecs on Cyanogen.
The workaround is to simply never send the end-of-stream signal. Instead, you just stop the codec. There is some chance that an in-flight buffer will be lost and you will drop a frame, but for a live recording this may not matter. (It's more of an issue for video editing.)
来源:https://stackoverflow.com/questions/22222059/mediacodec-signalendofinputstream-error