Encode video using MediaCodec API
Replace screenrecord execution by manual screen encoding using the MediaCodec API. The "screenrecord" solution had several drawbacks: - screenrecord output is buffered, so tiny frames may not be accessible immediately; - it did not output a frame until the surface changed, leading to a black screen on start; - it is limited to 3 minutes recording, so it needed to be restarted; - screenrecord added black borders in the video when the requested dimensions did not preserve aspect-ratio exactly (sometimes unavoidable since video dimensions must be multiple of 8); - rotation handling was hacky (killing the process and starting a new one). Handling the encoding manually allows to solve all these problems.
This commit is contained in:
@@ -65,8 +65,8 @@ public class DesktopConnection implements Closeable {
|
||||
outputStream.write(buffer, 0, buffer.length);
|
||||
}
|
||||
|
||||
public void sendVideoStream(byte[] videoStreamBuffer, int len) throws IOException {
|
||||
outputStream.write(videoStreamBuffer, 0, len);
|
||||
public OutputStream getOutputStream() {
|
||||
return outputStream;
|
||||
}
|
||||
|
||||
public ControlEvent receiveControlEvent() throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user