Video recording method and electronic device

By obtaining the video stream and audio stream directly from the hardware driver in the electronic device, avoiding encoding and decoding, the problem of high-resolution video recording caused by insufficient hardware capabilities is solved, and the video recording capability is improved.

CN117135299BActive Publication Date: 2024-09-13HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310477926.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-27
Publication Date
2024-09-13
Estimated Expiration
2043-04-27

AI Technical Summary

Technical Problem

During the video recording process, existing electronic devices cannot encode and decode high-resolution video streams when their hardware capabilities are low, resulting in the inability to record high-resolution videos.

Method used

By directly obtaining the video stream and audio stream from the hardware driver in the electronic device, the encoding and decoding process is avoided, and video recording at any resolution is achieved.

Benefits of technology

The video recording capabilities of electronic devices are improved, especially for devices with lower hardware capabilities, high-resolution video recording can be achieved, and for devices with higher hardware capabilities, hardware resource usage can be reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117135299B
    Figure CN117135299B
Patent Text Reader

Abstract

The embodiment of the present application provides a video recording method and an electronic device, the method is executed by an electronic device, the electronic device currently runs a first application, the method includes: receiving a first operation input by a user through the first application, the first operation requesting to start recording a video; in response to the first operation, capturing a video stream and an audio stream through a first hardware; if a preset condition is met, the video stream and the audio stream are obtained from a driver corresponding to the first hardware through the first application, the preset condition characterizes that the first application is allowed to directly obtain the video stream and the audio stream captured by the first hardware; the video stream and the audio stream are merged and stored through the first application to complete the video recording. The method can realize the recording of videos of any resolution, improving the video recording capability of the electronic device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of video processing technology, and in particular to a video recording method and electronic equipment. Background Art

[0002] Currently, more and more electronic devices can realize the video recording function. For example, in addition to electronic devices such as mobile phones and tablet computers, some large-screen devices also realize the video recording function.

[0003] In the process of video recording, the video stream is generally collected by the camera on the electronic device. After the collected video stream is decoded, it is encoded by the application into a video stream of the target format and recorded. When encoding and decoding the video stream, it is usually necessary to call the hardware capabilities of the codec. For large-screen devices with low hardware capabilities, it may not be possible to encode and decode high-resolution video streams, that is, it is impossible to record high-resolution videos. Summary of the invention

[0004] The present application provides a video recording method and an electronic device, which can record videos of any resolution, thereby improving the video recording capability of the electronic device.

[0005] In a first aspect, the present application provides a video recording method, which is executed by an electronic device, and the electronic device currently runs a first application. The method includes: receiving a first operation input by a user through the first application, and the first operation requests to start recording a video; in response to the first operation, capturing a video stream and an audio stream through a first hardware; if a preset condition is met, obtaining the video stream and the audio stream from a driver corresponding to the first hardware through the first application, and the preset condition indicates that the first application is allowed to directly obtain the video stream and the audio stream captured by the first hardware; merging and storing the video stream and the audio stream through the first application to complete the video recording.

[0006] The first application may be a home camera, and on the operation interface of the home camera, the user may click on the video control (i.e., the first operation) to trigger the start of video recording. Optionally, the first hardware may include a camera and a microphone, and after receiving the first operation, the video stream may be collected through the camera and the audio stream may be collected through the microphone.

[0007] The preset condition characterization allows the first application to directly obtain the original video data captured by the first hardware, that is, no decoding and encoding process is required. Therefore, when the preset condition is met, the electronic device can trigger the first application to directly obtain the video stream and audio stream from the driver corresponding to the first hardware, such as obtaining the video stream from the camera driver and obtaining the audio stream from the microphone driver. After the first application obtains the video stream and audio stream, it can merge them to complete the video recording.

[0008] With the above implementation, during the video recording process, the application in the electronic device can directly use the video stream captured by the camera for recording without the need for encoding and decoding, thereby realizing the recording of videos of any resolution, thereby improving the video recording capability of the electronic device, especially for electronic devices with lower hardware capabilities, high-resolution video recording can be realized, and for electronic devices with higher hardware capabilities, the usage of hardware resources can be reduced.

[0009] In combination with the first aspect, in some implementations of the first aspect, the electronic device includes an application framework layer and a hardware abstraction layer, and the obtaining of the video stream and the audio stream from the driver corresponding to the first hardware through the first application includes: the first application sends a request for obtaining the video stream and the audio stream to the driver corresponding to the first hardware through the application framework layer and the hardware abstraction layer; the driver corresponding to the first hardware sends the video stream and the audio stream to the first application through the hardware abstraction layer and the application framework layer.

[0010] Because applications in electronic devices usually require the transmission of application framework layer and hardware abstraction layer before they can transmit data between hardware drivers, therefore, in this implementation method, the first application can send a request to obtain video stream and audio stream to the driver corresponding to the first hardware through the application framework layer and hardware abstraction layer. Correspondingly, the driver corresponding to the first hardware also sends the video stream and audio stream to the first application through the hardware abstraction layer and application framework layer.

[0011] Optionally, before the first application sends a request to the driver corresponding to the first hardware, a data channel, such as a session channel, may be established between the driver corresponding to the first hardware, and then requests may be sent and video streams and data streams may be received based on the data channel.

[0012] Among them, when the driver corresponding to the first hardware transmits the video stream and the audio stream, it is usually first transmitted to the hardware abstraction layer, and then transmitted to the application framework layer by the hardware abstraction layer. In this implementation, the hardware abstraction layer does not need to perform the encoding operation again, and can directly transmit the video stream to the application framework layer. That is, the driver corresponding to the first hardware sends the video stream and the audio stream to the first application through the hardware abstraction layer and the application framework layer, including: the driver corresponding to the first hardware sends the video stream to the hardware abstraction layer; the hardware abstraction layer does not perform the decoding operation on the video stream, and executes according to the preset corresponding relationship, sending the video stream to the first application through the application framework layer, the corresponding relationship includes the mapping relationship between the first data format and the second data format, the first data format represents the data format supported by the hardware abstraction layer, the second data format represents the data format supported by the application framework layer, the first data format includes the data format corresponding to the video stream, and the corresponding relationship represents that the preset condition is met; and the driver corresponding to the first hardware sends the audio stream to the first application through the hardware abstraction layer and the application framework layer.

[0013] That is to say, the hardware abstraction layer includes the correspondence between the first data format supported and the second data format supported by the application framework layer, for example, the correspondence between the HAL_PIXEL_FORMAT_RAW_OPAQUE data format and the MALI_GRALLOC_FORMAT_INTERNAL_RAW16 data format, which defines a new data processing method. When the hardware abstraction layer receives a data stream corresponding to the HAL_PIXEL_FORMAT_RAW_OPAQUE data format, it can directly transmit the data stream to the application framework layer according to the above correspondence, without performing a decoding operation on the video stream. For the audio stream, it can be transmitted to the first application through the hardware abstraction layer and the application framework layer.

[0014] The above implementation method defines a new data processing method so that during the video recording process, the hardware abstraction layer no longer needs to perform the encoding and decoding process, and directly transmits the original video stream to the application. It can record videos of any resolution, thereby improving the video recording capability of electronic devices.

[0015] In combination with the first aspect, in some implementations of the first aspect, before receiving the first operation input by the user through the first application, the method further includes: setting a correspondence between the first data format and the second data format.

[0016] That is to say, the electronic device can set the correspondence between the first data format and the second data format in advance, so that when video recording is required later, the first application can directly use the original video stream for recording.

[0017] In combination with the first aspect, in some implementations of the first aspect, the preset condition includes a preset mark bit value being a target value.

[0018] Among them, a flag bit can be set in the electronic device, and a value can be assigned to the flag bit when the first application requests to start recording a video. When the value of the flag bit is a target value, it indicates that the preset condition is met; when the value of the flag bit is not the target value, it indicates that the preset condition is not met. For example, when the flag bit is equal to 1, it indicates that the preset condition is met.

[0019] In one implementation, after receiving the first operation input by the user through the first application, the method further includes: if it is detected that there is a correspondence between the first data format and the second data format, assigning a target value to the mark bit through the first application.

[0020] That is, after starting to record the video, if the electronic device has set the correspondence between the first data format and the second data format, which means that the first application is allowed to obtain the original video stream, the mark bit can be assigned to the target value at the same time for subsequent judgment of whether the preset conditions are met.

[0021] In combination with the first aspect, in some implementations of the first aspect, before receiving the first operation input by the user through the first application, the method further includes: receiving a video resolution set by the user through the first application;

[0022] Correspondingly, the above-mentioned capturing the video stream through the first hardware includes: capturing the video stream according to the video recording resolution through the first hardware.

[0023] Among them, the running interface of the first application may include a setting interface, which presents an entry for setting parameters such as photo mirroring, shooting mute, photo resolution, and video resolution, and the user can make corresponding settings according to needs. For example, different video resolutions can be set. Then the first hardware can capture the video stream according to the set video resolution to meet the different needs of users.

[0024] In combination with the first aspect, in some implementations of the first aspect, if the preset condition is met, the video stream and audio stream are obtained from the driver corresponding to the first hardware through the first application, including: if the recording resolution is greater than or equal to the resolution threshold and the preset condition is met, the video stream and audio stream are obtained from the driver corresponding to the first hardware through the first application.

[0025] Among them, the resolution threshold can be a preset threshold for distinguishing high resolution from low resolution. If the video resolution is less than the resolution threshold, it means that the video to be recorded is a low resolution video; if the video resolution is greater than or equal to the resolution threshold, it means that the video to be recorded is a high resolution video.

[0026] When the video recording resolution is greater than or equal to the resolution threshold, the hardware capabilities of the electronic device may not be able to support the encoding and decoding process. In this case, if the preset conditions are met, the electronic device can obtain the video stream and audio stream directly from the driver corresponding to the first hardware through the first application for video recording, so as to improve the video recording capability of the electronic device.

[0027] In combination with the first aspect, in some implementations of the first aspect, the above method also includes: if the video resolution is less than the resolution threshold, obtaining the video stream and the audio stream from the driver corresponding to the first hardware; decoding the video stream and sending it to the first application; encoding the decoded video stream through the first application, and merging and storing the audio stream and the encoded video stream to complete the video recording.

[0028] When the video resolution is less than the resolution threshold, the hardware capability of the electronic device can usually support the encoding and decoding process, so the electronic device can encode and decode the acquired video stream to improve the transmission efficiency of the video stream. For example, the video stream captured by the camera is in H264 format, which can be decoded into YUV format by the hardware abstraction layer and then transmitted to the first application to be encoded into H264 format video stream for recording.

[0029] In combination with the first aspect, in some implementations of the first aspect, after receiving a first operation input by a user through a first application, the method further includes: establishing a data channel between the first application and a driver corresponding to the first hardware;

[0030] Correspondingly, obtaining the video stream and the audio stream from the driver corresponding to the first hardware through the first application includes: the first application obtains the video stream and the audio stream from the driver corresponding to the first hardware through the data channel.

[0031] Optionally, the data channel between the first application and the driver corresponding to the first hardware may be a session channel (Session channel), through which data transmission between the first application and the driver corresponding to the first hardware may be achieved.

[0032] In combination with the first aspect, in some implementations of the first aspect, after capturing the video stream and the audio stream through the first hardware, the method further includes: obtaining the video stream from the driver corresponding to the first hardware through the first application, and generating and displaying a preview image based on the video stream.

[0033] After the electronic device completes video recording, in addition to generating the recorded video, it can also generate a corresponding preview image for the user to preview. Therefore, in addition to recording the video according to the process of the above implementation method, the electronic device can also generate a preview image according to the video stream during this process.

[0034] Optionally, the driver corresponding to the first hardware may send the video stream to the hardware abstraction layer, which decodes the video stream and transmits it to the first application. The first application may generate a preview image according to the decoded video stream for preview display.

[0035] In a second aspect, the present application provides a device, which is included in an electronic device, and the device has the function of implementing the electronic device behavior in the above-mentioned first aspect and the possible implementation of the above-mentioned first aspect. The function can be implemented by hardware, or it can be implemented by hardware executing corresponding software. The hardware or software includes one or more modules or units corresponding to the above-mentioned functions. For example, a receiving module or unit, a processing module or unit, etc.

[0036] In a third aspect, the present application provides an electronic device, comprising: a processor, a memory, and an interface; the processor, the memory, and the interface cooperate with each other so that the electronic device executes any one of the methods in the technical solution of the first aspect.

[0037] In a fourth aspect, the present application provides a chip, including a processor. The processor is used to read and execute a computer program stored in a memory to perform the method in the first aspect and any possible implementation thereof.

[0038] Optionally, the chip also includes a memory, and the memory is connected to the processor via a circuit or wire.

[0039] Further optionally, the chip also includes a communication interface.

[0040] In a fifth aspect, the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the processor executes any one of the methods in the technical solution of the first aspect.

[0041] In a sixth aspect, the present application provides a computer program product, the computer program product comprising: a computer program code, when the computer program code runs on an electronic device, the electronic device executes any one of the methods in the technical solution of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;

[0043] Figure 2 is a software structure block diagram of an electronic device provided in an embodiment of the present application;

[0044] Figure 3 This is an application scenario diagram of a video recording method provided in an embodiment of the present application;

[0045] Figure 4 is a schematic diagram of an example of a home camera setting interface provided in an embodiment of the present application;

[0046] Figure 5 is a schematic diagram of an example of a home camera preview interface provided in an embodiment of the present application;

[0047] Figure 6 is a flowchart of a video recording method provided in an embodiment of the present application;

[0048] Figure 7 is a flowchart of another video recording method provided in an embodiment of the present application;

[0049] Figure 8 is a flowchart of another video recording method provided in an embodiment of the present application;

[0050] Fig. 9 is a flowchart of another video recording method provided in an embodiment of the present application;

[0051] Fig.10 This is a flowchart of another video recording method provided in an embodiment of the present application. DETAILED DESCRIPTION

[0052] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.

[0053] In the following, the terms "first", "second", and "third" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first", "second", and "third" may explicitly or implicitly include one or more of the features.

[0054] With the development of electronic technology, more and more electronic devices can realize video recording function. For example, in addition to the early popular camera recording function such as mobile phones and tablets, some large-screen devices (such as smart TVs, smart large screens, etc.) have also launched video recording functions.

[0055] Taking the video recording function of a large-screen device as an example, during the video recording process, the camera on the large-screen device generally collects the video stream, which is decoded and then encoded into a video stream of the target format by the application (also called the upper-layer application) and recorded. For example, the camera collects a video stream in H264 format, which is decoded into YUV format by the hardware abstraction layer (HAL layer), and then transmitted to the upper-layer application to be encoded into a video stream in H264 format for recording; by converting the video stream in H264 format to YUV format for transmission, the data size of the video stream can be compressed and the transmission efficiency can be improved.

[0056] However, when encoding and decoding a video stream, it is usually necessary to call on the hardware capabilities of the codec, especially when the upper-layer application encodes a video stream in H264 format, it is necessary to call on the encoding capabilities of the encoder (or chip); for large-screen devices with low hardware capabilities, it may not be possible to encode high-resolution video streams (such as 4K videos with a resolution of 4096×2160), that is, it is impossible to record high-resolution videos.

[0057] In view of this, the embodiment of the present application provides a video recording method, during the video recording process, the application can directly use the video stream collected by the camera for recording, without the need for encoding and decoding, so as to achieve the recording of videos of any resolution, and improve the video recording capability of the electronic device. It can be understood that the video recording method provided in the embodiment of the present application can be applied to mobile phones, tablet computers, large-screen devices, vehicle-mounted devices, augmented reality (AR) / virtual reality (VR) devices, laptops, ultra-mobile personal computers (UMPC), netbooks, personal digital assistants (PDA) and other electronic devices with video recording functions, and the embodiment of the present application does not impose any restrictions on the specific types of electronic devices.

[0058] For example, Figure 1 1 is a schematic diagram of the structure of an example of an electronic device 100 provided in an embodiment of the present application. Taking the electronic device 100 as a large-screen device as an example, the electronic device 100 may include a processor 110, a memory 120, a communication module 130, and the like.

[0059] The processor 110 may include one or more processing units, and the memory 120 is used to store program codes and data. In the embodiment of the present application, the processor 110 may execute computer-executable instructions stored in the memory 120 to control and manage the actions of the electronic device 100.

[0060] The communication module 130 can be used for communication between various internal modules of the electronic device 100, or communication between the electronic device 100 and other external electronic devices. Exemplarily, if the electronic device 100 communicates with other electronic devices via a wired connection, the communication module 130 may include an interface, such as a USB interface. The USB interface may be an interface that complies with USB standard specifications, specifically a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface can be used to connect a charger to charge the electronic device 100, and can also be used to transmit data between the electronic device 100 and peripheral devices. It can also be used to connect headphones to play audio through the headphones. The interface can also be used to connect other electronic devices, such as augmented reality (AR) devices.

[0061] Alternatively, the communication module 130 may include an audio device, a radio frequency circuit, a Bluetooth chip, a wireless fidelity (Wi-Fi) chip, a near-field communication technology (NFC) module, etc., and can achieve interaction between the electronic device 100 and other electronic devices in a variety of different ways.

[0062] Optionally, the electronic device 100 may further include a display screen 140 , and the display screen 140 may display images or videos in a human-computer interaction interface.

[0063] Optionally, the electronic device 100 may further include a peripheral device 150 , such as a camera, a speaker, a microphone, etc.

[0064] Taking the electronic device 100 as a mobile phone as an example, the electronic device 100 may include, in addition to the above components or modules, a charging management module, a power management module, a battery, an antenna, a mobile communication module, a wireless communication module, a sensor module, a button, a motor, an indicator, and a subscriber identification module (SIM) card interface, etc. ( Figure 1 ). Among them, the sensor module may include a pressure sensor, a gyroscope sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, etc.

[0065] It should be understood that, in addition to Figure 1In addition to the various components or modules listed in the figure, the embodiment of the present application does not specifically limit the structure of the electronic device 100. In other embodiments of the present application, the electronic device 100 may also include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure can be implemented in hardware, software, or a combination of software and hardware.

[0066] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device 100.

[0067] Figure 2 1 is a software structure diagram of the electronic device 100 of the embodiment of the present application. The layered architecture divides the software into several layers, each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, namely, the application layer, the application framework layer, the hardware abstraction layer (HAL layer), and the kernel layer.

[0068] The application layer can include a series of application packages. Figure 2 As shown, the application package may include applications such as home camera, music, video, gallery, calendar, weather, settings, etc.

[0069] The application framework layer (Framework layer) provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.

[0070] Exemplarily, the application framework layer may include a camera service, an audio manager (Audio Flinger), and MediaCodec. Among them, MediaCodec is a codec component in the Android system, which can be used to access the codec provided by the underlying layer. The Camera Service can obtain camera data from the lower layer and upload it to the upper layer application to provide services for applications that need to access camera data. Audio Flinger can be responsible for the output and collection of audio data, the control of audio streams, the volume adjustment, the management of audio devices, etc.

[0071] In addition, the application framework layer can also include window managers, content providers, view systems, resource managers, notification managers, etc. ( Figure 2 not shown).

[0072] The window manager is used to manage window programs. The window manager can obtain the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc. The content provider is used to store and obtain data and make the data accessible to applications. The data can include videos, images, audio, browsing history and bookmarks. The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build applications. The display interface can be composed of one or more views. For example, it can include views for displaying text and views for displaying pictures. The resource manager provides various resources for applications, such as localized strings, icons, pictures, layout files, video files, etc. The notification manager enables applications to display notification information in the status bar, which can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc.

[0073] The hardware abstraction layer (HAL layer) is an abstracted structure between the kernel layer and the upper layer, and provides multiple API interfaces, which can provide services for the operating system and application programs. For example, the HAL layer can include CameraHAL and Audio HAL. Camera HAL can provide services for data interaction between the camera driver and the upper layer, and AudioHAL can provide services for data interaction between the audio driver and the upper layer.

[0074] In an embodiment of the present application, the application framework layer defines a new data format, for example, the HAL_PIXEL_FORMAT_RAW_OPAQUE data format is defined in Format_info.cpp, and the format can be supported and processed by the HAL layer. The HAL layer contains a correspondence between the new data format and the data format supported by the application framework layer, for example, the correspondence between the HAL_PIXEL_FORMAT_RAW_OPAQUE data format and the MALI_GRALLOC_FORMAT_INTERNAL_RAW16 (application framework layer) data format, that is, a new data processing method is defined. When the HAL layer receives a data stream corresponding to the HAL_PIXEL_FORMAT_RAW_OPAQUE data format, the data stream can be directly transmitted to the application framework layer according to the above correspondence. For example, this processing method allows the original video stream (i.e., the video stream in H264 format) to be directly transmitted to the Camera Service in the application framework layer.

[0075] The kernel layer is a layer between hardware and software. The kernel layer includes at least a display driver, a camera driver, and an audio driver. Exemplarily, the audio driver may include a microphone driver, etc.

[0076] For ease of understanding, the following embodiments of the present application will be described in detail with Figure 1 and Figure 2 Taking the electronic device with the structure shown as an example, the video recording method provided in the embodiment of the present application is specifically described in combination with the accompanying drawings and application scenarios.

[0077] For example, taking the electronic device as a large-screen device, Figure 3 Schematic diagram of the application scenario of the video recording method provided in the embodiment of the present application. Figure 3 As shown in Figure (a) in FIG. 1 , a user can record a video through a home camera application (hereinafter referred to as home camera). For example, a user can click a home camera icon on the desktop of an electronic device to run the home camera. The interface of the home camera after running is as follows: Figure 3 As shown in FIG. 5( b ), the interface presents a photo taking control 31 and a video recording control 32 . If the user clicks the video recording control 32 , video recording will start.

[0078] In one embodiment, the user can also set the photo taking function or video recording function of the home camera. For example, Figure 3 FIG. (b) also shows a setting control 33. After the user clicks the setting control 33, the electronic device can jump to Figure 4 The interface shown in the figure. Figure 4 As shown, the setting interface presents an entry for setting parameters such as photo mirroring, silent shooting, photo resolution, and video resolution. Users can make corresponding settings according to their needs.

[0079] In one embodiment, for a user to Figure 3 The electronic device may also provide a preview function for photos taken by the photo control 31 or videos taken by the video control 32 as shown in FIG. Figure 3 FIG. (b) also presents a preview control 34. After the user clicks the preview control 34, the electronic device can jump to Figure 5 The interface shown in the figure. Figure 5 As shown, the preview interface displays preview images of the photos or videos that have been taken.

[0080] In the above Figure 3 In the scenario shown, if the user clicks the video recording control 32, the video recording function is turned on, and the video recording method provided in the embodiment of the present application is also started accordingly. Figure 6 : is a flowchart of a video recording method provided in an embodiment of the present application. The method is executed by an electronic device and may specifically include:

[0081] S101, receiving a first operation input by a user through a first application, where the first operation requests to start recording a video.

[0082] The first application may be a home camera, and the first operation may be Figure 3 The click operation input to the video control 32 in Figure (b) may also be a voice command input by the user on the operating interface of the home camera. The embodiment of the present application does not limit the input form of the first operation.

[0083] S102: In response to a first operation, a video stream and an audio stream are captured by a first hardware.

[0084] The first hardware may include a camera and a microphone. After the electronic device receives the first operation input by the user, the electronic device may trigger corresponding hardware to collect video data in response to the first operation, such as collecting video streams through the camera and collecting audio streams through the microphone.

[0085] It can be understood that the video stream and audio stream (video stream and audio stream can also be collectively referred to as video data) captured by the first hardware are usually stored in the corresponding driver. For example, the video stream captured by the camera is stored in the camera driver, and the audio stream captured by the microphone is stored in the microphone driver, etc.

[0086] S103: If the preset condition is met, obtaining the video stream and the audio stream from the driver corresponding to the first hardware through the first application.

[0087] The preset condition indicates that the first application is allowed to directly obtain the original video data collected by the first hardware, that is, it does not need to go through the decoding and encoding process. Therefore, when the preset condition is met, the electronic device can trigger the first application to directly obtain the video stream and audio stream from the driver corresponding to the first hardware, such as obtaining the video stream from the camera driver and obtaining the audio stream from the microphone driver.

[0088] For example, if the video stream captured by the camera is data in H264 format, the first application can directly obtain the video stream in H264 format from the camera driver. It should be noted here that since the first application can directly obtain the video stream from the camera driver, it can obtain a video stream of any resolution without the need for encoding and decoding.

[0089] As another example, the audio stream collected by the microphone can be a segment of audio signals, and the first application can obtain the audio stream from the microphone driver and encode it into data in AAC format, WAV format, CDA format or MP3 format. It can be understood here that the audio stream has a smaller data volume than the video stream, and its encoding process does not require high hardware capabilities. Therefore, the embodiment of the present application can perform a normal encoding process on the audio stream, and the processing of the audio stream in the following embodiments will not be described in detail.

[0090] In one embodiment, a flag bit can be set in the electronic device, and the flag bit can be assigned a value when the first application requests to start recording a video. When the flag bit takes the target value, it indicates that the preset condition is met; when the flag bit does not take the target value, it indicates that the preset condition is not met. For example, when the flag bit is equal to 1, it indicates that the preset condition is met. Exemplarily, when the HAL layer of the electronic device defines the above data processing method, if the first application requests to start recording a video, the electronic device can assign the flag bit to the target value.

[0091] Optionally, the video data obtained by the first application from the driver corresponding to the first hardware can be temporarily stored in a buffer, and the buffer can also store the data size of the video data and the corresponding acquisition timestamp. Because the video data can include a video stream and an audio stream, both the video stream and the audio stream will have corresponding acquisition timestamps. For a video stream, it is usually composed of frames of images, and each frame of the image can correspond to an acquisition timestamp. For an audio stream, it is usually composed of segments of audio signals, and each segment of audio signals can correspond to an acquisition timestamp.

[0092] It is understood that if the preset condition is not met, the electronic device may not process the video temporarily (i.e., not record the video temporarily), or the video data may be obtained by decoding the video data in the related art and then encoding the video data by the first application. For example, a video stream in H264 format is decoded into YUV format and then transmitted to the first application to be encoded into a video stream in H264 format.

[0093] S104: The video stream and the audio stream are combined and stored by the first application to complete the video recording.

[0094] Since the video data includes a video stream and an audio stream, the first application is to obtain the video stream and the audio stream from drivers of different hardware respectively. Therefore, the electronic device needs to merge the video stream and the audio stream to complete the video recording.

[0095] Among them, in order to ensure the synchronization of the recorded video and audio, when the electronic device merges the video stream and the audio stream through the first application, it can time align the acquisition timestamp corresponding to the video stream with the acquisition timestamp corresponding to the audio stream, and merge the video stream and the audio stream with the same acquisition time.

[0096] In the above-mentioned video recording method, during the video recording process, the application in the electronic device can directly use the video stream captured by the camera for recording, without the need for encoding and decoding process, so as to realize the recording of video of any resolution, thereby improving the video recording capability of the electronic device, especially for electronic devices with lower hardware capabilities, it can realize the recording of high-resolution video, and for electronic devices with higher hardware capabilities, it can reduce the occupation of hardware resources.

[0097] It can be seen from the above embodiments that when the first application obtains video stream data, it usually obtains the video stream from the camera driver and obtains the audio stream from the microphone driver, that is, the video stream and the audio stream are transmitted to the first application through different channels. Therefore, after receiving the first operation input by the user, the electronic device can first establish a data channel between the first application and the drivers of different hardware, and then subsequently transmit the video data through the channel. For this process, Figure 7 As shown, it may specifically include:

[0098] S201, receiving a first operation input by a user through a first application, where the first operation requests to start recording a video.

[0099] S202: In response to a first operation, capture a video stream and an audio stream through a first hardware.

[0100] The process of S201-S202 may refer to S101-S102 in the above embodiment, and will not be described in detail here.

[0101] S203: Establish a data channel between the first application and a driver corresponding to the first hardware.

[0102] S204: If the preset condition is met, the first application obtains the video stream and the audio stream through the established data channel.

[0103] After the electronic device receives the first operation, in addition to collecting video data through the first hardware, a data channel can also be established between the first application and the driver corresponding to the first hardware. It can be understood that the embodiment of the present application does not limit the execution order between S202 and S203, and S202 can be executed first and then S203, or S203 can be executed first and then S202, or S202 and S203 can be executed simultaneously.

[0104] Optionally, the electronic device may establish a data channel between the first application and the camera driver, and establish a data channel between the first application and the microphone driver. For example, the data channel between the first application and the camera may be a Session channel.

[0105] Then, when the above preset conditions are met, the electronic device can trigger the first application to obtain video data through the established data channel. The acquisition process can refer to the description of the above embodiment and will not be repeated here.

[0106] S205: The video stream and the audio stream are combined and stored by the first application to complete the video recording.

[0107] The process of S205 may refer to S104 in the above embodiment, and will not be described in detail here.

[0108] In the above-mentioned video recording method, during the video recording process, the application in the electronic device can directly use the video stream captured by the camera for recording, without the need for encoding and decoding process, so as to realize the recording of video of any resolution, thereby improving the video recording capability of the electronic device; and, the electronic device can establish a data channel between the application and the hardware driver in advance, which can provide a basis for the subsequent transmission of video data.

[0109] Continue to see above Figure 3 Figure (b) and Figure 5 , Figure 3 FIG. (b) shows a preview control 34, and the user can jump to the preview control 34 after clicking the preview control 34. Figure 5 , which displays a preview of the photo or video that has been taken, that is, after the electronic device completes video recording, in addition to generating the recorded video, it also generates a preview image for the user to preview. Therefore, in addition to recording the video according to the process in the above embodiment, the electronic device also needs to generate a preview image in the process. For this process, Figure 8 As shown, it may specifically include:

[0110] S301, receiving a first operation input by a user through a first application, where the first operation requests to start recording a video.

[0111] S302: In response to a first operation, a video stream and an audio stream are captured by a first hardware.

[0112] The process of S301 - S302 may refer to S101 - S102 in the above embodiment, which will not be described in detail here.

[0113] S303: Obtain a video stream from a driver corresponding to the first hardware, and decode the video stream to generate a preview image.

[0114] The process of generating a preview image by an electronic device is different from the process of recording a video. In the process of generating a preview image, the video stream needs to be decoded and displayed.

[0115] In one embodiment, the electronic device can obtain a video stream from a camera driver through the Camera HAL of the HAL layer, and decode the video stream, and transmit the decoded video stream to the first application to generate a preview image.

[0116] For example, assuming that the camera captures a video stream in H264 format, the Camera HAL can obtain the video stream in H264 format from the camera driver and decode it into YUV format. The YUV format video stream is then transmitted to the first application, and the first application can generate a preview image of the YUV format video stream for preview display.

[0117] S304: If the preset condition is met, obtaining the video stream and the audio stream from the driver corresponding to the first hardware through the first application.

[0118] S305: The video stream and the audio stream are combined and stored by the first application to complete the video recording.

[0119] The process of S304-S305 may refer to S103-S104 in the above embodiment, and will not be described in detail here.

[0120] It can be understood that the process of generating the preview image by the electronic device can be performed simultaneously with the process of recording the video, that is, the electronic device starts two threads to respectively execute the two different processes.

[0121] In the above-mentioned video recording method, during the video recording process, the application in the electronic device can directly use the video stream captured by the camera for recording, without the need for encoding and decoding process, so as to realize the recording of videos of any resolution, thereby improving the video recording capability of the electronic device; and, the electronic device can also generate a preview image based on the video stream, so that the user can preview and view the recorded video conveniently.

[0122] Continue to see above Figure 4 , the setting interface presents an entry for setting parameters such as photo mirroring, silent shooting, photo resolution, and video resolution, and the user can make corresponding settings according to needs. For example, the user sets the video resolution to the resolution of 4K video, or to the resolution of 1080P video, etc. Generally, the resolution of 4K video is higher, and the resolution of 1080P video is lower. There may be a situation where the electronic device can record 1080P video but not 4K video. Therefore, the embodiment of the present application can also dynamically select the recording mode according to the video resolution set by the user, such as Fig. 9 As shown, the process may specifically include:

[0123] S401, receiving a video recording resolution set by a user through a first application.

[0124] Among them, users can Figure 4 The interface shown is used to set the video resolution. For example, the size of the video resolution can be directly input, or the available video resolutions can be selected from the video resolution setting entry. The embodiment of the present application does not limit the method of setting the video resolution.

[0125] S402: Receive a first operation input by a user through a first application, where the first operation requests to start recording a video.

[0126] S403: In response to the first operation, the video stream and the audio stream are captured according to the video recording resolution by the first hardware.

[0127] The process of S402-S403 can refer to S101-S102 in the above embodiment, which will not be described here. However, it should be noted that the first hardware here collects video data according to the above-set video resolution; it can be understood that if the user does not set the video resolution, the first hardware can collect video data according to the default video resolution, such as the default video resolution of 1080P.

[0128] S404: If the video resolution is less than the resolution threshold, obtain the video stream and the audio stream from the driver corresponding to the first hardware, and encode and decode the video stream.

[0129] S405: The audio stream and the encoded and decoded video stream are combined and stored by the first application to complete the video recording.

[0130] The resolution threshold may be a preset threshold for distinguishing high resolution from low resolution. If the video resolution is less than the resolution threshold, it means that the video to be recorded is a low resolution video; if the video resolution is greater than or equal to the resolution threshold, it means that the video to be recorded is a high resolution video. For example, the resolution threshold may be 4096×2160 (i.e., the resolution of a 4K video).

[0131] When the video resolution is less than the resolution threshold, the hardware capability of the electronic device can usually support the encoding and decoding process, so the electronic device can encode and decode the acquired video stream to improve the transmission efficiency of the video stream. For example, the video stream captured by the camera is in H264 format, which can be decoded into YUV format by Camera HAL and then transmitted to the first application to be encoded into H264 format video stream for recording.

[0132] After the electronic device encodes and decodes the video stream, the audio stream and the codec can be merged through the first application. The process can also perform time synchronization according to the acquisition timestamp corresponding to the audio stream and the acquisition timestamp corresponding to the video stream to complete video recording.

[0133] S406: If the video recording resolution is greater than or equal to the resolution threshold and the preset condition is met, the video stream and the audio stream are obtained from the driver corresponding to the first hardware through the first application.

[0134] S407, merging and storing the video stream and the audio stream through the first application to complete the video recording.

[0135] When the video recording resolution is greater than or equal to the resolution threshold, the hardware capabilities of the electronic device may not be able to support the encoding and decoding process. In this case, if the preset conditions are met, the electronic device can obtain the video stream and audio stream directly from the driver corresponding to the first hardware through the first application for video recording, so as to improve the video recording capability of the electronic device.

[0136] With the above-mentioned video recording method, the electronic device can dynamically select the recording mode according to the recording resolution set by the user. When the recording resolution is low, the electronic device can encode and decode the video stream during the acquisition process to improve the transmission efficiency of the video stream. When the recording resolution is high, the electronic device can directly use the video stream captured by the camera for recording without the need for encoding and decoding, thereby improving the video recording capability of the electronic device.

[0137] For the above Figure 8 The embodiment shown, combined with the above Figure 2 The software structure diagram is shown in the figure. The video recording method is described below. Fig.10 As shown, the method may include:

[0138] S11, the first application receives a first operation input by a user.

[0139] S12: In response to the first operation, the first application requests the Camera Service to establish a session channel.

[0140] The session channel (ie, data channel) requested to be created by the first application may be a Session channel. For example, the first application may request the Camera Service to establish a session channel through a CreateCaptureSession function.

[0141] When requesting to establish a session channel, the first application can request the Camera Service to create two Surface data streams, one is the Surface of the preview stream (for example, mPreviewSurface), and the other is the Surface of the recording stream (for example, mRecorderSurface). The Surface can be understood as a Buffer, which is used to provide functions such as processing or storing data during the preview or recording process.

[0142] It is understandable that when the first application requests the Camera Service to establish a session channel, it can also carry parameters such as the resolution and frame rate of the image captured during video recording.

[0143] S13, after receiving the request, Camera Service requests Camera HAL to establish a session channel.

[0144] Here, the Camera Service requests the Camera HAL to establish a session channel, which is similar to the above process and will not be repeated here.

[0145] S14, Camera HAL writes the video recording configuration information to the camera driver.

[0146] The video configuration information here may be information of parameters such as the resolution of the captured image and the capture frame rate, etc. For example, the Camera HAL may write the video configuration information to the camera driver through the configureStreams function.

[0147] S15, after the recording configuration information is written, the camera driver returns a status value to the first application through the Camera HAL and the Camera Service, and starts to collect the video stream.

[0148] The status value indicates whether the recording configuration information is written successfully. For example, when the status value is 1, it indicates that the recording configuration information is written successfully, and when the status value is 0, it indicates that the recording configuration information is written unsuccessfully.

[0149] Optionally, after the recording configuration information is written, the first application may also assign a value to the preset mark bit, and assign the value to a target value. For example, the initial value of the mark bit is 0, and the value assigned to the mark bit is the target value 1.

[0150] S16: The first application sends a request for obtaining a video stream to the Camera Service through the session channel.

[0151] When the first application sends a request to obtain a video stream, it can carry the format of the video stream to be obtained. Figure 8 It can be seen from the illustrated embodiment that after the first application obtains the video stream, it can be used for previewing and recording the video, and the data formats corresponding to the preview and video recording are different. Therefore, the first application can send down two data formats here, one representing the data format of the preview image, and the other representing the data format of the recorded video.

[0152] Exemplarily, the data format representing the preview image may be YCBCR_422_I, representing the YUV format; the data format representing the recorded video may be HAL_PIXEL_FORMAT_RAW_OPAQUE, representing the H264 format.

[0153] Optionally, the first application may send a request to obtain a video stream to the Camera Service through the createCaptureRequest function, where the request may be sent multiple times. For example, if the first application requests to obtain a video stream of N frames of images, N requests need to be sent.

[0154] S17, Camera Service sends a request for obtaining the video stream to Camera HAL through the session channel.

[0155] S18, Camera HAL sends a request for obtaining the video stream to the camera driver.

[0156] After the Camera Service receives a request to obtain a video stream, it can send the request to the camera driver through the Camera HAL.

[0157] S19, the camera driver transmits the collected video stream to the Camera HAL.

[0158] S20, Camera HAL decodes the video stream to obtain a decoded video stream.

[0159] The data format obtained after Camera HAL decodes the video stream is the data format representing the preview image, for example, a video stream decoded into a YUV format.

[0160] S21, Camera HAL transmits the decoded video stream to Camera Service through the session channel.

[0161] S22, Camera Service transmits the decoded video stream to the first application through the session channel.

[0162] S23: The first application generates a preview image according to the decoded video stream.

[0163] That is, the process of S19-S23 is a process in which the first application obtains a video stream from the camera driver and generates a preview image. In this process, the first application finally obtains a video stream in a YUV format.

[0164] S24, the camera driver transmits the collected video stream to the Camera HAL.

[0165] S25, Camera HAL transmits the received video stream to Camera Service through the session channel.

[0166] Among them, because Camera HAL defines a new data processing method, which allows the original video stream (that is, the video stream in H264 format) to be transmitted to Camera Service, when the first application requests to obtain the video stream in H264 format, Camera HAL can directly transmit the received video stream in H264 format to CameraService without the need for decoding.

[0167] It can be understood that the video stream taken out by Camera HAL from the camera driver can be copied to the memory space of mRecorderSurface, which can also store the data size of the video data and the corresponding acquisition timestamp. For example, the last four bytes are used to store the data size and the acquisition timestamp.

[0168] Optionally, in this step, the Camera HAL can also determine whether the original video stream can be directly transmitted to the Camera Service according to the value of the above-mentioned mark bit. For example, when the mark bit is 1, the original video stream can be directly transmitted to the CameraService, which indicates that the first application is allowed to obtain the original video data from the driver corresponding to the first hardware (that is, the preset condition is met).

[0169] S26, Camera Service transmits the received video stream to the first application through the session channel.

[0170] That is, the process of S24-S26 is a process in which the first application directly obtains the original video stream from the camera driver, and then the first application can merge the video stream and the audio stream to complete the video recording.

[0171] It can be understood that the process of generating a preview image in S19-S23 and the process of acquiring a video stream in S24-S26 can be performed simultaneously, and the embodiment of the present application does not limit the execution order thereof.

[0172] S27, the first application sends a request for obtaining an audio stream to the microphone driver through Audio Flinger and Audio HAL.

[0173] S28: The microphone driver transmits the audio stream to the first application through the Audio HAL and the Audio Flinger.

[0174] S29, the first application encodes the audio stream to obtain an encoded audio stream.

[0175] The channel through which the first application sends a request to the microphone and obtains the audio stream may be different from the conversation channel driven by the camera. It is a data channel for transmitting the audio stream. The process may adopt any technical solution that can be implemented in the relevant technology, and the embodiment of the present application does not limit this. Optionally, the first application may encode the audio stream into AAC format.

[0176] It can be understood that the process of obtaining the audio stream in S27-S29 can be performed simultaneously with the process of obtaining the video stream in S24-S26, so that the first application can obtain the audio stream and the video stream at the same time.

[0177] S30, the first application combines and stores the video stream and the audio stream to complete the video recording.

[0178] Among them, the video stream obtained by the first application is the original H264 format video stream, and the audio stream is the encoded AAC format audio stream. The first application can then merge and store the data streams in these two formats, thereby completing the video recording.

[0179] Exemplarily, the first application may merge the video stream and the audio stream through MediaMixer.

[0180] Optionally, after the video recording is completed, the first application may modify the value of the above-mentioned mark bit to an initial value, for example, modify the value of the mark bit from 1 to 0.

[0181] In the above-mentioned video recording method, during the video recording process, the application in the electronic device can directly use the video stream collected by the camera for recording without the need for encoding and decoding, thereby realizing the recording of videos of any resolution, thereby improving the video recording capability of the electronic device.

[0182] The above describes in detail an example of a video recording method provided by an embodiment of the present application. It is understandable that, in order to implement the above functions, the electronic device includes hardware and / or software modules corresponding to the execution of each function. Those skilled in the art should easily appreciate that, in conjunction with the units and algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in conjunction with the embodiments, but such implementation should not be considered to exceed the scope of the present application.

[0183] The embodiment of the present application can divide the functional modules of the electronic device according to the above method example. For example, each function can be divided into various functional modules, such as a detection unit, a processing unit, a display unit, etc., or two or more functions can be integrated into one module. The above integrated module can be implemented in the form of hardware or in the form of a software functional module. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.

[0184] It should be noted that all relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional module and will not be repeated here.

[0185] The electronic device provided in this embodiment is used to execute the above-mentioned video recording method, and thus can achieve the same effect as the above-mentioned implementation method.

[0186] In the case of an integrated unit, the electronic device may further include a processing module, a storage module and a communication module. The processing module may be used to control and manage the actions of the electronic device. The storage module may be used to support the electronic device to execute stored program codes and data, etc. The communication module may be used to support the electronic device to communicate with other devices.

[0187] Among them, the processing module can be a processor or a controller. It can implement or execute various exemplary logic boxes, modules and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of digital signal processing and a microprocessor, etc. The storage module can be a memory. The communication module can specifically be a device that interacts with other electronic devices, such as a radio frequency circuit, a Bluetooth chip, a Wi-Fi chip, etc.

[0188] In one embodiment, when the processing module is a processor and the storage module is a memory, the electronic device involved in this embodiment may be a Figure 1 Device of the structure shown.

[0189] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the processor executes the video recording method of any of the above embodiments.

[0190] The embodiment of the present application also provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the above-mentioned related steps to implement the video recording method in the above-mentioned embodiment.

[0191] In addition, an embodiment of the present application also provides a device, which can specifically be a chip, component or module, and the device may include a connected processor and memory; wherein the memory is used to store computer-executable instructions, and when the device is running, the processor can execute the computer-executable instructions stored in the memory so that the chip executes the video recording method in the above-mentioned method embodiments.

[0192] Among them, the electronic device, computer-readable storage medium, computer program product or chip provided in this embodiment are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above and will not be repeated here.

[0193] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0194] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0195] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0196] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0197] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.

[0198] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A video recording method, characterized in that: The method is applied to an electronic device, the electronic device includes an application framework layer and a hardware abstraction layer, and the electronic device currently runs a first application. The method includes: Receiving a first operation input by a user through the first application, the first operation requesting to start recording a video; In response to the first operation, capturing a video stream and an audio stream through a first hardware; If the preset condition is met, obtaining the video stream and the audio stream from a driver corresponding to the first hardware through the first application; The video stream and the audio stream are combined and stored by the first application to complete video recording; If the preset condition is met, obtaining the video stream and the audio stream from a driver corresponding to the first hardware through the first application includes: The first application sends a request for acquiring the video stream and the audio stream to a driver corresponding to the first hardware through the application framework layer and the hardware abstraction layer; The driver corresponding to the first hardware sends the video stream to the hardware abstraction layer; When the hardware abstraction layer receives a video stream corresponding to a first data format in a preset correspondence, the hardware abstraction layer does not perform a decoding operation on the video stream. According to the preset correspondence, the hardware abstraction layer transmits the video stream to the application framework layer, and the application framework layer sends the video stream to the first application. The preset correspondence includes a mapping relationship between the first data format and the second data format. The first data format represents a data format supported by the hardware abstraction layer, and the second data format represents a data format supported by the application framework layer. The first data format includes a data format corresponding to the video stream. The hardware abstraction layer includes the preset correspondence to represent that the preset condition is satisfied. The driver corresponding to the first hardware sends the audio stream to the first application through the hardware abstraction layer and the application framework layer.

2. The method according to claim 1, characterized in that Before receiving the first operation input by the user through the first application, the method further includes: A correspondence between the first data format and the second data format is set.

3. The method according to claim 1 or 2, characterized in that: After receiving the first operation input by the user through the first application, the method further includes: If the hardware abstraction layer includes a correspondence between the first data format and the second data format, assigning a preset flag bit as a target value through the first application; When the preset mark bit is the target value, it is determined that the preset condition is met.

4. The method according to claim 1, characterized in that: Before receiving the first operation input by the user through the first application, the method further includes: Receiving a video recording resolution set by the user through the first application; Accordingly, the collecting of the video stream by the first hardware includes: The video stream is captured by the first hardware according to the video recording resolution.

5. The method according to claim 4, characterized in that If the preset condition is met, obtaining the video stream and the audio stream from a driver corresponding to the first hardware through the first application includes: If the video recording resolution is greater than or equal to the resolution threshold and the preset condition is met, the video stream and the audio stream are acquired from a driver corresponding to the first hardware through the first application.

6. The method according to claim 5, characterized in that The method further comprises: If the video recording resolution is less than the resolution threshold, obtaining the video stream and the audio stream from a driver corresponding to the first hardware through the hardware abstraction layer; Decoding the video stream, and sending the decoded video stream and the audio stream to the first application; The decoded video stream is encoded by the first application, and the audio stream and the encoded video stream are combined and stored to complete video recording.

7. The method according to claim 1, characterized in that After receiving the first operation input by the user through the first application, the method further includes: Establishing a data channel between the first application and a driver corresponding to the first hardware; Correspondingly, obtaining the video stream and the audio stream from a driver corresponding to the first hardware through the first application includes: The first application obtains the video stream and the audio stream from a driver corresponding to the first hardware through the data channel.

8. The method according to claim 1, characterized in that After the video stream and the audio stream are captured by the first hardware, the method further includes: The first application obtains the video stream from a driver corresponding to the first hardware through the application framework layer and the hardware abstraction layer, and generates and displays a preview image according to the video stream.

9. The method according to claim 1, characterized in that: The first hardware includes a camera and a microphone.

10. An electronic device, characterized in that: include: one or more processors; one or more memories; The memory stores one or more programs, and when the one or more programs are executed by the processor, the electronic device executes the method according to any one of claims 1 to 9.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor is caused to execute the method according to any one of claims 1 to 9.