A video recording method, a shooting device and a readable storage medium

By responding to recording and lens switching commands in the shooting device, controlling different cameras to record and write to the same recording file, the problem of video discontinuity when switching cameras is solved, realizing the flexibility and convenience of video recording, and ensuring audio and video synchronization and smooth transition of the picture.

CN122457728APending Publication Date: 2026-07-24ARASHI VISION INC
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ARASHI VISION INC
Filing Date
2025-04-22
Publication Date
2026-07-24

Smart Images

  • Figure CN122457728A_ABST
    Figure CN122457728A_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a video recording method, a shooting device and a readable storage medium. The video recording method responds to a recording instruction, controls a first camera to perform a recording operation to obtain first video encoding data, writes the first video encoding data into a recording file, responds to a lens switching instruction, controls a second camera to perform a recording operation to obtain second video encoding data, writes the second video encoding data into the recording file, and finally responds to a recording stop instruction to generate a video playing file based on the recording file. Therefore, in the video recording process, the video recording method can switch different cameras to continue recording in response to the lens switching instruction, and writes the video encoding data obtained by the cameras before and after switching into the same recording file, realizes a dynamic real-time splicing effect, directly outputs a complete video when recording is terminated, and improves the flexibility and convenience of video recording.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of video recording technology, and in particular to a video recording method, shooting device and readable storage medium. Background Technology

[0002] With the development of the photography industry, shooting equipment has become increasingly feature-rich, resulting in better and better shooting effects. Shooting equipment typically features multiple cameras, such as front-facing and rear-facing cameras, allowing users to switch between different cameras for optimal shooting results.

[0003] When users record video using a camera, they typically use one of the cameras to record, saving the resulting video data as a separate video file. If they want to switch to another camera, they need to stop the current recording and then click the switch button. This allows the camera to control the other camera to record, saving the resulting video data as another separate video file. In other words, the video files captured by the camera before and after the switch are two separate video files, and continuous recording is not possible before and after the switch, making it impossible to directly obtain a complete recorded video. Summary of the Invention

[0004] The embodiments of this application aim to provide a video recording method, shooting device, and readable storage medium, which can directly output a complete video from the video captured by switching between front and rear cameras, thereby improving the flexibility and convenience of video recording.

[0005] To address the aforementioned technical problems, this application provides the following technical solutions:

[0006] In a first aspect, embodiments of this application provide a video recording method applied to a shooting device, the shooting device including a first camera and a second camera, the first camera and the second camera being a front-facing camera and a rear-facing camera, respectively, the method comprising:

[0007] In response to a recording command, the system controls the first camera to perform a recording operation, obtains the first video encoded data, and writes the first video encoded data into a recording file.

[0008] In response to a lens switching command, the system controls the second camera to perform a recording operation, obtains second video encoded data, and writes the second video encoded data into the recording file.

[0009] In response to the recording stop command, a video playback file is generated based on the recorded file.

[0010] In some embodiments, the method further includes:

[0011] In response to the lens switching command, the first camera is turned off and the second camera is turned on.

[0012] In some embodiments, the method further includes:

[0013] Determine the transition screen;

[0014] The transition frame is output after the first frame corresponding to the first video encoded data is output and before the second frame corresponding to the second video encoded data is output.

[0015] In some embodiments, determining the transition screen includes:

[0016] The transition frame is determined based on the last frame of the first video encoding data.

[0017] In some embodiments, generating a video playback file based on the recorded video file includes:

[0018] Acquire target audio data, wherein the target audio data is the audio data acquired between the recording instruction and the recording stop instruction;

[0019] The target audio data is extracted based on the timestamp to obtain the first audio data;

[0020] A video playback file is generated based on the video recording file and the first audio data.

[0021] In some embodiments, the step of extracting the target audio data based on a timestamp to obtain first audio data includes:

[0022] Determine a first moment and a second moment, wherein the first moment is the start time of the display of the transition screen, the second moment is the end time of the display of the transition screen, and the first moment and the second moment are one of the timestamps of the target audio data;

[0023] The second audio data is extracted from the target audio data to obtain the first audio data, wherein the second audio data is the data in the target audio data from the first time point to the second time point.

[0024] In some embodiments, after controlling the second camera to perform the recording operation, the method further includes:

[0025] Acquire the second video data captured by the second camera;

[0026] The second video data is used to perform audio and video synchronization operations based on timestamps.

[0027] In some embodiments, the method further includes:

[0028] In response to the lens switching command, the first camera is turned off within a preset time after the second camera is activated.

[0029] In some embodiments, the first camera captures first video data, and the second camera captures second video data; the method further includes:

[0030] After the second camera is activated, it is detected whether the preset buffer corresponding to the first camera has cached video cache data, wherein the video cache data is the data to be encoded in the first video data;

[0031] If so, the video cache data is encoded to obtain cached encoded data, and the cached encoded data is written to the video recording file;

[0032] If not, write the second video encoded data into the recorded file.

[0033] In some embodiments, if the preset buffer corresponding to the first camera does not contain the video cache data, the first camera is turned off.

[0034] In some embodiments, the method further includes:

[0035] After outputting the first frame corresponding to the first video encoded data and before outputting the second frame corresponding to the second video encoded data, the frame corresponding to the cached encoded data is output.

[0036] In some embodiments, the video file does not contain image data of transition scenes.

[0037] In some embodiments, the configuration parameters for the second camera when performing a recording operation are the same as the parameters configured for the first camera when performing a recording operation.

[0038] In a second aspect, embodiments of this application provide a shooting device, the shooting device comprising: a first camera, a second camera, and at least one processor; and,

[0039] A memory communicatively connected to the at least one processor; wherein,

[0040] The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enable the at least one processor to perform the video recording method described above;

[0041] The first camera and the second camera are respectively communicatively connected to the at least one processor. The first camera is configured to perform a recording operation under the control of the at least one processor, and the second camera is configured to perform a recording operation under the control of the at least one processor.

[0042] In a third aspect, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions for causing a computer device to perform the video recording method described above.

[0043] The beneficial effects of this application are as follows: Compared with the prior art, the embodiments of this application provide a video recording method. This method responds to a recording command, controls a first camera to perform recording operations, obtains first video encoded data, writes the first video encoded data into a video file, responds to a lens switching command, controls a second camera to perform recording operations, obtains second video encoded data, writes the second video encoded data into the video file, and finally responds to a recording stop command to generate a video playback file based on the video file. Therefore, this video recording method, during the video recording process, responds to lens switching commands, allowing switching between different cameras to continue recording, and writes the video encoded data obtained from the cameras before and after the switch into the same video file. When recording ends, it directly outputs a complete video, improving the flexibility and convenience of video recording. Attached Figure Description

[0044] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.

[0045] Figure 1 This is a schematic diagram of the structure of one of the shooting devices provided in the embodiments of this application;

[0046] Figure 2 This is a schematic diagram of the structure of one type of human-computer interaction screen provided in an embodiment of this application;

[0047] Figure 3 This is a schematic diagram of the structure of one of the shooting devices provided in the embodiments of this application;

[0048] Figure 4 A flowchart illustrating one of the video recording methods provided in this application embodiment;

[0049] Figure 5 A flowchart illustrating one of the video recording methods provided in this application embodiment;

[0050] Figure 6 for Figure 4 Flowchart of step S13;

[0051] Figure 7 A flowchart illustrating one of the video recording methods provided in this application embodiment;

[0052] Figure 8 This is a schematic diagram of the structure of one of the video recording devices provided in the embodiments of this application. Detailed Implementation

[0053] To facilitate understanding of this application, a more detailed description is provided below with reference to the accompanying drawings and specific embodiments. It should be noted that when an element is described as "connected" to another element, it can be directly connected to the other element, or there may be one or more intervening elements. Furthermore, the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0054] Unless otherwise defined, all technical and scientific terms used in this specification have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of this application. The term "and / or" as used in this specification includes any and all combinations of one or more of the associated listed items.

[0055] Furthermore, the technical features involved in the different embodiments of this application described below can be combined with each other as long as they do not conflict with each other.

[0056] Please see Figure 1 , Figure 1 This is a schematic diagram of the structure of a shooting device provided in an embodiment of this application, such as... Figure 1 As shown, the shooting device 100 includes a first camera 11 and a second camera 12, which serve as a front-facing camera and a rear-facing camera, respectively. The first camera 11 and the second camera 12 are disposed on opposite sides of the shooting device 100. The first camera 11 is located on the front of the shooting device and can be referred to as the front-facing camera, while the second camera 12 is located on the back of the shooting device and can be referred to as the rear-facing camera. In some embodiments, the first camera 11 is a rear-facing camera, and the second camera 12 is a front-facing camera. In other embodiments, the first camera 11 and the second camera 12 are not limited to being located on the front and back of the shooting device 100; they can also be disposed on other opposite sides of the shooting device 100.

[0057] The shooting device 100 also includes a display unit 13, which is equipped with a human-computer interaction screen for displaying images or videos captured by the camera to the user. It also provides feedback and receives user input commands, such as detecting user gestures like clicks and swipes to generate corresponding input commands, which the shooting device 100 then responds to. The display unit 13 can also receive control commands and display information sent by the shooting device 100 to display content corresponding to the control commands and information to the user.

[0058] For example: human-computer interaction screens, such as Figure 2 As shown, the human-computer interaction screen displays a record button 131 and a switch button 132. This embodiment of the application does not impose any restrictions on the relative positions of the record button 131 and the switch button 132. Figure 2 The example shown uses a record button 131 and a switch button 132 arranged side-by-side. When a user clicks the record button 131, the display unit 13 detects the click action and location, generates a record command, and the shooting device 100 responds to the record command, controlling the first camera 11 to perform recording. During recording, if the user clicks the switch button 132, the display unit 13 generates a lens switching command based on the click action and location, and the shooting device 100 responds to the lens switching command, switching to the second camera 12 to perform recording. The human-computer interaction screen can also display other parameters of the shooting device, for example... Figure 2 In this context, 2.5h represents the storage card status / remaining memory space available to store video duration, and 5.7k / 30 represents the shooting parameters of the shooting device. In other embodiments, the human-computer interaction screen may also display information such as the shooting device's battery status, the shooting mode being used, and the headphone connection status.

[0059] Meanwhile, when the first camera 11 or the second camera 12 is recording, the display unit 13 can display the captured images or videos to the user, so that the user can adjust the shooting posture or shooting position of the shooting device 100 according to the displayed images or videos. In some embodiments, the human-computer interaction screen is also provided with a playback button or a view button. When the user clicks the button, the display unit 13 detects the click action and the click position, generates a playback command or a view command, and the shooting device 100 responds to the playback command or view command by sending the corresponding video or image to the human-computer interaction screen so that the screen displays the photo or video image that the user wants to view.

[0060] In some embodiments, please continue reading Figure 1The shooting device 100 also includes an audio unit 14, which mainly consists of a microphone, an audio processing chip, an amplifier, and a speaker. The microphone collects sounds from the surrounding environment to obtain an audio signal. The audio signal is amplified, filtered, and noise-reduced by the audio processing chip to obtain a processed audio signal. The audio processing chip then converts the processed audio signal into audio data. The audio data is a digital signal. The audio processing chip then encodes the audio data according to a specific audio encoding format to obtain audio encoded data. The audio encoded data, together with the video data, is stored in the memory card or other storage medium of the shooting device 100 according to the storage format of the shooting device 100.

[0061] Please refer to the following: Figure 1 and Figure 3 The imaging device 100 also includes at least one processor 15 that is communicatively connected via a system bus or other means. Figure 1 and Figure 3 (Taking a single processor as an example) The processor 15 is connected to the memory 16, the first camera 11, the second camera 12, the audio unit 14, and the display unit 13. Figure 1 The first camera 11, the second camera 12, the audio unit 14, and the display unit 13 are all connected to the processor 15 via a system bus. In other embodiments, the first camera 11, the second camera 12, the audio unit 14, and the display unit 13 may also be connected to the processor 15 via multiple system buses or other means.

[0062] The memory 16 stores instructions that can be executed by the at least one processor 15. The processor 15 provides computing and control capabilities to control the shooting device 100 to execute relevant commands or instructions, such as any of the video recording methods provided in the following embodiments of this application.

[0063] The memory 16, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer-executable programs, and modules, such as the program instructions / modules corresponding to the video recording method provided in the following embodiments of this application. The processor 15 can implement the video recording method in any of the following method embodiments by running the non-transitory software programs, instructions, and modules stored in the memory 16. Specifically, the memory 16 may include high-speed random access memory and non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory 16 may also include memories remotely located relative to the processor 15, and these remote memories can be connected to the processor 15 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0064] It should be noted that the shooting device 100 may include, but is not limited to, at least one of mobile phones, tablets, personal computers (PCs), camera devices, and any shooting device equipped with a camera and capable of running video recording software.

[0065] Among them, the camera equipment can be, for example, a panoramic camera, a multispectral camera, or a multifocal length composite camera. The panoramic camera is based on a multi-lens design and is generally equipped with 2-8 cameras, which are distributed in a ring or symmetrically on the surface of the body. The field of view of a single lens is usually 180°-270°. Through multi-lens collaborative shooting, environmental data of 360° horizontal view + 180° vertical view can be collected in real time to form a spherical panoramic image, and 360°×180° full field of view coverage can be achieved through overlapping field of view stitching.

[0066] To improve the shooting effect, the shooting device is equipped with multiple cameras. When the user is using the shooting device to record, they usually use one of the cameras to record and save the video data as a separate video file. If they want to switch to another camera to record, they need to stop the current recording and then click the switch button so that the shooting device controls the other camera to record and saves the video data as another separate video file. That is, the video files obtained before and after switching cameras are two separate video files. Continuous recording cannot be performed before and after switching, and a complete recorded video cannot be obtained directly.

[0067] To address the aforementioned issues, this application provides a video recording method that can combine the video recorded by the camera before switching to the camera with the video recorded by the camera after switching to the camera into a complete video, thereby improving the convenience and flexibility of video recording.

[0068] Please see Figure 4, Figure 4 This is a flowchart illustrating a video recording method provided in an embodiment of this application, as shown below. Figure 4 As shown, the video recording method S100 includes:

[0069] S11. Responding to the recording command, control the first camera to perform recording operation, obtain the first video encoding data, and write the first video encoding data into the recording file;

[0070] When the user clicks the record button, the recording device receives the recording command and controls the first camera to perform the recording operation. Specifically, the first camera's shooting parameters are first configured. These parameters include lens operating parameters and lens attitude parameters. Lens operating parameters include AE ​​mode parameters, lens identification information, resolution, frame rate, and the rotation angle of the first camera during recording. Lens operating parameters indicate the recording method used by the first camera, such as the exposure mode. The lens identification information indicates the type of lens currently in use. Resolution determines the number of pixels in the image, such as 1920×1080, 3840×2160, etc. Frame rate indicates the number of frames captured per second, such as 24fps, 30fps, 60fps, etc. Lens attitude parameters refer to the shooting device's attitude, its position and orientation in space. The shooting device's attitude directly determines the shooting angle and content of the image.

[0071] The system controls the first camera to record video according to the shooting parameters, obtaining first video data. This first video data is then encoded to obtain first encoded video data. The first video data is raw video data, which is typically very large and inconvenient to store and transmit. By using an encoding algorithm to compress the first video data and convert it into encoded data of a specific format, the data size is significantly reduced while maintaining quality. This facilitates transmission over networks, storage on hard drives or other media, or meets the playback requirements of different devices.

[0072] When encoding the first video data, the shooting parameters affect the encoding method and effect. For example, the encoder determines the granularity of image sampling and encoding based on the resolution, processes the video's temporal information based on the frame rate, and preprocesses the image or adjusts the encoding strategy based on exposure parameters. Therefore, the encoder encodes the first video data based on the shooting parameters to obtain the first encoded video data.

[0073] After obtaining the initial video encoding data, it is stored in the recording file according to a specific file format and specifications. At the end of recording, a video playback file is generated based on the recording file. The video playback file is a file that can be directly shared or played, such as an MP4 file.

[0074] S12. In response to the lens switching command, control the second camera to perform recording operation, obtain the second video encoding data, and write the second video encoding data into the recording file;

[0075] When the user clicks the switch button, the shooting device receives the lens switch instruction and controls the second camera to perform recording.

[0076] In some embodiments, after receiving a lens switching command, the shooting device shuts down the first camera and then activates the second camera. Optionally, before shutting down the first camera, the shooting parameters of the first camera are saved. After switching cameras, the configuration parameters of the second camera are configured to the shooting parameters configured when the first camera performs recording operations. Then, the second camera is controlled to perform recording operations according to the shooting parameters to obtain second video data. Keeping the configuration parameters of the second camera consistent with those of the first camera ensures the consistency of the captured images before and after the switch, preventing overexposure or underexposure.

[0077] For example, it is necessary to determine how to rotate the image captured by the second camera after switching to the second camera, based on the rotation angle of the current image and the posture of the shooting device, so as to maintain the same proportion and angle as the image captured by the first camera.

[0078] Therefore, after the second camera performs recording according to the shooting parameters of the first camera and obtains the second video data, it is necessary to convert the second video data to the coordinate space of the first camera based on the rotation angle of the current image and the posture of the shooting device to obtain video conversion data. Then, an encoding operation is performed on the video conversion data to obtain the second video encoding data. The rotation angle can be obtained through lens identification information, i.e., the lens ID, which indicates the type and encoding of the lens used.

[0079] After obtaining the second video encoded data, the second video encoded data is written to the recording file. The first video encoded data and the second video encoded data are written to the same recording file. During the writing process, the first video encoded data and the second video encoded data are written to the recording file in sequence to form a complete recording file, achieving a dynamic real-time splicing effect during the recording process.

[0080] S13. In response to the recording stop command, generate a video playback file based on the recorded file.

[0081] When the user clicks the stop recording button, the recording device receives the recording stop command and generates a video playback file based on the recorded file. The video playback file is a file that can be played directly on a playback device, such as an MP4 file.

[0082] It should be noted that if the recording device receives a switching command again during the second camera's recording process, it will switch back to the first camera to continue recording, obtaining the first video encoded data, which will then be written to the recording file. In other words, the corresponding video encoded data is written to the recording file sequentially according to the recording order, until the recording device receives a recording stop command, at which point a video playback file is generated based on the recording file.

[0083] Therefore, this video recording method enables the videos captured before and after a shot change to form a complete video, achieving continuous recording before and after a shot change, thus improving the flexibility and convenience of video recording. Furthermore, this method directly writes the first and second video encoded data into the same recording file, achieving a dynamic real-time stitching effect during recording without requiring additional stitching operations, further enhancing the convenience of video recording.

[0084] In some embodiments, when the shooting device receives a switching instruction, it turns off the first camera and starts the second camera. During the switching process, since it is necessary to stop the image acquisition and signal transmission of the first camera and initialize the second camera to which it is about to switch, the display unit of the shooting device may temporarily lose the image signal, resulting in a black screen, which is not good for the user's viewing experience.

[0085] Based on the above problems, in some embodiments, such as Figure 5 As shown, the video recording method S100 also includes:

[0086] S14. Determine the transition screen;

[0087] In some embodiments, the transition screen is determined based on the last frame of the first video encoded data. For example, the last frame of the first video encoded data can be directly used as the transition screen, or the last frame of the first video encoded data can be blurred and used as the transition screen. In some embodiments, the transition screen can also be a preset screen. When initializing the shooting device, the user can be prompted to set the transition screen. For example, the shooting device may present multiple transition screens for the user to choose from. After the user selects one of the screens as the transition screen, the selected transition screen is stored in the storage medium. During the switching process, the shooting device retrieves the transition screen from the corresponding storage medium. In some embodiments, the transition screen can also be a screen containing animation effects, which can be set by the user as needed. This application embodiment does not limit this.

[0088] S15. After outputting the first frame corresponding to the first video encoding data and before outputting the second frame corresponding to the second video encoding data, output the transition frame.

[0089] During the first camera's recording, the recording device outputs the first frame corresponding to the first video encoding data. Upon receiving a switching command, it acquires and outputs a transition frame during the switching interval. After the second camera is activated, it performs recording operations to obtain the second video encoding data. Then, it removes the transition frame and outputs the second frame corresponding to the second video encoding data.

[0090] Therefore, by outputting a transitional frame after the first frame and before the second frame, the shooting device can avoid the visual impact of sudden interruption or black screen, making the lens transition smoother and more natural, making the user's visual experience more comfortable, and helping to improve the user's viewing experience.

[0091] In order to combine the videos captured by the front and rear cameras into a complete video, it is not necessary to write the transitional images output during the switching process into the recording file. That is, the recording file does not contain the image data of the transitional images, so that after the video captured by the first camera finishes playing, it can automatically connect to the video captured by the second camera.

[0092] However, since the audio unit is constantly in the acquisition state during the switching process, it will still collect the sound around the shooting device during the switching process and form corresponding audio data. During playback, after the video captured by the first camera finishes playing, the video captured by the second camera and the audio during the switching process will be played, causing audio and video to be out of sync.

[0093] To address the aforementioned issues, this application embodiment removes the audio data corresponding to the switching process when generating a video playback file based on the video recording file, thereby achieving audio-video synchronization.

[0094] Specifically, such as Figure 6 As shown, step S13 includes:

[0095] S131. Obtain target audio data, wherein the target audio data is audio data obtained between the recording instruction and the recording stop instruction;

[0096] The target audio data is the audio data acquired by the shooting device between receiving the recording instruction and receiving the recording stop instruction, that is, all the audio data of the shooting device from the start of recording to the end of recording. It includes the audio data during the recording of the first camera, the audio data during the switching process, and the audio data during the recording of the second camera.

[0097] S132. Extract the target audio data based on the timestamp to obtain the first audio data;

[0098] The target audio data includes first audio data and second audio data. The first audio data consists of the audio data captured by the first camera and the audio data captured by the second camera. The second audio data is the audio data corresponding to the switching process, specifically the audio data from the moment the first camera ends capturing data to the moment the second camera begins capturing data. The first and second audio data together constitute the target audio data. Therefore, for audio-video synchronization, the target audio data can be truncated based on the timestamps of the first camera ending capturing data and the second camera beginning capturing data, removing the second audio data to obtain the first audio data.

[0099] In some embodiments, during the switching process, the shooting device will display a transition screen. The display duration of the transition screen corresponds to the time period of the second audio data. The target audio data can be truncated based on the timestamp of the start time and the timestamp of the end time of the transition screen display. The second audio data is truncated to obtain the first audio data.

[0100] Specifically, firstly, a first time point and a second time point are determined, where the first time point is the start time of the transition screen display and the second time point is the end time of the transition screen display. The first time point and the second time point are timestamps of the target audio data. Then, the second audio data is extracted from the target audio data to obtain the first audio data, where the second audio data is the data from the first time point to the second time point in the target audio data.

[0101] For example, the target audio data includes audio data collected during the first camera's shooting period from time 0 to time t1, second audio data collected during the transition screen display period from time t1 to time t2, and audio data collected during the second camera's shooting period from time t2 to time t3. The audio data collected during the first camera's shooting period from time 0 to time t1 and the audio data collected during the second camera's shooting period from time t2 to time t3 together constitute the first audio data.

[0102] When generating a video playback file, the second audio data is extracted from the target audio data to obtain the first audio data. Then, the video playback file is generated based on the video recording file and the first audio data, thus achieving audio-video synchronization between the video recording file and the first audio data.

[0103] In some embodiments, the second audio data can also be extracted based on the time when the first camera is turned off and the time when the second camera is turned on. Specifically, a third time and a fourth time are first determined, where the third time is the time when the first camera is turned off and the fourth time is the time when the second camera is turned on. Then, the second audio data is extracted from the target audio data to obtain the first audio data, where the second audio data is the data in the target audio data from the third time to the fourth time.

[0104] In some embodiments, the first time point is equal to the third time point, and the second time point is equal to the fourth time point. In some embodiments, the difference between the first time point and the third time point is within the allowable error range, and the difference between the second time point and the fourth time point is within the allowable error range.

[0105] Therefore, the target audio data is extracted based on the timestamp to obtain the first audio data. The first audio data corresponds to the first video encoded data and the second video encoded data, thus achieving audio and video synchronization.

[0106] In some embodiments, the first audio data may contain errors. In order to further improve the audio-video synchronization effect of the second video data, after obtaining the first audio data, the second video data captured by the second camera is obtained, and the audio-video synchronization operation is performed on the second video data based on the timestamp.

[0107] When acquiring the second video data, a timestamp is added to each frame of the video image. The video timestamp is usually determined based on the video's frame rate and frame sequence number. While the second camera is acquiring the second video data, the capturing device also acquires the corresponding audio data. Similarly, a timestamp is added to each frame of the audio data. If the timestamp of the first frame of the second video data is the target timestamp, the audio data acquired during the second camera's capture period corresponding to the target timestamp is synchronized with the first frame of the second video data, and redundant audio data is deleted, achieving precise audio-video synchronization.

[0108] S133. Generate a video playback file based on the video recording file and the first audio data.

[0109] Finally, the second video data after the audio-video synchronization operation is performed is written to the recording file. Then, based on the first audio data obtained after the audio-video synchronization operation and the recording file, the final video playback file is generated. When the final video playback file is played, the audio and video are precisely synchronized, improving the video playback effect.

[0110] If the shooting device receives a switching command and turns off the first camera while starting the second camera, there will be a switching gap during the switching process, causing the video data captured by the first camera to drop frames, resulting in a discontinuous or uneven video playback.

[0111] In response to the above problems, in some embodiments, after receiving a lens switching command, the shooting device activates the second camera and then shuts down the first camera within a preset time after activating the second camera.

[0112] After activating the second camera, the shooting device can immediately shut down the first camera, or it can shut down the first camera within a preset time. The preset time can be set as needed. For example, after activating the second camera, the data to be encoded collected by the first camera can be encoded, and then the first camera can be shut down. The preset time is the time it takes for the data to be encoded collected by the first camera to be encoded to be encoded.

[0113] If the first camera is turned off within a preset time after the second camera is activated, the switching gap will be smaller during the switching process, resulting in a smoother transition.

[0114] In some embodiments, the video data captured by the camera needs to be processed by a preset buffer before being encoded. The processing of the preset buffer can be various required processing methods. For example, the processing of the preset buffer can be anti-shake processing to reduce or eliminate the image instability caused by the shaking of the shooting device. Another example is that the processing of the preset buffer can also be filtering processing, applying various filtering algorithms to the video data to smooth image noise, making the image more stable and clear, and further improving the anti-shake effect.

[0115] Furthermore, different video data are stored in different preset buffers. These preset buffers are established when the cameras are turned on. For example, if the first camera is turned on, a preset buffer corresponding to the first camera is established, and the first video data captured by the first camera is processed through this preset buffer. If the second camera is turned on, another preset buffer corresponding to the second camera is established, and the second video data captured by the second camera is processed through this other preset buffer.

[0116] The preset buffer operates on a first-in, first-out (FIFO) basis. If the storage space of the preset buffer is n units, such as n bytes or n seconds, then when switching to the second camera for shooting, the preset buffer also stores video cache data. The video cache data is the data to be encoded from the first video captured by the first camera, and its size is n units. This video cache data is not stored in the recording file. If the second video data captured by the second camera is directly encoded and stored in the recording file at this time, it will cause the video cache data to be not written to the recording file. The recording file will lack video cache data, resulting in incomplete images or videos captured by the first camera during video playback, and frame drops will occur.

[0117] Based on the above issues, such as Figure 7As shown, the video recording method S100 also includes:

[0118] S16. After the second camera is activated, it is detected whether the preset buffer corresponding to the first camera has cached video cache data, wherein the video cache data is the data to be encoded in the first video data;

[0119] The preset buffer corresponding to the first camera is established when the first camera is started. The first camera performs recording operation, acquires first video data, stores the first video data in the preset buffer, performs corresponding image stabilization or filtering, and then outputs the processed first video data. Then, the processed first video data is encoded to obtain the first video encoded data. Thus, the video buffer data in the preset buffer is the data to be encoded in the first video data.

[0120] After the second camera is activated, a preset buffer corresponding to the second camera is established to process the second video data captured by the second camera. If the second video encoded data obtained after the second video data is directly written into the recording file, the data in the preset buffer corresponding to the first camera will not be written into the recording file. The recording file will lack the data in the preset buffer corresponding to the first camera, resulting in the final video playback being discontinuous or the picture not smooth.

[0121] Therefore, after the second camera is activated, it is necessary to check whether the preset buffer area corresponding to the first camera has cached video data. Based on the detection result, the corresponding operation is performed to prevent frame loss.

[0122] S17. If so, perform an encoding operation on the video cache data to obtain cached encoded data, and write the cached encoded data into the video recording file;

[0123] If the preset buffer area corresponding to the first camera contains video cache data, the video cache data is output, and then the video cache data is encoded to obtain cache encoded data. The cache encoded data is written to the recording file, so that the first video data captured by the first camera is completely written to the recording file, thereby enabling the video captured by the first camera to be played completely, and the video to be more coherent or the picture to be smoother.

[0124] S18. If not, write the second video encoding data into the video recording file.

[0125] If there is no video cache data in the preset buffer area corresponding to the first camera, the second video encoding data is written into the recording file. The recording file stores the first video encoding data, cache encoding data and second video encoding data in sequence.

[0126] Correspondingly, when the camera outputs the captured footage, it outputs the first frame corresponding to the first video encoding data, then the frame corresponding to the buffer encoding data, and finally the second frame corresponding to the second video encoding data.

[0127] The preset buffer corresponding to the first camera closes when the first camera is turned off. When there is no video cache data in the preset buffer corresponding to the first camera, the first camera can be turned off directly, or it can be turned off after a period of time. For example, if it is detected that there is no video cache data in the preset buffer corresponding to the first camera, the first camera is turned off, and the preset buffer corresponding to the first camera closes accordingly. Closing the preset buffer whenever there is no video cache data is more intelligent and saves more computing resources.

[0128] For example, if it is detected that there is no video cache data in the preset buffer area corresponding to the first camera, the first camera will be turned off after a period of time, and the preset buffer area corresponding to the first camera will be closed accordingly.

[0129] In some embodiments, the preset buffer area corresponding to each camera can be implemented by different threads to process the corresponding video data. For example, when the first camera is started, a first thread is created to process the first video data. When the second camera is started, a second thread is created to process the second video data. After the second camera is started, it is checked whether there is video buffer data in the first thread. If so, the second video data is written to the first thread so that the first thread removes the video buffer data in a first-in-first-out manner. If not, the first thread is destroyed and a notification message is sent to the second thread so that the second thread outputs the second video data.

[0130] It should be noted that when the second video data is written to the first thread, it is also written to the second thread simultaneously. However, the second thread does not output the second video data. It only outputs the second video data after receiving a notification message from the first thread. The notification message typically includes timestamp information and buffer end indication information, so that after receiving the notification message, the second thread can determine that all video buffer data from the first thread has been output, as well as the timestamp of the last frame to be output, before outputting the second video data.

[0131] Therefore, in this embodiment of the application, the first video encoding data, the cached encoding data, and the second video encoding data are written to the same recording file in sequence, and there is no missing data in the recording file, which makes the final video playback more complete and the picture more coherent.

[0132] In some embodiments, after outputting the second video data, an audio-video synchronization operation is performed on the second video data, followed by encoding. For example, by obtaining the timestamp of the last frame of the video buffer data through a notification message, the audio data corresponding to the next timestamp is determined as the audio data corresponding to the first frame of the second video data. If the timestamp of the last frame of the video buffer data is T, the audio data corresponding to T+1 is determined as the audio data corresponding to the first frame of the second video data, and the audio data corresponding to T+1 is synchronized with the first frame of the second video data to achieve accurate audio-video synchronization of the second video data, thereby improving the playback effect.

[0133] In some embodiments, in order to combine the videos captured by the cameras before and after switching into a complete video, the videos captured by the first camera and the second camera can be stored in different video files, and then the video files can be spliced ​​together to form a complete video file.

[0134] Specifically, in response to a recording command, the system controls the first camera to perform a recording operation, obtains the first video encoded data, writes the first video encoded data into the first recording file, then in response to a lens switching command, controls the second camera to perform a recording operation, obtains the second video encoded data, writes the second video encoded data into the second recording file, and in response to a recording stop command, splices the first recording file and the second recording file to obtain the target recording file, and generates a video playback file based on the target recording file.

[0135] The first and second video files are two independent video files. At the end of the recording, the two independent video files are spliced ​​into one video file to achieve the splicing effect. This allows a complete video to be output directly at the end of the recording, improving the flexibility and convenience of video recording.

[0136] In summary, this video recording method responds to camera switching commands during the recording process, allowing it to switch between different cameras to continue recording. Furthermore, it writes the video encoded data captured by the cameras before and after the switch into the same recording file, achieving a dynamic real-time stitching effect. This allows for the direct output of a complete video segment when recording ends, improving the flexibility and convenience of video recording.

[0137] It should be noted that in the above embodiments, there is no necessarily a certain order between the above steps. Those skilled in the art can understand from the description of the embodiments of this application that the above steps may have different execution orders in different embodiments, that is, they may be executed in parallel or in interchange, etc.

[0138] As another aspect of the embodiments of this application, this application provides a video recording device 200. The video recording device 200 can be a software module, which includes several instructions stored in the memory of the shooting device. The processor can access the memory, call the instructions, and execute them to complete the video recording methods described in the above embodiments.

[0139] In some embodiments, the video recording device 200 can also be constructed from hardware devices. For example, the video recording device 200 can be constructed from one or more chips, and the chips can work together to complete the video recording methods described in the above embodiments. As another example, the video recording device 200 can also be constructed from various logic devices, such as general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), microcontrollers, ARM (Acorn RISC Machine) or other programmable logic devices, discrete gate or transistor logic, discrete hardware components, or any combination of these components.

[0140] Please see Figure 8 , Figure 8 This application provides a video recording device 200, which is applied to a shooting device. The shooting device includes a first camera and a second camera, which are front-facing and rear-facing cameras respectively. The video recording device 200 includes a first control module 21, a second control module 22, and a generation module 23.

[0141] The first control module 21 is used to respond to the recording command, control the first camera to perform recording operation, obtain the first video encoded data, and write the first video encoded data into the recording file. The second control module 22 is used to respond to the lens switching command, control the second camera to perform recording operation, obtain the second video encoded data, and write the second video encoded data into the recording file. The generation module 23 is used to respond to the recording stop command, and generate a video playback file based on the recording file.

[0142] It should be noted that since the video recording device and the video recording method in the above embodiments are based on the same application concept, the corresponding content in the above method embodiments is also applicable to the device embodiments, and will not be described in detail here.

[0143] In summary, this video recording device responds to camera switching commands during video recording, allowing it to switch between different cameras to continue recording. It also writes the video encoded data captured by the cameras before and after the switch into the same recording file, achieving a dynamic real-time stitching effect. This allows for the direct output of a complete video when recording ends, improving the flexibility and convenience of video recording.

[0144] This application also provides a non-transitory computer-readable storage medium storing computer-executable instructions that are executed by one or more processors, for example... Figure 3 One of the processors 15 can enable the one or more processors to execute the video recording method in any of the above method embodiments.

[0145] This application also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions that, when executed by a shooting device, cause the shooting device to perform any of the video recording methods described above.

[0146] The device or equipment embodiments described above are merely illustrative. The unit modules described as separate components may or may not be physically separate. The components shown as module units may or may not be physical units; that is, they may be located in one place or distributed across multiple network module units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0147] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software plus a general-purpose hardware platform, or of course, using hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the video recording method described in various embodiments or some parts of embodiments.

[0148] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and not to limit them; under the concept of this application, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations of different aspects of this application as described above, which are not provided in detail for the sake of brevity; although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

Claims

1. A video recording method applied to a shooting device, the shooting device comprising a first camera and a second camera, wherein the first camera and the second camera are a front-facing camera and a rear-facing camera, respectively, characterized in that, The method includes: In response to a recording command, the system controls the first camera to perform a recording operation, obtains the first video encoded data, and writes the first video encoded data into a recording file. In response to a lens switching command, the system controls the second camera to perform a recording operation, obtains second video encoded data, and writes the second video encoded data into the recording file. In response to the recording stop command, a video playback file is generated based on the recorded file.

2. The method according to claim 1, characterized in that, The method further includes: In response to the lens switching command, the first camera is turned off and the second camera is turned on.

3. The method according to claim 2, characterized in that, The method further includes: Determine the transition screen; The transition frame is output after the first frame corresponding to the first video encoded data is output and before the second frame corresponding to the second video encoded data is output.

4. The method according to claim 3, characterized in that, The determination of the transition screen includes: The transition frame is determined based on the last frame of the first video encoding data.

5. The method according to claim 4, characterized in that, The process of generating a video playback file based on the recorded file includes: Acquire target audio data, wherein the target audio data is the audio data acquired between the recording instruction and the recording stop instruction; The target audio data is extracted based on the timestamp to obtain the first audio data; A video playback file is generated based on the video recording file and the first audio data.

6. The method according to claim 5, characterized in that, The first audio data is obtained by extracting the target audio data based on the timestamp, including: Determine a first moment and a second moment, wherein the first moment is the start time of the display of the transition screen, the second moment is the end time of the display of the transition screen, and the first moment and the second moment are one of the timestamps of the target audio data; The second audio data is extracted from the target audio data to obtain the first audio data, wherein the second audio data is the data in the target audio data from the first time point to the second time point.

7. The method according to claim 1, characterized in that, The method further includes: In response to the lens switching command, the first camera is turned off within a preset time after the second camera is activated.

8. The method according to claim 7, characterized in that, The first camera captures first video data, the second camera captures second video data, and the method further includes: After the second camera is activated, it is detected whether the preset buffer corresponding to the first camera has cached video cache data, wherein the video cache data is the data to be encoded in the first video data; If so, the video cache data is encoded to obtain cached encoded data, and the cached encoded data is written to the video recording file; If not, write the second video encoded data into the recorded file.

9. The method according to claim 8, characterized in that, If the preset buffer corresponding to the first camera does not contain the video cache data, then the first camera is turned off.

10. The method according to claim 8, characterized in that, The method further includes: After outputting the first frame corresponding to the first video encoded data and before outputting the second frame corresponding to the second video encoded data, the frame corresponding to the cached encoded data is output.

11. The method according to any one of claims 1-10, characterized in that, The video file does not contain image data of transition scenes.

12. The method according to any one of claims 1-10, characterized in that, The configuration parameters for the second camera when performing recording operations are the same as those configured for the first camera when performing recording operations.

13. A shooting device, characterized in that, The shooting device includes: a first camera, a second camera, and at least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enable the at least one processor to perform the video recording method as described in any one of claims 1-12; The first camera and the second camera are respectively communicatively connected to the at least one processor. The first camera is configured to perform a recording operation under the control of the at least one processor, and the second camera is configured to perform a recording operation under the control of the at least one processor.

14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions for causing a computer device to perform the video recording method as described in any one of claims 1-12.