Video recording method and device, storage medium and video recording apparatus
By continuously encoding and saving video and audio data during the recording process, and generating complete index information when abnormally terminated, the problem of video recording devices being unable to play when abnormally terminated is solved, and normal playback of video files is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGZHOU SHIYUAN ELECTRONICS CO LTD
- Filing Date
- 2023-07-11
- Publication Date
- 2026-05-12
AI Technical Summary
When the video recording device terminates abnormally, it fails to generate index information, causing the player to be unable to play the video file.
During the recording process, video and audio data are continuously collected and encoded using a preset encoding format to generate unit video and audio encoded files. The data is continuously saved and encapsulated into video files using a preset encapsulation format in response to encapsulation commands.
确保视频文件生成完整的索引信息,播放器可以正常播放视频文件,解决了录制异常时的播放问题。
Smart Images

Figure CN119316654B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of video recording technology, and more specifically, to video recording methods, apparatus, storage media and video recording devices in the field of video recording technology. Background Technology
[0002] Video recording devices (such as surveillance equipment, mobile phones, and drones) typically use video container formats (such as MKV, AVI, and MP4) to directly encapsulate encoded video and audio data into video files.
[0003] When a video recording device uses this method to record video, if it encounters an abnormal termination situation (such as the recording application crashing), the player cannot read the index information located in the header container of the video file, and therefore cannot find the encoded video data and audio data in the video file, causing the player to be unable to play (decode) the video file. Summary of the Invention
[0004] This application provides a video recording method, apparatus, storage medium, and video recording device, which can ensure that the player can play video files.
[0005] In a first aspect, this application provides a video recording method, the method comprising:
[0006] During the recording process, unit video data and unit audio data are continuously collected;
[0007] The unit video data is encoded using a preset video encoding format to obtain a unit video encoded file, and the unit audio data is encoded using a preset audio encoding format to obtain a unit audio encoded file;
[0008] The unit video encoding file and the unit audio encoding file are continuously saved;
[0009] In response to the encapsulation command, the saved unit video encoded files and unit audio encoded files are encapsulated into a video file using a preset encapsulation format.
[0010] In some embodiments, after continuously saving the unit video encoded files and the unit audio encoded files, and before encapsulating the saved unit video encoded files and the unit audio encoded files into a video file in a preset encapsulation format in response to an encapsulation instruction, the method further includes:
[0011] Receive user input to end recording;
[0012] Generate encapsulation instructions based on the user operation used to end recording.
[0013] In some embodiments, after continuously saving the unit video encoded files and the unit audio encoded files, and before responding to the encapsulation instruction and encapsulating each of the saved unit video encoded files and each of the unit audio encoded files into a video file using a preset encapsulation format, the method further includes:
[0014] After the recording process abnormally ends, a user operation to save the video file is received.
[0015] Generate encapsulation instructions based on the user operations used to save the video file.
[0016] In some embodiments, the step of encapsulating the stored individual video encoded files and individual audio encoded files into a video file in response to the encapsulation instruction includes:
[0017] In response to the encapsulation command, each of the saved unit video encoded files is encapsulated into a video track corresponding to the preset encapsulation format, and each of the saved audio encoded files is encapsulated into an audio track corresponding to the preset encapsulation format.
[0018] In some embodiments, after encapsulating the saved unit video encoded files and unit audio encoded files into a video file using a preset encapsulation format, the method further includes:
[0019] Based on the unit video encoded file and the unit audio encoded file, generate file information;
[0020] The file information is written into a preset container of the video file.
[0021] In some embodiments, continuously saving the unit video encoded file and the unit audio encoded file includes:
[0022] The unit video encoding file and the unit audio encoding file are continuously saved to local storage and / or cloud storage, respectively.
[0023] In some embodiments, the step of continuously saving the unit video encoded file and the unit audio encoded file to local storage and / or cloud storage respectively includes:
[0024] The unit video encoded file is continuously saved to a video folder named with a unique identifier, and the unit audio encoded file is continuously saved to an audio folder named with the unique identifier; the video folder and the audio folder are located in local storage and / or cloud storage.
[0025] In some embodiments, the encapsulation instructions carry the unique identification code;
[0026] The step of responding to the encapsulation instruction by encapsulating the saved unit video encoded files and unit audio encoded files into a video file using a preset encapsulation format includes:
[0027] In response to the encapsulation instruction, each unit video encoded file in the video folder named with the unique identification code is obtained, and each unit audio encoded file in the audio folder named with the unique identification code is obtained;
[0028] Each of the unit video encoding files and each of the unit audio encoding files are packaged into a video file using a preset encapsulation format.
[0029] Secondly, this application provides a video recording apparatus, the video recording apparatus comprising:
[0030] The acquisition module is used to continuously acquire unit video data and unit audio data during the recording process;
[0031] The encoding module is used to encode the unit video data using a preset video encoding format to obtain a unit video encoded file, and to encode the unit audio data using a preset audio encoding format to obtain a unit audio encoded file;
[0032] A storage module is used to continuously save the unit video encoded file and the unit audio encoded file;
[0033] The encapsulation module is used to encapsulate the saved unit video encoding files and unit audio encoding files into a video file in response to the encapsulation command using a preset encapsulation format.
[0034] Thirdly, this application provides a computer program product containing instructions that, when run on a computer or processor, cause the computer or processor to perform the method of the first aspect or any of the embodiments of the first aspect.
[0035] Fourthly, this application provides a computer storage medium storing a computer program that, when executed, implements the method described in the first aspect or any of the embodiments of the first aspect.
[0036] Fifthly, this application provides a video recording device, the video recording device comprising:
[0037] Memory, used to store executable program code;
[0038] A processor is configured to call and run the executable program code from the memory, causing the video recording device to perform the method of the first aspect or any embodiment of the first aspect.
[0039] The beneficial effects of the technical solutions provided in this application include at least the following:
[0040] This application provides a video recording method, apparatus, storage medium, and video recording device. During recording, the video recording device continuously acquires unit video data and unit audio data, encodes the unit video data using a preset video encoding format to obtain unit video encoded files, and encodes the unit audio data using a preset audio encoding format to obtain unit audio encoded files. The unit video encoded files and unit audio encoded files are continuously saved. In response to a packaging instruction, the saved unit video encoded files and unit audio encoded files are packaged into a video file using a preset packaging format. Since only unit video encoded files and unit audio encoded files are saved, and there is no unencoded video or audio data, the video recording device can directly package the saved unit video encoded files and unit audio encoded files into a video file using the preset packaging format, thereby achieving video recording. Attached Figure Description
[0041] Figure 1 This application provides a schematic diagram of the system architecture for a video recording method according to an embodiment of the present application.
[0042] Figure 2 A flowchart illustrating a video recording method provided in this application embodiment;
[0043] Figure 3 Another flowchart of a video recording method provided in an embodiment of this application;
[0044] Figure 4 A schematic diagram illustrating a video recording device receiving a user operation to end recording, provided as an embodiment of this application;
[0045] Figure 5 This is a schematic diagram of the display interface of a video recording device provided in an embodiment of this application;
[0046] Figure 6 This is another schematic diagram of the display interface of a video recording device provided in an embodiment of this application;
[0047] Figure 7 Another flowchart of a video recording method provided in an embodiment of this application;
[0048] Figure 8 This is a schematic diagram of the structure of a video recording device provided in an embodiment of this application;
[0049] Figure 9 This is a schematic diagram of the structure of a video recording device provided in an embodiment of this application. Detailed Implementation
[0050] The technical solutions in this application will be clearly and thoroughly described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B. "And / or" in the text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.
[0051] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature.
[0052] Video recording devices (such as surveillance equipment, mobile phones, and drones) use video container formats (such as MKV, AVI, and MP4) to directly encapsulate encoded video and audio data into video files.
[0053] In common MP4 video files (video files encapsulated using the MP4 video container format), the video data acquired during recording is encoded using H.264 encoding, and the recorded audio data is encoded using AAC encoding. The encoded video data is then encapsulated into the video track corresponding to the MP4 container format, and the encoded audio data is encapsulated into the audio track corresponding to the MP4 container format to obtain the video file.
[0054] A video file corresponding to the MP4 container format can include at least a moov box and an mdat box, which can also be referred to as a moov container and an mdat container, respectively. After the encoded video data and encoded audio data are encapsulated into the video track and audio track to form a video file, index information corresponding to the video file can be obtained. The index information is written into the moov box located at the beginning of the video file (in some embodiments, the moov box may also be located at the end of the video file), while the encoded video data encapsulated into the video track and the encoded audio data encapsulated into the audio track are saved into the mdat box. The encoded video data and encoded audio data saved in the mdat box need to be accessed through the index information. That is, the player (decoder) needs to read the index information corresponding to the video file in the moov box in order to play (decode) the encoded video data and encoded audio data saved in the mdat box, so that the player can play the video file.
[0055] During video recording, if an abnormal termination occurs (which can also be understood as the video recording application crashing unexpectedly), at the moment of abnormal termination, there is still unencoded video and audio data on the recording device. Because this unencoded video and audio data is not packaged into a video file at the time of abnormal termination, no index information corresponding to the video file is generated, and therefore no index information is written to the moov box located at the beginning of the video file. In this situation, the player (decoder) cannot read the index information in the moov box, and therefore cannot play (decode) the encoded video and audio data saved in the mdat box, resulting in the player being unable to play the video file.
[0056] To address the issue of unplayable video files, this application provides a video recording method. The method includes continuously acquiring unit video data and unit audio data during recording; encoding the unit video data using a preset video encoding format to obtain a unit video encoded file, and encoding the unit audio data using a preset audio encoding format to obtain a unit audio encoded file; continuously saving the unit video encoded files and the unit audio encoded files; and, in response to a packaging instruction, packaging the saved unit video encoded files and unit audio encoded files into a video file using a preset packaging format. This method can solve the aforementioned problem of unplayable video files.
[0057] Please see Figure 1 , Figure 1This is a schematic diagram of the system architecture of a video recording method provided in an embodiment of this application.
[0058] like Figure 1 As shown, the system architecture may include at least a video recording device 101, which is equipped with at least a camera, a microphone, and a local disk. The camera and microphone are used by the video recording device 101 to capture video and audio data during recording, respectively. After capturing the video and audio data, the video recording device 101 encodes the video and audio data using selected video encoding formats and saves the encoded video and audio data to the local disk. The video recording device 101 may include at least a camera, smartwatch, smartphone, tablet, laptop, or desktop computer.
[0059] In this embodiment, firstly, the video recording device 101 can continuously collect unit video data and unit audio data during the recording process; secondly, the unit video data is encoded using a preset video encoding format to obtain a unit video encoded file, and the unit audio data is encoded using a preset audio encoding format to obtain a unit audio encoded file; then, the unit video encoded file and the unit audio encoded file are continuously saved; finally, in response to a packaging instruction, the video recording device 101 packages each saved unit video encoded file and each unit audio encoded file into a video file using a preset packaging format.
[0060] In some embodiments, the system architecture may further include a network 102 and a cloud storage 103. The network 102 may be a medium for providing a communication link between the video recording device 101 and the cloud storage 103. The network 102 may include various types of wireless communication links, such as Bluetooth communication links, Wireless-Fidelity (Wi-Fi) communication links, or microwave communication links.
[0061] Specifically, the video recording device 101 can save the encoded video and audio data to the cloud storage 103 via the network 102, saving storage space on the local disk of the video recording device 101. The video recording device 101 can also access the cloud storage 103 via the network 102 to retrieve the encoded video and audio data saved in the cloud storage 103.
[0062] It should be understood that Figure 1 The number of video recording devices 101, network 102 and cloud storage 103 is only illustrative. Depending on actual needs, there can be any number of video recording devices 101, network 102 and cloud storage 103.
[0063] Based on the above system architecture, this application provides a video recording method.
[0064] Please see Figure 2 , Figure 2 This is a flowchart illustrating a video recording method provided in an embodiment of this application.
[0065] like Figure 2 As shown, video recording methods can include at least:
[0066] S202, The video recording device continuously collects unit video data and unit audio data during the recording process.
[0067] The following embodiments of this application will be described using the H264 encoding format corresponding to the MP4 container format for video data encoding and the AAC encoding format corresponding to the MP4 container format for audio data encoding as examples.
[0068] As video recording continues, video and audio data are continuously generated. The video data generated by the video recording device can be continuously encoded into H264 video data using a video encoder, and the audio data can be continuously encoded into AAC audio data using an audio encoder.
[0069] In this context, a unit of video data can be the amount of data that can be encoded into one frame of H.264 video data; a unit of audio data can be 1024 sampling points, with the video recording device encoding each 1024 sampling points into a unit of AAC audio data. In other words, when the video recording device acquires enough data to encode one frame of H.264 video data, it obtains a unit of video data; when the video recording device acquires 1024 sampling points, it obtains a unit of audio data.
[0070] It should be noted that using 1024 sampling points to encode AAC audio data is a common practice, but different numbers of sampling points can be used for encoding as needed, and this application does not limit this.
[0071] S204, The video recording device encodes the unit video data using a preset video encoding format to obtain a unit video encoded file, and encodes the unit audio data using a preset audio encoding format to obtain a unit audio encoded file.
[0072] As video recording continues, video and audio data are continuously generated. At the same time, the encoding of video and audio data is also ongoing, resulting in the continuous generation of H264 video data and AAC audio data.
[0073] Specifically, when acquiring unit video data, the video recording device encodes the unit video data using the H.264 encoding format to obtain unit H.264 video data. When acquiring unit audio data, the video recording device encodes the unit audio data using the AAC encoding format to obtain AAC audio data.
[0074] S206, the video recording device continuously saves the unit video encoded file and the unit audio encoded file.
[0075] The continuously generated units of H264 video data and units of AAC audio data are sequentially saved to local storage and / or cloud storage, so that the units of H264 video data and units of AAC audio data can be obtained at any time.
[0076] S208, the video recording device responds to the encapsulation command by encapsulating the saved individual video encoding files and individual audio encoding files into a video file using a preset encapsulation format.
[0077] Since the H264 video data and AAC audio data of each unit can be stored on a local disk or in a cloud storage, when the video recording device responds to the encapsulation command, it can directly access the local disk or cloud storage to read the H264 video data and AAC audio data of each unit. The H264 video data and AAC audio data are then encapsulated into a video file using a video encapsulation editor and the MP4 encapsulation format.
[0078] When the recording process terminates, the video recording device responds to the encapsulation command and directly encapsulates the saved H.264 video data and AAC audio data. Specifically, the video recording device can directly encapsulate each H.264 video data into the video track corresponding to the MP4 encapsulation format and each AAC audio data into the audio track corresponding to the MP4 encapsulation format. After obtaining the video file, the video file can generate complete index information, while the H.264 video data encapsulated into the video track and the AAC audio data encapsulated into the audio track are saved in the mdat box. When the player plays the video file, the player (decoder) directly reads the index information of the video file in the mdat box to find the H.264 video data and AAC audio data in the mdat box, and the player plays (decodes) the H.264 video data and AAC audio data to realize the playback of the video file.
[0079] Compared to related technologies, this application directly encapsulates the stored H.264 video data and AAC audio data of each unit, eliminating the possibility of unencoded video and audio data remaining in the video recording device when the recording process terminates. Therefore, this application can generate complete index information corresponding to the video file and save this index information to the moov box. Since the moov box in the video file header can store complete index information, the player (decoder) can read the index information in the moov box to find the encoded video and audio data saved in the mdat box, thus enabling playback of the video file.
[0080] Please see Figure 3 , Figure 3 This is a flowchart illustrating a video recording method provided in an embodiment of this application.
[0081] like Figure 3 As shown, video recording methods can include at least:
[0082] S302, the video recording device continuously collects unit video data and unit audio data during the recording process.
[0083] S304, the video recording device encodes the unit video data using a preset video encoding format to obtain a unit video encoded file, and encodes the unit audio data using a preset audio encoding format to obtain a unit audio encoded file.
[0084] S306, the video recording device continuously saves the unit's video encoded file and unit's audio encoded file.
[0085] For details regarding steps S302 to S306, please refer to the detailed descriptions in steps S202 to S206, which will not be repeated here.
[0086] In some embodiments, the video recording device needs to encapsulate the saved unit video encoded file and unit audio encoded file upon receiving an encapsulation instruction. The encapsulation instruction received by the video recording device varies depending on the termination condition of the recording process. The termination of the recording process can specifically include two cases: normal termination and abnormal termination. The following sections S308 to S310 describe how to generate an encapsulation instruction for the case of normal termination, and S312 to S314 describe how to generate an encapsulation instruction for the case of abnormal termination. Specifically:
[0087] S308, the video recording device receives a user operation to end recording.
[0088] Please see Figure 4 , Figure 4This illustration shows a video recording device receiving a user operation to end recording, as provided in an embodiment of this application. When the video recording device receives an operation from the recorder (also referred to as the user) pressing the "End Recording" button, the video recording process ends normally, which can also be understood as the recording of the required video being completed. It should be noted that the user's button operation can be pressing a physical button on the video recording device or touching a button on the recording application's display interface. In some embodiments, the video recording device may also be prompted to end recording via voice, or a gesture corresponding to the normal end of the video recording process; this application does not impose limitations on this.
[0089] When the video recording device receives a user's command to end recording, it needs to encode the last generated video and audio data during the recording process (it should be noted that the video recording device encodes and saves the video and audio data simultaneously with their generation; therefore, when the user's command to end recording is received, the last generated video and audio data during recording has not yet been encoded), and then save the encoded H264 video and AAC audio data. Since the video recording ends normally, what is saved is the complete and encoded H264 video and AAC audio data.
[0090] S310, the video recording device generates encapsulation instructions based on user operations used to end recording.
[0091] Taking the saving of unit H264 video data and unit AAC audio data to the local disk as an example, when the video recording device receives the encapsulation instruction, the video recording device directly accesses the local disk and reads the saved unit H264 video data and unit AAC audio data.
[0092] The video encapsulation editor encapsulates H264 video data into the video track corresponding to the MP4 encapsulation format, and encapsulates AAC audio data into the audio track corresponding to the MP4 encapsulation format, thus encapsulating the video and audio encoded files generated during video recording into a video file.
[0093] Since the local disk stores complete and encoded H.264 video data and AAC audio data when video recording ends normally, the video container editor can generate complete index information corresponding to the video file after containerization and write this index information into the moov box of the video file. The player (decoder) can then read the index information in the moov box to find the encoded video and audio data stored in the mdat box, thus enabling playback of the video file.
[0094] In some embodiments, video recording may terminate abnormally, meaning the recording is not intentionally stopped by the user. Examples include, but are not limited to, the video recording application crashing unexpectedly or the video recording device running out of battery. In the event of an abnormal termination of video recording, the process of generating encapsulation instructions includes steps S312 to S314:
[0095] S312, after an abnormal recording process ends, the video recording device receives a user operation to save the video file.
[0096] Please see Figures 5 to 6 , Figure 5 This is a schematic diagram of the display interface of a video recording device provided in an embodiment of this application; Figure 6 This is another schematic diagram of the display interface of a video recording device provided in this application embodiment. An abnormal termination of the recording process can be understood as the recording application crashing, or it could be due to other reasons causing the abnormal termination of the recording process. In the case of a crashing recording application, the recorder needs to wait for the recording application to restart.
[0097] When you restart the recording application, a pop-up window will automatically appear on the recording application's screen displaying "Video cannot be played" (see...). Figure 5 ) or "There are videos that were not saved properly" (see Figure 6 The system will display messages such as "The video recorded by the recorder could not be saved properly and cannot be played back." When a user receives the above message, they need to press the "Restore Save" button (or the "End Recording" button mentioned above).
[0098] S314, the video recording device generates encapsulation instructions based on user operations used to save video files.
[0099] When the recording application crashes, it saves one unit of H264 video data and one unit of AAC audio data on the local disk.
[0100] When the video recording device receives the encapsulation command, it directly accesses the local disk to read the saved unit H264 video data and unit AAC audio data. The video encapsulation editor encapsulates each unit of H264 video data into the video track corresponding to the MP4 encapsulation format, and encapsulates each unit of AAC audio data into the audio track corresponding to the MP4 encapsulation format, thus encapsulating the unit video encoded files and unit audio encoded files generated during the video recording process into a video file.
[0101] S316, the video recording device responds to the encapsulation command by encapsulating the saved individual video encoded files and individual audio encoded files into a video file using a preset encapsulation format.
[0102] Since each unit of H264 video data and each unit of AAC audio data is stored on a local disk or cloud storage, when the video recording device responds to the encapsulation command, it can directly access the local disk or cloud storage to read the stored H264 video data and each AAC audio data. This allows the H264 video data and AAC audio data to be encapsulated into a video file using a video encapsulation editor and the MP4 encapsulation format.
[0103] Optionally, at the moment the recording application crashes, the final video data may not reach a full frame. This portion of video data cannot be encoded or saved. If recording one frame of video data takes 0.1 seconds, then recording unencoded video data may take tens of milliseconds. Simultaneously, the final audio data may not reach 1024 sampling points. This portion of audio data cannot be encoded or saved. If recording 1024 sampling points of audio data takes 0.1 seconds, then recording unencoded audio data may also take tens of milliseconds. Since unencoded and unsaved video and audio data cannot participate in encapsulation, the video file will lose tens of milliseconds of content containing unencoded and unsaved video and audio data.
[0104] S318, the video recording device generates file information based on the unit video encoding file and the unit audio encoding file.
[0105] S320, the video recording device writes file information into a preset container for the video file.
[0106] The video recording device generates file information based on the encapsulated video and audio data, and writes the file information into a preset container of the video file.
[0107] Specifically, since the local disk stores complete and encoded H.264 video data and AAC audio data, the video encapsulation editor generates complete index information corresponding to the video file after encapsulation and writes this index information into the video file's moov box. The player (decoder) can then read the index information in the moov box to locate the video and audio data stored in the mdat box, enabling playback of the video file. It should be noted that even if the recording application crashes momentarily, the unencoded video and audio data present will not participate in the encapsulation process and will not affect the encapsulation of the video file. The encapsulated video file will still generate complete index information corresponding to the video file and write this information into the moov box. Therefore, unencoded video and audio data will not affect the normal playback of the video file.
[0108] Please see Figure 7 , Figure 7 This is a flowchart illustrating a video recording method provided in an embodiment of this application.
[0109] like Figure 7 As shown, video recording methods can include at least:
[0110] S702, the video recording device continuously collects unit video data and unit audio data during the recording process.
[0111] S704, the video recording device encodes unit video data using a preset video encoding format to obtain a unit video encoded file, and encodes unit audio data using a preset audio encoding format to obtain a unit audio encoded file.
[0112] For details regarding steps S702 to S704, please refer to the detailed descriptions in steps S202 to S204, which will not be repeated here.
[0113] S706, the video recording device continuously saves the unit video encoded file and the unit audio encoded file to local storage and / or cloud storage, respectively.
[0114] The video recording device continuously saves the unit video encoded file to a video folder named with a unique identifier, and continuously saves the unit audio encoded file to an audio folder named with the unique identifier; the video folder and the audio folder are located in local storage and / or cloud storage.
[0115] Specifically, when a user presses the start recording button on the video recording device, the video recording device begins recording video and creates a video folder and an audio folder on the local disk.
[0116] It should be noted that users can start video recording by pressing the physical button on the video recording device; in some embodiments, users can also start video recording by touching the start recording button displayed on the screen of the video recording device.
[0117] As video recording continues, H.264 video data and AAC audio data are continuously generated. H.264 video data is stored in hexadecimal format, and can be continuously saved to a designated video folder on the local disk using a corresponding file management tool. Similarly, AAC audio data can be continuously saved to a designated audio folder on the local disk using a corresponding file management tool. Each generated H.264 video and AAC audio data file can be saved separately to the designated video and audio folders on the local disk.
[0118] When a video recording device needs to encapsulate encoded video and audio data, it can directly access the local disk to read the encoded H264 video data and AAC audio data stored on the local disk. The local disk is located inside the video recording device, which can improve the speed at which the video recording device reads the encoded H264 video data and AAC audio data.
[0119] To facilitate the video recording device's access to the local disk and read the encoded H.264 video and AAC audio data stored there, the device can create video and audio folders on the local disk upon starting recording, naming each folder with a unique identifier. As recording progresses, video and audio data are continuously generated, and the device continuously generates encoded unit video and audio files. It continuously saves the encoded video files to the video folder named with the unique identifier, and the encoded audio files to the audio folder named with the same unique identifier.
[0120] Specifically, the video recording device generates unique identifiers for naming video and audio folders. These unique identifiers can be UUIDs (Universally Unique Identifiers), which are used to name the video and audio folders respectively. For example, if the UUID is 1e78091f-0988-406a-b8c6-700c0434d824, then the video folder could be named 1e78091f-0988-406a-b8c6-700c0434d824.h264, and the audio folder could be named 1e78091f-0988-406a-b8c6-700c0434d824.aac.
[0121] In some embodiments, the unique identifier may also be a timestamp, etc., as long as the uniqueness of the unique identifier is ensured, and this application does not impose any limitations.
[0122] In some embodiments, the video recording device can also save H.264 video data and AAC audio data to cloud storage, saving storage space on the local disk of the video recording device 101. Specifically, when the user activates the start recording button on the video recording device, a folder creation request is sent to the server, and the server creates video folders and audio folders in the cloud storage.
[0123] For each frame of H264 video data encoded, the video recording device can upload the encoded H264 video data frame to the video folder in the cloud storage; for each 1024 sample points of AAC audio data encoded, the video recording device can upload the encoded AAC audio data containing 1024 sample points to the audio folder in the cloud storage.
[0124] It should be noted that the storage location and storage method of the encoded H264 video data and AAC audio data can be set according to the actual situation, and this application does not limit them.
[0125] S708, in response to the encapsulation instruction, the video recording device obtains each unit video encoded file in the video folder named with the unique identifier, and obtains each unit audio encoded file in the audio folder named with the unique identifier.
[0126] Taking the unique identifier 1e78091f-0988-406a-b8c6-700c0434d824 as an example, the encapsulation instruction can contain the unique identifier 1e78091f-0988-406a-b8c6-700c0434d824. Based on the 1e78091f-0988-406a-b8c6-700c0434d824 contained in the encapsulation instruction, the unit video encoding file in the folder 1e78091f-0988-406a-b8c6-700c0434d824.h264 and the unit audio encoding file in the folder 1e78091f-0988-406a-b8c6-700c0434d824.aac can be read from the local disk.
[0127] S710, the video recording device encapsulates each of the unit video encoding files and each of the unit audio encoding files into a video file using a preset encapsulation format.
[0128] When the video recording device responds to the encapsulation command and synthesizes the video file (1e78091f-0988-406a-b8c6-700c0434d824.mp4), the video recording device can locate the folder 1e78091f-0988-406a-b8c6-700c0434d824.aac containing various H264 video data and the folder 1e78091f-0988-406a-b8c6-700c0434d824.h264 containing various AAC video data in its local storage, and then synthesize them.
[0129] The video recording device will encapsulate the read H264 video data and AAC video data into a 1e78091f-0988-406a-b8c6-700c0434d824.mp4 file using MP4 encapsulation format.
[0130] When the recording process terminates, the video recording device responds to the encapsulation command and directly encapsulates the saved H.264 video data and AAC audio data using the encapsulation method. Specifically, the video recording device can directly encapsulate the H.264 video data into the video track corresponding to the MP4 encapsulation format and the AAC audio data into the audio track corresponding to the MP4 encapsulation format. After obtaining the video file, the video file generates complete index information, while the encoded video data encapsulated into the video track and the encoded audio data encapsulated into the audio track are saved in the mdat box. When the player plays the video file, the player (decoder) directly reads the index information of the video file in the mdat box to find each video encoded file and each audio encoded file in the mdat box. The player then plays (decodes) each video encoded file and each audio encoded file, thus enabling the player to play the video file.
[0131] Compared to related technologies, this application directly encapsulates the stored H.264 video data and AAC audio data of each unit, eliminating the possibility of unencoded video and audio data remaining in the video recording device when the recording process terminates. Therefore, this application can generate complete index information corresponding to the video file and save this index information to the moov box. Since the moov box in the video file header can store complete index information, the player (decoder) can read the index information in the moov box to find the encoded video and audio data saved in the mdat box, thus enabling playback of the video file.
[0132] In some embodiments, video data is encoded in a preset video encoding format, and audio data is encoded in a preset audio data encoding format. The preset container format supports both the preset video encoding format and the preset audio data encoding format. Specifically, the above description of the embodiments of this application uses the H.264 encoding format corresponding to the MP4 container format for video data encoding and the AAC encoding format corresponding to the MP4 container format for audio data encoding as an example. It should be noted that the container format of the video file can also be other formats, as long as the container format of the video file supports the encoding formats of both the video data and the audio data. For example, when the video file uses the MP4 container format, the encoding format of the video data corresponding to the MP4 container format can also be AV1, VP8, and VP9, etc., and the encoding format of the audio data corresponding to the MP4 container format can also be Opus and MP3, etc. When the video file uses the MOV container format, the encoding format of the video data corresponding to the MOV container format can also be MPEG-2, MPEG4-ASP (XVID), and H.264, etc., and the encoding format of the audio data corresponding to the MOV container format can also be PCM, MP3, and AAC, etc. In some embodiments, other video file container formats can also be used, and this application does not limit them.
[0133] Please see Figure 8 , Figure 8 This is a schematic diagram of the structure of a video recording device provided in an embodiment of this application.
[0134] like Figure 8 As shown, the video recording device 800 includes at least:
[0135] The acquisition module 810 is used to continuously acquire unit video data and unit audio data during the recording process;
[0136] The encoding module 820 is used to encode the unit video data using a preset video encoding format to obtain a unit video encoded file, and to encode the unit audio data using a preset audio encoding format to obtain a unit audio encoded file;
[0137] The storage module 830 is used to continuously save the unit video encoding file and the unit audio encoding file;
[0138] The encapsulation module 840 is used to encapsulate the stored unit video encoding files and unit audio encoding files into a video file in response to the encapsulation command using a preset encapsulation format.
[0139] In some embodiments, the video recording device 800 further includes:
[0140] The first receiving module is used to receive user operations to end recording.
[0141] The first generation module is used to generate encapsulation instructions based on the user operation used to end recording.
[0142] In some embodiments, the video recording device 800 further includes:
[0143] The second receiving module is used to receive user operations for saving the video file after the abnormal end of the recording process.
[0144] The second generation module is used to generate encapsulation instructions based on the user operation for saving the video file.
[0145] In some embodiments, the encapsulation module 840 is specifically configured to, in response to an encapsulation instruction, encapsulate each of the saved unit video encoded files into a video track corresponding to the preset encapsulation format, and encapsulate each of the saved unit audio encoded files into an audio track corresponding to the preset encapsulation format.
[0146] In some embodiments, the video recording device 800 further includes:
[0147] The third generation module is used to generate file information based on the unit video encoded file and the unit audio encoded file;
[0148] The writing module is used to write the file information into a preset container of the video file.
[0149] In some embodiments, the storage module 830 is specifically configured to continuously save the unit video encoded file and the unit audio encoded file to local storage and / or cloud storage, respectively.
[0150] In some embodiments, the storage module 830 is specifically configured to continuously save the unit video encoded file to a video folder named with a unique identifier, and to continuously save the unit audio encoded file to an audio folder named with the unique identifier; the video folder and the audio folder are located in local storage and / or cloud storage.
[0151] In some embodiments, the encapsulation instructions carry the unique identification code; the encapsulation module 840 includes at least:
[0152] The acquisition unit is configured to, in response to the encapsulation instruction, acquire each unit video encoded file in the video folder named by the unique identification code, and acquire each unit audio encoded file in the audio folder named by the unique identification code;
[0153] The encapsulation unit is used to encapsulate each of the unit video encoded files and each of the unit audio encoded files into a video file using a preset encapsulation format.
[0154] This embodiment also provides a computer program product, which includes computer program code. When the computer program code is run on a computer, it causes the computer to execute a video recording method described in the above embodiment.
[0155] This embodiment also provides a computer storage medium that stores computer program code. When the computer program is executed, it implements a video recording method described in the above embodiment.
[0156] Figure 9 This is a schematic diagram of the structure of a video recording device provided in an embodiment of this application.
[0157] For example, such as Figure 9 As shown, the video recording device 900 may include at least: a memory 910, a processor 920, a camera, a microphone, and a local disk. The memory 910 stores executable program code 911, and the processor 920 is used to call and execute the executable program code 911 to perform the video recording method. The camera and microphone are used by the video recording device 900 to acquire video and audio data during the recording process, respectively. After acquiring the video and audio data, the video and audio data are encoded using selected video encoding formats and video encoding methods, respectively, and the encoded video and audio data are saved to the local disk. This facilitates the video recording device's reading of the encoded video and audio data from the local disk, improving the speed at which the video recording device reads the encoded video and audio data.
[0158] This embodiment can divide the video recording device 900 into functional modules according to the above method example. For example, each function can be assigned to a separate module, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware. It should be noted that the module division in this embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.
[0159] When each function is divided into modules corresponding to its specific function, the video recording device 900 may include: a status acquisition module and a prompt control module, etc. It should be noted that all relevant content of each step involved in the above method embodiments can be referenced from the functional descriptions of the corresponding functional modules, and will not be repeated here.
[0160] The video recording device 900 provided in this embodiment is used to execute the above-described sound source prompting method, and thus can achieve the same effect as the above-described implementation method.
[0161] When using integrated units, the video recording device 900 may include a processing module and a storage module. The processing module is used to control and manage the operations of the video recording device 900. The storage module is used to support the video recording device 900 in executing program code and data.
[0162] The processing module may be a processor or a controller, which can implement or execute various exemplary logic blocks, modules, and circuits as disclosed in this application. The processor may also be a combination of computing functions, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and microprocessors, etc., and the storage module may be a memory.
[0163] In addition, the video recording device 900 provided in the embodiments of this application may specifically be a chip, component or module. The video recording device 900 may include a connected processor and a memory. The memory is used to store instructions. When the video recording device 900 is running, the processor may call and execute the instructions to make the chip execute a sound source prompting method in the above embodiments.
[0164] In this embodiment, the video recording device 900, computer-readable storage medium, computer program product or chip are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here.
[0165] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0166] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0167] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A video recording method, characterized in that, include: During the recording process, unit video data and unit audio data are continuously collected; The unit video data is encoded using a preset video encoding format to obtain a unit video encoded file, and the unit audio data is encoded using a preset audio encoding format to obtain a unit audio encoded file; The unit video encoding file and the unit audio encoding file are continuously saved; In response to the encapsulation command, the saved individual unit video encoded files and individual unit audio encoded files are encapsulated into a video file using a preset encapsulation format; The step of responding to the encapsulation instruction by encapsulating the saved unit video encoded files and unit audio encoded files into a video file using a preset encapsulation format includes: In response to the encapsulation command, the saved individual video encoded files are encapsulated into a video track corresponding to the preset encapsulation format, and the saved individual audio encoded files are encapsulated into an audio track corresponding to the preset encapsulation format, thereby generating a video file and obtaining complete index information corresponding to the video file. The index information is used by the player to play the video file.
2. The video recording method according to claim 1, characterized in that, After continuously saving the unit video encoded file and the unit audio encoded file, before responding to the encapsulation instruction and encapsulating each saved unit video encoded file and each unit audio encoded file into a video file using a preset encapsulation format, the method further includes: Receive user input to end recording; Generate encapsulation instructions based on the user operation used to end recording.
3. The video recording method according to claim 1, characterized in that, After continuously saving the unit video encoded file and the unit audio encoded file, before responding to the encapsulation instruction and encapsulating each saved unit video encoded file and each unit audio encoded file into a video file using a preset encapsulation format, the method further includes: After the recording process abnormally ends, a user operation to save the video file is received. Generate encapsulation instructions based on the user operations used to save the video file.
4. The video recording method according to any one of claims 1-3, characterized in that, After the process of encapsulating the saved unit video encoded files and unit audio encoded files into a video file using a preset encapsulation format, it further includes: Based on the unit video encoded file and the unit audio encoded file, generate file information; The file information is written into a preset container of the video file.
5. The video recording method according to claim 1, characterized in that, The continuous saving of the unit video encoded file and the unit audio encoded file includes: The unit video encoding file and the unit audio encoding file are continuously saved to local storage and / or cloud storage, respectively.
6. The video recording method according to claim 5, characterized in that, The step of continuously saving the unit video encoded file and the unit audio encoded file to local storage and / or cloud storage respectively includes: The unit video encoded file is continuously saved to a video folder named with a unique identifier, and the unit audio encoded file is continuously saved to an audio folder named with the unique identifier; the video folder and the audio folder are located in local storage and / or cloud storage.
7. The video recording method according to claim 6, characterized in that, The encapsulation instruction carries the unique identification code; The step of responding to the encapsulation instruction by encapsulating the saved unit video encoded files and unit audio encoded files into a video file using a preset encapsulation format includes: In response to the encapsulation instruction, each unit video encoded file in the video folder named with the unique identification code is obtained, and each unit audio encoded file in the audio folder named with the unique identification code is obtained; Each of the unit video encoding files and each of the unit audio encoding files are packaged into a video file using a preset encapsulation format.
8. A video recording device, characterized in that, include: The acquisition module is used to continuously acquire unit video data and unit audio data during the recording process; The encoding module is used to encode the unit video data using a preset video encoding format to obtain a unit video encoded file, and to encode the unit audio data using a preset audio encoding format to obtain a unit audio encoded file; A storage module is used to continuously save the unit video encoded file and the unit audio encoded file; The encapsulation module is used to encapsulate the saved unit video encoding files and unit audio encoding files into a video file in a preset encapsulation format in response to the encapsulation command. The encapsulation module is specifically used to respond to encapsulation instructions by encapsulating each of the saved unit video encoded files into a video track corresponding to the preset encapsulation format, and encapsulating each of the saved unit audio encoded files into an audio track corresponding to the preset encapsulation format, thereby generating a video file and obtaining complete index information corresponding to the video file. The index information is used by the player to play the video file.
9. A computer storage medium, characterized in that, The computer storage medium stores a computer program that, when executed, implements the method as described in any one of claims 1 to 7.
10. A video recording device, characterized in that, include: Memory, used to store executable program code; A processor is configured to call and run the executable program code from the memory, causing the video recording device to perform the method as described in any one of claims 1 to 7.