Equipment screen copying method and system, medium and electronic equipment
Video rendering through a web graphics processor and using Android debugging bridge and scrcpy services to realize video stream replication of mobile device screens, solving the complex and cost-effective solutions in the existing technology, achieving efficient screen projection and reducing server operation and maintenance costs.
Patent Information
- Application Number
- CN202411955794.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-27
- Publication Date
- 2025-03-28
AI Technical Summary
The prior art realizes screen projection from a mobile device screen to a web page, the solution is complex and costly, and wastes computer resources.
Video rendering is achieved through a web graphics processor, using Android debugging bridge and scrcpy services to realize video streaming replication of mobile device screens without running and maintaining servers.
It realizes efficient video streaming replication of mobile device screens, reduces server operation and maintenance costs, and uses local hardware resources to improve video processing performance.
Smart Images

Figure CN119729084A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of streaming media processing, and in particular to a device screen duplication method, system, medium and electronic device. Background Art
[0002] At present, with the popularity of mobile devices and the development of the Internet, mobile devices have become a part of people's lives. There are many scenarios in which the screen of a mobile device can be projected onto a web page for easy use by users. Most of the current technical solutions are based on WebAssembly or streaming media servers. The technical solutions are complex, the implementation cost is high, and computer resources are wasted. Summary of the invention
[0003] The purpose of this application is to provide a device screen replication method, system, computer-readable storage medium and electronic device, which can render video through a Web graphics processor and absorb screen replication of mobile devices without running and maintaining a server.
[0004] In order to solve the above technical problems, this application provides a device screen duplication method, and the specific technical solution is as follows:
[0005] After starting the Android Debug Bridge, a TCP client is created locally as a client of the Android Debug Bridge server, for receiving information of the Android Debug Bridge server;
[0006] Establishing a communication connection between the Android debug bridge server and the target device through the TCP client so that the Android debug bridge server pushes the scrcpy server file to the target device;
[0007] Starting the scrcpy service based on the scrcpy server file and executing the Android debug bridge server command to enable the socket service;
[0008] Create a scrcpy client and create a socket client according to the socket service;
[0009] On the socket client, a canvas is created, and the video stream of the target device is used as a texture in the form of video frames and rendered on the canvas through a Web graphics processor to perform video stream replication of the target device.
[0010] Optionally, before establishing a communication connection between the Android debug bridge server and the target device through the TCP client, the following steps are included:
[0011] Read the list of historically connected devices and the list of currently debuggable devices;
[0012] Comparing the current adjustable device list with the historical connected device list;
[0013] If the current adjustable device list and the historical connected device list contain the same device, use the same device as the target device;
[0014] If the current debuggable device list and the historical connection device list do not contain the same device, the target device is determined from the current debuggable device list.
[0015] Optionally, after establishing a communication connection between the Android debug bridge server and the target device through the TCP client, the method further includes:
[0016] Determining a transmission channel between the target device and the Android Debug Bridge server;
[0017] A transmission ID is generated based on the transmission channel, where the transmission ID is used to identify the target device.
[0018] Optionally, after starting the scrcpy service, also include:
[0019] A random number is generated, where the random number is used to generate a service name for the socket service.
[0020] Optionally, creating a canvas, using the video stream of the target device in the form of video frames as a texture, and rendering on the canvas through a Web graphics processor includes:
[0021] Create a canvas element, obtain and configure the context information of the Web graphics processor;
[0022] Parsing the video stream of the target device using a video decoder to obtain a video frame;
[0023] Importing the video frame as a texture into a shader program of the Web graphics processor;
[0024] Configure texture sampling rules and texture coordinate wrapping rules;
[0025] The Web graphics processor drawing command is called to control the Web graphics processor to enable the shader program to render the video frame texture according to the configured texture sampling rule and the texture coordinate wrapping rule.
[0026] Optionally, when the video stream of the target device is parsed by using a video decoder to obtain a video frame, the method further includes:
[0027] Create a write stream to receive the video stream in the socket service;
[0028] The write stream is used to perform the following judgment:
[0029] Determining whether the video stream contains configuration parameters;
[0030] If yes, updating the canvas size of the canvas element according to the cropped size of the video frame, and configuring the media type of the video decoder according to the configuration parameters;
[0031] If not, a video data block is created and passed to the video decoder to decode the video stream into video frames; the video data block is used to transmit the video stream to the video decoder.
[0032] Optionally, if the historical connection device list does not include the target device, the method further includes:
[0033] The target device is added to the historical connection device list, and the device name and device serial number of the target device are recorded.
[0034] The present application also provides a device screen duplication system, including:
[0035] A client creation module is used to create a TCP client locally as a client of the Android Debug Bridge server after starting the Android Debug Bridge, and is used to receive information of the Android Debug Bridge server;
[0036] A file push module, used to establish a connection between the Android debug bridge server and the target device, so that the Android debug bridge server pushes the scrcpy server file to the target device;
[0037] A socket service enabling module, used to start the scrcpy service based on the scrcpy server file, and execute an Android debug bridge server command to enable the socket service;
[0038] A socket client creation module, used to create a scrcpy client, and to create a socket client according to the socket service;
[0039] The video replication module is used to create a canvas on the socket client, use the video stream of the target device in the form of video frames as texture, and render it on the canvas through a Web graphics processor to perform video stream replication of the target device.
[0040] The present application also provides a computer-readable storage medium having a computer program stored thereon, and the computer program implements the steps of the above-mentioned method when executed by a processor.
[0041] The present application also provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps of the above-mentioned method when calling the computer program in the memory.
[0042] The present application provides a device screen copying method, comprising: after starting an Android debug bridge, locally creating a TCP client as a client of an Android debug bridge server, for receiving information of the Android debug bridge server; establishing a communication connection between the Android debug bridge server and a target device through the TCP client, so that the Android debug bridge server pushes a scrcpy server file to the target device; starting a scrcpy service based on the scrcpy server file, executing an Android debug bridge server command to enable a socket service; creating a scrcpy client, and creating a socket client according to the socket service; on the socket client, creating a canvas, using the video stream of the target device as a texture in the form of video frames, and rendering on the canvas through a Web graphics processor to perform video stream copying of the target device.
[0043] When executing the target device screen copy, this application uses the Android Debug Bridge to create a local TCP client as the client of the Android Debug Bridge server, thereby realizing the use of JavaScript language to build the client of the scrcpy service, enabling the scrcpy server on the target device, and displaying the video stream on the target device screen as a component of the web page. At the same time, on the socket client, the video stream is displayed through the created canvas, which is convenient for adjusting the canvas size according to the frame size of the video stream. In addition, this application uses the Web graphics processor to render the video, which can use local hardware resources to improve the video processing performance, without the need for a remote server to render the video, saving the server's operation and maintenance costs.
[0044] The present application also provides a device screen copying system, a computer-readable storage medium and an electronic device, which have the above-mentioned beneficial effects and are not described in detail here. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0046] Figure 1 A flowchart of a device screen copying method provided in an embodiment of the present application;
[0047] Figure 2 A flowchart of the video rendering process provided by an embodiment of the present application;
[0048] Figure 3 A schematic diagram of the structure of a device screen duplication system provided in an embodiment of the present application;
[0049] Figure 4 A structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0051] The object information involved in this application, including but not limited to the object device information, object personal information, etc., and data, including but not limited to data used for analysis, stored data, displayed data, etc., are all information and data authorized by the object or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the laws, regulations and standards of relevant countries and regions.
[0052] See also Figure 1 , Figure 1 A flowchart of a device screen copying method provided in an embodiment of the present application, the method comprising:
[0053] S101: After starting the Android Debug Bridge, a TCP client is created locally as a client of the Android Debug Bridge server;
[0054] S102: establishing a communication connection between the Android debug bridge server and the target device through the TCP client, so that the Android debug bridge server pushes the scrcpy server file to the target device;
[0055] S103: starting the scrcpy service based on the scrcpy server file, and executing an Android debug bridge server command to enable a socket service;
[0056] S104: creating a scrcpy client, and creating a socket client according to the socket service;
[0057] S105: On the socket client, a canvas is created, and the video stream of the target device is used as a texture in the form of video frames and rendered on the canvas through a Web graphics processor to perform video stream replication of the target device.
[0058] Android Debug Bridge refers to the ADB (Android Debug Bridge) service. The target device of this application needs to turn on the USB debugging switch in order to connect to the Android Debug Bridge (ADB, Android Debug Bridge).
[0059] First, after starting the Android Debug Bridge, you can specifically start the ADB service through the command adb start-server, and create a TCP client locally as the client of the Android Debug Bridge server to receive information from the Android Debug Bridge server. The port number of the TCP client is not limited here, for example, the default port number 5037 can be used.
[0060] In an optional execution mode, before executing step 102, the historical connection device list and the current debuggable device list may be read first, and the current debuggable device list and the historical connection device list may be compared:
[0061] If the current adjustable device list and the historical connected device list contain the same device, use the same device as the target device;
[0062] If the current debuggable device list and the historical connection device list do not contain the same device, the target device is determined from the current debuggable device list.
[0063] You can open the device management page of the target device to read the historical connected device list connectedDevices. Then use the ADB server command host:track-devices to get the current adjustable device list as deviceList. The track-devices command can respond to the connection status and debugging status of the connected device in real time.
[0064] Compare the current adjustable device list deviceList with the historical connected device list connectedDevices to determine whether there is a device that has been connected. If so, traverse the historical connected device list connectedDevices and compare it with the current adjustable device list deviceList to obtain the first connectable device information device. Otherwise, take the first device in deviceList and get the transportId of the target device to be connected.
[0065] When executing S102 , a server command host:transport-id:${transportId} may be used to establish a connection between the target device and the server.
[0066] In a feasible implementation manner, the transmission channel between the target device and the Android debug bridge server may be determined first, and then a transmission ID may be generated based on the transmission channel, and the transmission ID is used to identify the target device.
[0067] Note that the transport ID, or transportId, is used here to identify the device instead of the device serial number. This is because the serial numbers of mobile devices produced by different manufacturers may be the same. The transportId is a transmission channel ID temporarily created when the ADB service detects that the device can be debugged. It is unique in the same ADB service. Using this field can avoid connecting to the wrong device.
[0068] Specifically, you can use the command adb push scrcpy-server / data / local / tMP24030444 / scrcpy-server.jar to push the scrcpy server file to the mobile device.
[0069] In step S103, the scrcpy service can be started based on the scrcpy server file, and the Android debug bridge server command can be executed to enable the socket service. Specifically, the scrcpy service is started first, and a random number scid can be generated. This random number is used to generate the service name of the socket service by executing the ADB server command:
[0070] exec:CLASSPATH= / data / local / tMP24030444 / scrcpy-server.jar app_process / com.genymobile.scrcpy.Server 2.3.1 log_level=verbose tunnel_forward=truescid= <scid>audio=false;
[0071] 2.3.1 indicates the version of scrcpy, tunnel_forward=true specifies that the ADB tunnel is a forward connection, and audio=false disables audio. After this command is successfully executed, a socket service will be started on the target device, and its name is localabstract:scrcpy_ <scid>.
[0072] In step S104, a scrcpy client needs to be created, and the development document of scrcpy discloses the docking protocol with the scrcpy service, and the same protocol can be used to communicate with the scrcpy service. The client and server establish communication using separate video, audio, and control sockets.
[0073] According to the random number scid generated in the above steps, get the corresponding socket name localabstract:scrcpy_ <scid>, created on the socket client for receiving video stream and control stream respectively.
[0074] After scrcpy is successfully started, the original video stream from the target device will be received in real time in the socket client that receives the video stream.
[0075] Thereafter, a canvas is created on the socket client, and the video stream of the target device is used as a texture in the form of video frames and rendered on the canvas by a Web graphics processor, thereby achieving video stream replication of the target device.
[0076] When executing the target device screen copy, the embodiment of the present application uses the Android Debug Bridge to create a local TCP client as the client of the Android Debug Bridge server, thereby realizing the use of JavaScript language to build the client of the scrcpy service, enabling the scrcpy server on the target device, and displaying the video stream on the screen of the target device as a component of the web page. At the same time, on the socket client, the video stream is displayed by the created canvas, which is convenient for adjusting the canvas size according to the frame size of the video stream. In addition, the present application uses the Web graphics processor to render the video, which can utilize local hardware resources to improve the video processing performance, without the need for a remote server to render the video, saving the server's operation and maintenance costs.
[0077] For step 105, see Figure 2 , Figure 2 The video rendering process flow chart provided in the embodiment of the present application may include:
[0078] S201: Create a canvas element, obtain and configure the context information of the Web graphics processor;
[0079] S202: parsing the video stream of the target device using a video decoder to obtain a video frame;
[0080] S203: Importing the video frame as a texture into the shader program of the Web graphics processor;
[0081] S204: configuring texture sampling rules and texture coordinate wrapping rules;
[0082] S205: Calling a Web graphics processor drawing command to control the Web graphics processor to enable the shader program to render the video frame texture according to the configured texture sampling rule and the texture coordinate wrapping rule.
[0083] During the video rendering process, the WebCodecs API may be used to decode and render the video stream in the browser. The video stream standard is not limited, including but not limited to the H.264 standard video stream.
[0084] Texture sampling rules mainly involve how to get color values from the texture based on given texture coordinates, and texture coordinate wrapping rules determine what to do when texture coordinates exceed the standard range of [0.0, 1.0].
[0085] Taking the H.264 standard video stream as an example, a specific implementation process may be as follows:
[0086] Create an HTML <canvas>The element obtains and configures the context information of the Web graphics processor, which can specify where to render the graphics, thereby allowing the Web graphics processor to use the video frames decoded from the video stream as textures and interact with the Web graphics processor for rendering.
[0087] Use the VideoDecoder API to create a video decoder corresponding to the H.264 standard video stream.
[0088] The video decoder uses the H.264 standard protocol to parse video stream data.
[0089] Import video frames as textures into the shader program of the Web GPU.
[0090] Create a sampler, configure the texture sampling rule as neighbor filtering, and configure the texture coordinate wrapping rule to clamp the coordinates of the excess part to the edge to prevent boundary artifacts.
[0091] A Web graphics processor drawing command is initiated and submitted to the Web graphics processor, and the Web graphics processor performs video frame texture rendering.
[0092] When decoding the video stream data, a write stream may be further created to receive the video stream in the socket service;
[0093] The write stream is used to perform the following judgment process:
[0094] Determining whether the video stream contains configuration parameters;
[0095] If yes, updating the canvas size of the canvas element according to the cropped size of the video frame, and configuring the media type of the video decoder according to the configuration parameters;
[0096] If not, a video data block is created and passed to the video decoder to decode the video stream into video frames; the video data block is used to transmit the video stream to the video decoder.
[0097] In the processing of video streams, configuration parameters (also called SPS / PPS, i.e. sequence parameter set and picture parameter set) are part of the H.264 / AVC video coding standard, which contain key information required to decode the video stream, such as resolution, frame rate, color format, etc. Usually, these parameters are sent at the beginning of the video stream so that the decoder can correctly configure itself to process the upcoming video frames.
[0098] If the video stream contains configuration parameters: At this time, you can update the canvas size of the canvas element: If the video stream contains configuration parameters, the decoder will parse these parameters to determine the resolution of the video frame. Then, the size of the canvas element is updated according to the video frame size to ensure that the video frame can be displayed correctly on the canvas. In addition, you can also configure the media type of the video decoder: According to the configuration parameters, set the video decoder to match the encoding format and parameters of the video stream, such as resolution, frame rate, etc.
[0099] If the video stream does not contain configuration parameters, it means that the video stream may be unconfigured or the configuration parameters have been processed before. At this time, a video data block can be created as a buffer or container to store video data.
[0100] The video data block is used to transmit the video stream to the video decoder. It acts as an intermediate storage to temporarily save the video stream data until the decoder is ready to process the data.
[0101] See also Figure 3 , Figure 3 A schematic diagram of the structure of a device screen copying system provided in an embodiment of the present application, the system comprising:
[0102] A client creation module is used to create a TCP client locally as a client of the Android Debug Bridge server after starting the Android Debug Bridge, and is used to receive information of the Android Debug Bridge server;
[0103] A file push module, used to establish a connection between the Android debug bridge server and the target device, so that the Android debug bridge server pushes the scrcpy server file to the target device;
[0104] A socket service enabling module, used to start the scrcpy service based on the scrcpy server file, and execute an Android debug bridge server command to enable the socket service;
[0105] A socket client creation module, used to create a scrcpy client, and to create a socket client according to the socket service;
[0106] The video replication module is used to create a canvas on the socket client, use the video stream of the target device in the form of video frames as texture, and render it on the canvas through a Web graphics processor to perform video stream replication of the target device.
[0107] Based on the above embodiments, as a preferred embodiment, it also includes:
[0108] The list detection module is used to read the historical connection device list and the current debuggable device list; compare the current debuggable device list and the historical connection device list; if the current debuggable device list and the historical connection device list have the same device, use the same device as the target device; if the current debuggable device list and the historical connection device list do not have the same device, determine the target device from the current debuggable device list.
[0109] Based on the above embodiments, as a preferred embodiment, it also includes:
[0110] The device identification module is used to determine the transmission channel between the target device and the Android debug bridge server; generate a transmission ID based on the transmission channel, and the transmission ID is used to identify the target device.
[0111] Based on the above embodiments, as a preferred embodiment, it also includes:
[0112] The service name generation module is used to generate a random number, and the random number is used to generate a service name of the socket service.
[0113] Based on the above embodiment, as a preferred embodiment, the video duplication module is a module for performing the following steps:
[0114] Create a canvas element, obtain and configure the context information of the Web graphics processor;
[0115] Parsing the video stream of the target device using a video decoder to obtain a video frame;
[0116] Importing the video frame as a texture into a shader program of the Web graphics processor;
[0117] Configure texture sampling rules and texture coordinate wrapping rules;
[0118] The Web graphics processor drawing command is called to control the Web graphics processor to enable the shader program to render the video frame texture according to the configured texture sampling rule and the texture coordinate wrapping rule.
[0119] Based on the above embodiments, as a preferred embodiment, it also includes:
[0120] A video stream receiving module, used for creating a write stream to receive the video stream in the socket service;
[0121] The write stream is used to perform the following judgment:
[0122] Determining whether the video stream contains configuration parameters;
[0123] If yes, updating the canvas size of the canvas element according to the cropped size of the video frame, and configuring the media type of the video decoder according to the configuration parameters;
[0124] If not, a video data block is created and passed to the video decoder to decode the video stream into video frames; the video data block is used to transmit the video stream to the video decoder.
[0125] Based on the above embodiments, as a preferred embodiment, it also includes:
[0126] The device recording module is used to add the target device to the historical connection device list and record the device name and device serial number of the target device.
[0127] The present application also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed, the steps provided in the above embodiment can be implemented. The storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0128] The present application also provides an electronic device, see Figure 4 , a structural diagram of an electronic device provided in an embodiment of the present application, such as Figure 4 As shown, a processor 1410 and a memory 1420 may be included.
[0129] Among them, the processor 1410 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1410 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 1410 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 1410 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1410 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0130] The memory 1420 may include one or more computer-readable storage media, which may be non-transitory. The memory 1420 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 1420 is at least used to store the following computer program 1421, wherein, after the computer program is loaded and executed by the processor 1410, it can implement the relevant steps in the method performed by the electronic device side disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 1420 may also include an operating system 1422 and data 1423, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 1422 may include Windows, Linux, Android, etc.
[0131] In some embodiments, the electronic device may further include a display screen 1430 , an input / output interface 1440 , a communication interface 1450 , a sensor 1460 , a power source 1470 , and a communication bus 1480 .
[0132] certainly, Figure 4 The structure of the electronic device shown does not constitute a limitation on the electronic device in the embodiments of the present application. In actual applications, the electronic device may include Figure 4 More or fewer components than shown, or combinations of certain components.
[0133] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other. For the system provided in the embodiment, since it corresponds to the method provided in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0134] Specific examples are used herein to illustrate the principles and implementation methods of the present application, and the description of the above embodiments is only used to help understand the method and core ideas of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the present application.
[0135] It should also be noted that, in this specification, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.< / canvas> < / scid> < / scid> < / scid>
Claims
1. A device screen copying method, characterized in that: include: After starting the Android Debug Bridge, a TCP client is created locally as a client of the Android Debug Bridge server, for receiving information of the Android Debug Bridge server; Establishing a communication connection between the Android debug bridge server and the target device through the TCP client so that the Android debug bridge server pushes the scrcpy server file to the target device; Starting the scrcpy service based on the scrcpy server file and executing the Android debug bridge server command to enable the socket service; Create a scrcpy client and create a socket client according to the socket service; On the socket client, a canvas is created, and the video stream of the target device is used as a texture in the form of video frames and rendered on the canvas through a Web graphics processor to perform video stream replication of the target device.
2. The device screen copying method according to claim 1, characterized in that: Before establishing a communication connection between the Android debug bridge server and the target device through the TCP client, the method further includes: Read the list of historically connected devices and the list of currently debuggable devices; Comparing the current adjustable device list with the historical connected device list; If the current adjustable device list and the historical connected device list contain the same device, use the same device as the target device; If the current debuggable device list and the historical connection device list do not contain the same device, the target device is determined from the current debuggable device list.
3. The device screen copying method according to claim 2, characterized in that: After establishing a communication connection between the Android debug bridge server and the target device through the TCP client, the method further includes: Determining a transmission channel between the target device and the Android Debug Bridge server; A transmission ID is generated based on the transmission channel, where the transmission ID is used to identify the target device.
4. The device screen copying method according to claim 3, characterized in that: After starting the scrcpy service, it also includes: A random number is generated, where the random number is used to generate a service name for the socket service.
5. The device screen copying method according to claim 1, characterized in that: Creating a canvas, using the video stream of the target device as a texture in the form of video frames, and rendering on the canvas through a Web graphics processor includes: Create a canvas element, obtain and configure the context information of the Web graphics processor; Parsing the video stream of the target device using a video decoder to obtain a video frame; Importing the video frame as a texture into a shader program of the Web graphics processor; Configure texture sampling rules and texture coordinate wrapping rules; The Web graphics processor drawing command is called to control the Web graphics processor to enable the shader program to render the video frame texture according to the configured texture sampling rule and the texture coordinate wrapping rule.
6. The device screen copying method according to claim 5, characterized in that: When the video stream of the target device is parsed by a video decoder to obtain a video frame, the method further includes: Create a write stream to receive the video stream in the socket service; The write stream is used to perform the following judgment: Determining whether the video stream contains configuration parameters; If yes, updating the canvas size of the canvas element according to the cropped size of the video frame, and configuring the media type of the video decoder according to the configuration parameters; If not, a video data block is created and passed to the video decoder to decode the video stream into video frames; the video data block is used to transmit the video stream to the video decoder.
7. The device screen copying method according to claim 2, characterized in that: If the historical connection device list does not include the target device, the method further includes: The target device is added to the historical connection device list, and the device name and device serial number of the target device are recorded.
8. A device screen duplication system, characterized in that: include: A client creation module is used to create a TCP client locally as a client of the Android Debug Bridge server after starting the Android Debug Bridge, and is used to receive information of the Android Debug Bridge server; A file push module, used to establish a connection between the Android debug bridge server and the target device, so that the Android debug bridge server pushes the scrcpy server file to the target device; A socket service enabling module, used to start the scrcpy service based on the scrcpy server file, and execute an Android debug bridge server command to enable the socket service; A socket client creation module, used to create a scrcpy client, and to create a socket client according to the socket service; The video replication module is used to create a canvas on the socket client, use the video stream of the target device in the form of video frames as texture, and render it on the canvas through a Web graphics processor to perform video stream replication of the target device.
9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the device screen copying method as described in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed, the steps of the device screen copying method according to any one of claims 1 to 7 are implemented.