mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-07-29 04:08:56 +00:00
Enable video output file, with pts set by server
This commit is contained in:
parent
b5c64c0f5a
commit
d706c5df39
7 changed files with 126 additions and 10 deletions
|
@ -3,6 +3,7 @@ package com.genymobile.scrcpy;
|
|||
import com.genymobile.scrcpy.wrappers.SurfaceControl;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.media.MediaMuxer;
|
||||
import android.media.MediaCodec;
|
||||
import android.media.MediaCodecInfo;
|
||||
import android.media.MediaFormat;
|
||||
|
@ -80,6 +81,8 @@ public class ScreenEncoder implements Device.RotationListener {
|
|||
private boolean encode(MediaCodec codec, FileDescriptor fd) throws IOException {
|
||||
boolean eof = false;
|
||||
MediaCodec.BufferInfo bufferInfo = new MediaCodec.BufferInfo();
|
||||
ByteBuffer bBuffer = ByteBuffer.allocate(16);
|
||||
|
||||
while (!consumeRotationChange() && !eof) {
|
||||
int outputBufferId = codec.dequeueOutputBuffer(bufferInfo, -1);
|
||||
eof = (bufferInfo.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0;
|
||||
|
@ -90,6 +93,12 @@ public class ScreenEncoder implements Device.RotationListener {
|
|||
}
|
||||
if (outputBufferId >= 0) {
|
||||
ByteBuffer codecBuffer = codec.getOutputBuffer(outputBufferId);
|
||||
bBuffer.position(0);
|
||||
bBuffer.putLong(bufferInfo.presentationTimeUs);
|
||||
bBuffer.putInt(bufferInfo.flags);
|
||||
bBuffer.putInt(codecBuffer.remaining());
|
||||
bBuffer.position(0);
|
||||
IO.writeFully(fd, bBuffer);
|
||||
IO.writeFully(fd, codecBuffer);
|
||||
}
|
||||
} finally {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue