A web page H265 video decoding method on low-end devices
By setting keyframes during the video decoding process and determining whether to discard frames based on the decoding delay time, the problem of low-configuration hardware devices not working properly is solved, and more efficient video decoding is achieved.
Patent Information
- Application Number
- CN202210449825.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-26
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2042-04-26
AI Technical Summary
The prior art will still consume a lot of CPU resources during video decoding, resulting in low-configuration hardware devices not working properly.
By setting keyframes and judging whether the decoding is timely based on the calculated decoding delay time, if not timely, discarding unimportant frames and only rendering keyframes.
It effectively reduces CPU resource consumption during video decoding and ensures that low-configured hardware devices can work normally.
Smart Images

Figure CN114866781B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a decoding method, and more particularly to a web page H265 video decoding method on a low-profile device. Background Art
[0002] Conventional plug-ins for playing h265 videos use software decoding, which consumes a lot of CPU resources. If all frames of the video are rendered, low-configuration hardware devices may not work properly.
[0003] Therefore, in the prior art, there is a patent number 2019108671134 entitled a video decoding method, apparatus and computer device, which determines the key frames in the video to be decoded, then determines the frames to be selected and the frames to be decoded, and uses different decoding methods to decode the selected frames and the frames to be decoded, so as to achieve the effect of alleviating the calculation pressure of video decoding. However, it is essentially a rendering of all frames of the video to be decoded. Therefore, although a certain decoding pressure is alleviated, there is still a problem that low-configuration hardware devices cannot work properly. Summary of the invention
[0004] In view of the deficiencies in the prior art, the object of the present invention is to provide a web page H265 video decoding method on a low-configuration device that can enable a low-configuration hardware device to work normally.
[0005] To achieve the above object, the present invention provides the following technical solution: a web page H265 video decoding method on a low-profile device, comprising the following steps:
[0006] Step 1: Obtain the video to be decoded and set a key frame in the video to be decoded;
[0007] Step 2: Calculate the decoding delay time;
[0008] Step three, judging whether the decoding is timely according to the delay time obtained in step two, and if the decoding is not timely, discarding unimportant frames and only rendering key frames.
[0009] As a further improvement of the present invention, the specific steps of setting the key frame in step 1 are as follows:
[0010] Step 1, obtain the websocket streaming data, and traverse the data to obtain the value of each frame;
[0011] Step 1 and 2, determine whether the value of each frame is within the range of greater than 16 and less than 32. If it is not within the range, no processing is performed. If it is within the range, the frame is set as a key frame.
[0012] As a further improvement of the present invention, the specific steps of calculating the decoding delay time in step 2 are as follows: step 21, inputting the current frame timestamp;
[0013] Step 22, determine whether the input current frame timestamp is empty, if it is empty, the delay time is equal to -1, and then return to the delay time and end, if it is not empty, proceed to the next step;
[0014] Step 23, determine whether the timestamp of the first frame is empty. If it is empty, the delay time is equal to the current timestamp minus the start timestamp minus the timestamp of the current input frame plus the timestamp of the first frame, and then return to the delay time and end. If it is not empty, proceed to the next step;
[0015] Step 24, assign the timestamp of the input frame to the timestamp of the first frame, assign the current timestamp to the start timestamp, the delay time is equal to -1, and the process ends after returning the delay time.
[0016] As a further improvement of the present invention, the specific steps of decoding the lost frame in step 3 are as follows:
[0017] Step 31, obtaining a decoded video stream array;
[0018] Step 32, determine whether the length of the video stream array is greater than 0. If not, return to the above step to re-acquire the decoded video stream array. If greater than 0, proceed to the next step.
[0019] Step 33, determine whether the frame loss flag is yes, if yes, enter the key frame judgment process and return to step 32, if the frame loss flag is no, enter the rendering step and return to step 32.
[0020] As a further improvement of the present invention, the key frame determination process has the following specific steps:
[0021] Step 331, traverse the video stream array, determine whether each frame therein is a key frame, if not a key frame, discard the frame, if it is a key frame, decode the key frame, and set the frame loss flag to no;
[0022] Step 332, continue execution after a delay of 10 milliseconds and return to step 32.
[0023] As a further improvement of the present invention, the rendering step is specifically as follows:
[0024] Step 1, determine whether the delay time is greater than the cache time. If not, traverse the video stream array and decode frame by frame and then re-determine whether the delay time is greater than the cache time. If it is greater than the cache time, proceed to the next step;
[0025] Step 2, reset the delay time, set the frame loss indication to yes, and continue to execute after a delay of 10 milliseconds and return to step 32.
[0026] The beneficial effect of the present invention is that through the setting of step one, the key frame can be effectively set, and then through the setting of step two and step three, it can be judged whether the decoding is timely through the delay time, and unimportant frames can be discarded when the decoding is not timely, thus achieving the effect of low-configuration hardware equipment being able to work normally. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 Flowchart for setting keyframes;
[0028] Figure 2 Flowchart for calculating decoding delay;
[0029] Figure 3 Flowchart for decoding lost frames. DETAILED DESCRIPTION
[0030] The present invention will be further described below in detail with reference to the embodiments shown in the accompanying drawings.
[0031] Reference Figure 1 As shown, a web page H265 video decoding method on a low-profile device of this embodiment includes the following steps:
[0032] Step 1: Obtain the video to be decoded and set a key frame in the video to be decoded;
[0033] Step 2: Calculate the decoding delay time;
[0034] Step three, judging whether the decoding is timely according to the delay time obtained in step two, and when the decoding is not timely, discarding unimportant frames and only rendering key frames. By setting the above three steps, unimportant frames can be effectively discarded when the decoding is not timely. Compared with the method of using all rendering in the prior art, it is a good way to achieve the effect of low-configuration hardware devices being able to work normally.
[0035] As an improved specific implementation method, the specific steps of setting the key frame in step 1 are as follows:
[0036] Step 1, obtain the websocket streaming data, and traverse the data to obtain the value of each frame;
[0037] Steps one and two, determine whether the value of each frame is within the range of greater than 16 and less than 32. If it is not within the range, no processing is performed. If it is within the range, the frame is set as a key frame. Through the settings of the above steps, the value calculation can be used to effectively determine whether the frame is a key frame. The overall setting process is simple and fast. Among them, the websocket push stream data is parsed by the code in the form of an array, and each array item is the value of each frame.
[0038] As an improved specific implementation method, the specific steps of calculating the decoding delay time in step 2 are as follows:
[0039] Step 21, input the current frame timestamp;
[0040] Step 22, determine whether the input current frame timestamp is empty, if it is empty, the delay time is equal to -1, and then return to the delay time and end, if it is not empty, proceed to the next step;
[0041] Step 23, determine whether the timestamp of the first frame is empty. If it is empty, the delay time is equal to the current timestamp minus the start timestamp minus the timestamp of the current input frame plus the timestamp of the first frame, and then return to the delay time and end. If it is not empty, proceed to the next step;
[0042] Step 24, assign the timestamp of the input frame to the timestamp of the first frame, assign the current timestamp to the start timestamp, the delay time is equal to -1, and the delay time ends after returning. Through the settings of the above steps, the delay time can be effectively calculated as well as the timestamp of the current frame and the timestamp of the first frame. The delay time refers to the intermediate time from when a frame of data is received by the browser to when the frame of data begins to be rendered. By calculating the delay time, it can be determined whether the current device can process all data frames in time. If the delay time is greater than the value set by yourself (the default setting time is one second), it is determined that the current device cannot process all data frames in time, and thus enters the process of frame loss. If all can be processed within the set time, no processing will be done on the data frame.
[0043] As an improved specific implementation method, the specific steps of decoding the lost frame in step 3 are as follows:
[0044] Step 31, obtaining a decoded video stream array;
[0045] Step 32, determine whether the length of the video stream array is greater than 0. If not, return to the above step to re-acquire the decoded video stream array. If greater than 0, proceed to the next step.
[0046] In step 33, determine whether the frame loss flag is yes. If yes, enter the key frame judgment process and return to step 32. If the frame loss flag is no, enter the rendering step and return to step 32. By setting the above three steps, the decoding frame loss process can be completed simply and effectively.
[0047] As a specific implementation method of the improvement, the specific steps of the key frame judgment process are as follows:
[0048] Step 331, traverse the video stream array, determine whether each frame therein is a key frame, if not a key frame, discard the frame, if it is a key frame, decode the key frame, and set the frame loss flag to no;
[0049] Step 332, after a delay of 10 milliseconds, continue to execute and return to step 32. Through the settings of the above steps, it is possible to effectively determine whether it is a key frame, and at the same time, unimportant frames can be effectively discarded.
[0050] As a specific implementation of the improvement, the rendering step is specifically as follows:
[0051] Step 1, determine whether the delay time is greater than the cache time. If not, traverse the video stream array and decode frame by frame and then re-determine whether the delay time is greater than the cache time. If it is greater than the cache time, proceed to the next step;
[0052] Step 2, reset the delay time, and set the frame loss indication to yes. After a delay of 10 milliseconds, continue to execute and return to step 32. Through the above method, the delay time can be used to determine whether timely decoding can be achieved. At the same time, if timely decoding cannot be achieved, the frame is set as a discarded frame and then the key frame is judged, and the frame is discarded when it is judged to be unimportant.
[0053] In summary, the decoding method of this embodiment discards unimportant frames and only renders key frames when decoding is not timely, which well achieves the effect that low-configuration hardware devices can work normally.
[0054] The above is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should also be regarded as the protection scope of the present invention.
Claims
1. A web page H265 video decoding method on a low-end device, characterized by: The steps include: Step 1: Obtain the video to be decoded and set a key frame in the video to be decoded; Step 2: Calculate the decoding delay time; Step 3: determine whether the decoding is timely according to the delay time obtained in step 2, and when the decoding is not timely, discard unimportant frames and only render key frames; the specific steps of setting the key frames in step 1 are as follows: Step 1, obtain the websocket streaming data, and traverse the data to obtain the value of each frame; Step 1 and 2, determine whether the value of each frame is within the range of greater than 16 and less than 32. If it is not within the range, no processing is performed. If it is within the range, the frame is set as a key frame. The specific steps for calculating the decoding delay time in step 2 are as follows: Step 21, input the current frame timestamp; Step 22, determine whether the input current frame timestamp is empty, if it is empty, the delay time is equal to -1, and then return to the delay time and end, if it is not empty, proceed to the next step; Step 23, determine whether the timestamp of the first frame is empty. If it is empty, the delay time is equal to the current timestamp minus the start timestamp minus the timestamp of the current input frame plus the timestamp of the first frame, and then return to the delay time and end. If it is not empty, proceed to the next step; Step 24, assign the timestamp of the input frame to the timestamp of the first frame, assign the current timestamp to the start timestamp, the delay time is equal to -1, and the process ends after returning the delay time; The specific steps of decoding the lost frame in step 3 are as follows: Step 31, obtaining a decoded video stream array; Step 32, determine whether the length of the video stream array is greater than 0. If not, return to the previous step to re-acquire the decoded video stream array. If greater than 0, proceed to the next step. Step 33, determine whether the frame loss flag is yes, if yes, enter the key frame determination process and return to step 32, if the frame loss flag is no, enter the rendering step and return to step 32; the specific steps of the key frame determination process are as follows: Step 331, traverse the video stream array, determine whether each frame therein is a key frame, if not a key frame, discard the frame, if it is a key frame, decode the key frame, and set the frame loss flag to no; Step 332: After a delay of 10 milliseconds, continue to execute and return to step 32; the rendering steps are as follows: Determine whether the delay time is greater than the cache time. If not, traverse the video stream array and decode frame by frame to re-determine whether the delay time is greater than the cache time. If it is greater than the cache time, proceed to the next step. Reset the delay time and set the frame loss indication to yes. After a delay of 10 milliseconds, continue to execute and return to step 32.
Citation Information
Patent Citations
Video framedropping strategy based on grading mechanism
CN102368823A
Media data processing method and device
CN103428483A