Video recording method and device, storage medium and video recording equipment
By continuously collecting and encoding video data and audio data in the video recording device, and generating complete index information when abnormal termination is generated, the problem of video files cannot be played is solved, ensuring that the player can play video files normally.
Patent Information
- Application Number
- CN202310852894.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-11
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2043-07-11
AI Technical Summary
When the video recording device terminates abnormally, it cannot generate video file index information, resulting in the player being unable to play video files.
During the recording process, video data and audio data are continuously collected, and encoded in a preset encoding format, saved as a unit file, and encapsulate it into a video file in a preset packaging format in response to the encapsulation instruction to ensure that the complete index information is generated.
It realizes that the video recording device can generate complete video file index information when it is terminated abnormally, ensuring that the player can play video files normally.
Smart Images

Figure CN119316654A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of video recording technology, and more specifically, to a video recording method, apparatus, storage medium and video recording equipment in the field of video recording technology. Background Art
[0002] Video recording devices (such as surveillance equipment, mobile phones, and drones, etc.) usually use video packaging formats (such as MKV, AVI, and MP4, etc.) to directly package the encoded video data and audio data into video files.
[0003] When the video recording device uses this method to perform video recording, if an abnormal termination occurs (for example, the recording application crashes), the player cannot read the index information in the header container of the video file, and thus cannot find the encoded video data and audio data in the video file, resulting in the player being unable to play (decode) the video file. Summary of the invention
[0004] The present application provides a video recording method, apparatus, storage medium and video recording device, which can ensure that a player can play video files.
[0005] In a first aspect, the present application provides a video recording method, the method comprising:
[0006] During the recording process, the unit video data and unit audio data are continuously collected;
[0007] Encoding the unit video data in a preset video encoding format to obtain a unit video encoding file, and encoding the unit audio data in a preset audio encoding format to obtain a unit audio encoding file;
[0008] Continuously saving the unit video encoding file and the unit audio encoding file;
[0009] In response to the encapsulation instruction, each of the saved unit video encoding files and each of the saved unit audio encoding files are encapsulated into a video file in a preset encapsulation format.
[0010] In some embodiments, after continuously saving the unit video encoding files and the unit audio encoding files, and before responding to the encapsulation instruction to encapsulate each of the saved unit video encoding files and each of the unit audio encoding files into a video file in a preset encapsulation format, the method further includes:
[0011] Receive a user operation for ending recording;
[0012] A packaging instruction is generated based on the user operation for ending the recording.
[0013] In some embodiments, after continuously saving the unit video encoding files and the unit audio encoding files, before responding to the encapsulation instruction and encapsulating each of the saved unit video encoding files and each of the unit audio encoding files into a video file in a preset encapsulation format, the method further includes:
[0014] After the recording process ends abnormally, receiving a user operation for saving the video file;
[0015] A packaging instruction is generated based on the user operation for saving the video file.
[0016] In some embodiments, in response to the encapsulation instruction, encapsulating each of the stored unit video encoding files and each of the unit audio encoding files into a video file in a preset encapsulation format includes:
[0017] In response to the encapsulation instruction, each of the saved unit video encoding files is encapsulated into a video track corresponding to the preset encapsulation format, and each of the saved audio encoding files is encapsulated into an audio track corresponding to the preset encapsulation format.
[0018] In some embodiments, after packaging each of the stored unit video encoding files and each of the unit audio encoding files into a video file in a preset packaging format, the process further includes:
[0019] Generate file information based on the unit video encoding file and the unit audio encoding file;
[0020] The file information is written into a preset container of the video file.
[0021] In some embodiments, the continuously saving the unit video encoding file and the unit audio encoding file includes:
[0022] The unit video encoding file and the unit audio encoding file are continuously saved to a local storage and / or a cloud storage, respectively.
[0023] In some embodiments, the continuously saving the unit video encoding file and the unit audio encoding file to a local storage and / or a cloud storage, respectively, includes:
[0024] The unit video encoding file is continuously saved in a video folder named with a unique identification code, and the unit audio encoding file is continuously saved in an audio file named with the unique identification code; the video folder and the audio folder are located in a local storage and / or a cloud storage.
[0025] In some embodiments, the packaging instruction carries the unique identification code;
[0026] In response to the encapsulation instruction, encapsulating each of the stored unit video encoding files and each of the unit audio encoding files into a video file in a preset encapsulation format includes:
[0027] In response to the packaging instruction, obtaining each of the unit video encoding files in the video folder named with the unique identification code, and obtaining each of the unit audio encoding files in the audio folder named with the unique identification code;
[0028] Each of the unit video encoding files and each of the unit audio encoding files are packaged into a video file in a preset packaging format.
[0029] In a second aspect, the present application provides a video recording device, the video recording device comprising:
[0030] A collection module, used to continuously collect unit video data and unit audio data during the recording process;
[0031] An encoding module, configured to encode the unit video data in a preset video encoding format to obtain a unit video encoding file, and to encode the unit audio data in a preset audio encoding format to obtain a unit audio encoding file;
[0032] A storage module, used for continuously storing the unit video encoding file and the unit audio encoding file;
[0033] The encapsulation module is used to respond to the encapsulation instruction and encapsulate the stored unit video encoding files and the unit audio encoding files into a video file in a preset encapsulation format.
[0034] In a third aspect, the present application provides a computer program product comprising instructions, which, when executed on a computer or a processor, enables the computer or the processor to execute the method in the first aspect or any one of the embodiments of the first aspect.
[0035] In a fourth aspect, the present application provides a computer storage medium storing a computer program. When the computer program is executed, the method in the above-mentioned first aspect or any one of the embodiments of the first aspect is implemented.
[0036] In a fifth aspect, the present application provides a video recording device, the video recording device comprising:
[0037] A memory for storing executable program codes;
[0038] The processor is used to call and run the executable program code from the memory, so that the video recording device executes the method in the first aspect or any one of the embodiments of the first aspect.
[0039] The beneficial effects brought by the technical solution provided by the embodiment of the present application include at least:
[0040] The embodiments of the present application provide a video recording method, apparatus, storage medium and video recording device. During the recording process, the video recording device continuously collects unit video data and unit audio data, encodes the unit video data in a preset video encoding format to obtain a unit video encoding file, and encodes the unit audio data in a preset audio encoding format to obtain a unit audio encoding file. The unit video encoding files and the unit audio encoding files are continuously saved; in response to the encapsulation instruction, each saved unit video encoding file and each unit audio encoding file are encapsulated into a video file in a preset encapsulation format. Since what is saved are unit video encoding files and unit audio encoding files, and there is no unencoded video data and audio data, the video recording device can directly encapsulate the saved unit video encoding files and unit audio encoding files in a preset encapsulation format to obtain a video file, thereby realizing video recording. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 A schematic diagram of the system architecture of a video recording method provided in an embodiment of the present application;
[0042] Figure 2 A flowchart of a video recording method provided in an embodiment of the present application;
[0043] Figure 3 Another flow chart of a video recording method provided in an embodiment of the present application;
[0044] Figure 4 A schematic diagram of a video recording device receiving a user operation for ending recording provided by an embodiment of the present application;
[0045] Figure 5 is a schematic diagram of a display interface of a video recording device provided in an embodiment of the present application;
[0046] Figure 6 is another schematic diagram of a display interface of a video recording device provided in an embodiment of the present application;
[0047] Figure 7 Another flow chart of a video recording method provided in an embodiment of the present application;
[0048] Figure 8 A schematic diagram of the structure of a video recording device provided in an embodiment of the present application;
[0049] Fig. 9 A schematic diagram of the structure of a video recording device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0050] The technical solution in the present application will be described clearly and in detail below in conjunction with the accompanying drawings. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B: "and / or" in the text is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0051] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying 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 the features.
[0052] Video recording devices (such as surveillance equipment, mobile phones, and drones, etc.) use video packaging formats (such as MKV, AVI, and MP4, etc.) to directly package the encoded video data and audio data into video files.
[0053] In a commonly used MP4 video file (a video file encapsulated using the MP4 video encapsulation format), the video data obtained during the recording process can be encoded using the H264 encoding format, and the audio data obtained during the recording can be encoded using the AAC encoding format. The encoded video data is encapsulated into a video track corresponding to the MP4 encapsulation format, and the encoded audio data is encapsulated into an audio track corresponding to the MP4 encapsulation format to obtain a video file.
[0054] The video file corresponding to the MP4 encapsulation format may at least include a moov box and an mdat box, which may also be referred to as a moov container and an mdat container, respectively. After the encoded video data and the encoded audio data are respectively encapsulated into the video track and the audio track to form a video file, the index information corresponding to the video file may be obtained, and the index information may be written into the moov box located at the head of the video file (in some embodiments, the moov box may also be located at the tail of the video file), and the encoded video data encapsulated into the video track and the encoded audio data encapsulated into the audio track are stored in the mdat box. The encoded video data and the encoded audio data stored 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 before playing (decoding) the encoded video data and the encoded audio data stored in the mdat box, so that the player can play the video file.
[0055] During the video recording process, if an abnormal termination (which can also be understood as the video recording application abnormally crashes), at the moment when the recording device abnormally terminates, there are still video data and audio data in the recording device that have not yet been encoded. Since there are video data and audio data in the recording device that have not yet been encoded when the recording device abnormally terminates, the encoded video data and the encoded audio data are not packaged into a video file, and no index information corresponding to the video file will be generated, and no index information will be written into the moov box located at the head of the video file. In this case, the player (decoder) cannot read the index information in the moov box, and cannot play (decode) the encoded video data and the encoded audio data saved in the mdat box, resulting in the player being unable to play the video file.
[0056] In order to solve the problem that video files cannot be played, an embodiment of the present application provides a video recording method, which includes continuously collecting unit video data and unit audio data during the recording process; encoding the unit video data in a preset video encoding format to obtain a unit video encoding file, and encoding the unit audio data in a preset audio encoding format to obtain a unit audio encoding file; continuously saving the unit video encoding file and the unit audio encoding file; and in response to an encapsulation instruction, encapsulating each of the saved unit video encoding files and each of the unit audio encoding files into a video file in a preset encapsulation format. This method can solve the problem that the above-mentioned video file cannot be played.
[0057] See also Figure 1 , Figure 1A schematic diagram of the system architecture of a video recording method provided in an embodiment of the present application.
[0058] like Figure 1 As shown, the system architecture may at least include a video recording device 101, and the video recording device 101 is at least configured with a camera, a microphone, and a local disk. The camera and the microphone are respectively used for the video recording device 101 to collect video data and audio data during the recording process. After the video recording device 101 collects the video data and the audio data, the video recording device 101 encodes the video data and the audio data in a selected video encoding format and a video encoding format, respectively, and saves the encoded video data and audio data to a local disk. The video recording device 101 may at least include a camera, a smart watch, a smart phone, a tablet computer, a laptop portable computer, a desktop computer, etc.
[0059] In an embodiment of the present application, first, the video recording device 101 can continuously collect unit video data and unit audio data during the recording process; secondly, encode the unit video data using a preset video encoding format to obtain a unit video encoding file, and encode the unit audio data using a preset audio encoding format to obtain a unit audio encoding file; then, continuously save the unit video encoding file and the unit audio encoding file; finally, the video recording device 101 responds to the encapsulation instruction to encapsulate each of the saved unit video encoding files and each of the unit audio encoding files into a video file in a preset encapsulation 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, for example, the wireless communication link may include a Bluetooth communication link, a Wireless-Fidelity (Wi-Fi) communication link, or a microwave communication link.
[0061] Specifically, the video recording device 101 can save the encoded video data and audio data to the cloud storage 103 through the network 102, saving the storage space of the local disk of the video recording device 101. The video recording device 101 can also access the cloud storage 103 through the network 102 to obtain the encoded video data and audio data saved in the cloud storage 103.
[0062] It should be understood that Figure 1 The number of video recording devices 101, networks 102 and cloud storages 103 is only illustrative, and any number of video recording devices 101, networks 102 and cloud storages 103 may be used according to actual needs.
[0063] Based on the above system architecture, an embodiment of the present application provides a video recording method.
[0064] See also Figure 2 , Figure 2 A flowchart of a video recording method provided in an embodiment of the present application.
[0065] like Figure 2 As shown, the video recording method may at least include:
[0066] S202, the video recording device continuously collects unit video data and unit audio data during the recording process.
[0067] The subsequent embodiments of the present application are described by taking the encoding of video data using the H264 encoding format corresponding to the MP4 encapsulation format and the encoding of audio data using the AAC encoding format corresponding to the MP4 encapsulation format as an example.
[0068] As the video recording proceeds, video data and audio data are continuously generated. The video data generated by the video recording device can be continuously encoded by the video encoder in the H264 encoding format to obtain H264 video data, and the audio data can be continuously encoded by the audio encoder in the AAC encoding format to obtain AAC audio data.
[0069] The unit video data may be an amount that can be encoded to form one frame of H264 video data; the unit audio data may be 1024 sampling points, and the video recording device encodes each 1024 sampling points into a unit AAC audio data. That is, when the video recording device collects an amount that can be encoded to form one frame of H264 video data, the unit video data is obtained, and when the video recording device collects 1024 sampling points, the unit audio data is obtained.
[0070] It should be noted that the method of using 1024 sampling points to encode AAC audio data is a conventional method, and different numbers of sampling points can also be used for encoding according to needs, 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 encoding file, and encodes the unit audio data using a preset audio encoding format to obtain a unit audio encoding file.
[0072] As the video recording proceeds, video data and audio data are continuously generated. At the same time, the encoding of the video data and the encoding of the audio data are also continuously performed, so H264 video data and AAC audio data are also continuously generated.
[0073] Specifically, when unit video data is collected, the video recording device uses the H264 encoding format to encode the unit video data to obtain unit H264 video data. When unit audio data is collected, the video recording device uses the AAC encoding format to encode the unit audio data to obtain AAC audio data.
[0074] S206: The video recording device continues to save the unit video encoding file and the unit audio encoding file.
[0075] The continuously generated unit H264 video data and unit AAC audio data are sequentially saved to the local storage and / or cloud storage so that the unit H264 video data and unit AAC audio data can be obtained at any time.
[0076] S208, the video recording device responds to the encapsulation instruction and encapsulates each saved unit video encoding file and each unit audio encoding file into a video file in a preset encapsulation format.
[0077] Since each unit of H264 video data and each unit of AAC audio data can be saved in a local disk or cloud storage, when the video recording device responds to the encapsulation instruction, the video recording device can directly access the local disk or cloud storage to read each unit of H264 video data and each unit of AAC audio data, so as to encapsulate the H264 video data and AAC audio data into a video file through a video encapsulation editor and using the MP4 encapsulation format.
[0078] When the recording process terminates, the video recording device responds to the encapsulation instruction and directly uses the stored H264 video data and AAC audio data to encapsulate. Specifically, the video recording device can directly encapsulate each H264 video data into the video track corresponding to the MP4 encapsulation format, and encapsulate each AAC audio data into the audio track corresponding to the MP4 encapsulation format to obtain the video file. The video file can generate complete index information, and the H264 video data encapsulated into the video track and the AAC audio data of the encapsulated 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 moov box to find the H264 video data and AAC audio data in the mdat box, and the player plays (decodes) the H264 video data and AAC audio data, so that the player plays the video file.
[0079] Compared with the related art, since the present application directly uses the stored H264 video data and AAC audio data units for encapsulation, there is no situation where the video recording device has video data and audio data that cannot be encoded in the future when the recording process is terminated. Therefore, the present application can generate complete index information corresponding to the video file and save the index information in the moov box; since the moov box at the head of the video file can store complete index information, the player (decoder) can read the index information in the moov box to find the encoded video data and encoded audio data stored in the mdat box, thereby realizing the playback of the video file.
[0080] See also Figure 3 , Figure 3 A flowchart of a video recording method provided in an embodiment of the present application.
[0081] like Figure 3 As shown, the video recording method may at least include:
[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 encoding file, and encodes the unit audio data using a preset audio encoding format to obtain a unit audio encoding file.
[0084] S306: The video recording device continues to save the unit video encoding file and the unit audio encoding file.
[0085] Regarding steps S302 to S306, please refer to the detailed description 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 encoding file and unit audio encoding file upon receiving the encapsulation instruction. When the termination of the recording process is different, the encapsulation instruction received by the video recording device is also different. The termination of the recording process can specifically include two situations: normal termination and abnormal termination. The following S308 to S310 introduce how to generate the encapsulation instruction for the normal termination situation, and S312 to S314 introduce how to generate the encapsulation instruction for the abnormal termination situation. Specifically:
[0087] S308: The video recording device receives a user operation for ending recording.
[0088] See also Figure 4 , Figure 4A schematic diagram of a video recording device receiving a user operation for ending recording provided in an embodiment of the present application. When the video recording device receives the operation of 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 normal recording of the video to be recorded. It should be noted here that the user's button operation can be pressing a physical button on the video recording device, or touching a button on the display interface of the recording application. In some embodiments, the video recording device can also be prompted by voice to end recording, or by a gesture corresponding to the normal end of the video recording process to prompt the video recording device to end recording, which is not limited in this application.
[0089] When the video recording device receives the user operation to end recording, the video recording device needs to encode the video data and audio data generated in the recording process respectively (it should be noted that the video recording device encodes and saves the video data and audio data while generating them, so when the user operation to end recording is received, the video data and audio data generated in the recording process have not been encoded yet), and save the encoded H264 video data and AAC audio data. Since the video recording ends normally, the complete and encoded H264 video data and AAC audio data are saved.
[0090] S310: The video recording device generates a packaging instruction based on a user operation for ending recording.
[0091] Taking the example of saving unit H264 video data and unit AAC audio data in the local disk, when the video recording device receives the encapsulation instruction, the video recording device directly accesses the local disk to read the saved unit H264 video data and unit AAC audio data.
[0092] The video encapsulation editor encapsulates the unit H264 video data into the video track corresponding to the MP4 encapsulation format, and encapsulates the unit AAC audio data into the audio track corresponding to the MP4 encapsulation format, so as to encapsulate the unit video encoding file and the unit audio encoding file generated during the video recording process into a video file.
[0093] Since the local disk stores complete and encoded H264 video data and AAC audio data when the video recording ends normally, the video packaging editor can generate complete index information corresponding to the video file after packaging, and write the index information into the moov box of the video file. The player (decoder) can read the index information in the moov box to find the encoded video data and encoded audio data stored in the mdat box, and play the video file.
[0094] In some embodiments, during the video recording process, abnormal termination may occur, that is, the recording is not terminated subjectively by the user, such as but not limited to abnormal flashback of the video recording application, exhaustion of the battery of the video recording device, etc. In the case of abnormal termination of the video recording, the process of generating the packaging instruction includes S312 to S314:
[0095] S312: After the recording process ends abnormally, the video recording device receives a user operation for saving a video file.
[0096] See also Figures 5 and 6 , Figure 5 is a schematic diagram of a display interface of a video recording device provided in an embodiment of the present application; Figure 6 1 is another schematic diagram of a display interface of a video recording device provided by an embodiment of the present application. The abnormal end of the recording process can be understood as the recording application crashing, or it may be due to other circumstances causing the abnormal end of the recording process. In the case of the recording application crashing, the recorder needs to wait until the recording application is restarted.
[0097] When you restart the recording application, a pop-up window will appear on the recording application interface to inform you that the video cannot be played (see Figure 5 ) or "There is a video that was not saved properly" (see Figure 6 ) and so on, prompting the recorder that the recorded video cannot be saved normally and cannot be played normally. When the user receives the above prompt, the user is required to press the "resume saving" (or the above-mentioned "end recording") button.
[0098] S314: The video recording device generates a packaging instruction based on the user operation for saving the video file.
[0099] When the recording application crashes, a unit of H264 video data and a unit of AAC audio data are saved in the local disk.
[0100] When the video recording device receives the encapsulation instruction, 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 H264 video data into a video track corresponding to the MP4 encapsulation format, and encapsulates each unit AAC audio data into an audio track corresponding to the MP4 encapsulation format, so as to encapsulate the unit video encoding file and the unit audio encoding file generated during the video recording process into a video file.
[0101] S316, the video recording device responds to the encapsulation instruction and encapsulates each saved unit video encoding file and each unit audio encoding file into a video file in a preset encapsulation format.
[0102] Since each unit of H264 video data and each unit of AAC audio data are stored in the local disk or cloud storage, when the video recording device responds to the encapsulation instruction, the video recording device can directly access the local disk or cloud storage to read the stored each H264 video data and each AAC audio data, so that the H264 video data and AAC audio data can be encapsulated into a video file through a video encapsulation editor and in MP4 encapsulation format.
[0103] Optionally, at the moment when the recording application flashes back, the video data finally generated may not reach one frame, and this part of the video data that does not reach one frame cannot be encoded and saved. It takes 0.1 seconds for a video recording device to record one frame of video data, so it may take tens of milliseconds for the video recording device to record the unencoded video data. At the same time, the audio data finally generated may not reach the number of 1024 sampling points, and this part of the audio data that does not reach 1024 sampling points cannot be encoded and saved. It takes 0.1 seconds for a video recording device to record audio data of 1024 sampling points, so it may take tens of milliseconds for the video recording device to record the unencoded audio data. Since the video data and audio data that have not been encoded and saved cannot participate in packaging, it can be seen that the video file will lose tens of milliseconds of content containing video data and audio data that have not been encoded and saved.
[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 the file information into a preset container of the video file.
[0106] The video recording device generates file information based on the encapsulated video data 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 H264 video data and AAC audio data, the video encapsulation editor can generate complete index information corresponding to the video file after encapsulation, and write the index information into the moov box of the video file. The player (decoder) can read the index information in the moov box to find the video data and audio data stored in the mdat box, thereby playing the video file. It should be noted that even if the recording application crashes, the existing unencoded video data and audio data will not participate in the encapsulation process, and will not affect the encapsulation of the video file. The encapsulated video file can still generate complete index information corresponding to the video file, and write the index information into the moov box, so the unencoded video data and audio data will not affect the normal playback of the video file.
[0108] See also Figure 7 , Figure 7 A flowchart of a video recording method provided in an embodiment of the present application.
[0109] like Figure 7 As shown, the video recording method may at least include:
[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 the unit video data using a preset video encoding format to obtain a unit video encoding file, and encodes the unit audio data using a preset audio encoding format to obtain a unit audio encoding file.
[0112] Regarding steps S702 to S704, please refer to the detailed description in steps S202 to S204, which will not be repeated here.
[0113] S706, the video recording device continues to save the unit video encoding file and the unit audio encoding file to the local storage and / or cloud storage respectively.
[0114] The video recording device continuously saves the unit video encoding file into a video folder named with a unique identification code, and continuously saves the unit audio encoding file into an audio file named with the unique identification code; the video folder and the audio folder are located in a local storage and / or a cloud storage.
[0115] Specifically, when the user turns on the start recording button on the video recording device, the video recording device starts video recording and creates a video folder and an audio folder in the local disk.
[0116] It should be noted that the user can start video recording of the video recording device by pressing a physical button on the video recording device; in some embodiments, the user can also touch the start recording button displayed on the display screen of the video recording device to start video recording of the video recording device.
[0117] As the video recording proceeds, H264 video data and AAC audio data are continuously generated. H264 video data is stored in the form of hexadecimal data, so the H264 video data can be continuously saved to the video folder set in the local disk using the corresponding file management tool. And the AAC audio data can also be continuously saved to the audio folder set in the local disk using the corresponding file management tool. And each generated H264 video data and AAC audio data file can be saved to the set video folder and the set audio folder of the local disk respectively.
[0118] When the video recording device needs to encapsulate the encoded video data and audio data, the video recording device can directly access the local disk to read the encoded H264 video data and AAC audio data saved in the local disk. The local disk is located inside the video recording device, which can increase the speed at which the video recording device reads the encoded H264 video data and AAC audio data.
[0119] At the same time, in order to facilitate the video recording device to read the encoded H264 video data and AAC audio data saved in the local disk, the video recording device can create a video folder and an audio folder in the local disk when starting video recording, and name the video folder and the audio folder respectively with a unique identification code. As the video is recorded, video data and audio data are continuously generated, and the video recording device continuously generates encoded unit video encoding files and unit audio encoding files, and continuously saves the unit video encoding files in the video folder named with the unique identification code, and continuously saves the unit audio encoding files in the audio folder named with the unique identification code.
[0120] Specifically, the video recording device generates a unique identification code for naming the video folder and the audio folder. The unique identification code may be a UUID (Universally Unique Identifier), and the video folder and the audio folder are named using the UUID. For example, the UUID may be 1e78091f-0988-406a-b8c6-700c0434d824, then the video folder may be named 1e78091f-0988-406a-b8c6-700c0434d824.h264, and the audio folder may be named 1e78091f-0988-406a-b8c6-700c0434d824.aac.
[0121] In some embodiments, the unique identification code may also be a timestamp, etc., as long as the uniqueness of the unique identification code is ensured, and this application does not limit this.
[0122] In some embodiments, the video recording device may also save the H264 video data and AAC audio data to the cloud storage, saving storage space of the local disk of the video recording device 101. Specifically, when the user turns on the start recording button on the video recording device, a folder creation request is sent to the server, and the server creates a video folder and an audio folder in the cloud storage.
[0123] Every time a frame of H264 video data is encoded, the video recording device can upload the encoded frame of H264 video data to a video folder in the cloud storage; every time 1024 sampling points of AAC audio data are encoded, the video recording device can upload the encoded AAC audio data containing 1024 sampling points to an 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 actual conditions, and this application does not limit this.
[0125] S708, the video recording device responds to the encapsulation instruction to obtain each of the unit video encoding files in the video folder named with the unique identification code, and obtains each of the unit audio encoding files in the audio folder named with the unique identification code.
[0126] Taking the unique identification code 1e78091f-0988-406a-b8c6-700c0434d824 as an example, the encapsulation instruction may include the unique identification code 1e78091f-0988-406a-b8c6-700c0434d824. Then, according to the 1e78091f-0988-406a-b8c6-700c0434d824 included in the encapsulation instruction, the unit video encoding file in the 1e78091f-0988-406a-b8c6-700c0434d824.h264 folder and the unit audio encoding file in the 1e78091f-0988-406a-b8c6-700c0434d824.aac folder may be read in 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 in a preset encapsulation format.
[0128] When the video recording device responds to the encapsulation instruction and synthesizes the video file (1e78091f-0988-406a-b8c6-700c0434d824.mp4), the video recording device can find the 1e78091f-0988-406a-b8c6-700c0434d824.aac folder storing various H264 video data and the 1e78091f-0988-406a-b8c6-700c0434d824.h264 folder storing various AAC video data in the local storage according to the unique identification code 1e78091f-0988-406a-b8c6-700c0434d824 and synthesize them.
[0129] The video recording device encapsulates each H264 video data and each AAC video data read into the 1e78091f-0988-406a-b8c6-700c0434d824.mp4 file using the MP4 encapsulation format.
[0130] When the recording process is terminated, the video recording device responds to the encapsulation instruction and directly uses the stored H264 video data and AAC audio data for encapsulation. Specifically, the video recording device can directly encapsulate the H264 video data into the video track corresponding to the MP4 encapsulation format, and encapsulate the AAC audio data into the audio track corresponding to the MP4 encapsulation format to obtain the video file. The video file can generate complete index information, and the encoded video data encapsulated into the video track and the encoded audio data of the encapsulated 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 moov box to find each video encoding file and each audio encoding file in the mdat box, and the player plays (decodes) each video encoding file and each audio encoding file, so that the player plays the video file.
[0131] Compared with the related art, since the present application directly uses the stored H264 video data and AAC audio data units for encapsulation, there is no situation where the video recording device has video data and audio data that cannot be encoded in the future when the recording process is terminated. Therefore, the present application can generate complete index information corresponding to the video file and save the index information in the moov box; since the moov box at the head of the video file can store complete index information, the player (decoder) can read the index information in the moov box to find the encoded video data and encoded audio data stored in the mdat box, thereby realizing the playback of the video file.
[0132] In some embodiments, the video data is encoded in a preset video encoding format, and the audio data is encoded in a preset audio data encoding format, wherein the preset encapsulation format supports the preset video encoding format and the preset audio data encoding format. Specifically, the above description of the embodiments of the present application is based on the H264 encoding format corresponding to the MP4 encapsulation format used for encoding the video data, and the AAC encoding format corresponding to the MP4 encapsulation format used for encoding the audio data as an example. It should be noted that the encapsulation format of the video file may also be other formats, ensuring that the encapsulation format of the video file supports the encoding format of the video data and the encoding format of the audio data. For example: when the video file adopts the MP4 encapsulation format, the encoding format of the video data corresponding to the MP4 encapsulation format may also be AV1, VP8 and VP9, etc., and the encoding format of the audio data corresponding to the MP4 encapsulation format may also be Opus and MP3, etc. When the video file adopts the MOV encapsulation format, the encoding format of the video data corresponding to the MOV encapsulation format may also be MPEG-2, MPEG4-ASP (XVID) and H264, etc., and the encoding format of the audio data corresponding to the MOV encapsulation format may also be PCM, MP3 and AAC, etc. In some embodiments, it may also be the encapsulation format of other video files, which is not limited by the present application.
[0133] See also Figure 8 , Figure 8 A schematic diagram of the structure of a video recording device provided in an embodiment of the present application.
[0134] like Figure 8 As shown, the video recording device 800 at least includes:
[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 in a preset video encoding format to obtain a unit video encoding file, and to encode the unit audio data in a preset audio encoding format to obtain a unit audio encoding file;
[0137] A storage module 830, used for continuously storing the unit video encoding file and the unit audio encoding file;
[0138] The encapsulation module 840 is used to encapsulate each of the stored unit video encoding files and each of the stored unit audio encoding files into a video file in a preset encapsulation format in response to the encapsulation instruction.
[0139] In some embodiments, the video recording device 800 further includes:
[0140] A first receiving module, used to receive a user operation for ending recording;
[0141] The first generating module is used to generate a packaging instruction based on the user operation for ending the recording.
[0142] In some embodiments, the video recording device 800 further includes:
[0143] The second receiving module is used to receive a user operation for saving a video file after the recording process ends abnormally.
[0144] The second generating module is used to generate a packaging instruction based on the user operation for saving the video file.
[0145] In some embodiments, the encapsulation module 840 is specifically used to encapsulate each of the saved unit video encoding files into a video track corresponding to the preset encapsulation format in response to the encapsulation instruction, and to encapsulate each of the saved unit audio encoding files into an audio track corresponding to the preset encapsulation format.
[0146] In some embodiments, the video recording device 800 further includes:
[0147] A third generating module, used for generating file information based on the unit video encoding file and the unit audio encoding 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 used to continuously save the unit video encoding file and the unit audio encoding file to the local storage and / or cloud storage respectively.
[0150] In some embodiments, the storage module 830 is specifically used to continuously save the unit video encoding file in a video folder named with a unique identification code, and to continuously save the unit audio encoding file in an audio folder named with the unique identification code; the video folder and the audio folder are located in the local storage and / or cloud storage.
[0151] In some embodiments, the encapsulation instruction carries the unique identification code; the encapsulation module 840 at least includes:
[0152] an acquisition unit, configured to acquire, in response to the encapsulation instruction, each of the unit video encoding files in the video folder named with the unique identification code, and acquire each of the unit audio encoding files in the audio folder named with the unique identification code;
[0153] The encapsulation unit is used to encapsulate each of the unit video encoding files and each of the unit audio encoding files into a video file in a preset encapsulation format.
[0154] This embodiment further provides a computer program product, which includes: computer program code, when the computer program code is run on a computer, it enables the computer to execute a video recording method in the above embodiment.
[0155] This embodiment further provides a computer storage medium, which stores computer program code. When the computer program is executed, a video recording method in the above embodiment is implemented.
[0156] Fig. 9 A schematic diagram of the structure of a video recording device provided in an embodiment of the present application.
[0157] For example, Fig. 9 As shown, the video recording device 900 may at least include: a memory 910, a processor 920, a camera, a microphone and a local disk, wherein the memory 910 stores an executable program code 911, and the processor 920 is used to call and execute the executable program code 911 to perform a video recording method. The camera and the microphone are respectively used for the video recording device 900 to collect video data and audio data during the recording process. After the video recording device collects the video data and audio data, the video data and audio data are respectively encoded in the selected video encoding format and video encoding format, and the encoded video data and audio data are saved to the local disk, so that the video recording device can read the encoded video data and audio data in the local disk, thereby improving the speed at which the video recording device reads the encoded video data and audio data.
[0158] In this embodiment, the video recording device 900 can be divided into functional modules according to the above method example. For example, each functional module can be corresponded, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware. It should be noted that the division of modules in this embodiment is schematic and is only a logical function division. There may be other division methods in actual implementation.
[0159] In the case of dividing each functional module according to each function, the video recording device 900 may include: a state acquisition module and a prompt control module, etc. It should be noted that all relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional module, which will not be repeated here.
[0160] The video recording device 900 provided in this embodiment is used to execute the above-mentioned sound source prompting method, and thus can achieve the same effect as the above-mentioned implementation method.
[0161] In the case of an integrated unit, the video recording device 900 may include a processing module and a storage module. The processing module may be used to control and manage the actions of the video recording device 900. The storage module may be used to support the video recording device 900 to execute mutual program codes and data.
[0162] The processing module may be a processor or a controller, which may implement or execute various exemplary logic blocks, modules and circuits disclosed in the present application. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, etc. The storage module may be a memory.
[0163] In addition, the video recording device 900 provided in the embodiment of the present application can specifically be a chip, a component or a module, and the video recording device 900 may include a connected processor and a memory; wherein the memory is used to store instructions, and when the video recording device 900 is running, the processor can call and execute instructions so that the chip executes a sound source prompt method in the above embodiment.
[0164] Among them, the video recording device 900, computer-readable storage medium, computer program product or chip provided in this embodiment are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above, and will not be repeated here.
[0165] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0166] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0167] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A video recording method, characterized in that: include: During the recording process, the unit video data and unit audio data are continuously collected; Encoding the unit video data in a preset video encoding format to obtain a unit video encoding file, and encoding the unit audio data in a preset audio encoding format to obtain a unit audio encoding file; Continuously saving the unit video encoding file and the unit audio encoding file; In response to the encapsulation instruction, each of the saved unit video encoding files and each of the saved unit audio encoding files are encapsulated into a video file in a preset encapsulation format.
2. The video recording method according to claim 1, characterized in that: After the unit video encoding file and the unit audio encoding file are continuously saved, and before the saved unit video encoding files and the unit audio encoding files are packaged into a video file in a preset packaging format in response to the packaging instruction, the method further includes: Receive a user operation for ending recording; A packaging instruction is generated based on the user operation for ending the recording.
3. The video recording method according to claim 1, characterized in that: After the unit video encoding file and the unit audio encoding file are continuously saved, and before the saved unit video encoding files and the unit audio encoding files are packaged into a video file in a preset packaging format in response to the packaging instruction, the method further includes: After the recording process ends abnormally, receiving a user operation for saving the video file; A packaging instruction is generated based on the user operation for saving the video file.
4. The video recording method according to any one of claims 1 to 3, characterized in that: In response to the encapsulation instruction, encapsulating each of the stored unit video encoding files and each of the unit audio encoding files into a video file in a preset encapsulation format includes: In response to the encapsulation instruction, each of the saved unit video encoding files is encapsulated into a video track corresponding to the preset encapsulation format, and each of the saved unit audio encoding files is encapsulated into an audio track corresponding to the preset encapsulation format.
5. The video recording method according to any one of claims 1 to 3, characterized in that: After encapsulating each of the stored unit video encoding files and each of the unit audio encoding files into a video file in a preset encapsulation format, the method further includes: Generate file information based on the unit video encoding file and the unit audio encoding file; The file information is written into a preset container of the video file.
6. The video recording method according to claim 1, characterized in that: The continuously saving the unit video encoding file and the unit audio encoding file includes: The unit video encoding file and the unit audio encoding file are continuously saved to a local storage and / or a cloud storage, respectively.
7. The video recording method according to claim 6, characterized in that: The continuously saving the unit video encoding file and the unit audio encoding file to the local storage and / or the cloud storage respectively includes: The unit video encoding file is continuously saved in a video folder named with a unique identification code, and the unit audio encoding file is continuously saved in an audio folder named with the unique identification code; the video folder and the audio folder are located in a local storage and / or a cloud storage.
8. The video recording method according to claim 7, characterized in that: The encapsulation instruction carries the unique identification code; In response to the encapsulation instruction, encapsulating each of the stored unit video encoding files and each of the unit audio encoding files into a video file in a preset encapsulation format includes: In response to the packaging instruction, obtaining each of the unit video encoding files in the video folder named with the unique identification code, and obtaining each of the unit audio encoding files in the audio folder named with the unique identification code; Each of the unit video encoding files and each of the unit audio encoding files are packaged into a video file in a preset packaging format.
9. A video recording device, characterized in that: include: A collection module, used to continuously collect unit video data and unit audio data during the recording process; An encoding module, configured to encode the unit video data in a preset video encoding format to obtain a unit video encoding file, and to encode the unit audio data in a preset audio encoding format to obtain a unit audio encoding file; A storage module, used for continuously storing the unit video encoding file and the unit audio encoding file; The encapsulation module is used to respond to the encapsulation instruction and encapsulate the stored unit video encoding files and the unit audio encoding files into a video file in a preset encapsulation format.
10. A computer storage medium, characterized in that: The computer storage medium stores a computer program, and when the computer program is executed, the method according to any one of claims 1 to 8 is implemented.
11. A video recording device, characterized in that: include: A memory for storing executable program codes; A processor, configured to call and run the executable program code from the memory, so that the video recording device executes the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Media file recording and playing method and terminal
CN106534748A
Multimedia file recovery method, device and equipment
CN110336804A
Write-in method of moov container in multimedia file and computer readable storage medium
CN113555040A
Display device and streaming media file synthesis method
CN114666516A