Recording method and apparatus
By isolating the recording and rendering logic in mini-games and dynamically replacing the GLES rendering buffer object, the problems of high performance consumption in mini-game recording and UI recording are solved, achieving a low-intrusion and high-efficiency recording solution.
Patent Information
- Application Number
- CN202211533345.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-30
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2042-11-30
AI Technical Summary
Existing game recording methods consume a lot of performance in mini-games, and screen recording will record UI interfaces of non-mini-game scenes into the video, affecting the user experience.
By creating frame buffer objects and render buffer objects, and dynamically replacing the GLES render buffer object, the recording logic and rendering logic are isolated. This is integrated into the mini-game engine using aspect-oriented programming, avoiding code intrusion and performance loss.
Without affecting the original drawing logic, reduce code invasiveness and performance loss, ensure that UI interfaces outside of mini-game scenes are not recorded during the recording process, and improve the user playback experience.
Smart Images

Figure CN115920376B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a recording method, apparatus, computer equipment, and computer-readable storage medium. Background Art
[0002] With the development of computer technology, people can play various online games on computer devices. In competitive games, players often need to review their games, and some game platforms provide game recording and playback functions.
[0003] Existing game recording methods include screen recording or caching rendering instructions, which are not suitable for small games and consume a lot of performance.
[0004] It should be noted that the above content is not necessarily prior art, nor is it intended to limit the scope of patent protection of this application. Summary of the Invention
[0005] The purpose of the embodiments of the present application is to provide a recording method, apparatus, computer device and computer-readable storage medium to solve the above-mentioned problems.
[0006] One aspect of an embodiment of the present application provides a recording method, the method comprising:
[0007] Create a first framebuffer object and a first renderbuffer object;
[0008] In response to starting recording, creating a first texture object, a second frame buffer object, a third frame buffer object, and a second texture object, and reassociating the first render buffer object with the second frame buffer object to obtain a second render buffer object associated with the frame buffer object;
[0009] Generate a drawing result based on a preset drawing logic, and render the drawing result to the first texture object based on the first frame buffer object;
[0010] Using the data in the first texture object to display a target view through the second frame buffer object and the second render buffer object;
[0011] The data in the first texture object is used to record a target video through the third frame buffer object and the second texture object.
[0012] Optionally, using the data in the first texture object to display a target view through the second frame buffer object and the second render buffer object includes:
[0013] Rendering the data in the first texture object into the second render buffer object through the second frame buffer object;
[0014] using data in the second render buffer object for displaying the target view.
[0015] Optionally, the using data in the first texture object for recording the target video through the third frame buffer object and the second texture object comprises:
[0016] rendering data in the first texture object to the second texture object through the third frame buffer object, the second texture object being associated to the third frame buffer object;
[0017] video encoding according to data in the second texture object to obtain the target video.
[0018] Optionally, the method further comprises:
[0019] associating the first render buffer object to the first frame buffer object before starting recording;
[0020] displaying content to be displayed into a corresponding view through the first frame buffer object and the first render buffer object.
[0021] Optionally, the displaying content to be displayed into a corresponding view through the first frame buffer object and the first render buffer object comprises:
[0022] rendering real-time content of a preset drawing logic into the first render buffer object based on the first frame buffer object;
[0023] determining to execute a display operation according to operation information of a drawing API of GLES;
[0024] displaying content in the first render buffer object into the corresponding view in a case where it is determined to execute the display operation.
[0025] Optionally, the method further comprises:
[0026] replacing the first render buffer object with the first texture object to associate the first texture object to the first frame buffer object after starting recording;
[0027] disassociating the first render buffer object from the first frame buffer object and re-associating the first render buffer object to the second frame buffer object to obtain a second render buffer object.
[0028] Optionally, the method further comprises:
[0029] configuring an execution code of a screen exchange method, the screen exchange method being used for displaying data in the second render buffer object onto a screen.
[0030] The calling order of the screen exchange method is set behind target code, and a function of the target code comprises rendering data of a first texture through the second frame buffer object, the second render buffer object, and rendering data in the first texture object through the third frame buffer object and the second texture.
[0031] Another aspect of the embodiments of the present application provides a recording device, and the device comprises:
[0032] A first creating module is configured to create a first frame buffer object and a first render buffer object.
[0033] A second creating module is configured to, in response to starting recording, create a first texture object, a second frame buffer object, a third frame buffer object, a second texture object, and re-associate the first render buffer object to the second frame buffer object to obtain a second render buffer object associated to the frame buffer object.
[0034] A rendering module is configured to generate a rendering result based on preset rendering logic, and render the rendering result to the first texture object based on the first frame buffer object.
[0035] A display module is configured to use data in the first texture object for displaying a target view through the second frame buffer object and the second render buffer object.
[0036] A recording module is configured to use data in the first texture object for recording a target video through the third frame buffer object and the second texture object.
[0037] Another aspect of the embodiments of the present application provides a computer device, which comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor is configured to execute the computer program to implement the steps of the recording method.
[0038] Another aspect of the embodiments of the present application provides a computer readable storage medium, which stores a computer program executable by at least one processor to make the at least one processor execute the steps of the recording method.
[0039] The recording method, device, computer device, and computer readable storage medium provided by the embodiments of the present application have the following advantages: after starting recording, the recording logic and the rendering logic are isolated. In the case of not affecting the original rendering logic, the recording is completed, and the code invasiveness and performance loss are reduced. Moreover, the problem that the screen recording records the UI interface (such as a close button) of a non-small game scene into a video is avoided, and the playback experience of the user is ensured. BRIEF DESCRIPTION OF DRAWINGS
[0040] Figure 1 A diagram illustrating an operating environment of a recording system according to an embodiment of the present application is shown;
[0041] Figure 2 A flowchart illustrating a recording method according to an embodiment of the present application is shown;
[0042] Figure 3 A sub-flowchart illustrating step S200 is shown; Figure 2
[0043] A sub-flowchart illustrating step S202 is shown; Figure 4
[0044] A sub-flowchart illustrating step S204 is shown; Figure 5 Figure 3 A sub-flowchart illustrating step S302 is shown;
[0045] Figure 6 A sub-flowchart illustrating step S304 is shown;
[0046] Figure 7 Figure 2 A sub-flowchart illustrating step S206 is shown;
[0047] Figure 8 A sub-flowchart illustrating step S208 is shown; Figure 2
[0048] A sub-flowchart illustrating step S210 is shown; Figure 9
[0049] A sequence diagram illustrating starting recording and the operation after starting recording is shown; Figure 10
[0050] A block diagram illustrating a recording device according to an embodiment of the present application is shown; and Figure 11
[0051] A diagram illustrating a hardware architecture of a computer device according to an embodiment of the present application is shown. Figure 12 DETAILED DESCRIPTION
[0052] In order to make the objects, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and should not be used to limit the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of the present application.
[0053] It should be noted that the descriptions of "first", "second", etc. in the embodiments of the present application are for descriptive purposes only and should not be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" or "second" may explicitly or implicitly include at least one of such features. In addition, the technical solutions between the various embodiments can be combined with each other, but this must be based on the fact that they can be implemented by ordinary technicians in this field. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by this application.
[0054] In the description of this application, it should be understood that the numerical labels before the steps do not indicate the order in which the steps are executed. They are only used to facilitate the description of this application and to distinguish each step. Therefore, they cannot be understood as limitations on this application.
[0055] Explanation of terms involved in this application:
[0056] GLES (OpenGL for Embedded Systems): A subset of the OpenGL 3D graphics API, it's designed for embedded devices like mobile phones and PDAs. OpenGL (Open Graphics Library) is a professional graphics programming interface that defines a cross-language, cross-platform programming interface specification. It's used for 3D graphics (and 2D as well) and is a powerful, easy-to-use, low-level graphics library.
[0057] RBO (Render Buffer Object) is a 2D image buffer. RBO can be used to allocate and store color, depth or stencil values, and can be used as color, depth or stencil attachment in FBO.
[0058] FBO (Frame Buffer Object) is a container to which a buffer can be added, to which a texture object or a render buffer object can be added.
[0059] Texture objects can be written with images or a series of data and can be used to add details to objects.
[0060] VBO (Vertex Buffer Object) is used for primitive index buffering.
[0061] VAO (Vertex Array Object), which can be used to manage VBO, reduce glBindBuffer, glEnableVertexAttribArray, glVertexAttribPointer and other operations. Among them, glBindBuffer specifies the name of the buffer object. glEnableVertexAttribArray specifies the index of the regular vertex attribute to be enabled or disabled. glVertexAttribPointer specifies the index of the regular vertex attribute to be modified.
[0062] iOS system is a mobile operating system developed by Apple Inc.
[0063] Android system is a free and open source operating system based on Linux kernel. It can be used in mobile devices such as smart phones and tablet computers, and is led and developed by Google and Open Handset Alliance.
[0064] API (Application Program Interface) is a set of definitions, programs and protocols. The main functions of API include providing a set of common functions. By calling API functions to develop application programs, the programming task can be reduced. API is also a kind of middleware, which provides data sharing for various platforms.
[0065] Media Codec is a coding and decoding interface introduced in Android 4.1 version, which can be used to access the underlying multimedia codec of Android, such as encoder / decoder component. It is part of the underlying multimedia support infrastructure of Android.
[0066] AVFoundation is one of the multimedia frameworks in iOS, based on Object-C / Swift interface, which can be used to play, edit and re-encode audio and video files.
[0067] In order to facilitate the understanding of the technical personnel in the art, the technical solutions provided by the embodiments of the present application are described as follows:
[0068] The general implementation of game recording is screen recording. Taking the recording of mobile terminal (such as smart phone, tablet computer, etc.) small game as an example, iOS uses ReplayKit system framework, and Android uses MediaProjection. In addition to screen recording, there are also ways to record by caching and replaying rendering instructions.
[0069] Since the small game belongs to a mode of point and play, play and go, the screen recording mode is not suitable, the life cycle of screen recording is common in the application level, and the screen recording will record some non-small game scene UI interface (such as the close button) into the video, which is not suitable for the experience of playback.
[0070] In addition, using the rendering instruction cache, the playback mode to record, although it can solve the problem of non-game scene UI recording, but the code invasion of the whole small game engine is too strong, and the performance loss is too large, which is not suitable for the game recording of small game.
[0071] Therefore, the embodiment of the application provides a recording and playback scheme for small games. In the scheme, by hooking the related system API (iOS platform) and dynamically replacing the rendering buffer object of GLES, the recording logic and the rendering logic can be finally isolated, the small game developer does not need to pay attention to the specific recording process, and the small game engine is integrated in a facet manner, which has no invasion to the core rendering logic code of the small game engine. See later.
[0072] Figure 1 The environment running diagram of the recording method according to the embodiment of the application is schematically shown.
[0073] As Figure 1 shown, the environment diagram includes a server 2, a network 4, game terminals (6A, 6B, … and 8A, 8B, …), wherein:
[0074] The server 2, as a game service platform, can be composed of a single or multiple computing devices. The single or multiple computing devices can include virtualized computing instances. The virtualized computing instances can include virtual machines, such as emulations of computer systems, operating systems, servers, etc. The computing devices can load the virtual machines based on virtual images and / or other data defining specific software (e.g., operating systems, specialized applications, servers) for emulation. As the demand for different types of processing services changes, different virtual machines can be loaded and / or terminated on one or more computing devices. A hypervisor can be implemented to manage the use of different virtual machines on the same computing device.
[0075] The server 2 can provide game platform services and provide various services such as data interaction between various game terminals.
[0076] The server 2 can be configured to communicate with game terminals 6A, 6B, … and 8A, 8B, …, etc. through the network 4. The game terminals can include any type of computing device, such as mobile devices, tablet devices, laptop computers, virtual reality devices, game devices, set-top boxes, vehicle-mounted terminals, smart televisions, television boxes, etc.
[0077] Game terminals (6A, 6B, … and 8A, 8B, …) are configured to run game execution programs. The game execution programs are configured to provide game login, operation, payment, etc. The game terminals 6A, 6B, … and the game terminals 8A, 8B, … are devices used by two parties in a game scenario. It should be noted that the above devices are exemplary, and the number of game terminals used by two parties in different game scenarios can be increased or decreased.
[0078] The game execution program can be an applet, a light application, a webpage, etc. Taking the game terminal 6A as an example:
[0079] The game terminal 6A can be configured with a game execution program. The game execution program outputs (presents, plays) content to a user. The content can be a game login page, a game screen, audio, comments, and / or the like. For example, the game execution program is configured to provide a game login page and provide a user input account and password to the server 2 to determine whether to enter a game page according to the server 2. In the game page, a player can select a game virtual character and apply to the server 2 to form or join a certain game match. In the game match, the player can operate the game virtual character by inputting instructions, such as moving forward, moving backward, attacking, etc.
[0080] It should be noted that the above game match can be various battles, such as a man-machine battle, a guild battle, a group battle, etc.
[0081] Embodiment One
[0082] This embodiment is described taking the game terminal 6A as an execution subject.
[0083] Figure 2 A flowchart of a recording method according to Embodiment One of the present application is schematically shown.
[0084] As shown in Figure 2 The recording method can include steps S200-S208, wherein:
[0085] Step S200, creating a first frame buffer object and a first rendering buffer object;
[0086] Step S202, in response to starting recording, creating a first texture object, a second frame buffer object, a third frame buffer object, a second texture object, and re-associating the first rendering buffer object to the second frame buffer object to obtain a second rendering buffer object associated with the frame buffer object;
[0087] Step S204, generating a rendering result based on a preset rendering logic and rendering the rendering result to the first texture object based on the first frame buffer object;
[0088] Step S206, using the data in the first texture object for a display target view through the second frame buffer object and the second render buffer object.
[0089] Step S208, using the data in the first texture object for a recording target video through the third frame buffer object and the second texture object.
[0090] The recording method provided by the embodiment of the present application separates the recording logic and the rendering and display logic after starting recording, so that the game developer does not need to pay attention to the specific recording process, and the recording method is integrated into the game engine in a facet manner, without invasiveness to the core rendering logic code of the game engine. The recording is completed without affecting the original rendering logic, and the code invasiveness and performance loss are reduced. Moreover, the UI interface (such as a close button) of a non-game scene is avoided from being recorded into the video, so as to ensure the playback experience of the user.
[0091] The following will be described in detail in combination with Figure 2 The steps S200-S208 and other newly added steps will be described in detail. In the game process, the recording is started under the condition that the user manually triggers or other triggering conditions are met, so the operation can be divided into operations before and after recording. It should be noted that the steps before starting recording belong to optional steps of the embodiment.
[0092] Before starting recording:
[0093] Step S200 Step S100, creating a first frame buffer object and a first render buffer object.
[0094] As shown in FIG. 1, the recording method can include steps S100-S102: Figure 3
[0095] Step S300, before starting recording, associating the first render buffer object to the first frame buffer object.
[0096] Step S302, displaying the content to be displayed into a corresponding view through the first frame buffer object and the first render buffer object.
[0097] In order to normally display the game view on the screen, the frame buffer object and the render buffer object need to be created when the game is started. In order to distinguish from other frame buffer objects and render buffer objects in the following, the frame buffer object and the render buffer object created at this time are called the first frame buffer object and the first render buffer object.
[0098] In the exemplary application, in the normal operation mode of the mini-game, that is, when the game recording and playback is not turned on, the rendering process of the screen display area will go through the following two stages: 1. Construct the first frame buffer object and the first rendering buffer object; 2. Construct the rendering loop.
[0099] 1. If Figure 4 As shown, the process of constructing the first frame buffer object and the first render buffer object is as follows:
[0100] First: Create a rendering view (such as GLKView) that will eventually be displayed on the screen.
[0101] Second: Create the first framebuffer object and the first renderbuffer object. The first renderbuffer object will be associated with the renderview, and the first renderbuffer object will be associated with the first framebuffer object (that is, the first renderbuffer object is associated with the first framebuffer object). Therefore, subsequent operations can be performed on the first framebuffer object.
[0102] 2. The process of building a rendering loop is as follows:
[0103] At the beginning of each rendering cycle, the game first binds to the previously created first framebuffer object, then performs the game's default drawing logic. After the default drawing logic is completed, the GLES drawing API is used to determine whether the content needs to be displayed. If display is required, the contents of the first renderbuffer object are displayed to the render view through Swap / Present. Swap / Present is used to swap screen contents with off-screen buffers (such as the original renderbuffer object).
[0104] like Figure 5 As shown, step S102 "displaying the content to be displayed in the corresponding view using the first frame buffer object and the first render buffer object" can include steps S500 to S504. Step S500 renders the real-time content of the preset drawing logic into the first render buffer object based on the first frame buffer object; step S502 determines to perform a display operation based on the operation information of the GLES drawing API; and step S504 displays the content in the first render buffer object in the corresponding view if it is determined to perform the display operation.
[0105] It should be noted that the first frame buffer object is a container to which buffers can be added.
[0106] like Figure 6As shown, after the first frame buffer object is associated with the first render buffer object, the first frame buffer object is bound so that the first frame buffer object can be used as a rendering target. After the first frame buffer object is bound, all rendering operations will be rendered into the attachment (the first render buffer object) of the first frame buffer object. Therefore, after the to-be-displayed content is obtained through preset drawing logic, the to-be-displayed content can be rendered into the first render buffer object through the first frame buffer object. The content rendered into the first render buffer object does not necessarily have to be displayed on the screen. Therefore, it is necessary to further determine whether to be displayed on the screen. If the drawing API of the GLES decides to be displayed on the screen, the content in the first render buffer object is displayed on the rendering view (screen) through Swap / Present, otherwise, it is not displayed on the screen. It can be known that the embodiment can realize rendering of a screen display area.
[0107] The above is a normal processing flow when the game recording playback is not started. The embodiment performs aspect processing on the recording flow, and completes recording without affecting the original drawing logic. After the recording is started, the specific flow is as follows.
[0108] After starting recording:
[0109] Step S202 In response to starting the recording, a first texture object, a second frame buffer object, a third frame buffer object, a second texture object are created, and the first render buffer object is re-associated with the second frame buffer object to obtain a second render buffer object associated with the frame buffer object.
[0110] The starting of the recording can be triggered based on a key or a touch screen gesture, triggered based on time, or triggered based on other manners.
[0111] Unlike screen recording or recording by using a rendering instruction cache and replay, the embodiment introduces aspect AOP (aspect oriented programming) processing to reduce code invasiveness and performance loss, complete recording without affecting the original drawing logic, and reduce code invasiveness and performance loss.
[0112] Specifically, in response to starting the recording, the following operations are performed:
[0113] First, a first texture object is created.
[0114] Second, a second frame buffer object is created.
[0115] Third, the first render buffer object is re-associated with the second frame buffer object, and the first render buffer object after re-association can also be referred to as a second render buffer object.
[0116] Fourthly, a third frame buffer object is created.
[0117] Fifthly, a second texture object is created.
[0118] The first texture object is used as a common input for subsequent display and recording.
[0119] The second frame buffer object and the second render buffer object are used for rendering a view, and the third frame buffer object and the second texture object are used for recording.
[0120] In the above, the recording logic and the rendering (display) logic are isolated, the small game developer does not need to pay attention to the specific recording process, and is integrated into the small game engine in a facet manner, without invasiveness to the core rendering logic code of the small game engine.
[0121] In an optional embodiment, in order to ensure the above-mentioned logic isolation, the recording method further comprises:
[0122] After starting recording, the first render buffer object is replaced by the first texture object, so as to associate the first texture object to the first frame buffer object;
[0123] The first render buffer object and the first frame buffer object are disassociated, and the first render buffer object is re-associated to the second frame buffer object to obtain a second render buffer object.
[0124] Step S204 The preset rendering logic is used to generate a rendering result, and the rendering result is rendered to the first texture object based on the first frame buffer object.
[0125] The preset rendering logic comprises operation and processing logic for points, lines, surfaces, colors, shapes, etc., and can be implemented by a graphics engine.
[0126] In the case where the first frame buffer object is bound, the first frame buffer object can be used as a rendering target. Therefore, all rendering operations will be rendered to the attachment of the first frame buffer object. In this embodiment, the attachment of the first frame buffer object is dynamically replaced by the first render buffer object to the first texture object.
[0127] In this embodiment, since the attachment of the first frame buffer object is replaced by the first texture object, the rendering result output by the preset rendering logic is first rendered to the first texture object. The first texture object can be used as a common input for subsequent display and recording.
[0128] Step S206 The data in the first texture object is used for a display target view through the second frame buffer object and the second render buffer object.
[0129] In step S204, the rendering result is rendered to the first texture object. Since the first texture object is readable and writable, the data in the first texture object can be read and displayed by rendering through the second frame buffer object and the second render buffer object.
[0130] In optional embodiments, as shown in FIG. 7, step S206 "using the data in the first texture object for displaying the target view through the second frame buffer object and the second render buffer object" can include step S700 of rendering the data in the first texture object to the second render buffer object through the second frame buffer object, and step S702 of using the data in the second render buffer object for displaying the target view. Figure 7
[0131] After the second frame buffer object is bound, the second frame buffer object can also be used as a rendering target. Thus, the data in the first texture object can be read and rendered to the second render buffer object associated with the second frame buffer object. Then, the content in the second render buffer object can be presented to the rendering view (screen) by Swap / Present. It can be seen that the embodiment can perform rendering and display of the view in a situation isolated from the recording operation.
[0132] Step S208 using the data in the first texture object for recording the target video through the third frame buffer object and the second texture object.
[0133] As described above, the rendering result is rendered to the first texture object. Since the first texture object is readable and writable, the data in the first texture object can be read and used for video encoding through the third frame buffer object and the second texture object.
[0134] In optional embodiments, as shown in FIG. 8, step S208 "using the data in the first texture object for recording the target video through the third frame buffer object and the second texture object" can include step S800 of rendering the data in the first texture object to the second texture object through the third frame buffer object, the second texture object being associated with the third frame buffer object, and step S802 of performing video encoding according to the data in the second texture object to obtain the target video. Figure 8
[0135] After the third frame buffer object is bound, the third frame buffer object can also be used as a rendering target. Thus, data can be read from the first texture object and rendered into the second texture object associated with the third frame buffer object. It can be seen that the embodiment can perform the video recording operation in a situation isolated from the rendering and display operation.
[0136] In an exemplary application, the drawing of the first texture object into the second texture object can be performed through an API for drawing the GLES-related texture object, and then the video encoding can be performed asynchronously by a video encoder, so as to generate the recorded video. It should be noted that the video encoder is different between the Android and iOS platforms. On the Android platform, a Media Codec-related implementation can be used, while on the iOS platform, an AVFoundation-related implementation is used.
[0137] It should also be noted that the settings of the iOS and Android systems are different for the running of the recording logic and the rendering and display logic. In order to make the recording applicable to the above systems, the following embodiments can be used.
[0138] In an optional embodiment, the method further comprises: configuring an execution code of a screen exchange method, the screen exchange method being used to display data in the second rendering buffer object to a screen; and setting a calling order of the screen exchange method behind a target code, a function of the target code including rendering data of a first texture through the second frame buffer object and the second rendering buffer object, and rendering data in the first texture object through the third frame buffer object and the second texture. That is, after starting recording, the screen exchange method is adjusted behind the drawing code; the screen exchange method includes a presentRenderbuffer method or a Swap method, and the drawing code includes drawing to the second frame buffer object and drawing to the third frame buffer object. Through the above setting, the dual functions of drawing and recording are realized.
[0139] In the iOS system environment, after starting recording, the calling order of the presentRenderbuffer method of the context object is adjusted behind the calling of the drawing code. Specifically, through a method swizzle (method deception) manner, the presentRenderbuffer method of the EAGLContext (context object) is dynamically hooked, and the calling of the above drawing code is performed before the method is called, so as to realize recording and rendering and display. The hook is used to change the program flow.
[0140] In the Android system environment, after starting recording, the flow of Swap call is adjusted to the drawing code.
[0141] In order to make the application easier to understand, the following is combined with Figure 9 and Figure 10 An exemplary application is provided.
[0142] The flow after starting recording is:
[0143] The preset drawing logic is first associated with the first frame buffer object, and then with the first texture object.
[0144] The first texture object is associated with the second frame buffer object, and then with the second rendering buffer object, and then with the rendering view.
[0145] The first texture object is associated with the third frame buffer object, and then with the second texture object, and then with the video encoder.
[0146] The first rendering buffer object is dynamically replaced by the first texture object, and the drawing result of the preset drawing logic is first rendered to the first texture object. The first texture object serves as a common input for subsequent display and recording. For the rendering and display process, a new frame buffer object (second frame buffer object) is additionally constructed and associated with the previous first rendering buffer object (which can also be referred to as the second rendering buffer object). By operating the API of the GLES related texture object drawing, the final drawing of the first texture object to the second rendering buffer object is completed. For the recording process, a new frame buffer object (third frame buffer object) is also constructed, and the second frame buffer object is associated with a new texture object (second texture object). By operating the API of the GLES related texture object drawing, the final drawing of the first texture object to the second texture object is completed, and then it is asynchronously given to the video encoder for video encoding, and finally the generation of the recorded video is completed. The video encoder is different on the Android and iOS platforms. On the Android platform, Media Codec related implementation can be used, while on the iOS platform, AVFoundation related implementation is used.
[0147] The steps of starting recording and ending recording are as follows:
[0148] S1000, the small game starts recording and sends a recording instruction to the recorder.
[0149] S1002, the recorder notifies the recording renderer to create a flow.
[0150] S1004, after receiving the notification, the recording renderer creates a first texture object, a second texture object, a second rendering buffer object, a second frame buffer object, and a third frame buffer object.
[0151] The first frame buffer object is associated with the first texture object.
[0152] The second framebuffer object is associated with the second renderbuffer object.
[0153] The third framebuffer object is associated with the second texture object.
[0154] S1006: The recording renderer draws the content onto the screen through the first texture object, the second frame buffer object, and the second rendering buffer object.
[0155] S1008: The recording renderer asynchronously submits the content to the video encoder through the first texture object, the third frame buffer object, and the second texture object.
[0156] S1010, the mini-game ends recording and sends an end-recording instruction to the recorder.
[0157] S1012: The recorder notifies the recording renderer to release related resources.
[0158] S1014: The recording renderer releases related resources, such as unbinding the second frame buffer object and the third frame buffer object.
[0159] S1016: The recording renderer calls back the recording result to the recorder.
[0160] S1018: The recorder returns the recording result to the mini-game.
[0161] Example 2
[0162] Figure 11 The block diagram of the recording device according to the second embodiment of the present application is schematically shown. The recording device can be divided into one or more program modules, one or more program modules are stored in a storage medium and executed by one or more processors to complete the embodiment of the present application. The program module referred to in the embodiment of the present application refers to a series of computer program instruction segments that can complete specific functions. The following description will specifically introduce the functions of each program module in this embodiment. Figure 11 As shown, the recording device 1100 may include a first creation module 1110, a second creation module 1120, a rendering module 1130, a display module 1140, and a recording module 1150, wherein:
[0163] A first creation module 1110 is configured to create a first frame buffer object and a first rendering buffer object;
[0164] A second creation module 1120 is configured to, in response to starting recording, create a first texture object, a second frame buffer object, a third frame buffer object, and a second texture object, and reassociate the first render buffer object with the second frame buffer object to obtain a second render buffer object associated with the frame buffer object;
[0165] rendering module 1130 is configured to generate a rendering result based on preset rendering logic, and render the rendering result to the first texture object based on the first frame buffer object;
[0166] display module 1140 is configured to use data in the first texture object for a display target view through the second frame buffer object and the second rendering buffer object;
[0167] recording module 1150 is configured to use data in the first texture object for a recording target video through the third frame buffer object and the second texture object.
[0168] In an optional embodiment, the display module 1140 is further configured to:
[0169] render data in the first texture object into the second rendering buffer object through the second frame buffer object;
[0170] use data in the second rendering buffer object to display the target view.
[0171] In an optional embodiment, the recording module 1150 is further configured to:
[0172] render data in the first texture object into the second texture object through the third frame buffer object, the second texture object being associated with the third frame buffer object;
[0173] perform video encoding according to data in the second texture object to obtain the target video.
[0174] In an optional embodiment, the display module 1140 is further configured to:
[0175] associate the first rendering buffer object with the first frame buffer object before starting recording;
[0176] display content to be displayed into a corresponding view through the first frame buffer object and the first rendering buffer object.
[0177] In an optional embodiment, the display module 1140 is further configured to:
[0178] render real-time content of preset rendering logic into the first rendering buffer object based on the first frame buffer object;
[0179] determine to perform a display operation according to operation information of a rendering API of GLES;
[0180] in a case where it is determined to perform the display operation, display content in the first rendering buffer object into the corresponding view.
[0181] In an optional embodiment, the apparatus further comprises an associating module configured to:
[0182] After starting the recording, the first rendering buffer object is replaced by the first texture object to associate the first texture object to the first frame buffer object;
[0183] The first rendering buffer object and the first frame buffer object are disassociated, and the first rendering buffer object is re-associated to the second frame buffer object to obtain a second rendering buffer object.
[0184] In an optional embodiment, the apparatus further comprises a configuring module configured to:
[0185] Configure execution code of a screen swapping method, the screen swapping method being configured to display data in the second rendering buffer object to a screen;
[0186] Set a calling order of the screen swapping method behind target code, a function of the target code comprising: rendering data of a first texture through the second frame buffer object and the second rendering buffer object, and rendering data in the first texture object through the third frame buffer object and the second texture.
[0187] Embodiment Three
[0188] Figure 12 A hardware architecture schematic diagram of a computer device 10000 suitable for implementing the recording method according to Embodiment Three of the present application is schematically shown. The computer device 10000 can be used as any one of the game terminals 6A, 6B, … and 8A, … In this embodiment, the computer device 10000 is a device capable of automatically performing numerical calculation and / or information processing according to a pre-set or stored instruction. For example, it can be a smart phone, a tablet computer, a laptop, a personal computer, a virtual device, a set-top box, a television, a projector, a vehicle terminal, etc. As shown in the figure, the computer device 10000 at least includes but is not limited to a memory 10010, a processor 10020, and a network interface 10030 which are communicatively connected through a system bus. Among them: Figure 12
[0189] The memory 10010 includes at least one type of computer-readable storage media, such as a flash memory, a hard disk, a multimedia card micro (e.g., SD or DX memory, etc.), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, and the like. In some embodiments, the memory 10010 can be an internal memory module of the computer device 10000, such as a hard disk or a memory of the computer device 10000. In other embodiments, the memory 10010 can also be an external memory device of the computer device 10000, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, and the like. Of course, the memory 10010 can include both an internal memory module and an external memory device of the computer device 10000. In this embodiment, the memory 10010 is generally used to store an operating system and various application programs installed in the computer device 10000, such as program codes of the recording method, and the like. In addition, the memory 10010 can also be used to temporarily store various data that have been output or will be output.
[0190] The processor 10020 can be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip in some embodiments. The processor 10020 is generally used to control the overall operation of the computer device 10000, such as performing control and processing related to data interaction or communication of the computer device 10000, and the like. In this embodiment, the processor 10020 is used to run program codes or process data stored in the memory 10010.
[0191] The network interface 10030 can include a wireless network interface or a wired network interface, and is generally used to establish a communication link between the computer device 10000 and other computer devices. For example, the network interface 10030 is used to connect the computer device 10000 with an external terminal through a network, to establish a data transmission channel and a communication link between the computer device 10000 and the external terminal, and the like. The network can be an Intranet, the Internet, a Global System of Mobile communication (GSM), a Wideband Code Division Multiple Access (WCDMA), a 4G network, a 5G network, Bluetooth, Wi-Fi, and the like wireless or wired network.
[0192] It should be noted that, Figure 12 Only the computer device with the components 10010-10030 is shown, but it should be understood that all the shown components are not required to be implemented, and more or fewer components can be alternatively implemented.
[0193] In this embodiment, the recording method stored in the memory 10010 can also be divided into one or more program modules, and executed by one or more processors (in this embodiment, the processor 10020) to complete the recording method in the embodiments of the present application.
[0194] Embodiment Four
[0195] The present application also provides a computer readable storage medium, the computer readable storage medium has a computer program stored thereon, and the computer program is executed by a processor to implement the steps of the recording method in the embodiments.
[0196] In this embodiment, the computer readable storage medium includes a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the computer readable storage medium can be an internal storage unit of the computer device, such as a hard disk or a memory of the computer device. In other embodiments, the computer readable storage medium can also be an external storage device of the computer device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device. Of course, the computer readable storage medium can also include both the internal storage unit and the external storage device of the computer device. In this embodiment, the computer readable storage medium is usually used to store an operating system and various application software installed on the computer device, such as program codes of the recording method in the embodiments, etc. In addition, the computer readable storage medium can also be used to temporarily store various data that have been output or will be output.
[0197] Obviously, those skilled in the art should understand that each module or each step of the above-mentioned embodiments of the present application can be realized by a general computing device, which can be concentrated on a single computing device or distributed on a network composed of multiple computing devices, and optionally, each module or each step can be realized by program codes executable by a computing device, so that each module or each step can be stored in a storage device and executed by a computing device, and in some cases, the steps shown or described can be executed in different order, or each module or each step can be manufactured into an individual integrated circuit module, or multiple modules or steps can be manufactured into a single integrated circuit module. Therefore, the embodiments of the present application are not limited to any specific combination of hardware and software.
[0198] It should be noted that the above is only the preferred embodiment of the present application, and does not limit the patent protection scope of the present application, and any equivalent structure or equivalent process transformation using the content of the specification and drawings of the present application, or direct or indirect application in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A recording method, characterized in that: The method comprises: Create a first framebuffer object and a first renderbuffer object; In response to starting recording, creating a first texture object, a second frame buffer object, a third frame buffer object, and a second texture object, and reassociating the first render buffer object with the second frame buffer object to obtain a second render buffer object associated with the frame buffer object; Generate a drawing result based on a preset drawing logic, and render the drawing result to the first texture object based on the first frame buffer object; Using the data in the first texture object to display a target view through the second frame buffer object and the second render buffer object; Using the data in the first texture object to record a target video through the third frame buffer object and the second texture object; The step of using the data in the first texture object to display a target view through the second frame buffer object and the second render buffer object includes: Rendering the data in the first texture object into the second render buffer object through the second frame buffer object; The data in the second render buffer object is used to display the target view.
2. The recording method according to claim 1, wherein: The step of using the data in the first texture object to record a target video through the third frame buffer object and the second texture object includes: Rendering data in the first texture object to the second texture object via the third frame buffer object, wherein the second texture object is associated with the third frame buffer object; Video encoding is performed according to the data in the second texture object to obtain the target video.
3. The recording method according to any one of claims 1 to 2, characterized in that: The method further comprises: Before starting recording, associating the first renderbuffer object with the first framebuffer object; The content to be displayed is displayed in a corresponding view through the first frame buffer object and the first rendering buffer object.
4. The recording method according to claim 3, wherein: The displaying the content to be displayed in a corresponding view through the first frame buffer object and the first render buffer object includes: Based on the first frame buffer object, rendering the real-time content of the preset drawing logic into the first render buffer object; Determine the display operation to be performed based on the operation information of the GLES drawing API; In a case where it is determined to perform the display operation, the content in the first rendering buffer object is displayed in the corresponding view.
5. The recording method according to claim 3, wherein: The method further comprises: After starting recording, replacing the first renderbuffer object with the first texture object to associate the first texture object with the first framebuffer object; The first renderbuffer object and the first framebuffer object are disassociated, and the first renderbuffer object is reassociated with the second framebuffer object to obtain a second renderbuffer object.
6. The recording method according to any one of claims 1 to 2, characterized in that: The method further comprises: Configuring an execution code of a screen swap method, wherein the screen swap method is used to display the data in the second rendering buffer object on a screen; The calling order of the screen swap method is set after the target code, and the functions of the target code include: rendering the data of the first texture through the second frame buffer object and the second rendering buffer object, and rendering the data in the first texture object through the third frame buffer object and the second texture.
7. A recording device, characterized in that: The device comprises: A first creation module, configured to create a first frame buffer object and a first rendering buffer object; a second creation module, configured to, in response to starting recording, create a first texture object, a second frame buffer object, a third frame buffer object, and a second texture object, and reassociate the first render buffer object with the second frame buffer object to obtain a second render buffer object associated with the frame buffer object; a rendering module, configured to generate a drawing result based on a preset drawing logic, and render the drawing result to the first texture object based on the first frame buffer object; A display module, configured to use the data in the first texture object to display a target view through the second frame buffer object and the second render buffer object; a recording module, configured to use the data in the first texture object to record a target video through the third frame buffer object and the second texture object; The step of using the data in the first texture object to display a target view through the second frame buffer object and the second render buffer object includes: Rendering the data in the first texture object into the second render buffer object through the second frame buffer object; The data in the second render buffer object is used to display the target view.
8. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, it is used to implement the steps of the recording method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that A computer program is stored therein, and the computer program can be executed by at least one processor to enable the at least one processor to perform the steps of the recording method described in any one of claims 1 to 6.
10. A computer program product, characterized in that The method comprises a computer program, wherein the computer program can be executed by at least one processor to enable the at least one processor to perform the steps of the recording method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Screen recording method and device, computer equipment and computer readable storage medium
CN112218148A