From 1488792efb6fa8d676bf1111656081ba5ba0bc27 Mon Sep 17 00:00:00 2001 From: YongKang Zhou Date: Thu, 29 Aug 2024 16:22:54 +0800 Subject: [PATCH] Fix encoder_name param while initialising Client 1. Make `encoder_name` work again 2. Add `codec_name` param to work with encoder_name --- scrcpy/core.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scrcpy/core.py b/scrcpy/core.py index a9e1497..95ebc3d 100644 --- a/scrcpy/core.py +++ b/scrcpy/core.py @@ -33,6 +33,7 @@ def __init__( lock_screen_orientation: int = LOCK_SCREEN_ORIENTATION_UNLOCKED, connection_timeout: int = 3000, encoder_name: Optional[str] = None, + codec_name: Optional[str] = None, ): """ Create a scrcpy client, this client won't be started until you call the start function @@ -48,6 +49,7 @@ def __init__( lock_screen_orientation: lock screen orientation, LOCK_SCREEN_ORIENTATION_* connection_timeout: timeout for connection, unit is ms encoder_name: encoder name, enum: [OMX.google.h264.encoder, OMX.qcom.video.encoder.avc, c2.qti.avc.encoder, c2.android.avc.encoder], default is None (Auto) + codec_name: codec name, enum: [h264, h265, av1], default is None (Auto) """ # Check Params assert max_width >= 0, "max_width must be greater than or equal to 0" @@ -66,6 +68,12 @@ def __init__( "c2.qti.avc.encoder", "c2.android.avc.encoder", ] + assert codec_name in [ + None, + "h264", + "h265", + "av1" + ] # Params self.flip = flip @@ -77,6 +85,7 @@ def __init__( self.lock_screen_orientation = lock_screen_orientation self.connection_timeout = connection_timeout self.encoder_name = encoder_name + self.codec_name = codec_name # Connect to device if device is None: @@ -154,6 +163,8 @@ def __deploy_server(self) -> None: f"max_size={self.max_width}", f"max_fps={self.max_fps}", f"video_bit_rate={self.bitrate}", + f"video_encoder={self.encoder_name}" if self.encoder_name else "video_encoder=OMX.google.h264.encoder", + f"video_codec={self.codec_name}" if self.codec_name else "video_codec=h264", "tunnel_forward=true", "send_frame_meta=false", "control=true", @@ -161,8 +172,9 @@ def __deploy_server(self) -> None: "show_touches=false", "stay_awake=false", "power_off_on_close=false", - "clipboard_autosync=false" + "clipboard_autosync=false", ] + print(commands) self.__server_stream: AdbConnection = self.device.shell( commands,