Automatic video testing method

By adding black video frames to video tests and calculating PSNR values, the problem that existing video testing methods rely on manual judgment is solved, and video automated testing and quality control are realized, which improves testing efficiency and accuracy.

CN119854482APending Publication Date: 2025-04-18FUSHI ZHITONG ELECTRONIC TECH (JINAN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411828781.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-12
Publication Date
2025-04-18

Smart Images

  • Figure CN119854482A_ABST
    Figure CN119854482A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of video processing, in particular to an automatic video testing method, which comprises the following steps of: acquiring a video I and a video II to be processed; black video frames are added to the starting ends of the first video and the second video respectively; finding out each frame of picture in the new video I and the new video II by utilizing a program, calculating the gray-scale value of the whole frame of picture, and judging whether the picture is a black picture or not; respectively and continuously reading contents in the new video I and the new video II, and if the next frame of the black picture is not the black picture, judging that the frame is the first frame of the new video I or the new video II; or, when the next frame of the non-black picture is the black picture, the frame is the last frame of the first new video or the second new video; calculating the PSNR value of the first new video or the second new video from the first frame to the last nth frame, and then calculating the average PSNR; and judging the video content by comparing the value of the PSNR of the new video I or the new video II.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of video processing, in particular to an automatic video testing method. Background Art

[0002] Existing video testing methods mostly rely on manual judgment, which is inefficient, costly, and prone to errors. They lack objective and quantifiable video quality evaluation indicators, and cannot effectively and accurately compare the input and output of the video processing process, making it difficult to quickly locate the problem. Especially in the testing and verification of large-scale video processing algorithms, there are problems such as long testing cycles and high costs.

[0003] The main bottleneck of video automation testing is how to correctly determine whether the input and output videos are consistent. The traditional method is to use pixel-by-pixel comparison to determine whether the content of two videos is consistent. However, this method is only applicable to original videos that have not been compressed. For some compressed videos, due to different compression ratios and compression algorithms and different GOP (group of pictures) during compression, the pixels of two compressed videos cannot be completely 100% identical. Therefore, it is impossible to use an automated method for comparison, and thus the purpose of automated testing cannot be achieved. It can only be changed to semi-automatic manual verification to determine whether the video content is the same. Summary of the invention

[0004] In view of the above problems, the present invention provides a video automation testing method, which solves the problems that the existing video testing methods mostly rely on manual judgment, are inefficient, costly and prone to errors.

[0005] The technical solution adopted by the present invention to solve its technical problem is: a video automation test method, the method comprising: obtaining a video 1 and a video 2 to be processed; adding black video frames to the starting ends of the video 1 and the video 2 respectively to obtain a new video 1 and a new video 2; confirming the contents of the original video 1 and the video 2 in the new video 1 and the new video 2; using a program to find each frame of the new video 1 and the new video 2, and calculating the grayscale value of the entire frame to determine whether it is a black screen; continuously reading the contents of the new video 1 and the new video 2 respectively, if the next frame of the black screen is not a black screen, it can be determined that this frame is the first frame of the new video 1 or the new video 2; or, when the next frame of the non-black screen is a black screen, it indicates that this frame is the last frame of the new video 1 or the new video 2; calculating the PSNR value of the new video 1 or the new video 2 from the first frame, calculating to the last nth frame, and then calculating the average PSNR; and judging the video content by comparing the PSNR values ​​of the new video 1 or the new video 2.

[0006] As an optimization, the black video frame is a full black video frame of at least 5 frames generated by using opencv, and the full black video frame is inserted into the starting end of video one and video two respectively by using opencv.

[0007] As an optimization, the steps to determine whether it is a black screen are: setting a threshold for the number of black pixels; reading each frame of the new video one or the new video two, and converting the image into a grayscale image; calculating the amount of melanin in the grayscale image; when the amount of melanin in the grayscale image is greater than the set threshold for the number of black pixels, this is a black screen frame; when the amount of melanin in the grayscale image is less than the set threshold for the number of black pixels, this is the content of the video one or the video two.

[0008] As an optimization, the PSNR is calculated as follows: The processed image is I, the real image is K, and the peak signal-to-noise ratio is defined as: Among them, MAX represents the maximum value of the pixel on the image, which is usually defined as 1 or 255, and MSE is defined as: .

[0009] The beneficial effects of the present invention are as follows: the video automation test method provided by the present invention automatically determines the difference between video input and output through accurate PSNR (peak signal-to-noise ratio) and other objective index comparisons, realizes the automated testing, quality control and fault location of the video processing algorithm, and supports customized test parameters. In an innovative way, the PSNR technology, which was originally only used for video quality assessment, is applied to video comparison, thereby effectively comparing two encoded videos and achieving the purpose of automated coding testing; the biggest advantage is that it provides a complete video automation test system that can automatically compare the input and output of the entire video sequence, and provide a detailed test report, using PSNR to evaluate whether two videos are the same, thereby improving test efficiency and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] Attached Figure 1 Provides basic methods for PSNR automation testing; Attached Figure 2 A flowchart for adding a completely black video frame to the present invention; Attached Figure 3 It is a flow chart of the interpretation of black screen frames and source video frames of the present invention; Attached Figure 4 This is a flow chart of comparing the PSNR of Video 1 and Video 2 according to the present invention. DETAILED DESCRIPTION

[0011] It should be noted that the following detailed descriptions are illustrative and are intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present application belongs.

[0012] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.

[0013] The present invention discloses a video automation testing method, which comprises: obtaining a video 1 and a video 2 to be processed; adding black video frames to the starting ends of the video 1 and the video 2 respectively to obtain a new video 1 and a new video 2; confirming the contents of the original video 1 and the video 2 in the new video 1 and the new video 2, capturing the encoded streaming video, recording the encoded streaming, and playing to confirm that the black video frames have been added before and after the video content, and the video source content can be correctly played and the original video is the same; using a program to find each frame in the new video 1 and the new video 2, and calculating the grayscale value of the entire frame to determine whether it is a black picture; continuously reading the contents of the new video 1 and the new video 2 respectively, and if the next frame of the black picture is not a black picture, it can be determined that this frame is the first frame of the new video 1 or the new video 2; or, when the next frame of the non-black picture is a black picture, it means that this frame is the last frame of the new video 1 or the new video 2; if Figure 4 As shown, the PSNR value of the new video one or the new video two is calculated from the first frame to the last nth frame, and then the average PSNR is calculated; the video content is judged by comparing the PSNR value of the new video one or the new video two. If the PSNR is less than 35dB, it can be determined that the contents of the two videos are different or very different, and the test is determined to have failed. Otherwise, PSNR>35dB indicates that the video one is similar to the video two, and the two videos can be determined to have the same content.

[0014] Automatic judgment of the consistency of video input and output is achieved based on PSNR comparison. PSNR, the full name of which is Peak Signal-to-Noise Ratio, is an objective indicator for measuring video quality. It is usually used to compare the difference between the original video and the compressed or processed video. The higher the PSNR value, the smaller the distortion and the better the video quality. Simply put, PSNR calculates the ratio between the maximum possible pixel value and the noise (that is, the difference between the original video and the processed video), and this ratio is expressed in decibels (dB). Figure 1 As shown, by directly calculating the PSNR values ​​of Video 1 and Video 2, it is possible to determine whether the two videos are the same or similar. When the PSNR value reaches a certain index, it can be determined that the two videos have the same content. By using this method of calculating PSNR, an automated video encoding test can be achieved. In actual test applications, the original video will be played in a loop, so it is impossible to determine whether the captured encoded Video 1 and Video 2 will have the same starting point. If the starting points are different, the frames cannot be aligned and the calculated PSNR value will be very low, and they will be determined to be different videos, and cannot be correctly compared.

[0015] like Figure 2 As shown, the black video frame insertion step, the black video frame is a full black video frame of at least 5 frames generated by using opencv, and the full black video frame is inserted at the starting end of video one and video two respectively using opencv.

[0016] like Figure 3 As shown, the steps of determining whether it is a black screen are: setting a threshold value for the number of black pixels; reading each frame of the new video one or the new video two, and converting the image into a grayscale image; calculating the amount of melanin in the grayscale image; when the amount of melanin in the grayscale image is greater than the set threshold value for the number of black pixels, this is a black screen frame; when the amount of melanin in the grayscale image is less than the set threshold value for the number of black pixels, this is the content of the video one or the video two.

[0017] The PSNR is calculated as follows: The processed image is I, the real image is K, and the peak signal-to-noise ratio is defined as: Among them, MAX represents the maximum value of the pixel on the image, which is usually defined as 1 or 255, and MSE is defined as: .

[0018] The above-mentioned specific implementations are only specific cases of the present invention. The patent protection scope of the present invention includes but is not limited to the product form and style of the above-mentioned specific implementations. Any appropriate changes or modifications made to them by ordinary technicians in the technical field that conform to the claims of the present invention shall fall within the patent protection scope of the present invention.

Claims

1. A video automation testing method, characterized in that: The method comprises: Get video 1 and video 2 to be processed; Add black video frames to the starting ends of the video 1 and the video 2 respectively to obtain a new video 1 and a new video 2; Confirming the contents of the original video 1 and the original video 2 in the new video 1 and the new video 2; Using a program to find each frame in the new video 1 and the new video 2, and calculating the grayscale value of the entire frame to determine whether it is a black frame; Continuously reading the contents of the new video 1 and the new video 2 respectively, if the next frame of the black screen is not a black screen, it can be determined that this frame is the first frame of the new video 1 or the new video 2; or, When the next frame of the non-black picture is a black picture, it means that this frame is the last frame of the new video 1 or the new video 2; Calculate the PSNR value of the new video 1 or the new video 2 starting from the first frame, and calculate to the last nth frame, and then calculate the average PSNR; The video content is determined by comparing the PSNR values ​​of the new video 1 or the new video 2.

2. The video automation testing method according to claim 1, characterized in that: The black video frame is a full black video frame of at least 5 frames generated by using opencv, and the full black video frame is inserted at the starting end of video one and video two respectively by using opencv.

3. The video automation testing method according to claim 1, characterized in that: The steps to determine whether it is a black screen are: Set a threshold for the number of black pixels; Read each frame of the new video 1 or the new video 2, and convert the image into a grayscale image; Calculating the amount of melanin in the grayscale image; When the amount of melanin in the grayscale image is greater than the set threshold of the amount of black pixels, this is a black screen frame; When the amount of melanin in the grayscale image is less than a set threshold of the amount of black pixels, this is the content of the video one or the video two.

4. The video automation testing method according to claim 1, characterized in that: The PSNR is calculated as follows: The processed image is I, the real image is K, and the peak signal-to-noise ratio is defined as: Among them, MAX represents the maximum value of the pixel on the image, which is usually defined as 1 or 255, and MSE is defined as: 。