Video processing method and device, electronic equipment and storage medium
By inserting a frame header into the video file of the driving recorder and uploading it to the cloud, the problem of personal privacy leakage when uploading the video file is solved, and the frame header is replaced on the car side to ensure the integrity of the video file, achieving extended memory card storage Video file duration while protecting privacy and integrity.
Patent Information
- Application Number
- CN202410670045.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-28
- Publication Date
- 2024-09-03
AI Technical Summary
In the existing technology, when the driving recorder uploads the compressed video files to the cloud, there is a risk of leaking the user's personal privacy, and it cannot effectively extend the storage time of the video files on the memory card.
Insert the frame header before the key frames and non-key frames of the video file on the vehicle end, and upload the modified frame header to the cloud to ensure that the cloud cannot decrypt the video file. At the same time, the frame header is replaced on the vehicle end to ensure the integrity of the video file. .
It effectively protects users' personal privacy and extends the storage time of video files on the memory card, while ensuring the integrity and availability of video files.
Smart Images

Figure CN118590710A
Abstract
Description
Technical Field
[0001] This application belongs to the field of data processing technology, and in particular relates to a video processing method, apparatus, electronic device and storage medium. Background Technology
[0002] Currently, dashcams compress video files of the driving environment during vehicle operation using H.264 or H.265 video compression methods and save them to memory cards (such as flash memory cards, Trans-flash cards, and TF cards). Since the recorded video files of the driving environment provide evidence for determining liability in traffic accidents, dashcams need to store a large number of video files, but the storage space of dashcam memory cards is limited.
[0003] To extend the storage time of video files on dashcam memory cards, current technologies either directly upload compressed video files to cloud storage servers or encrypt the video files before uploading them to the cloud, and periodically clear the video files on the memory card. Storing unencrypted compressed video files in the cloud risks compromising user privacy, while the encryption keys for encrypted video files are also stored in the cloud, thus still posing a risk of user privacy leaks.
[0004] Uploading compressed video files to the cloud using existing technology poses a risk of privacy breaches for users. Summary of the Invention
[0005] This application provides a video processing method, apparatus, electronic device, and storage medium, which can solve the problem of the risk of personal privacy leakage when uploading compressed video files to the cloud.
[0006] In a first aspect, embodiments of this application provide a video processing method applied to a vehicle, including:
[0007] Multiple image packets are obtained after compressing a video file, wherein any image packet includes one keyframe and multiple non-keyframes, and the keyframe is an intra-frame encoded image frame;
[0008] A frame header is inserted before each of the key frames and non-key frames, wherein the frame header includes a frame type identifier, a frame data length, and a frame timestamp;
[0009] The first frame header corresponding to the key frame of the image package, each non-key frame, and the second frame header corresponding to each non-key frame are all uploaded to the cloud, and the compressed video file of the vehicle end is processed.
[0010] If the image package is played or exported, the first frame header corresponding to the key frame of the image package, each of the non-key frames, and the second frame header corresponding to each of the non-key frames are downloaded to the vehicle terminal.
[0011] The first frame header is replaced with the third frame header corresponding to the key frame on the vehicle side, wherein the frame timestamp of the third frame header is the same as the frame timestamp of the first frame header, and the frame data length of the third frame header is different from the frame data length of the first frame header.
[0012] In one embodiment, the frame data length of the first frame header is zero;
[0013] Inserting frame headers before each of the keyframes and non-keyframes, including:
[0014] Obtain the image features corresponding to the key frame and each of the non-key frames, the data length corresponding to each of the non-key frames, and the time corresponding to the key frame and each of the non-key frames;
[0015] Based on the image features corresponding to the key frame and each non-key frame, the data length corresponding to each non-key frame, and the time corresponding to the key frame and each non-key frame, a first frame header corresponding to the key frame and a second frame header corresponding to the non-key frame are created respectively.
[0016] The first frame header is inserted before the key frame, and each of the second frame headers is inserted before each of the non-key frames.
[0017] In one embodiment, based on the image features corresponding to the key frame and each of the non-key frames, the data length corresponding to each of the non-key frames, and the time corresponding to the key frame and each of the non-key frames, a first frame header corresponding to the key frame and a second frame header corresponding to the non-key frames are created, including:
[0018] Based on the image features of the key frames and each of the non-key frames, the frame type of the first frame header and the frame type corresponding to each of the second frame headers are identified;
[0019] Based on the frame type of the first frame header and the frame type corresponding to each of the second frame headers, the frame type identifier of the first frame header is set as a key frame identifier, and the frame type identifier of each of the second frame headers is set as a non-key frame identifier.
[0020] Set the frame data length of the first frame header to zero, and set the frame data length of the second frame header to the data length corresponding to each of the non-critical frames.
[0021] Based on the times corresponding to the key frames and each of the non-key frames, determine the frame timestamps of the key frames and the frame timestamps corresponding to each of the non-key frames.
[0022] Based on the frame type identifier, frame data length and frame timestamp corresponding to the key frame, create the first frame header corresponding to the key frame;
[0023] Based on the frame type identifier, frame data length, and frame timestamp corresponding to the non-critical frame, a second frame header is created for the non-critical frame.
[0024] In one embodiment, the first frame header corresponding to the keyframe of the image packet, each of the non-keyframes, and the second frame header corresponding to each of the non-keyframes are all uploaded to the cloud, including:
[0025] The network interface of the vehicle-mounted identification communication network;
[0026] Based on the network interface and the network status of the vehicle, the network type of the communication network is determined;
[0027] Based on the network type and the user's preset upload preferences, determine whether the network type meets the preset upload preferences;
[0028] If the network type meets the preset upload preference, the first frame header corresponding to the key frame of the image packet, each of the non-key frames, and the second frame header corresponding to each of the non-key frames are all uploaded to the cloud.
[0029] In one embodiment, the network type includes Wi-Fi and cellular networks;
[0030] The preset upload preferences include uploading only under the WIFI, or uploading under both the WIFI and the cellular network.
[0031] In one embodiment, processing the compressed video file at the vehicle end includes:
[0032] Based on a preset interval, the storage space of the vehicle is confirmed;
[0033] If the used storage space is greater than or equal to a preset storage ratio threshold, delete each non-key frame and the corresponding second frame header in the compressed video file, and retain the key frames.
[0034] In one embodiment, the frame data length of the third frame header is the same as the data length of the keyframe;
[0035] Replacing the first frame header with the third frame header corresponding to the keyframe on the vehicle side includes:
[0036] Based on the image features, data length, and time corresponding to the keyframe, a third frame header corresponding to the keyframe is created.
[0037] Based on the frame timestamp of the first frame header, determine the third frame header that has the same frame timestamp as the first frame header;
[0038] Replace the first frame header with the third frame header corresponding to the keyframe.
[0039] Secondly, embodiments of this application provide a video processing apparatus applied to a vehicle, comprising:
[0040] The acquisition module is used to acquire multiple image packets after the compressed video file is generated, wherein any image packet includes one key frame and multiple non-key frames, and the key frame is an intra-frame encoded image frame;
[0041] An insertion module is used to insert a frame header before each of the key frames and non-key frames, wherein the frame header includes a frame type identifier, a frame data length, and a frame timestamp;
[0042] The upload module is used to upload the first frame header corresponding to the key frame of the image package, each non-key frame, and the second frame header corresponding to each non-key frame to the cloud, and to process the compressed video file of the vehicle end.
[0043] The download module is used to download the first frame header corresponding to the key frame of the image package, each of the non-key frames, and the second frame header corresponding to each of the non-key frames to the vehicle terminal if the image package is played or exported.
[0044] The replacement module is used to replace the first frame header with the third frame header corresponding to the key frame on the vehicle end, wherein the frame timestamp of the third frame header is the same as the frame timestamp of the first frame header, and the frame data length of the third frame header is different from the frame data length of the first frame header.
[0045] Thirdly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method as described in any one of the first aspects above.
[0046] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method as described in any one of the first aspects above.
[0047] Fifthly, embodiments of this application provide a computer program product that, when run on an electronic device, causes the electronic device to perform the method described in any one of the first aspects above.
[0048] It is understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant descriptions in the first aspect above, and will not be repeated here.
[0049] The beneficial effects of the embodiments in this application compared with the prior art are:
[0050] This application provides a video processing method applied to a vehicle-side application. It involves inserting a first frame header (with a different frame data length than the third frame header corresponding to the keyframe on the vehicle-side) before the keyframe. Then, the first frame header corresponding to the keyframe, each non-keyframe, and the second frame header corresponding to each non-keyframe are all uploaded to the cloud. The keyframe is an intra-coded image frame. Compared to existing technologies where the cloud can decompress or decrypt video files, this method addresses the issue that because the frame data length of the first frame header of the keyframe differs from the frame data length of the third frame header corresponding to the keyframe on the vehicle-side, the cloud cannot obtain the correct keyframe and cannot decrypt the video file using the cloud's encryption key. Therefore, it delays... The system extends the storage time of video files on the vehicle-side storage card while protecting user privacy. If a user wants to play or export the image packets of a video file, the system downloads the first frame header corresponding to the keyframes of the image packet, each non-keyframe, and the second frame header corresponding to each non-keyframe to the vehicle-side storage card. Then, the first frame header is replaced with the third frame header corresponding to the keyframes on the vehicle-side storage card, and the frame timestamp of the third frame header is the same as that of the first frame header. Therefore, the system can restore the original video file's image packets and enable normal playback without causing any issues with missing video files stored in the cloud. This extends the storage time of video files on the vehicle-side storage card while maintaining the integrity of the video files. Attached Figure Description
[0051] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0052] Figure 1 This is a schematic flowchart of a video processing method provided in an embodiment of this application;
[0053] Figure 2 This is a schematic diagram showing the distribution of I-frames, P-frames, and B-frames in an image packet provided in an embodiment of this application;
[0054] Figure 3This is a schematic diagram of the process of inserting frame headers before key frames and non-key frames in step S200 according to an embodiment of this application.
[0055] Figure 4 This is a schematic diagram of the process of step S220 provided in an embodiment of the present application, which is to create a first frame header corresponding to a key frame and a second frame header corresponding to a non-key frame based on the image features corresponding to key frames and each non-key frame, the data length corresponding to each non-key frame, and the time corresponding to key frames and each non-key frame.
[0056] Figure 5 This is a schematic diagram of an image packet inserted into the first frame header and the second frame header according to an embodiment of this application;
[0057] Figure 6 This is a schematic diagram of the process of uploading the first frame header corresponding to the key frame of the image packet, each non-key frame, and the second frame header corresponding to each non-key frame to the cloud in step S300 of an embodiment of this application.
[0058] Figure 7 This is a schematic diagram of the first frame header and frame data distribution of each non-key frame of a downloaded image packet provided in an embodiment of this application;
[0059] Figure 8 This is a schematic diagram of the structure of a video processing device provided in an embodiment of this application. Detailed Implementation
[0060] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0061] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0062] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0063] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0064] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0065] Currently, dashcams compress video files of the driving environment they record using H.264 or H.265 video compression methods before storing them on a memory card. Since these recorded video files provide evidence for determining liability in traffic accidents, dashcams need to store a large number of video files, but the storage space on a dashcam's memory card is limited.
[0066] To extend the storage time of video files on dashcam memory cards, current technologies either directly upload compressed video files to cloud storage servers or encrypt the video files before uploading them to the cloud, and periodically clear the video files on the memory card. Storing unencrypted compressed video files in the cloud risks compromising user privacy, while the encryption keys for encrypted video files are also stored in the cloud, thus still posing a risk of user privacy leaks.
[0067] To address the aforementioned issues, this application provides a video processing method applied to a vehicle. The method involves acquiring multiple image packets from a compressed video file, where each image packet includes one keyframe and multiple non-keyframes. The keyframe is an intra-coded image frame. Frame headers are inserted before the keyframe and each non-keyframe, each header including a frame type identifier, frame data length, and frame timestamp. The first frame header corresponding to the keyframe, each non-keyframe, and each non-keyframe's corresponding second frame header are uploaded to the cloud, and the compressed video file on the vehicle is processed. If the image packet is played or exported, the first frame header corresponding to the keyframe, each non-keyframe, and each non-keyframe's corresponding second frame header are downloaded to the vehicle. The first frame header is replaced with a third frame header corresponding to the keyframe on the vehicle, where the frame timestamp of the third frame header is the same as that of the first frame header, but the frame data length of the third frame header is different from that of the first frame header. Compared to existing technologies that can decompress or decrypt video files in the cloud, this new technology addresses the issue of the cloud's inability to obtain the correct keyframes or decrypt video files using the cloud's encryption key because the length of the first frame header of the keyframe differs from the length of the third frame header corresponding to the keyframe on the vehicle. This extends the storage time of video files on the vehicle's memory card while protecting user privacy. Furthermore, when a user wants to play or export the video file's image packets, the third frame header from the vehicle's memory card replaces the first frame header, restoring the original video file's image packets for normal playback without causing any loss of video files stored in the cloud. This approach maintains the integrity of the video files while extending their storage time on the vehicle's memory card.
[0068] The technical solution of this application will be illustrated below through specific embodiments.
[0069] Firstly, such as Figure 1 As shown, this application embodiment provides a video processing method applied to a vehicle, including steps S100, S200, S300, S400 and S500.
[0070] Step S100: Obtain multiple image packets after compressing the video file.
[0071] In one embodiment, H.264 and H.265 video compression methods compress analog video files recorded by a dashcam into multiple image packets. Each image packet (Group of Pictures, GOP) includes one keyframe and multiple non-keyframes. The keyframe is an intra-coded image frame (also called an I-frame). Each image packet is a sequence of multiple image frames from the I-frame to the next I-frame. There is only one I-frame in an image packet. An I-frame is a complete picture, and decoding only requires the data of this frame and does not require other reference frames. Non-keyframes include predictive coded image frames (also called P-frames) and bidirectional predictive coded image frames (also called B-frames). A P-frame is a difference frame between this frame and a previous keyframe (or P-frame). It needs to use the preceding I-frame or P-frame and is encoded using motion prediction. A B-frame is a bidirectional difference frame, that is, a B-frame records the difference data between this frame and the preceding and following frames. It needs to refer to both the preceding P-frame or I-frame and the following P-frame or I-frame.
[0072] It should be noted that, based on the principles of H.264 and H.265 video compression, P-frames and B-frames cannot be successfully decoded without an I-frame. That is, if the cloud only has B-frames or P-frames but no corresponding I-frames, decoding cannot be performed, and the image packet or video file will be invalid data. Among the three types of image frames (I-frame, P-frame, and B-frame), the I-frame occupies the largest storage space, since each image packet contains only one I-frame; the remaining image frames are B-frames and P-frames. Therefore, for video files captured by a dashcam, B-frames and P-frames occupy approximately 2 / 3 to 3 / 4 of the total video file storage space. The larger the image packet size of the video file, the more than 3 / 4 of the total video file storage space will be occupied by B-frames and P-frames. Figure 2 As shown, Figure 2 This is a schematic diagram showing the distribution of I-frames, P-frames, and B-frames in an image packet.
[0073] Step S200: Insert frame headers before key frames and each non-key frame.
[0074] In one embodiment, the frame header includes a frame type identifier, a frame data length, and a frame timestamp. The frame type identifier indicates the type of the image frame, the frame data length indicates the data length of the image frame, and the frame timestamp indicates the time when the image frame was recorded. Inserting frame headers before key frames and each non-key frame increases the difficulty of decompressing or decrypting the image packet and improves the security of video files stored in the cloud.
[0075] In one embodiment, such as Figure 3 As shown, frame headers are inserted before key frames and non-key frames respectively, including steps S210, S220, and S230.
[0076] Step S210: Obtain the image features corresponding to key frames and each non-key frame, the data length corresponding to each non-key frame, and the time corresponding to each key frame and each non-key frame.
[0077] In one embodiment, the image features and time corresponding to the keyframe (i.e., I-frame) are obtained to construct the first frame header, and the image features, data length, and time corresponding to each non-keyframe (i.e., each P-frame and each B-frame) are obtained to construct the second frame header. It should be noted that since the frame data length of the first frame header is a preset length value, it is not necessary to obtain the data length corresponding to the keyframe when constructing the first frame header.
[0078] Step S220: Based on the image features corresponding to key frames and non-key frames, the data length corresponding to each non-key frame, and the time corresponding to key frames and non-key frames, create the first frame header corresponding to the key frame and the second frame header corresponding to the non-key frame.
[0079] In one embodiment, a first frame header corresponding to a key frame is created based on the image features and time corresponding to the key frame; a second frame header corresponding to a non-key frame is created based on the image features, data length, and time corresponding to each non-key frame.
[0080] In one embodiment, such as Figure 4 As shown, based on the image features corresponding to key frames and non-key frames, the data length corresponding to each non-key frame, and the time corresponding to key frames and non-key frames, a first frame header corresponding to the key frame and a second frame header corresponding to the non-key frame are created, including steps S221, S222, S223, S224, S225, and S226.
[0081] Step S221: Based on the image features of key frames and non-key frames, identify the frame type of the first frame header and the frame type corresponding to each second frame header.
[0082] In one embodiment, based on the image features of key frames and each non-key frame, the frame type of the first frame header and the frame type corresponding to each second frame header are identified to avoid misidentification leading to incorrect frame header insertion.
[0083] In one embodiment, after obtaining each frame of encoded image data from the dashcam's encoder, each frame is parsed to identify its type. H.264 and H.265 video streams consist of multiple Network Abstraction Layer (NAL) units, each beginning with a start code, such as hexadecimal 0x000001 or 0x00000001. The first byte of the NAL unit (after the start code) includes the NAL unit type. In H.264, the NAL type is defined by the lower 5 bits of the first byte. For example, the NAL type code for an Instantaneous Decoding Refresh (IDR) frame is 5, indicating an I-frame. In H.265, the NAL type is defined by the lower 6 bits of the first byte. The NAL type code for an IDR frame might be 19 or 20; thus, it's possible to distinguish whether the image frame in the image packet is an I-frame or a non-I-frame.
[0084] Step S222: Based on the frame type of the first frame header and the frame type corresponding to each second frame header, set the frame type identifier of the first frame header as a key frame identifier, and set the frame type identifier of each second frame header as a non-key frame identifier.
[0085] In one embodiment, based on the frame type of the first frame header and the frame type corresponding to each second frame header, the frame type identifier of the first frame header is set as a key frame identifier, and the frame type identifier of each second frame header is set as a non-key frame identifier, so that the image frame can be accurately distinguished as a key frame or a non-key frame during decompression or decryption.
[0086] In one embodiment, the frame header formats of the first, second, and third frame headers all include a frame type identifier, a frame data length, and a frame timestamp. The frame type identifier is 1 byte (i.e., 1 byte) and is used to identify the type of image frame. The frame data length is 4 bytes (i.e., a 32-bit integer) and is used to represent the data length of the image frame (in bytes). The frame timestamp is 8 bytes (i.e., a 64-bit integer) and is used to record the timestamp of the image frame, identifying its specific time position in the video stream. After identifying the frame type of each image frame, a corresponding frame type identifier is assigned according to the frame type of each image frame; for example, 0x01 represents an I-frame, and 0x02 represents a non-I-frame.
[0087] Step S223: Set the frame data length of the first frame header to zero, and set the frame data length of the second frame header to the data length corresponding to each non-key frame.
[0088] In one embodiment, after identifying the frame type of each image frame, the frame data length of the first frame header is set to zero, thereby causing the image packet including the first frame header to be unable to obtain the complete image of the key frame, and the frame data length of the second frame header is set to the data length corresponding to each non-key frame. The frame data length of each non-key frame occupying storage space is not changed, and the byte length of the original image frame in the video file is used.
[0089] Step S224: Based on the times corresponding to the key frames and each non-key frame, determine the frame timestamp of the key frame and the frame timestamp of each non-key frame.
[0090] In one embodiment, the frame timestamp of a key frame is determined based on the time corresponding to the key frame, and the frame timestamp of each non-key frame is determined based on the time corresponding to each non-key frame. The frame timestamp can be determined using the acquisition time of the video file image frame, or based on the start time and frame rate of the video file stream.
[0091] Step S225: Based on the frame type identifier, frame data length and frame timestamp corresponding to the key frame, create the first frame header corresponding to the key frame.
[0092] Step S226: Based on the frame type identifier, frame data length and frame timestamp corresponding to the non-critical frame, create the second frame header corresponding to the non-critical frame.
[0093] In one embodiment, an image frame has a raw frame data length of 2048 bytes, a timestamp of 1589531234567890 (accurate to microseconds), and a frame type of I-frame (e.g., encoded as 0x01). The normal frame header (i.e., the third frame header) contains: Frame type: 0x01, Frame data length: 0x00000800 (2048 bytes, big-endian), Frame timestamp: 0x1635A2B3C4D5E6F0 (1589531234567890, big-endian). Since the frame data length of the first frame header needs to be set to zero, the first frame header contains: Frame type: 0x01, Frame data length: 0x00000000, Frame timestamp: 0x1635A2B3C4D5E6F0 (1589531234567890, big-endian). It should be noted that the frame data length of the first frame header can also be set to a preset data length, and the range of values for the preset data length is smaller than the data length of the original frame.
[0094] Step S230: Insert the first frame header before the keyframe, and insert each second frame header before each non-keyframe.
[0095] In one embodiment, a first frame header is inserted before a keyframe, and each second frame header is inserted before each non-keyframe. That is, the newly constructed first frame header, in binary form, is inserted before the I-frame data to form a new data frame; the second frame headers, in binary form, are inserted before each non-keyframe data to form a new data frame, and this is processed before uploading or storage. Figure 5 As shown, Figure 5 This diagram illustrates the insertion of the first and second frame headers into an image packet. In the diagram, the I1 frame header is the first frame header of the keyframe, while the B1 and P1 frame headers are the second frame headers corresponding to non-keyframes.
[0096] Step S300: Upload the first frame header corresponding to the keyframe of the image package, each non-keyframe, and the second frame header corresponding to each non-keyframe to the cloud, and process the compressed video file on the vehicle end.
[0097] In one embodiment, the first frame header corresponding to the keyframe of the image package, each non-keyframe, and the second frame header corresponding to each non-keyframe are all uploaded to the cloud, and the compressed video file on the vehicle end is processed. That is, the first frame header of the keyframe of the image package uploaded to the cloud is a modified frame header, which makes the keyframe unable to be read, decompressed, or decrypted normally, thereby improving the security of the video file and reducing the risk of leaking user personal privacy.
[0098] In one embodiment, such as Figure 6 As shown, the first frame header corresponding to the key frame of the image packet, each non-key frame, and the second frame header corresponding to each non-key frame are all uploaded to the cloud, including steps S310, S320, S330, and S340.
[0099] Step S310: The vehicle identifies the network interface of the communication network.
[0100] Step S320: Determine the network type of the communication network based on the network interface and the network status of the vehicle.
[0101] Step S330: Based on the network type and the user's preset upload preferences, determine whether the network type meets the preset upload preferences.
[0102] Step S340: If the network type meets the preset upload preference, upload the first frame header corresponding to the key frame of the image packet, each non-key frame, and the second frame header corresponding to each non-key frame to the cloud.
[0103] In one embodiment, the network type includes Wi-Fi and cellular networks.
[0104] In one embodiment, the vehicle first identifies the network interfaces of all available communication networks, such as Wi-Fi and cellular network interfaces. Next, it registers a listener for network status changes, receiving notifications when network status changes, including network availability, network connection type, and network connection status. For Wi-Fi and cellular networks, the vehicle detects their connection status and determines whether the current network type is Wi-Fi or cellular data based on the detected network status changes. Then, based on the network type and the user's preset upload preferences, it determines whether the network type meets the preset upload preferences. If the network type meets the preset upload preferences, the vehicle uploads the first frame header corresponding to the keyframe of the image packet, all non-keyframes, and the second frame header corresponding to each non-keyframe to the cloud. If the network type does not meet the preset upload preferences, the vehicle pauses the upload of the first frame header corresponding to the keyframe of the image packet, all non-keyframes, and the second frame header corresponding to each non-keyframe, waiting for the network type to meet the preset upload preferences before resuming the upload.
[0105] In one embodiment, users can set preset upload preferences through the user interface, such as setting "upload only under WiFi" or "upload under both WiFi and cellular data", that is, the preset upload preferences include uploading only under WiFi, or uploading under both WiFi and cellular networks.
[0106] In one embodiment, the video file upload process begins with data frame preparation. For each video frame to be uploaded, its frame header information is read to check whether the frame type is an I-frame or a non-I-frame. For non-I-frames, the frame image data and second frame header of each frame are prepared for upload. For I-frames, the frame image data and first frame header are prepared for upload, or the frame header data of the third frame header is read into memory and its length is modified to 0, thus becoming the first frame header. Then, an upload decision is made. Based on network environment detection and upload condition settings (e.g., upload only under WiFi), it is determined whether to start the upload process. If the network type meets the preset upload preference, the upload process continues; if the network type does not meet the preset upload preference, the upload waits until the network type meets the preference before proceeding. Then, data upload is performed. After the network type meets the preset upload preference, the prepared first frame headers corresponding to keyframes, each non-keyframe, and the second frame headers corresponding to each non-keyframe are uploaded to the cloud storage server. For example, data is sent to a specified server endpoint using HTTP POST or other protocols. Simultaneously, the upload status is monitored, and upon successful upload, a response from the cloud storage server is obtained to confirm that the video data has been received.
[0107] In one embodiment, processing compressed video files on the vehicle end includes: confirming the vehicle end's storage space based on a preset interval duration; if the used storage space is greater than or equal to a preset storage ratio threshold, deleting all non-keyframes and their corresponding second frame headers in the compressed video file, while retaining keyframes; that is, when the storage space on the vehicle end's storage card is insufficient, deleting uploaded video data, and only saving the third frame header of keyframes and the image frame data of keyframes, thus saving storage card space and extending the storage time of video on the storage card. The preset interval duration is less than or equal to 15 minutes, and the preset storage ratio threshold is greater than or equal to 80%. Simultaneously, based on the timestamps of each image frame in the video file, the keyframe data with the longest interval from the present is deleted first. For example, for a historical I-frame sequence, the timestamps of the I-frames are read as T1 and T2, and then the cloud is notified to delete all image frames between timestamps T1 and T2 from the cloud to maintain content synchronization between the vehicle end's storage card and the cloud. While retaining I-frames with shorter intervals from the present, P-frames and B-frames with longer intervals from the present are cleared to free up memory card space.
[0108] Step S400: If playing or exporting an image package, download the first frame header corresponding to the keyframe of the image package, each non-keyframe, and the second frame header corresponding to each non-keyframe to the vehicle end.
[0109] In one embodiment, if playing or exporting an image package, the first frame header corresponding to the keyframes of the image package, each non-keyframe, and the second frame header corresponding to each non-keyframe are downloaded to the vehicle terminal for user use. Figure 7 As shown, Figure 7 The diagram shows the first frame header and frame data distribution of each non-critical frame in the downloaded image packet. In the diagram, frame headers I1 and I2 are both first frame headers, but their frame timestamps are different. Frame headers B1 and P1 are both second frame headers.
[0110] In step S500, the first frame header is replaced with the third frame header corresponding to the key frame on the vehicle side. The frame timestamp of the third frame header is the same as the frame timestamp of the first frame header, but the frame data length of the third frame header is different from the frame data length of the first frame header.
[0111] In one embodiment, the frame data length of the third frame header is the same as the data length of the keyframe.
[0112] In one embodiment, replacing the first frame header with the third frame header corresponding to the key frame on the vehicle side includes: creating a third frame header corresponding to the key frame based on the image features, data length, and time corresponding to the key frame; determining a third frame header with the same frame timestamp as the first frame header based on the frame timestamp of the first frame header; and replacing the first frame header with the third frame header corresponding to the key frame. This ensures the continuity and integrity of the video file and improves the user experience.
[0113] In one embodiment, the detailed steps for viewing and exporting full video data include: First, the user requests full video data, i.e., the user selects the video time period to be viewed or exported on the application interface on the vehicle. The user selects the start and end times of the video file through the user interface to initiate a full video viewing or export request. Second, the user requests non-keyframe data, i.e., based on the user-selected time period, the request is sent to the cloud storage server. The cloud calculates the timestamp range of the required video data and requests all non-keyframe data and keyframe headers within the user-selected time period. Then, data is downloaded, i.e., a response is received from the cloud, and downloading all frames within the requested timestamp range begins. Next, the vehicle prepares local keyframe data, i.e., searching the vehicle's local storage card for keyframe (i.e., I-frame) data corresponding to the user's time period, and finding all keyframe data within the requested user's time period on the local storage card. Finally, data merging is performed, i.e., downloading all data within the timestamp range corresponding to the time period from the cloud sequentially according to timestamp order (i.e., the first frame header corresponding to the keyframe, each non-keyframe, and the second frame header corresponding to each non-keyframe), or sorting all downloaded frames according to timestamps after downloading. Based on the timestamp in the third frame header of the I-frame within the requested time period stored locally, the first frame header of the downloaded I-frame is located, and the first frame header is replaced with the third frame header to construct a complete video data stream. This also includes inserting keyframe data after the corresponding first frame header to ensure the continuity and integrity of video playback.
[0114] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0115] The beneficial effects of the embodiments in this application compared with the prior art are:
[0116] This application provides a video processing method applied to a vehicle-side application. It involves inserting a first frame header (with a different frame data length than the third frame header corresponding to the keyframe on the vehicle-side) before the keyframe. Then, the first frame header corresponding to the keyframe, each non-keyframe, and the second frame header corresponding to each non-keyframe are all uploaded to the cloud. The keyframe is an intra-coded image frame. Compared to existing technologies where the cloud can decompress or decrypt video files, this method addresses the issue that because the frame data length of the first frame header of the keyframe differs from the frame data length of the third frame header corresponding to the keyframe on the vehicle-side, the cloud cannot obtain the correct keyframe and cannot decrypt the video file using the cloud's encryption key. Therefore, it delays... The system extends the storage time of video files on the vehicle-side storage card while protecting user privacy. If a user wants to play or export the image packets of a video file, the system downloads the first frame header corresponding to the keyframes of the image packet, each non-keyframe, and the second frame header corresponding to each non-keyframe to the vehicle-side storage card. Then, the first frame header is replaced with the third frame header corresponding to the keyframes on the vehicle-side storage card, and the frame timestamp of the third frame header is the same as that of the first frame header. Therefore, the system can restore the original video file's image packets and enable normal playback without causing any issues with missing video files stored in the cloud. This extends the storage time of video files on the vehicle-side storage card while maintaining the integrity of the video files.
[0117] Secondly, such as Figure 8 As shown, this application embodiment provides a video processing device 100, applied to a vehicle, including:
[0118] The acquisition module 110 is used to acquire multiple image packets after the compressed video file is generated. Each image packet includes one key frame and multiple non-key frames. The key frame is an intra-frame encoded image frame.
[0119] The insertion module 120 is used to insert frame headers before key frames and each non-key frame, respectively. The frame header includes a frame type identifier, frame data length, and frame timestamp.
[0120] The upload module 130 is used to upload the first frame header corresponding to the key frame of the image package, each non-key frame, and the second frame header corresponding to each non-key frame to the cloud, and to process the compressed video file on the vehicle end.
[0121] The download module 140 is used to download the first frame header corresponding to the keyframes of the image package, each non-keyframe, and the second frame header corresponding to each non-keyframe to the vehicle end when playing or exporting the image package.
[0122] The replacement module 150 is used to replace the first frame header with the third frame header corresponding to the key frame on the vehicle side. The frame timestamp of the third frame header is the same as the frame timestamp of the first frame header, but the frame data length of the third frame header is different from the frame data length of the first frame header.
[0123] In one embodiment, the frame data length of the first frame header is zero; the insertion module is further configured to obtain the image features corresponding to the key frame and each non-key frame, the data length corresponding to each non-key frame, and the time corresponding to the key frame and each non-key frame respectively; based on the image features corresponding to the key frame and each non-key frame, the data length corresponding to each non-key frame, and the time corresponding to the key frame and each non-key frame respectively, create the first frame header corresponding to the key frame and the second frame header corresponding to the non-key frame respectively; insert the first frame header before the key frame, and insert each second frame header before each non-key frame respectively.
[0124] In one embodiment, the insertion module is further configured to: identify the frame type of the first frame header and the frame type corresponding to each second frame header based on the image features of the key frame and each non-key frame; set the frame type identifier of the first frame header as a key frame identifier and set the frame type identifier of each second frame header as a non-key frame identifier based on the frame type of the first frame header and the frame type corresponding to each second frame header; set the frame data length of the first frame header to zero and set the frame data length of the second frame header to the data length corresponding to each non-key frame; determine the frame timestamp of the key frame and the frame timestamp corresponding to each non-key frame based on the time corresponding to the key frame and each non-key frame; create the first frame header corresponding to the key frame based on the frame type identifier, frame data length, and frame timestamp corresponding to the key frame; and create the second frame header corresponding to the non-key frame based on the frame type identifier, frame data length, and frame timestamp corresponding to the non-key frame.
[0125] In one embodiment, the upload module is further configured to: identify the network interface of the communication network on the vehicle side; determine the network type of the communication network based on the network interface and the network status on the vehicle side; determine whether the network type meets the preset upload preference based on the network type and the user's preset upload preference; and upload the first frame header corresponding to the key frame of the image packet, each non-key frame, and the second frame header corresponding to each non-key frame to the cloud.
[0126] In one embodiment, the network type includes Wi-Fi and cellular networks; the preset upload preference includes uploading only under Wi-Fi, or uploading under both Wi-Fi and cellular networks.
[0127] In one embodiment, the upload module is further configured to determine the vehicle's storage space based on a preset interval duration; if the used storage space is greater than or equal to a preset storage ratio threshold, delete each non-key frame and the second frame header corresponding to each non-key frame in the compressed video file, and retain the key frames.
[0128] In one embodiment, the frame data length of the third frame header is the data length of the key frame; the replacement module is further configured to create a third frame header corresponding to the key frame based on the image features, the corresponding data length, and the corresponding time of the key frame; determine a third frame header with the same frame timestamp as the first frame header based on the frame timestamp of the first frame header; and replace the first frame header with the third frame header corresponding to the key frame.
[0129] It should be noted that the information interaction and execution process between the above modules / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.
[0130] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0131] Thirdly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method as described in any one of the first aspects above.
[0132] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method as described in any one of the first aspects above.
[0133] Fifthly, embodiments of this application provide a computer program product that, when run on an electronic device, causes the electronic device to perform the method described in any one of the first aspects above.
[0134] It is understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here.
[0135] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms.
[0136] The computer-readable medium may include at least: any entity or device capable of carrying computer program code to a photographic device / terminal device, recording media, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media. Examples include USB flash drives, portable hard drives, magnetic disks, or optical discs. In some jurisdictions, according to legislation and patent practice, computer-readable media may not be electrical carrier signals or telecommunication signals.
[0137] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0138] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0139] In the embodiments provided in this application, it should be understood that the disclosed apparatus / network devices and methods can be implemented in other ways. For example, the apparatus / network device 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 system, 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.
[0140] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0141] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A video processing method, It is characterized in that Applied to the vehicle side, including: Acquire multiple image packages after compressing the video file, wherein any of the image packages includes one key frame and multiple non-key frames, and the key frame is an intra-frame coded image frame; Inserting a frame header before the key frame and each of the non-key frames respectively, wherein the frame header includes a frame type identifier, a frame data length, and a frame timestamp; Uploading the first frame header corresponding to the key frame of the image package, each of the non-key frames, and the second frame header corresponding to each of the non-key frames to the cloud, and processing the compressed video file on the vehicle side; If the image package is played or exported, the first frame header corresponding to the key frame of the image package, each of the non-key frames and the second frame header corresponding to each of the non-key frames are downloaded to the vehicle end; The first frame header is replaced with a third frame header corresponding to the key frame on the vehicle side, wherein a frame timestamp of the third frame header is the same as a frame timestamp of the first frame header, and a frame data length of the third frame header is different from a frame data length of the first frame header.
2. The method according to claim 1, It is characterized in that The frame data length of the first frame header is zero; Inserting frame headers before the key frame and each of the non-key frames respectively includes: Acquire image features corresponding to the key frame and each of the non-key frames, data length corresponding to each of the non-key frames, and time corresponding to the key frame and each of the non-key frames; Based on the image features corresponding to the key frame and each of the non-key frames, the data length corresponding to each of the non-key frames, and the time corresponding to the key frame and each of the non-key frames, respectively, create a first frame header corresponding to the key frame and a second frame header corresponding to the non-key frame; The first frame header is inserted before the key frame, and each of the second frame headers is inserted before each of the non-key frames.
3. The method according to claim 2, It is characterized in that Based on the image features corresponding to the key frame and each of the non-key frames, the data length corresponding to each of the non-key frames, and the time corresponding to the key frame and each of the non-key frames, respectively creating a first frame header corresponding to the key frame and a second frame header corresponding to the non-key frame, including: Based on the image features of the key frame and each of the non-key frames, identifying the frame type of the first frame header and the frame types corresponding to each of the second frame headers; Based on the frame type of the first frame header and the frame types corresponding to each of the second frame headers, the frame type identifier of the first frame header is set as a key frame identifier, and the frame type identifier of each of the second frame headers is set as a non-key frame identifier; Setting the frame data length of the first frame header to zero, and setting the frame data length of the second frame header to the data length corresponding to each of the non-key frames; Determine a frame timestamp of the key frame and a frame timestamp corresponding to each of the non-key frames based on the times corresponding to the key frame and each of the non-key frames respectively; Creating a first frame header corresponding to the key frame based on a frame type identifier, a frame data length, and a frame timestamp corresponding to the key frame; A second frame header corresponding to the non-key frame is created based on the frame type identifier, frame data length and frame timestamp corresponding to the non-key frame.
4. The method according to claim 1, It is characterized in that Uploading the first frame header corresponding to the key frame of the image package, each of the non-key frames, and the second frame header corresponding to each of the non-key frames to the cloud, including: The vehicle-side identifies a network interface of the communication network; Determining the network type of the communication network based on the network status of the network interface and the vehicle end; Based on the network type and the preset upload preference of the user, determining whether the network type satisfies the preset upload preference; If the network type satisfies the preset upload preference, the first frame header corresponding to the key frame of the image packet, each of the non-key frames, and the second frame header corresponding to each of the non-key frames are all uploaded to the cloud.
5. The method according to claim 1, It is characterized in that The network types include WIFI and cellular network; The preset upload preference includes uploading only under the WIFI, or uploading under both the WIFI and the cellular network.
6. The method according to claim 1, It is characterized in that Processing the compressed video file on the vehicle side includes: Based on a preset interval duration, confirming the storage space of the vehicle end; If the used storage space is greater than or equal to a preset storage ratio threshold, each of the non-key frames and the second frame header corresponding to each of the non-key frames in the compressed video file are deleted, and the key frames are retained.
7. The method according to claim 1, It is characterized in that The frame data length of the third frame header is the data length of the key frame; Replacing the first frame header with a third frame header corresponding to the key frame of the vehicle end includes: Creating a third frame header corresponding to the key frame based on the image feature, the corresponding data length, and the corresponding time corresponding to the key frame; Based on the frame timestamp of the first frame header, determining the third frame header having the same frame timestamp as the first frame header; The first frame header is replaced by a third frame header corresponding to the key frame.
8. A video processing device, It is characterized in that Applied to the vehicle side, including: An acquisition module, used for acquiring a plurality of image packages after compressing a video file, wherein any of the image packages includes a key frame and a plurality of non-key frames, and the key frame is an intra-frame coded image frame; An inserting module, used for inserting a frame header before the key frame and each of the non-key frames respectively, wherein the frame header includes a frame type identifier, a frame data length and a frame timestamp; An uploading module, used to upload the first frame header corresponding to the key frame of the image package, each of the non-key frames and the second frame header corresponding to each of the non-key frames to the cloud, and process the compressed video file of the vehicle end; A download module, for downloading the first frame header corresponding to the key frame of the image package, each of the non-key frames and the second frame header corresponding to each of the non-key frames to the vehicle end when the image package is played or exported; A replacement module is used to replace the first frame header with a third frame header corresponding to the key frame on the vehicle side, wherein the frame timestamp of the third frame header is the same as the frame timestamp of the first frame header, and the frame data length of the third frame header is different from the frame data length of the first frame header.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing a computer program. It is characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
