Video file detection method and device, electronic equipment and storage medium
By acquiring multimodal information of video files and using FFmpeg to parse video streams, calculating frame rate and frame duration, and comparing the time difference between consecutive frames, the problem of poor portability in existing video file detection technologies is solved, enabling flexible and effective video file detection in in-vehicle infotainment systems.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD
- Filing Date
- 2025-01-09
- Publication Date
- 2026-07-31
AI Technical Summary
Existing video file detection methods suffer from poor portability in in-vehicle infotainment systems, cannot be implemented in standalone applications, and cannot adapt to the needs of different third-party applications.
By acquiring multimodal information of the video file, including data size and video stream information, FFmpeg is used to parse the video stream, extract multi-frame data packets, calculate the frame rate and frame duration, compare the time difference between consecutive frames, and determine the detection result of the video file.
It improves the flexibility and adaptability of video file detection, enabling easy deployment in different application scenarios, ensuring the integrity and authenticity of video content, and identifying potential problems in video files such as dropped frames, stuttering, or editing traces.
Smart Images

Figure CN119893163B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of video file detection technology, specifically to a video file detection method, apparatus, electronic device, and computer-readable storage medium. Background Technology
[0002] With the development of technology, browsing and viewing USB media files has become a common multimedia entertainment function in in-vehicle infotainment systems. Because local videos come from various sources, and due to operational errors during the transfer of various media, video files can be corrupted to varying degrees. This can lead to various strange problems when displaying lists or playing videos. Therefore, it is necessary to detect video file corruption as early as possible.
[0003] Most related technologies use the ffmpeg command-line method for detection. However, this method requires first integrating an ffmpeg application into the system to support the ffmpeg command line. Then, the application uses a runtime to write the string command into the system for execution, waits for completion, reads the string result, and parses the string. Specific information in the returned string is then used to determine if there are any errors. However, this method has poor portability; it lacks portability for standalone applications and cannot be implemented in other third-party applications. Therefore, a more adaptable video file detection method is urgently needed. Summary of the Invention
[0004] To address the aforementioned technical problems, embodiments of this application provide a video file detection method and apparatus, an electronic device, a computer-readable storage medium, and a computer program product.
[0005] According to one aspect of the embodiments of this application, a video file detection method is provided, comprising: acquiring multimodal information of a video file to be detected, the multimodal information including the data size and video stream information of the video file to be detected; if the data size is greater than a preset data size threshold, parsing the video stream information to obtain parsed multi-frame data packets; determining the frame rate information of the video file to be detected based on the multi-frame data packets, and determining the duration of each frame corresponding to the video file to be detected based on the frame rate information; acquiring the time difference between any two consecutive frames in the video file to be detected, and determining the detection result of the video file to be detected based on the time difference and the duration of each frame.
[0006] According to one aspect of the embodiments of this application, parsing the video stream information to obtain parsed multi-frame data packets includes: obtaining basic information of the video stream, the basic information including the duration of the video file to be detected; if the duration is greater than a preset duration threshold, obtaining the screen size of the video in the video stream information; if the screen size is greater than a preset size threshold, parsing the video stream information to obtain parsed multi-frame data packets.
[0007] According to one aspect of the embodiments of this application, parsing the video stream information to obtain parsed multi-frame data packets includes: obtaining a target decoder corresponding to the video stream information, decoding the video stream based on the target decoder to obtain a decoded video stream; and obtaining multi-frame data packets from the decoded video stream, wherein the multi-frame data packets include multi-frame data that constitutes the video stream.
[0008] According to one aspect of this application, determining the frame rate information of the video file to be detected based on the multi-frame data packets, and determining the duration of each frame corresponding to the video file to be detected based on the frame rate information, includes: acquiring the frame rate information in the multi-frame data packets; if the frame rate information matches the actual playback speed of the video file to be detected, then determining the frame rate information as valid frame rate information; and determining the duration of each frame corresponding to the video file to be detected based on the valid frame rate information.
[0009] According to one aspect of the embodiments of this application, after determining the frame rate information of the video file to be detected based on the multi-frame data packets, and determining the duration of each frame corresponding to the video file to be detected based on the frame rate information, the method further includes: if the duration of any frame in the video file to be detected is less than or equal to zero, then a detection result indicating that the video file to be detected is corrupted is obtained; if the duration of any frame in the video file to be detected is greater than zero, then the timestamp of each frame in the video file to be detected is obtained.
[0010] According to one aspect of the present application, obtaining the time difference between any two consecutive frames in the video file to be detected, and determining the detection result of the video file to be detected based on the time difference and the duration of each frame, includes: obtaining the timestamps corresponding to any two consecutive frames in the video file to be detected; calculating the time difference between any two consecutive frames based on the corresponding timestamps; and obtaining a detection result that the video file to be detected is corrupted if the time difference is less than or equal to zero or the time difference is greater than the duration of each frame.
[0011] According to one aspect of the embodiments of this application, determining the detection result of the video file to be detected based on the time difference and the duration of each frame includes: if the time difference is greater than zero and the time difference is less than the duration of each frame, then obtaining the timestamp of each frame in the video file to be detected; if the timestamps of each frame show an increasing relationship in time, then obtaining a normal detection result for the video file to be detected.
[0012] According to one aspect of the embodiments of this application, a video file detection apparatus is provided. The apparatus includes: an acquisition module for acquiring multimodal information of a video file to be detected, the multimodal information including the data size and video stream information of the video file to be detected; a parsing module for parsing the video stream information to obtain parsed multi-frame data packets if the data size is greater than a preset data size threshold; a determination module for determining the frame rate information of the video file to be detected based on the multi-frame data packets, and determining the duration of each frame of the video file to be detected based on the frame rate information; and a detection module for acquiring the time difference between two consecutive frames in the video file to be detected, and determining the detection result of the video file to be detected based on the time difference and the duration of each frame.
[0013] According to one aspect of the embodiments of this application, an electronic device is provided, including: one or more processors; and a storage device for storing one or more programs, which, when executed by the one or more processors, cause the electronic device to implement the video file detection method as described above.
[0014] According to one aspect of the embodiments of this application, a computer-readable storage medium is provided, on which computer-readable instructions are stored, which, when executed by a computer's processor, cause the computer to perform the video file detection method as described above.
[0015] According to one aspect of the embodiments of this application, a computer program product is also provided, including a computer program that, when executed by a processor, implements the steps in the video file detection method described above.
[0016] In the technical solution provided by the embodiments of this application, by first checking the data size of the video file, unnecessary processing of excessively large or unsuitable files can be avoided, thereby saving computing resources and time. By comparing the time difference between two consecutive frames with the duration of each frame, abnormal frames or frame rate changes in the video file can be detected. This is particularly important for applications such as video surveillance and content review. Anomaly detection can reveal potential problems in the video file, such as dropped frames, stuttering, or editing traces, thereby ensuring the integrity and authenticity of the video content. On the other hand, this solution can handle video files of different sizes and formats, enhancing the system's flexibility and adaptability. This solution can run as a standalone application or be integrated as part of other video processing systems, making it easy to deploy in different application scenarios and seamlessly collaborate with other components.
[0017] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description
[0018] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It is obvious that the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort. In the drawings:
[0019] Figure 1 This is a schematic diagram illustrating an implementation environment for video file detection, as shown in an exemplary embodiment of this application.
[0020] Figure 2 This is a flowchart illustrating a video file detection method in an exemplary embodiment of this application;
[0021] Figure 3 This is a flowchart illustrating a video file detection method in another exemplary embodiment of this application;
[0022] Figure 4 This is a flowchart illustrating a video file detection method in another exemplary embodiment of this application;
[0023] Figure 5 This is a flowchart illustrating a video file detection method in another exemplary embodiment of this application;
[0024] Figure 6 This is a flowchart illustrating a video file detection method in another exemplary embodiment of this application;
[0025] Figure 7This is a flowchart illustrating a video file detection method in another exemplary embodiment of this application;
[0026] Figure 8 This is a flowchart illustrating a video file detection method in another exemplary embodiment of this application;
[0027] Figure 9 This is a simplified flowchart illustrating the process of detecting video files in a navigation interface in an exemplary application scenario.
[0028] Figure 10 This is a block diagram illustrating a video file detection apparatus according to an exemplary embodiment of this application;
[0029] Figure 11 A schematic diagram of the structure of a computer system suitable for implementing the electronic device of the present application is shown. Detailed Implementation
[0030] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0031] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0032] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0033] In this application, "multiple" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0034] FFmpeg is a powerful open-source computer program specifically designed for processing various tasks such as encoding, decoding, conversion, streaming, filtering, and playback of digital audio and video files. It supports almost all common audio and video formats and can run on multiple operating system platforms, including Android. Here is a detailed introduction to FFmpeg: Key features include: Encoding / Decoding: FFmpeg supports various audio and video codecs, allowing conversion between different file formats; Format Conversion: It can convert video and audio files from one container format to another, such as converting MP4 files to AVI files; Streaming: FFmpeg can be used to create and receive live streaming media, supporting multiple streaming protocols; Filtering and Editing: It provides rich filters and editing functions, allowing for operations such as cropping, scaling, adding watermarks, and adjusting volume on video and audio; Device Compatibility: It can generate video and audio files suitable for various devices and platforms (such as mobile phones, tablets, smart TVs, etc.). In some feasible embodiments of this application, a method for detecting whether a video file is corrupted can be implemented in the Android system using Java / Kotlin code based on the ffmpeg library and JNI (Java Native Interface) technology, which is a programming framework, thus taking into account both portability and versatility.
[0035] Figure 1 This is a schematic diagram illustrating an implementation environment for video file detection of locally stored video files, as shown in an exemplary embodiment of this application. Figure 1 As shown, a video file is stored on the local storage 110. The multimodal information of the video file to be detected on the local storage 110 can be obtained through the server 120. The multimodal information may include the data size and video stream information of the video file to be detected. If the server 120 detects that the data size of the video file to be detected is greater than a preset data size threshold, it can further parse the video stream information to obtain the parsed multi-frame data packets. Then, the frame rate information of the video file to be detected can be determined based on the multi-frame data packets, and the duration of each frame of the video file to be detected can be determined based on the frame rate information. After that, the server 120 obtains the time difference between two consecutive frames in the video file to be detected, and determines the detection result of the video file to be detected based on the time difference and the duration of each frame, thereby realizing the detection of the local video file.
[0036] in, Figure 1 The server 120 shown can be any terminal device that supports the installation of navigation map software, such as a smartphone, in-vehicle computer, tablet computer, laptop computer, or wearable device, but is not limited to these.
[0037] Most related technologies use the ffmpeg command-line method for detection. However, this method requires first integrating an ffmpeg application into the system to support the ffmpeg command line. Then, the application uses a runtime to write the string command into the system for execution, waits for completion, reads the string result, parses the string, and uses specific information in the returned string to determine if there are any errors. However, this method has poor portability; it is not portable for standalone applications and cannot be implemented in other third-party applications.
[0038] The problems mentioned above are universally applicable to general local video file detection. Therefore, in order to solve these problems, embodiments of this application propose a video file detection method, a video file detection device, an electronic device, a computer-readable storage medium, and a computer program product, which will be described in detail below.
[0039] Please see Figure 2 , Figure 2 This is a flowchart illustrating a video file detection method in an exemplary embodiment of this application. This method can be applied to… Figure 1 The implementation environment shown is specifically executed by the intelligent server 120 within that implementation environment. It should be understood that this method can also be applied to other exemplary implementation environments and executed by devices in other implementation environments; this embodiment does not limit the implementation environment to which the method is applicable.
[0040] like Figure 2 As shown, in an exemplary embodiment, the video file detection method includes at least steps S210 to S240, which are described in detail below:
[0041] Step S210: Obtain the multimodal information of the video file to be detected. The multimodal information includes the data size of the video file to be detected and the video stream information.
[0042] For example, the size of a video file can be obtained through file system properties. In most operating systems, file managers or command-line tools can display the file size. For instance, in Windows, you can right-click the file and select "Properties" to view its size; in Linux or macOS, you can use the `ls -lh` command to list files and their sizes. If you need to obtain the video file size programmatically, you can choose a suitable file processing library. For example, in Python, you can use the `os.path.getsize()` function from the `os` library to get the file size (in bytes), and then convert it to a more suitable unit (such as KB, MB, etc.) as needed.
[0043] Video stream information typically includes the video's encoding format, resolution, frame rate, bitrate, and other information, which is crucial for video processing and analysis. Video stream information can be obtained using specialized video processing libraries or tools, or through FFmpeg commands to acquire detailed stream information.
[0044] In step S220, if the data size is greater than the preset data size threshold, the video stream information is parsed to obtain the parsed multi-frame data packets.
[0045] For example, a preset data size threshold for the video file to be detected can be set according to actual business needs. The size of the video file can be easily obtained using file system APIs or commands (such as the `os.path.getsize()` function in Python). The obtained file size is then compared with the preset threshold to determine whether further parsing of the video stream information is necessary. FFmpeg is a powerful open-source tool capable of parsing various video formats and extracting video frames.
[0046] Running FFmpeg commands: To extract video frames, you need to run specific FFmpeg commands. For example, you can extract a frame from a video at regular time intervals: depending on your needs, you can adjust the FPS (frames per second) value, or change the format and naming convention of the output file.
[0047] Processing the parsed results: After the FFmpeg command is executed, a series of image files will be found in the specified directory, which represent the multi-frame data packets extracted from the video.
[0048] Step S230: Determine the frame rate information of the video file to be detected based on multi-frame data packets, and determine the duration of each frame of the video file to be detected based on the frame rate information.
[0049] For example, firstly, some key information needs to be extracted from the previously extracted multi-frame data packets (usually image files). However, the frame rate cannot be directly read from these image files because the frame rate information is embedded in the original video file. But the frame rate can be obtained using information already obtained by FFmpeg when extracting frames, or by rerunning the FFmpeg command. Frame rate (Frames Per Second, FPS) represents the number of frames played per second. Therefore, the duration of each frame (in seconds) can be calculated by dividing 1 second by the frame rate. Once the frame rate is known (e.g., 25 FPS), the duration of each frame can be calculated. For a 25 FPS video, the duration of each frame is 1 / 25 of a second, or 0.04 seconds.
[0050] Step S240: Obtain the time difference between two consecutive frames in the video file to be detected, and determine the detection result of the video file to be detected based on the time difference and the duration of each frame.
[0051] For example, to obtain the actual time difference between two consecutive frames, a deeper analysis of the video stream may be required. This typically involves a detailed understanding of the video encoding, as inter-frame delays or jumps may be introduced during the encoding process. Tools like FFmpeg can provide timestamp information for each frame, which can be used to calculate the time difference between two consecutive frames. To determine the detection result for a video file, a time difference threshold needs to be set. This threshold can be set based on the expected frame rate of the video file, the application scenario, or user requirements. The calculated time difference between two consecutive frames is compared to the set threshold. If the time difference exceeds the threshold, it may indicate frame loss, frame duplication, or encoding problems in the video file. Based on the comparison result, the detection result for the video file is generated. This may include marking inter-frame time differences that exceed the threshold, calculating the overall quality score of the video file, or providing other relevant information.
[0052] In some embodiments of this application, by first checking the data size of the video file, unnecessary processing of excessively large or unsuitable files can be avoided, thereby saving computing resources and time. By comparing the time difference between two consecutive frames with the duration of each frame, abnormal frames or frame rate changes in the video file can be detected. This is particularly important for applications such as video surveillance and content review. Anomaly detection can reveal potential problems in the video file, such as dropped frames, stuttering, or editing traces, thereby ensuring the integrity and authenticity of the video content. On the other hand, this solution can handle video files of different sizes and formats, enhancing the system's flexibility and adaptability. This solution can run as a standalone application or be integrated as part of other video processing systems, making it easy to deploy in different application scenarios and seamlessly collaborate with other components.
[0053] Based on the above embodiments, please refer to Figure 3 In one exemplary embodiment provided in this application, the specific implementation process of parsing the video stream information to obtain the parsed multi-frame data packets may further include steps S310 to S330, which are described in detail below:
[0054] Step S310: Obtain basic information about the video stream, including the duration of the video file to be detected;
[0055] Step S320: If the duration exceeds a preset duration threshold, obtain the video frame size in the video stream information;
[0056] In step S330, if the screen size is larger than a preset size threshold, the video stream information is parsed to obtain the parsed multi-frame data packets.
[0057] For example, multimedia processing tools such as FFmpeg are used to analyze video files and obtain their basic information, which typically includes the video's encoding format, bitrate, frame rate, and duration. If the duration is lower than a preset duration threshold (which can be a reasonable threshold set according to actual business needs, or even zero), the extracted video duration is compared with the preset duration threshold. If the duration does not exceed the threshold, the video file is considered corrupted. If the duration exceeds the threshold, the frame size (length and width) is obtained and compared with preset length and width thresholds (which can be zero). If either the length or width is zero, the video file is considered corrupted. If the frame size exceeds a preset size threshold, the video stream information can be further parsed to obtain multi-frame data packets.
[0058] Optionally, FFmpeg can be used to implement the specific operation process. For example, from the FFmpeg output, find the field representing the video duration (e.g., Duration) and the fields representing the video frame size (e.g., width and height). If both the video duration and frame size exceed preset thresholds, an FFmpeg command for extracting video frames can be constructed as needed. For instance, the command `ffmpeg -iinput_video.mp4frame_%04d.png` can be used to extract all frames. Executing the constructed FFmpeg command in the command line or script will initiate the video parsing process and generate an output directory containing multi-frame data packets (e.g., image files). This yields the multi-frame data packets after parsing the video file.
[0059] In some embodiments of this application, by first checking the duration of the video file, subsequent processing of video files that are too short (may not contain useful information or do not require in-depth analysis) can be avoided, thereby saving computing resources and time. Only when the duration and screen size of the video file meet specific conditions will the video stream information be analyzed in depth to obtain multi-frame data packets. This processing method makes subsequent video analysis or processing more targeted and improves the accuracy and efficiency of the analysis.
[0060] Based on the above embodiments, please refer to Figure 4In one exemplary embodiment provided in this application, the specific implementation process of parsing the video stream information to obtain the parsed multi-frame data packets may further include steps S410 and S420, which are described in detail below:
[0061] Step S410: Obtain the target decoder corresponding to the video stream information, and decode the video stream based on the target decoder to obtain the decoded video stream;
[0062] Step S420: Obtain multi-frame data packets from the decoded video stream. The multi-frame data packets include multi-frame data that makes up the video stream.
[0063] For example, first, the encoding format of the video stream needs to be determined. This can usually be obtained by examining the video file's metadata or using a multimedia processing tool such as FFmpeg. Based on the video stream's encoding format, an appropriate decoder is selected. The decoder can be a software decoder (such as the decoder built into FFmpeg) or a hardware decoder (such as a GPU-accelerated decoder). The decoder's parameters are configured as needed, such as the location of the input video stream and the decoded output format. The video stream is then decoded using the decoder. This typically involves reading the video stream data, passing it to the decoder, and receiving the decoded output. The decoded video stream usually contains a series of consecutive frames. The frame boundaries need to be determined to correctly segment each frame. Based on the frame boundaries, the data for each frame is extracted from the decoded video stream. This may require converting the frame data to a specific format or storing it in an appropriate data structure. The extracted frame data is then organized into multi-frame data packets. These data packets can contain a series of consecutive frames for subsequent processing or analysis.
[0064] Furthermore, if no target decoder is found during the query or selection process, it may indicate that the video file's encoding format is not supported or the file itself is corrupted. In this case, a detection result can be generated to mark the video file as corrupted or undecodeable.
[0065] In some embodiments of this application, using a target decoder that matches the target video stream information can ensure that the video stream is decoded correctly and efficiently, and multi-frame data packets can be directly extracted from the decoded video stream, making subsequent video processing steps (such as frame analysis, feature extraction, etc.) more convenient and efficient. This avoids the complexity and uncertainty that may be caused by directly operating in the original encoded video stream.
[0066] Based on the above embodiments, please refer to Figure 5In one exemplary embodiment provided in this application, the specific implementation process of determining the frame rate information of the video file to be detected based on multi-frame data packets, and determining the duration of each frame corresponding to the video file to be detected based on the frame rate information, may further include steps S510 to S530, which are described in detail below:
[0067] Step S510: Obtain frame rate information from multi-frame data packets;
[0068] Step S520: If the frame rate information matches the actual playback speed of the video file to be detected, then the frame rate information is determined to be valid frame rate information.
[0069] Step S530: Determine the duration of each frame of the video file to be detected based on the effective frame rate information.
[0070] For example, use appropriate tools or libraries (such as FFmpeg, libavcodec, etc.) to parse multi-frame data packets to extract the video frames and associated metadata contained within. Extract frame rate information from the parsed multi-frame data packets or associated metadata. Frame rate is typically expressed in frames per second (FPS). This can usually be obtained by playing the video and measuring its playback time, or by using video processing tools to analyze the video file's metadata to obtain playback speed information.
[0071] It's important to note that if the video is recorded at a constant frame rate, its actual playback speed should match the frame rate information (i.e., the number of frames played per second equals the frame rate). The extracted frame rate information is compared with the actual playback speed of the video file being tested. If they match (or match within a certain error range), the frame rate information is considered valid. Once valid frame rate information is determined, it can be used to calculate the duration of each frame. The frame duration (in seconds) can be calculated by dividing 1 second by the frame rate, i.e., frame duration = 1 / frame rate.
[0072] In some embodiments of this application, by verifying the consistency between the frame rate information and the actual playback speed of the video, it can be ensured that the frame rate information used is accurate and effective. This helps to maintain high precision in subsequent video analysis, processing or synchronization operations based on the frame rate, and improves the accuracy and effectiveness of video file detection.
[0073] Based on the above embodiments, please refer to Figure 6 In one exemplary embodiment provided in this application, after determining the frame rate information of the video file to be detected based on multi-frame data packets, and determining the duration of each frame corresponding to the video file to be detected based on the frame rate information, the specific implementation process of the above video file detection method may further include steps S610 and S620, which are described in detail below:
[0074] Step S610: If the duration of any frame in the video file to be detected is less than or equal to zero, then the detection result of the video file to be detected being corrupted is obtained.
[0075] Step S620: If the duration of any frame in the video file to be detected is greater than zero, then obtain the timestamp of each frame in the video file to be detected.
[0076] For example, iterate through all frames in the video file to be tested, checking the duration of each frame. For each frame, check if its duration is less than or equal to zero. If any frame's duration is found to be less than or equal to zero, it indicates that the video may be corrupted or data is lost. If any frame's duration is found to be less than or equal to zero during the check, immediately generate a detection result, marking the video file to be tested as corrupted. This detection result can be an error code, a boolean value, or an object containing error information. If, after checking the duration of all frames, it is confirmed that the duration of each frame is greater than zero, the video can be considered complete and uncorrupted. After confirming the video's integrity, use appropriate tools or libraries (such as FFmpeg, libavformat, etc.) to obtain the timestamp of each frame in the video. The timestamp is typically used to represent the relative position or absolute time of the frame in the video.
[0077] In some embodiments of this application, to avoid wasting time and resources in subsequent processing, it becomes meaningful to obtain the timestamp of each frame when it is confirmed that the duration of all frames in the video file is greater than zero. Timestamps are key information for video synchronization, editing and processing. They ensure the correct order and temporal relationship of the video content. Then, by obtaining accurate timestamps, a reliable basis can be provided for subsequent video file detection.
[0078] Based on the above embodiments, please refer to Figure 7 In one exemplary embodiment provided in this application, the specific implementation process of obtaining the time difference between any two consecutive frames in the video file to be detected and determining the detection result of the video file to be detected based on the time difference and the duration of each frame may further include steps S710 to S730, which are described in detail below:
[0079] Step S710: Obtain the timestamps corresponding to any two consecutive frames in the video file to be detected;
[0080] Step S720: Calculate the time difference between any two consecutive frames based on their respective timestamps;
[0081] Step S730: If the time difference is less than or equal to zero or the time difference is greater than the duration of each frame, the detection result of the video file to be detected being corrupted is obtained.
[0082] Following the examples described above, select the timestamps corresponding to any two consecutive frames in the video file to be tested, and calculate the difference between the timestamp of the later frame and the time difference of the previous frame. If the time difference is less than or equal to zero, this usually means that the timestamp information is incorrect or the video frame order is disordered, thus indicating that the video file may be corrupted. Given the duration of each frame (calculated according to the examples above), if the time difference between two consecutive frames is greater than this duration, this may also indicate a problem with the video file, because under normal circumstances, the time interval between two consecutive frames should not exceed the duration of a single frame.
[0083] Optionally, in some feasible embodiments, if any unreasonable situation (time difference less than or equal to zero or greater than the duration of each frame) is found during the time difference check, a flag is set to indicate that the video file is corrupted, and detailed information leading to the corruption detection result, such as frame number, timestamp, and time difference, is recorded for subsequent analysis and debugging.
[0084] In some embodiments of this application, calculating the time difference by comparing the timestamps of two consecutive frames can more accurately identify corruption in video files. If the time difference is less than or equal to zero, or greater than the duration of each frame, this is usually an indication of video file corruption or improper editing, suggesting potential problems such as frame loss, duplication, or timestamp errors, thus improving the accuracy and effectiveness of video file detection.
[0085] Based on the above embodiments, please refer to Figure 8 In one exemplary embodiment provided in this application, the specific implementation process of determining the detection result of the video file to be detected based on the time difference and the duration of each frame may further include steps S810 and S820, which are described in detail below:
[0086] Step S810: If the time difference is greater than zero and the time difference is less than the duration of each frame, then obtain the timestamp of each frame in the video file to be detected.
[0087] Step S820: If the timestamps of each frame show an increasing relationship in time, then the detection result of the video file to be detected is normal.
[0088] For example, the video processing tools or libraries mentioned in the above embodiments iterate through each frame of the video and calculate the time difference between two consecutive frames. They verify that each time difference is greater than zero and less than the known duration of each frame. If all time differences meet this condition, we can initially conclude that the video is temporally continuous, without any skipped or repeated frames. They then iterate through the extracted timestamps and check if they increase sequentially. This means that the timestamp of each subsequent frame should be greater than the timestamp of the previous frame. If all time differences between frames are greater than zero and less than the duration of each frame, and all timestamps show an increasing relationship, then we can conclude that the video file being tested is normal.
[0089] In some embodiments of this application, the status of video files can be determined very accurately through rigorous checks of time differences and timestamp increment relationships. This method can identify even very minor video corruption or timestamp errors, ensuring the integrity and accuracy of video files. This process ensures the normality of video files before processing, thereby avoiding errors or anomalies caused by file corruption or timestamp errors in subsequent processing, which helps improve the stability and reliability of video processing.
[0090] Figure 9 This is a simplified flowchart illustrating a video file inspection process in an exemplary application scenario. In the application scenario shown in Figure 9, the process involves: acquiring multimodal information of the video file to be inspected, including its data size and video stream information; acquiring basic information of the video stream, including its duration; if the duration exceeds a preset duration threshold, acquiring the frame size of the video in the video stream information; if the frame size exceeds a preset size threshold, parsing the video stream information to obtain parsed multi-frame data packets; acquiring the target decoder corresponding to the video stream information, and decoding the video stream based on the target decoder to obtain the decoded video stream; if the duration of any frame in the video file to be inspected is less than or equal to zero, a detection result indicating the video file is corrupted is obtained; if the duration of any frame in the video file to be inspected is greater than zero, the timestamp of each frame in the video file to be inspected is acquired; if the time difference is less than or equal to zero or greater than the duration of each frame, a detection result indicating the video file is corrupted is obtained; if the timestamps of each frame show an increasing relationship in time, a detection result indicating the video file is normal is obtained. For detailed implementation process, please refer to the descriptions in the aforementioned embodiments; they will not be repeated here.
[0091] Figure 10 This is a block diagram illustrating a video file detection apparatus according to an exemplary embodiment of this application. The apparatus can be applied to… Figure 1The implementation environment shown is specifically configured in server 120. This device can also be applied to other exemplary implementation environments and specifically configured in other devices. This embodiment does not limit the implementation environment to which the device is applicable.
[0092] like Figure 10 As shown, the exemplary video file detection device includes: an acquisition module 1010, which acquires multimodal information of the video file to be detected, including the data size and video stream information of the video file to be detected; a parsing module 1020, which parses the video stream information to obtain parsed multi-frame data packets if the data size is greater than a preset data size threshold; a determination module 1030, which determines the frame rate information of the video file to be detected based on the multi-frame data packets, and determines the duration of each frame of the video file to be detected based on the frame rate information; and a detection module 1040, which acquires the time difference between any two consecutive frames in the video file to be detected, and determines the detection result of the video file to be detected based on the time difference and the duration of each frame.
[0093] According to one aspect of the embodiments of this application, the above-mentioned parsing module 1020 further includes obtaining basic information of the video stream, including the duration of the video file to be detected; if the duration is greater than a preset duration threshold, then obtaining the screen size of the video in the video stream information; if the screen size is greater than a preset size threshold, then parsing the video stream information to obtain the parsed multi-frame data packets.
[0094] According to one aspect of the embodiments of this application, the parsing module 1020 further includes: obtaining a target decoder corresponding to the video stream information, decoding the video stream based on the target decoder to obtain a decoded video stream; and obtaining multi-frame data packets from the decoded video stream, wherein the multi-frame data packets include multi-frame data that constitute the video stream.
[0095] According to one aspect of the embodiments of this application, the parsing module 1020 further includes: acquiring frame rate information in multi-frame data packets; if the frame rate information matches the actual playback speed of the video file to be detected, then determining the frame rate information as valid frame rate information; and determining the duration of each frame corresponding to the video file to be detected based on the valid frame rate information.
[0096] According to one aspect of the embodiments of this application, the determination module 1030 further includes: if the duration of any frame in the video file to be detected is less than or equal to zero, then a detection result indicating that the video file to be detected is corrupted is obtained; if the duration of any frame in the video file to be detected is greater than zero, then the timestamp of each frame in the video file to be detected is obtained.
[0097] According to one aspect of the embodiments of this application, the detection module 1040 further includes: obtaining the timestamps corresponding to any two consecutive frames in the video file to be detected; calculating the time difference between any two consecutive frames based on their respective timestamps; and obtaining a detection result that the video file to be detected is corrupted if the time difference is less than or equal to zero or greater than the duration of each frame.
[0098] According to one aspect of the embodiments of this application, the detection module 1040 further includes: if the time difference is greater than zero and the time difference is less than the duration of each frame, then the timestamp of each frame in the video file to be detected is obtained; if the timestamps of each frame show an increasing relationship in time, then the detection result of the video file to be detected is normal.
[0099] The video file detection device and the video file detection method provided in the above embodiments belong to the same concept. The specific operation methods of each module and unit have been described in detail in the method embodiments and will not be repeated here. In practical applications, the video file detection device provided in the above embodiments 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. This is not a limitation here.
[0100] Embodiments of this application also provide an electronic device, including: one or more processors; and a storage device for storing one or more programs, which, when executed by one or more processors, cause the electronic device to implement the video file detection method provided in the above embodiments.
[0101] Figure 11 A schematic diagram of the structure of a computer system suitable for implementing the electronic device of the present application is shown. Figure 11 The computer system 1100 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0102] like Figure 11As shown, the computer system 1100 includes a Central Processing Unit (CPU) 1101, which can perform various appropriate actions and processes, such as executing the methods described in the above embodiments, based on programs stored in Read-Only Memory (ROM) 1102 or programs loaded from storage portion 1108 into Random Access Memory (RAM) 1103. The RAM 1103 also stores various programs and data required for system operation. The CPU 1101, ROM 1102, and RAM 1103 are interconnected via a bus 1104. An Input / Output (I / O) interface 1105 is also connected to the bus 1104.
[0103] The following components are connected to I / O interface 1105: an input section 1106 including a keyboard, mouse, etc.; an output section 1107 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 1108 including a hard disk, etc.; and a communication section 1109 including a network interface card such as a LAN (Local Area Network) card, modem, etc. The communication section 1109 performs communication processing via a network such as the Internet. A drive 1110 is also connected to I / O interface 1105 as needed. Removable media 1111, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 1110 as needed so that computer programs read from them can be installed into storage section 1108 as needed.
[0104] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program including a computer program for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 1109, and / or installed from removable medium 1111. When the computer program is executed by central processing unit (CPU) 1101, it performs various functions defined in the system of this application.
[0105] The computer-readable medium shown in the embodiments of this application may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium may be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying a computer-readable computer program. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.
[0106] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. Each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0107] The units described in the embodiments of this application can be implemented in software or hardware, and the described units can also be located in a processor. The names of these units do not necessarily limit the specific unit itself.
[0108] Another aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the video file detection method as described above. This computer-readable storage medium may be included in the electronic device described in the above embodiments, or it may exist independently and not assembled into the electronic device.
[0109] Another aspect of this application provides a computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the video file detection method provided in the various embodiments described above.
[0110] The above description is merely a preferred exemplary embodiment of this application and is not intended to limit the implementation of this application. Those skilled in the art can easily make corresponding modifications or alterations based on the main concept and spirit of this application. Therefore, the scope of protection of this application should be determined by the scope of protection claimed in the claims.
Claims
1. A video file detection method characterized by, include: Obtain multimodal information of the video file to be detected, wherein the multimodal information includes the data size and video stream information of the video file to be detected; If the data size is greater than a preset data size threshold, the video stream information is parsed to obtain parsed multi-frame data packets, including: Obtain basic information about the video stream, including the duration of the video file to be detected; If the duration exceeds a preset duration threshold, the screen size of the video in the video stream information is obtained; If the image size is larger than a preset size threshold, the video stream information is parsed to obtain parsed multi-frame data packets; The frame rate information of the video file to be detected is determined based on the multi-frame data packets, and the duration of each frame of the video file to be detected is determined based on the frame rate information. Obtain the time difference between any two consecutive frames in the video file to be detected, and determine the detection result of the video file to be detected based on the time difference and the duration of each frame.
2. The method of claim 1, wherein, The step of parsing the video stream information to obtain parsed multi-frame data packets includes: Obtain the target decoder corresponding to the video stream information, and decode the video stream based on the target decoder to obtain the decoded video stream; Multi-frame data packets are obtained from the decoded video stream, and the multi-frame data packets include multi-frame data that makes up the video stream.
3. The method of claim 2, wherein, The step of determining the frame rate information of the video file to be detected based on the multi-frame data packets, and determining the duration of each frame corresponding to the video file to be detected based on the frame rate information, includes: Obtain the frame rate information from the multi-frame data packets; If the frame rate information matches the actual playback speed of the video file to be detected, then the frame rate information is determined to be valid frame rate information; The duration of each frame in the video file to be detected is determined based on the effective frame rate information.
4. The method of claim 1, wherein, After determining the frame rate information of the video file to be detected based on the multi-frame data packets, and determining the duration of each frame corresponding to the video file to be detected based on the frame rate information, the method further includes: If the duration of any frame in the video file to be detected is less than or equal to zero, then the detection result is that the video file to be detected is corrupted. If the duration of any frame in the video file to be detected is greater than zero, then the timestamp of each frame in the video file to be detected is obtained.
5. The method of claim 4, wherein, The step of obtaining the time difference between any two consecutive frames in the video file to be detected, and determining the detection result of the video file to be detected based on the time difference and the duration of each frame, includes: Obtain the timestamps corresponding to any two consecutive frames in the video file to be detected; Calculate the time difference between any two consecutive frames based on their respective timestamps; If the time difference is less than or equal to zero or the time difference is greater than the duration of each frame, then the detection result of the video file to be detected being corrupted is obtained.
6. The method of claim 1, wherein, Determining the detection result of the video file to be detected based on the time difference and the duration of each frame includes: If the time difference is greater than zero and the time difference is less than the duration of each frame, then the timestamp of each frame in the video file to be detected is obtained. If the timestamps of each frame show an increasing relationship in time, then the detection result of the video file to be detected is normal.
7. A video file detection apparatus characterized by comprising: The device includes: The acquisition module acquires multimodal information of the video file to be detected, including the data size and video stream information of the video file to be detected. The parsing module, if the data size is greater than a preset data size threshold, parses the video stream information to obtain parsed multi-frame data packets, including: obtaining basic information of the video stream, the basic information including the duration of the video file to be detected; if the duration is greater than a preset duration threshold, obtaining the screen size of the video in the video stream information; if the screen size is greater than a preset size threshold, parsing the video stream information to obtain parsed multi-frame data packets. The determination module determines the frame rate information of the video file to be detected based on the multi-frame data packets, and determines the duration of each frame corresponding to the video file to be detected based on the frame rate information; The detection module obtains the time difference between any two consecutive frames in the video file to be detected, and determines the detection result of the video file to be detected based on the time difference and the duration of each frame.
8. An electronic device, comprising: include: One or more processors; A storage device for storing one or more programs, which, when executed by one or more processors, cause the electronic device to implement the video file detection method as described in any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that, It stores computer-readable instructions, which, when executed by the computer's processor, cause the computer to perform the video file detection method according to any one of claims 1 to 6.