Audio and video recording method and related device

By using dual audio and video mixers working alternately during audio and video recording, the frame loss problem in traditional recording solutions is solved, achieving efficient segmented audio and video recording, ensuring user experience, and without requiring modifications to the system framework.

CN116233344BActive Publication Date: 2026-05-08XI AN FIBOCOM WIRELESS INC
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
XI AN FIBOCOM WIRELESS INC
Filing Date
2023-03-15
Publication Date
2026-05-08

AI Technical Summary

Technical Problem

Traditional audio and video recording solutions suffer from frame loss, resulting in a poor user experience.

Method used

By using a dual audio and video mixer alternately, in segmented recording mode, the first audio and video mixer is used to mix the audio and video and save the data. Then, the second audio and video mixer is initialized to prepare for the next segment of recording, thus reducing the gap between recording stages.

Benefits of technology

It effectively reduces frame loss during audio and video segmentation recording, improves user experience, and can be implemented in upper-level apps without modifying the system framework.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116233344B_ABST
    Figure CN116233344B_ABST
Patent Text Reader

Abstract

The application discloses an audio and video recording method and device, electronic equipment and computer readable storage medium. The method comprises the following steps: determining corresponding segment conditions in a segment recording mode, and initializing a first audio and video mixer; performing an audio and video mixing operation by using the first audio and video mixer to obtain first audio and video data; when a real-time recording condition meets the segment conditions, saving the first audio and video data as a first audio and video file, initializing a second audio and video mixer; performing an audio and video mixing operation by using the second audio and video mixer to obtain second audio and video data; when the real-time recording condition meets the segment conditions, saving the second audio and video data as a second audio and video file, initializing the first audio and video mixer; and returning to the step of performing the audio and video mixing operation by using the first audio and video mixer to obtain the first audio and video data. The technical scheme provided by the application can effectively solve the frame loss problem in the audio and video segment recording process, thereby guaranteeing the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of multimedia technology, and in particular to an audio and video recording method, as well as an audio and video recording device, electronic device, and computer-readable storage medium. Background Technology

[0002] With the rapid development of multimedia technology, the application of audio and video recording is becoming increasingly widespread, for example, in monitoring scenarios such as law enforcement, education, and healthcare. Since the recorded audio and video are generally used as backups and may be downloaded and viewed by many users, the recording quality has become the most important requirement in the field of audio and video recording and playback technology. However, traditional synchronous loop segmented recording schemes for audio and video still suffer from frame loss issues, resulting in a poor user experience.

[0003] Therefore, how to effectively solve the frame loss problem in the process of segmented audio and video recording is an urgent problem to be solved by those skilled in the art. Summary of the Invention

[0004] The purpose of this application is to provide an audio and video recording method that can effectively solve the frame loss problem in the process of segmented audio and video recording, thereby ensuring user experience. Another purpose of this application is to provide an audio and video recording device, an electronic device, and a computer-readable storage medium, all of which have the above-mentioned beneficial effects.

[0005] Firstly, this application provides an audio and video recording method, including:

[0006] When the recording mode is segmented recording mode, determine the segmentation conditions corresponding to the segmented recording mode and initialize the first audio and video mixer;

[0007] The first audio-video mixer is used to generate the first audio-video data from the audio data recorded by the audio thread and the video data recorded by the video thread.

[0008] When the real-time recording conditions meet the segmentation conditions, the first audio and video data is saved as the first audio and video file, and the second audio and video mixer is initialized.

[0009] The second audio-video mixer is used to generate second audio-video data from the audio data recorded by the audio thread and the video data recorded by the video thread;

[0010] When the real-time recording conditions meet the segmentation conditions, the second audio and video data is saved as a second audio and video file, and the first audio and video mixer is initialized;

[0011] Return to the step of generating the first audio and video data by using the first audio and video mixer to combine the audio data recorded by the audio thread and the video data recorded by the video thread.

[0012] Optionally, before saving the first audio / video data as a first audio / video file, the method further includes:

[0013] Control the audio thread and the video thread to stop recording;

[0014] Accordingly, before generating the second audio and video data by combining the audio data recorded by the audio thread and the video data recorded by the video thread using the second audio and video mixer, the method further includes:

[0015] Control the audio thread and the video thread to start recording.

[0016] Optionally, controlling the audio thread and the video thread to stop recording includes:

[0017] A stop command is sent to the audio thread and the video thread to cause the audio thread to stop recording and set a stop flag, so that the video thread stops recording when it detects the stop flag in the audio thread.

[0018] Optionally, after controlling the audio thread and the video thread to stop recording, the method further includes:

[0019] Control the first audio / video mixer to stop running.

[0020] Optionally, after saving the first audio / video data as a first audio / video file, the method further includes:

[0021] Release resources from the first audio / video mixer.

[0022] Optionally, the audio and video recording method further includes:

[0023] Control the audio thread to set a key audio frame flag for the first frame of audio in the audio data;

[0024] The video thread is controlled to set a key video frame flag for the first frame of the video data.

[0025] Optionally, the segmentation condition is a segmentation condition based on a preset recording duration, a segmentation condition based on a preset file size, or a segmentation condition based on a preset file length.

[0026] Secondly, this application also discloses an audio and video recording device, comprising:

[0027] The first initialization module is used to determine the segmentation conditions corresponding to the segmented recording mode and initialize the first audio and video mixer when the recording mode is segmented recording mode.

[0028] The first recording generation module is used to generate first audio and video data by using the first audio and video mixer to combine the audio data recorded by the audio thread and the video data recorded by the video thread.

[0029] The second initialization module is used to save the first audio and video data as a first audio and video file and initialize the second audio and video mixer when the real-time recording conditions meet the segmentation conditions.

[0030] The second recording generation module is used to generate second audio and video data by using the second audio and video mixer to combine the audio data recorded by the audio thread and the video data recorded by the video thread.

[0031] The third initialization module is used to save the second audio and video data as a second audio and video file and initialize the first audio and video mixer when the real-time recording conditions meet the segmentation conditions.

[0032] The loop module is used to return to the step of generating the first audio and video data by using the first audio and video mixer to combine the audio data recorded by the audio thread and the video data recorded by the video thread.

[0033] Thirdly, this application also discloses an electronic device, comprising:

[0034] Memory, used to store computer programs;

[0035] A processor, configured to execute the computer program to implement any of the audio / video recording methods described above.

[0036] Fourthly, this application also discloses a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of any of the audio and video recording methods described above.

[0037] This application provides an audio and video recording method, including: when the recording mode is a segmented recording mode, determining the segmentation conditions corresponding to the segmented recording mode and initializing a first audio and video mixer; using the first audio and video mixer to generate first audio and video data from audio data recorded by an audio thread and video data recorded by a video thread; when the real-time recording conditions meet the segmentation conditions, saving the first audio and video data as a first audio and video file and initializing a second audio and video mixer; using the second audio and video mixer to generate second audio and video data from audio data recorded by an audio thread and video data recorded by a video thread; when the real-time recording conditions meet the segmentation conditions, saving the second audio and video data as a second audio and video file and initializing the first audio and video mixer; and returning to the step of using the first audio and video mixer to generate the first audio and video data from audio data recorded by an audio thread and video data recorded by a video thread.

[0038] By applying the technical solution provided in this application, to achieve synchronous segmented audio and video recording, two audio and video mixers can be pre-created, namely the first audio and video mixer and the second audio and video mixer mentioned above, to achieve audio and video recording of adjacent segments in an alternating manner. In the first recording stage, the first audio and video mixer, after initialization, is used to perform audio and video mixing operations, and the first audio and video data is saved after the first recording stage ends. At the same time, the second audio and video mixer is initialized so that when entering the second recording stage, the second audio and video mixer can be directly used to perform audio and video mixing operations, thereby realizing the second stage recording. Obviously, the setting of two audio and video mixers enables the saving operation of the first audio and video mixed data in the first audio and video mixer and the initialization operation of the second audio and video mixer to be performed synchronously. Compared with the traditional technology that uses one audio and video mixer to perform audio and video data saving operations first and then perform audio and video mixer initialization operations, this effectively shortens the gap between the first recording stage and the second recording stage, thereby effectively reducing the frame loss problem in the segmented audio and video recording process and ensuring user experience. Furthermore, the audio and video recording method provided in this application embodiment can be implemented in the upper-layer APP without any modification or adaptation to the system framework layer, and has high practicality.

[0039] The audio and video recording device, electronic device, and computer-readable storage medium provided in this application also have the above-mentioned technical effects, and will not be described in detail here. Attached Figure Description

[0040] To more clearly illustrate the technical solutions in the prior art and the embodiments of this application, the accompanying drawings used in the description of the prior art and the embodiments of this application will be briefly introduced below. Of course, the accompanying drawings described below with respect to the embodiments of this application are only a part of the embodiments in this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort, and such other drawings also fall within the protection scope of this application.

[0041] Figure 1 A flowchart illustrating an audio / video recording method provided in this application;

[0042] Figure 2 A schematic diagram of the structure of an audio and video recording device provided in this application;

[0043] Figure 3 This is a schematic diagram of the structure of an electronic device provided in this application. Detailed Implementation

[0044] The core of this application is to provide an audio and video recording method that can effectively solve the frame loss problem in the process of segmented audio and video recording, thereby ensuring user experience. Another core aspect of this application is to provide an audio and video recording device, electronic device, and computer-readable storage medium, all of which have the aforementioned beneficial effects.

[0045] To provide a clearer and more complete description of the technical solutions in the embodiments of this application, the technical solutions in the embodiments of this application will be described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.

[0046] This application provides an audio and video recording method.

[0047] Please refer to Figure 1 , Figure 1 This is a flowchart illustrating an audio / video recording method provided in this application, which may include the following steps S101 to S105.

[0048] S101: When the recording mode is segmented recording mode, determine the segmentation conditions corresponding to the segmented recording mode and initialize the first audio and video mixer.

[0049] This step aims to determine the recording mode. It's understood that during audio and video recording, the recording mode can be divided into segmented recording mode and real-time recording mode. Segmented recording mode refers to saving the recording data each time a preset segmentation condition is met (such as the recording duration reaching a preset length). Each saved recording data represents the audio and video data recorded in each recording stage. Real-time recording mode, on the other hand, involves recording in real-time and saving the recording data only when the recording is completely finished. The saved recording data represents the audio and video data recorded throughout the entire recording process.

[0050] Specifically, users can select the recording mode according to their actual needs. When the user selects the segmented recording mode, the segmentation conditions corresponding to the segmented recording mode can be further determined. The specific content of the segmentation conditions does not affect the implementation of this technical solution. Users can set them according to their own actual needs. For example, they can set a preset duration for each interval to record in segments, or they can record in segments according to a preset recording data size, etc.

[0051] Furthermore, while determining the segmentation conditions corresponding to the segmented recording mode, the first audio-video mixer can be initialized. This first audio-video mixer is used to mix audio and video data to generate mixed audio-video data (here referring to the first audio-video data described below). It is understandable that performing the determination of segmentation conditions and the initialization of the first audio-video mixer simultaneously helps to improve audio-video recording efficiency.

[0052] S102: Use the first audio-video mixer to generate the first audio-video data from the audio data recorded by the audio thread and the video data recorded by the video thread.

[0053] This step aims to generate the first audio and video data, a process based on the initialized first audio and video mixer described above. Specifically, after receiving a recording command, the system will start an audio thread and a video thread. The audio thread is used for audio recording to obtain audio data, while the video thread is used for video recording to obtain video data. Furthermore, after completing the initialization of the first audio and video mixer, it can be used to mix the audio data recorded by the audio thread and the video data recorded by the video thread to obtain the first audio and video data.

[0054] S103: When the real-time recording conditions meet the segmentation conditions, save the first audio and video data as the first audio and video file, and initialize the second audio and video mixer.

[0055] This step aims to store and process the first audio and video data. It is understood that, due to the segmented recording mode, during the audio and video recording process, the recording data will be saved each time a preset segmentation condition is met. Based on this, the real-time recording conditions can be monitored in real time to determine whether the real-time recording conditions meet the segmentation conditions, such as whether the real-time recording duration reaches the preset duration or whether the real-time recording data size meets the preset data size. Furthermore, when the monitoring shows that the real-time recording conditions meet the segmentation conditions, the first audio and video data can be converted into a first audio and video file. Of course, this application does not limit the file type of the first audio and video file; in one possible implementation, it can be saved as an MP4 format.

[0056] Furthermore, while saving the first audio and video data, the second audio and video mixer can be initialized. This second audio and video mixer is used to mix audio and video data to generate mixed audio and video data (hereinafter referred to as the second audio and video data). It is understandable that initializing the second audio and video mixer while saving the first audio and video data, that is, initializing the second audio and video mixer before the start of the next recording stage, can effectively avoid initializing the audio and video mixer again in the next recording stage. This effectively shortens the gap between two adjacent recording stages, thereby effectively reducing frame loss problems during segmented audio and video recording.

[0057] S104: Use the second audio-video mixer to generate second audio-video data from the audio data recorded by the audio thread and the video data recorded by the video thread.

[0058] This step aims to generate the second audio and video data, a process based on the initialized second audio and video mixer described above. It can be understood that after completing the initialization of the second audio and video mixer, the next segmented recording stage begins. In this stage, the second audio and video mixer can be directly used (without needing to initialize it in this recording stage) to mix the audio data recorded by the audio thread and the video data recorded by the video thread to obtain the second audio and video data.

[0059] S105: When the real-time recording conditions meet the segmentation conditions, save the second audio and video data as the second audio and video file, initialize the first audio and video mixer, and return to S102.

[0060] This step aims to achieve cyclic segmented recording of audio and video. As mentioned above, during the audio and video recording process, recording data is saved each time a preset segmentation condition is met. Therefore, during the current audio and video recording stage, real-time recording conditions are also monitored. When the real-time recording conditions meet the segmentation conditions, the second audio and video data is saved as the second audio and video file. Simultaneously, the first audio and video mixer is initialized to facilitate audio and video mixing in the next segmented recording stage. Thus, by setting two audio and video mixers and using them alternately, adjacent segments of audio and video recording are achieved, which helps reduce frame dropping issues during the segmented audio and video recording process.

[0061] As can be seen, the audio and video recording method provided in this application, in order to achieve synchronous segmented audio and video recording, can pre-create two audio and video mixers, namely the first audio and video mixer and the second audio and video mixer mentioned above, to achieve audio and video recording of adjacent segments in an alternating manner. In the first recording stage, the first audio and video mixer, after initialization, is used to perform audio and video mixing operations, and the first audio and video data is saved after the first recording stage ends. At the same time, the second audio and video mixer is initialized so that when entering the second recording stage, the second audio and video mixer can be directly used to perform audio and video mixing operations, thereby realizing the second stage recording. Obviously, the setting of two audio and video mixers enables the saving operation of the first audio and video mixed data in the first audio and video mixer and the initialization operation of the second audio and video mixer to be performed synchronously. Compared with the traditional technology, which uses one audio and video mixer to perform audio and video data saving operations first and then performs audio and video mixer initialization operations, it effectively shortens the gap between the first recording stage and the second recording stage, thereby effectively reducing the frame loss problem in the segmented audio and video recording process, and thus ensuring user experience. Furthermore, the audio and video recording method provided in this application embodiment can be implemented in the upper-layer APP without any modification or adaptation to the system framework layer, and has high practicality.

[0062] Based on the above embodiments:

[0063] In one embodiment of this application, before saving the first audio and video data as the first audio and video file, the method may further include: controlling the audio thread and the video thread to stop recording;

[0064] Accordingly, before generating the second audio and video data using the second audio and video mixer, the process may further include: controlling the audio and video threads to start recording.

[0065] To further reduce frame loss during audio and video recording, the audio and video recording method provided in this application embodiment can further implement control functions for the audio thread and the video thread. These control functions mainly include thread start control function and thread stop control function.

[0066] Specifically, before saving the first audio and video data as the first audio and video file, the audio thread and video thread can be stopped from recording, that is, the recording of audio and video data can be stopped. This operation can also effectively avoid the problem of audio and video recording exceeding the recording conditions. Furthermore, after saving the first audio and video data as the first audio and video file and initializing the second audio and video mixer, before using the second audio and video mixer to generate the second audio and video data, the audio thread and video thread can be started again, that is, the recording of audio and video data can be restarted.

[0067] It should be noted that the above-mentioned control over audio and video threads applies to each segmented recording stage.

[0068] In one embodiment of this application, the above-mentioned control of the audio thread and video thread to stop recording may include: sending a stop command to the audio thread and video thread to cause the audio thread to stop recording and set a stop flag, so that the video thread stops recording when it detects the stop flag in the audio thread.

[0069] This application provides a method for controlling the audio and video threads to stop recording. Specifically, when the real-time recording conditions meet the segmentation conditions, a stop command can be sent to both the audio and video threads simultaneously. Upon receiving the stop command, the audio thread immediately responds and stops audio recording, while simultaneously setting a stop flag. The video thread, upon receiving the stop command, immediately responds by monitoring the audio thread to determine if it can detect the stop flag. If the stop flag is detected, it indicates that the audio thread has successfully stopped recording, and the video thread can then stop recording video data. Conversely, if the video thread does not detect the stop flag in the audio thread, it indicates that the audio thread has failed to stop recording and is still recording audio data; in this case, the video thread will not stop recording video data. Real-time monitoring of the stop command can be achieved by setting a `run` function in both the video and audio threads. Of course, restarting the video and audio threads can also be implemented using the above method.

[0070] Clearly, based on the above implementation method, it can be guaranteed that the audio thread and the video thread can stop recording and restart recording at the same time, thereby ensuring the synchronization of the audio thread and the video thread.

[0071] Furthermore, it should be noted that the above-mentioned embodiments use a video thread monitoring an audio thread to achieve synchronization between the video and audio threads. Of course, the reverse operation can also be used, i.e., the audio thread monitoring the video thread to achieve synchronization; this application does not limit this approach. However, in actual operation, the sampling rate of the audio thread is much higher than that of the video thread. Therefore, using a video thread to monitor the audio thread, so that the audio thread stops running before the video thread, is more helpful in reducing frame drop issues.

[0072] In one embodiment of this application, after the above-mentioned control of the audio thread and video thread to stop recording, it may further include: controlling the first audio and video mixer to stop running.

[0073] It is understandable that after the audio and video threads stop recording, the process of saving the first audio and video data in the first audio and video mixer will begin. At this time, in order to avoid the first audio and video mixer being in a running state from affecting the saving operation of the first audio and video data, the first audio and video mixer can be stopped after the audio and video threads stop recording and before the first audio and video data is saved.

[0074] In one embodiment of this application, after saving the first audio and video data as a first audio and video file, the method may further include: releasing resources of the first audio and video mixer.

[0075] To avoid unnecessary resource consumption, after saving the first audio and video data as the first audio and video file, the first audio and video mixer can be further released to provide audio and video mixing services for subsequent new segmented recording stages.

[0076] In one embodiment of this application, the audio and video recording method may further include: controlling the audio thread to set a key audio frame flag for the first frame of audio in the audio data; and controlling the video thread to set a key video frame flag for the first frame of video in the video data.

[0077] The audio and video recording method provided in this application embodiment can further realize the function of setting key frames during segmented recording. That is, in each recording stage, the audio thread is controlled to set the first frame of audio in the audio data recorded in the current recording stage as the key audio frame, and the video thread is controlled to set the first frame of video in the video data recorded in the current recording stage as the key video frame. This process can be achieved by setting a key flag bit for the first frame of video and the first frame of audio.

[0078] Understandably, based on this implementation method, when playing recorded audio and video, if it is necessary to fast forward or rewind the playback screen, each fast forward or rewind operation can fast forward or rewind the playback screen to the first frame of a certain audio or video file, and can ensure that the audio and video playback is synchronized.

[0079] In one embodiment of this application, the above segmentation conditions may be segmentation conditions based on preset recording duration, or segmentation conditions based on preset file size, or segmentation conditions based on preset file length.

[0080] This application provides several different types of segmentation conditions, namely, segmentation conditions based on preset recording duration, segmentation conditions based on preset file size, and segmentation conditions based on preset file length. Specifically, the segmentation condition based on preset recording duration means that whenever the recording duration reaches the preset duration, the segmentation condition is considered met, the current recording stage ends, and the next recording stage begins. The segmentation condition based on preset file size means that whenever the size of the recorded audio / video file reaches the preset file size, the segmentation condition is considered met, the current recording stage ends, and the next recording stage begins. The segmentation condition based on preset file length means that whenever the length of the recorded audio / video file reaches the preset file length, the segmentation condition is considered met, the current recording stage ends, and the next recording stage begins.

[0081] It should be noted that the specific values ​​of the preset recording duration, preset file size, and preset file length do not affect the implementation of this technical solution, and can all be customized by technical personnel according to actual needs. This application does not impose any restrictions on these values.

[0082] Based on the above embodiments:

[0083] This application provides another audio and video recording method, the implementation process of which is as follows:

[0084] (1) Set up two Muxer encoders (first audio / video mixer and second audio / video mixer), with mMuxerCount set to 2 by default;

[0085] (2) Upon receiving a recording instruction, determine the recording mode and initialize the first audio-video mixer;

[0086] (3) When the recording mode is segmented recording mode, determine the segmentation conditions;

[0087] (4) Use the audio thread to record audio data, use the video thread to record video data, control the audio thread to set the first audio frame of the current recording stage as the key audio frame, control the video thread to set the first video frame of the current recording stage as the key video frame, use the first video encoder to encode the audio data and video data to obtain the first audio and video data.

[0088] (5) When the segmentation conditions are met, a stop command is sent to the audio thread and the video thread;

[0089] (6) The audio thread responds to the stop command and automatically stops running, and sets the stop flag; the video thread responds to the stop command and monitors the stop flag in the audio thread, and automatically stops running when it is detected;

[0090] (7) Control the first audio and video mixer to stop running, release its resources, save the first video data as an MP4 file, and initialize the second audio and video mixer;

[0091] (8) Send a restart command to the audio thread and the video thread, use the audio thread to record audio data, use the video thread to record video data, control the audio thread to set the first audio frame of the current recording stage as the key audio frame, control the video thread to set the first video frame of the current recording stage as the key video frame, use the second video encoder to encode the audio data and video data to obtain the second audio and video data.

[0092] (9) When the segmentation conditions are met, a stop command is sent to the audio thread and the video thread;

[0093] (10) The audio thread responds to the stop command and automatically stops running and sets the stop flag; the video thread responds to the stop command and monitors the stop flag in the audio thread, and automatically stops running when it is detected;

[0094] (11) Control the second audio and video mixer to stop running, release its resources, save the second video data as an MP4 file, and initialize the first audio and video mixer at the same time;

[0095] (12) Send a restart command to the audio thread and video thread, and return (4).

[0096] As can be seen, the audio and video recording method provided in this application, in order to achieve synchronous segmented audio and video recording, can pre-create two audio and video mixers, namely the first audio and video mixer and the second audio and video mixer mentioned above, to achieve audio and video recording of adjacent segments in an alternating manner. In the first recording stage, the first audio and video mixer, after initialization, is used to perform audio and video mixing operations, and the first audio and video data is saved after the first recording stage ends. At the same time, the second audio and video mixer is initialized so that when entering the second recording stage, the second audio and video mixer can be directly used to perform audio and video mixing operations, thereby realizing the second stage recording. Obviously, the setting of two audio and video mixers enables the saving operation of the first audio and video mixed data in the first audio and video mixer and the initialization operation of the second audio and video mixer to be performed synchronously. Compared with the traditional technology, which uses one audio and video mixer to perform audio and video data saving operations first and then performs audio and video mixer initialization operations, it effectively shortens the gap between the first recording stage and the second recording stage, thereby effectively reducing the frame loss problem in the segmented audio and video recording process, and thus ensuring user experience. Furthermore, the audio and video recording method provided in this application embodiment can be implemented in the upper-layer APP without any modification or adaptation to the system framework layer, and has high practicality.

[0097] This application provides an audio and video recording device.

[0098] Please refer to Figure 2 , Figure 2 This application provides a schematic diagram of the structure of an audio and video recording device, which may include:

[0099] The first initialization module 100 is used to determine the segmentation conditions corresponding to the segmentation recording mode and initialize the first audio and video mixer when the recording mode is segmented recording mode.

[0100] The first recording generation module 200 is used to generate first audio and video data by using the first audio and video mixer to combine the audio data recorded by the audio thread and the video data recorded by the video thread.

[0101] The second initialization module 300 is used to save the first audio and video data as the first audio and video file and initialize the second audio and video mixer when the real-time recording conditions meet the segmentation conditions.

[0102] The second recording generation module 400 is used to generate second audio and video data by using the second audio and video mixer to combine the audio data recorded by the audio thread and the video data recorded by the video thread.

[0103] The third initialization module 500 is used to save the second audio and video data as the second audio and video file and initialize the first audio and video mixer when the real-time recording conditions meet the segmentation conditions.

[0104] The loop module 600 is used to return the steps of generating the first audio and video data by using the first audio and video mixer to combine the audio data recorded by the audio thread and the video data recorded by the video thread.

[0105] As can be seen, the audio and video recording apparatus provided in this application embodiment can pre-create two audio and video mixers, namely the first audio and video mixer and the second audio and video mixer, to achieve synchronous segmented audio and video recording. These mixers are used interchangeably to record adjacent segments of audio and video. In the first recording stage, the first audio and video mixer, after initialization, performs audio and video mixing operations, and the first audio and video data is saved after the first recording stage ends. At the same time, the second audio and video mixer is initialized so that when entering the second recording stage, the second audio and video mixer can be used directly to perform audio and video mixing operations, thereby achieving the second stage of recording. Obviously, the setting of two audio and video mixers enables the saving operation of the first audio and video mixed data in the first audio and video mixer and the initialization operation of the second audio and video mixer to be performed synchronously. Compared with the traditional technology that uses one audio and video mixer to perform audio and video data saving operations first and then perform audio and video mixer initialization operations, this effectively shortens the gap between the first recording stage and the second recording stage, thereby effectively reducing the frame loss problem in the segmented audio and video recording process and ensuring user experience. Furthermore, the audio and video recording method provided in this application embodiment can be implemented in the upper-layer APP without any modification or adaptation to the system framework layer, and has high practicality.

[0106] In one embodiment of this application, the audio and video recording device may further include a first control module, used to control the audio thread and video thread to stop recording before the first audio and video data is saved as the first audio and video file; and to control the audio thread and video thread to start recording before the second audio and video data is generated by using the second audio and video mixer to combine the audio data recorded by the audio thread and the video data recorded by the video thread.

[0107] In one embodiment of this application, the first control module described above can be specifically used to send a stop command to the audio thread and the video thread, so that the audio thread stops recording and sets a stop flag, and the video thread stops recording when it detects the stop flag in the audio thread.

[0108] In one embodiment of this application, the audio and video recording device may further include a second control module, used to control the first audio and video mixer to stop running after the audio thread and video thread have stopped recording as described above.

[0109] In one embodiment of this application, the audio and video recording device may further include a resource release module for releasing resources of the first audio and video mixer after the first audio and video data is saved as the first audio and video file.

[0110] In one embodiment of this application, the audio and video recording device may further include a third control module, which controls the audio thread to set a key audio frame flag for the first frame of audio in the audio data; and controls the video thread to set a key video frame flag for the first frame of video in the video data.

[0111] In one embodiment of this application, the above segmentation conditions may be segmentation conditions based on preset recording duration, or segmentation conditions based on preset file size, or segmentation conditions based on preset file length.

[0112] For a description of the apparatus provided in the embodiments of this application, please refer to the above method embodiments; further details will not be repeated here.

[0113] This application provides an electronic device.

[0114] Please refer to Figure 3 , Figure 3 This application provides a schematic diagram of the structure of an electronic device, which may include:

[0115] Memory, used to store computer programs;

[0116] A processor, used to execute computer programs, can implement the steps of any of the audio and video recording methods described above.

[0117] like Figure 3 The diagram shows the structural composition of an electronic device, which may include a processor 10, a memory 11, a communication interface 12, and a communication bus 13. The processor 10, memory 11, and communication interface 12 all communicate with each other through the communication bus 13.

[0118] In this embodiment, the processor 10 may be a central processing unit (CPU), an application-specific integrated circuit, a digital signal processor, a field-programmable gate array, or other programmable logic devices.

[0119] The processor 10 can call the program stored in the memory 11. Specifically, the processor 10 can execute the operations in the embodiments of the audio and video recording method.

[0120] The memory 11 is used to store one or more programs. The programs may include program code, which includes computer operation instructions. In this embodiment, the memory 11 stores at least a program for implementing the following functions:

[0121] When the recording mode is segmented recording mode, determine the segmentation conditions corresponding to the segmented recording mode and initialize the first audio and video mixer;

[0122] The first audio-video mixer is used to generate the first audio-video data from the audio data recorded by the audio thread and the video data recorded by the video thread.

[0123] When the real-time recording conditions meet the segmentation conditions, the first audio and video data is saved as the first audio and video file, and the second audio and video mixer is initialized.

[0124] The second audio-video mixer is used to generate second audio-video data from the audio data recorded by the audio thread and the video data recorded by the video thread;

[0125] When the real-time recording conditions meet the segmentation conditions, the second audio and video data is saved as the second audio and video file, and the first audio and video mixer is initialized.

[0126] Return to the steps of generating the first audio and video data using the first audio and video mixer from the audio data recorded by the audio thread and the video data recorded by the video thread.

[0127] In one possible implementation, the memory 11 may include a program storage area and a data storage area, wherein the program storage area may store the operating system and applications required for at least one function; and the data storage area may store data created during use.

[0128] In addition, memory 11 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device or other volatile solid-state storage device.

[0129] Communication interface 12 can be an interface for the communication module, used to connect with other devices or systems.

[0130] Of course, it should be noted that, Figure 3 The structure shown does not constitute a limitation on the electronic device in the embodiments of this application. In practical applications, the electronic device may include more than Figure 3 More or fewer components as shown, or combinations of certain components.

[0131] This application provides a computer-readable storage medium.

[0132] The computer-readable storage medium provided in this application embodiment stores a computer program, which, when executed by a processor, can implement the steps of any of the audio and video recording methods described above.

[0133] The computer-readable storage medium may include various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0134] For a description of the computer-readable storage medium provided in the embodiments of this application, please refer to the above method embodiments; further details will not be repeated here.

[0135] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to the method section.

[0136] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software 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, but such implementation should not be considered beyond the scope of this application.

[0137] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0138] The audio and video recording method, apparatus, electronic device, and computer-readable storage medium provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are merely for the purpose of helping to understand the method and its core ideas. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of this application.

Claims

1. An audio and video recording method, characterized in that, include: When the recording mode is segmented recording mode, determine the segmentation conditions corresponding to the segmented recording mode and initialize the first audio and video mixer; The first audio-video mixer is used to generate the first audio-video data from the audio data recorded by the audio thread and the video data recorded by the video thread. When the real-time recording conditions meet the segmentation conditions, the first audio and video data is saved as the first audio and video file, and the second audio and video mixer is initialized. The second audio-video mixer is used to generate second audio-video data from the audio data recorded by the audio thread and the video data recorded by the video thread; When the real-time recording conditions meet the segmentation conditions, the second audio and video data is saved as a second audio and video file, and the first audio and video mixer is initialized; Returning to the step of using the first audio-video mixer to generate the first audio-video data from the audio data recorded by the audio thread and the video data recorded by the video thread; Before saving the first audio and video data as the first audio and video file, the method further includes: controlling the audio thread and the video thread to stop recording; Accordingly, before generating the second audio and video data by using the second audio and video mixer to combine the audio data recorded by the audio thread and the video data recorded by the video thread, the method further includes: controlling the audio thread and the video thread to start recording; The step of controlling the audio thread and the video thread to stop recording includes: sending a stop command to the audio thread and the video thread to cause the audio thread to stop recording and set a stop flag, so that the video thread stops recording when it detects the stop flag in the audio thread.

2. The audio and video recording method according to claim 1, characterized in that, After controlling the audio thread and the video thread to stop recording, the method further includes: Control the first audio / video mixer to stop running.

3. The audio and video recording method according to claim 1, characterized in that, After saving the first audio and video data as a first audio and video file, the method further includes: Release resources from the first audio / video mixer.

4. The audio and video recording method according to any one of claims 1 to 3, characterized in that, Also includes: Control the audio thread to set a key audio frame flag for the first frame of audio in the audio data; The video thread is controlled to set a key video frame flag for the first frame of the video data.

5. The audio and video recording method according to claim 1, characterized in that, The segmentation conditions are either preset recording duration, preset file size, or preset file length.

6. An audio and video recording device, characterized in that, include: The first initialization module is used to determine the segmentation conditions corresponding to the segmented recording mode and initialize the first audio and video mixer when the recording mode is segmented recording mode. The first recording generation module is used to generate first audio and video data by using the first audio and video mixer to combine the audio data recorded by the audio thread and the video data recorded by the video thread. The second initialization module is used to save the first audio and video data as a first audio and video file and initialize the second audio and video mixer when the real-time recording conditions meet the segmentation conditions. The second recording generation module is used to generate second audio and video data by using the second audio and video mixer to combine the audio data recorded by the audio thread and the video data recorded by the video thread. The third initialization module is used to save the second audio and video data as a second audio and video file and initialize the first audio and video mixer when the real-time recording conditions meet the segmentation conditions. The loop module is used to return to the step of generating the first audio and video data by using the first audio and video mixer to combine the audio data recorded by the audio thread and the video data recorded by the video thread. The first control module is used to control the audio thread and the video thread to stop recording before the first audio and video data is saved as the first audio and video file; Before generating the second audio and video data by combining the audio data recorded by the audio thread and the video data recorded by the video thread using the second audio and video mixer, the audio thread and the video thread are controlled to start recording; The first control module is specifically used to send a stop command to the audio thread and the video thread, so that the audio thread stops recording and sets a stop flag, and the video thread stops recording when it detects the stop flag in the audio thread.

7. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the audio / video recording method as described in any one of claims 1 to 5 when executing the computer program.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the audio and video recording method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method and system for circularly recording video

    CN114615451A