Video variable speed control method, system, device and storage medium
By receiving the user-defined speed adjustment value and processing it in segments, different video frame decoding methods are used to solve the problems of slow video speed adjustment response and stuttering, achieving more efficient video playback and audio-video synchronization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- AFIRSTSOFT CO LTD
- Filing Date
- 2022-12-21
- Publication Date
- 2026-06-02
AI Technical Summary
Existing video speed adjustment methods have a slow response time, which can easily lead to video stuttering or audio-video desynchronization.
By receiving the user-defined speed value and comparing it with the preset first and second thresholds, the variable speed playback control is achieved by sequentially reading frames, video seek skipping frames, and skipping keyframes, respectively. Different video frame decoding methods are used according to different speed value ranges.
Improved video response speed, optimized screen stuttering issues, and ensured audio and video synchronization.
Smart Images

Figure CN115988268B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of video speed control technology, and in particular to a video speed control method, system, device and storage medium. Background Technology
[0002] With the development of multimedia technology, more and more people are using mobile phones, computers and other devices to watch videos. Different people are interested in different parts of the same video. They want to fast-forward through the parts they are not interested in, and slow down the parts they are interested in or that contain a lot of information. In addition, the speed needs to be adjusted during the video editing process to match the plot or to achieve various dramatic effects. Therefore, video speed adjustment is a basic and important operation.
[0003] Existing video speed adjustment methods are mostly implemented by sequentially reading frames, decrypting frames, and dropping frames. The response speed is relatively slow, which may cause video stuttering or video playback to continue after the audio has finished, resulting in desynchronization problems.
[0004] Therefore, existing technologies still need to be improved and developed. Summary of the Invention
[0005] The main objective of this invention is to provide a video speed control method, system, device, and storage medium to solve the problems of the prior art described in the background.
[0006] The first aspect of this invention provides a video speed control method, comprising the following steps:
[0007] Receives the speed setting set by the user;
[0008] The speed change value is compared with a preset first threshold and a second threshold, wherein the first threshold is less than the second threshold;
[0009] If the speed change value is less than or equal to the first threshold, speed change playback control is achieved by sequentially reading and dropping frames.
[0010] If the speed change value is greater than the first threshold and less than the second threshold, then speed playback control is achieved through video seek frame skipping and frame dropping methods.
[0011] If the speed change value is greater than or equal to the second threshold, speed playback control is achieved by skipping frames to read and interpret keyframes.
[0012] In an optional embodiment of the first aspect of the present invention, the step of implementing variable speed playback control by sequentially reading and dropping frames if the variable speed value is less than or equal to the first threshold includes:
[0013] Entering variable speed playback mode, when reading the next video frame each time, the expected time position of the next video frame is calculated based on the frame number of the previous video frame, the inter-frame interval of video playback, and the variable speed value.
[0014] The expected time position is compared with the past time position of the previous video frame. If the expected time position is less than or equal to the past time position, the previous video frame is played as the next video frame.
[0015] If the desired time position is greater than the past time position, then the subsequent video frames of the previous video frame are decoded frame by frame sequentially; for each subsequent video frame decoded, the timestamp of the subsequent video frame is obtained; if the timestamp is less than the desired time position, and the difference between the desired time position and the timestamp is greater than the inter-frame interval, then the subsequent video frame is discarded; if the timestamp is greater than the desired time position, or the difference between the desired time position and the timestamp is less than the inter-frame interval, then the subsequent video frame is played as the next video frame.
[0016] In an optional embodiment of the first aspect of the present invention, the step of implementing variable speed playback control by means of video seek frame skipping and frame dropping if the variable speed value is greater than the first threshold and less than the second threshold includes:
[0017] Entering variable speed playback mode, when reading the next video frame each time, the expected time position of the next video frame is calculated based on the frame number of the previous video frame, the inter-frame interval of video playback, and the variable speed value.
[0018] Scan the video frame data packets near the desired time position to obtain the key frame data packets closest to the desired time position, and decode the key frame;
[0019] Starting from the keyframe, subsequent video frames are decoded frame by frame sequentially. For each subsequent video frame decoded, a timestamp is obtained. If the timestamp is less than the expected time position and the difference between the expected time position and the timestamp is greater than the inter-frame interval, the subsequent video frame is discarded. If the timestamp is greater than the expected time position, or the difference between the expected time position and the timestamp is less than the inter-frame interval, the subsequent video frame is played as the next video frame.
[0020] In an optional embodiment of the first aspect of the present invention, the step of implementing variable speed playback control by skipping frames to interpret keyframes if the variable speed value is greater than or equal to the second threshold includes:
[0021] Entering variable speed playback mode, when reading the next video frame each time, the expected time position of the next video frame is calculated based on the frame number of the previous video frame, the inter-frame interval of video playback, and the variable speed value.
[0022] Scan the video frame data packets near the desired time position to obtain the key frame data packet closest to the desired time position, decode the key frame, and play the key frame as the next video frame.
[0023] In an optional embodiment of the first aspect of the present invention, calculating the desired time position of the next video frame based on the frame number of the previous video frame, the inter-frame interval of video playback, and the speed change value includes:
[0024] The frame rate of the video playback is obtained from the file information of the video file;
[0025] The inter-frame interval is calculated based on the frame rate and using a preset inter-frame interval calculation formula.
[0026] The desired time position is obtained by multiplying the inter-frame interval by the speed change value by (the number of frames + 1).
[0027] In an optional embodiment of the first aspect of the present invention, for any single reading of a video frame, the number of frames of the video frame = the number of readings to which the video frame belongs - 1.
[0028] In an optional embodiment of the first aspect of the present invention, the value range of the first threshold is (0, 2], and the value range of the second threshold is [8, 12].
[0029] A second aspect of the present invention provides a video speed control system, the video speed control system comprising:
[0030] The speed change value receiving module is used to receive the speed change value set by the user;
[0031] A gear shift value comparison module is used to compare the gear shift value with a preset first threshold and a second threshold, wherein the first threshold is less than the second threshold;
[0032] The first speed control module is used to implement speed playback control by sequentially reading and dropping frames if the speed value is less than or equal to the first threshold.
[0033] The second speed control module is used to control the playback speed by means of video seek frame skipping and frame dropping if the speed value is greater than the first threshold and less than the second threshold.
[0034] The third speed control module is used to implement speed control by reading and interpreting keyframes by skipping frames if the speed value is greater than or equal to the second threshold.
[0035] A third aspect of the present invention provides a video speed control device, the video speed control device comprising: a memory and at least one processor, the memory storing instructions, and the memory and the at least one processor being interconnected via a circuit;
[0036] The at least one processor invokes the instructions in the memory to cause the video speed control device to perform the video speed control method as described in any of the preceding claims.
[0037] A fourth aspect of the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the video speed control method as described in any of the preceding claims.
[0038] Beneficial Effects: This invention provides a video speed control method, system, device, and storage medium. The method includes receiving a user-set speed value, comparing the speed value with a preset first threshold and a second threshold, wherein the first threshold is less than the second threshold; if the speed value is less than or equal to the first threshold, speed playback control is achieved by sequentially reading and dropping frames; if the speed value is greater than the first threshold but less than the second threshold, speed playback control is achieved by video seek frame skipping and frame dropping; if the speed value is greater than or equal to the second threshold, speed playback control is achieved by skipping and keyframe reading. This invention segments the speed range using the first and second thresholds, and different methods are used to interpret video frames when the speed value falls within different segmented ranges, improving response speed and optimizing image stuttering. Attached Figure Description
[0039] Figure 1 This is a schematic diagram of an embodiment of a video speed control method according to the present invention;
[0040] Figure 2 This is a schematic diagram of an embodiment of a video speed control system according to the present invention;
[0041] Figure 3 This is a schematic diagram of an embodiment of a video speed control device according to the present invention. Detailed Implementation
[0042] This invention provides a video speed control method, system, device, and storage medium. The terms "first," "second," "third," "fourth," etc. (if applicable) in the specification, claims, and accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be understood in addition to those illustrated herein.
[0043] Or implemented in a sequence other than that described. Furthermore, the terms “comprising” or “having” and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units that are expressly listed, but may include other steps or units that are not expressly listed or that are inherent to such process, method, product, or apparatus.
[0044] See Figure 1 The first aspect of this invention provides a video speed control method, comprising the following steps:
[0045] S100, Receive the speed value set by the user; In this invention, the speed value set by the user can be any speed value selected by the user from the speed options provided in the video playback interface.
[0046] S200. The speed change value is compared with a preset first threshold and a second threshold, wherein the first threshold is less than the second threshold. In this invention, the value range of the first threshold is (0, 2], and the value range of the second threshold is [8, 12]. The purpose of the first threshold and the second threshold is to divide the video speed change interval into three segments, namely, a slow low-speed segment, a medium-speed segment, and a high-speed segment. For example, the first threshold is 1 and the second threshold is 10.
[0047] S300. If the speed change value is less than or equal to the first threshold, speed playback control is achieved by sequentially reading and discarding frames. In this invention, sequentially reading and discarding frames means that after the video enters speed change mode, starting from the current video stream's frame reading time position, each subsequent frame is decoded sequentially, and each decoded frame is compared with the expected time position of the next frame reading to determine whether each decoded frame is a playback frame to be read. This mode is suitable for video speed changes to a slow speed because in the case of slow speed, the span between adjacent playback frames to be read is small, so the number of video frames to be decoded and judged as to whether to discard is small, so the sequential reading and discarding of frames can be adopted.
[0048] S400. If the speed change value is greater than the first threshold and less than the second threshold, then speed playback control is achieved through video seek frame skipping and frame dropping. In this invention, the video seek frame skipping and frame dropping method refers to the method of reading the next frame after the video enters speed change by first changing the reading frame position of the video stream to a key frame near the expected time position of the next reading frame through video seek, and then decoding each subsequent frame from this key frame and determining whether each decoded frame is the playback frame to be read. This mode is suitable for the case of video speed change to medium speed. In the case of medium speed, the span between adjacent playback frames to be read is large, so the number of video frames to be decoded and judged to be discarded is also large. If the sequential frame reading and frame dropping method is still adopted, the decoding and judgment speed will inevitably be slow. However, by using video seek, some video frames that do not need to be decoded can be skipped, thereby speeding up the frame interpretation speed.
[0049] S500. If the speed change value is greater than or equal to the second threshold, speed playback control is achieved by skipping frames to read keyframes. In this invention, skipping frames to read keyframes means changing the reading frame position of the video stream to a keyframe near the expected time position of the next reading frame through video seek, and directly using the keyframe as the playback frame. This mode is suitable for situations where the video speed is changed to high speed. In high-speed cases, the span between adjacent playback frames to be read is very large, so the number of video frames that need to be decoded and judged whether to discard is also very large. If the method of sequentially reading and discarding frames is still adopted, the decoding and judgment speed is even slower. In this mode, the video seek method can also be used, but after obtaining the keyframe, it will not compare the keyframe with the expected time position of the next reading frame. Although this mode has a certain impact on the picture accuracy, it is difficult to perceive in high-speed playback.
[0050] In an optional embodiment of the first aspect of the present invention, the step of implementing variable speed playback control by sequentially reading and dropping frames if the variable speed value is less than or equal to the first threshold includes:
[0051] Entering variable speed playback mode, when reading the next video frame, the expected time position of the next video frame is calculated based on the frame number of the previous video frame, the inter-frame interval of video playback, and the variable speed value. In this invention, each time a video frame is read, the time position t1 and the frame number n1 of this reading are recorded. If it is the first frame, the time position is defined as 0 and the frame number is also 0. For subsequent video frames, for any reading of a video frame, the frame number of the video frame is equal to the reading number of the video frame - 1. For example, the second time a video frame is read, the frame number of the video frame is calculated to be 1, the third time a video frame is read, the frame number of the video frame is calculated to be 2, and so on.
[0052] Specifically, calculating the desired time position of the next video frame based on the frame number of the previous video frame, the inter-frame interval of the video playback, and the speed change value includes: obtaining the frame rate of the video playback from the file information of the video file; calculating the inter-frame interval based on the frame rate and using a preset inter-frame interval calculation formula; and obtaining the desired time position by multiplying the inter-frame interval by the speed change value and (the number of frames + 1). In this step, taking the time position of the previous video frame as t1 and the frame number as n1 as an example, the desired time position of the next video frame is calculated as t2 = (n1 + 1) × i × s, where i represents the inter-frame interval between two frames, which can be calculated from the frame rate, i = 1000 / fps, the frame rate fps can be read from the information of the video file, and s represents the current speed change value.
[0053] The expected time position is compared with the past time position of the previous video frame. If the expected time position is less than or equal to the past time position, the previous video frame is played as the next video frame. In this invention, if the expected time position is less than or equal to the past time position, it means that the previous video frame is also the expected next video frame, and the previous video frame can be played directly. This situation usually occurs when the speed value s is less than 1, that is, when playing at a slow speed.
[0054] If the desired time position is greater than the past time position, then the subsequent video frames of the previous video frame are decoded frame by frame sequentially; for each subsequent video frame decoded, the timestamp of the subsequent video frame is obtained; if the timestamp is less than the desired time position, and the difference between the desired time position and the timestamp is greater than the inter-frame interval, then the subsequent video frame is discarded; if the timestamp is greater than the desired time position, or the difference between the desired time position and the timestamp is less than the inter-frame interval, then the subsequent video frame is played as the next video frame. In general, a video file consists of several video frame data packets ordered by timestamps. In this invention, decoding the subsequent video frames of the previous video frame frame by frame means first finding the timestamp corresponding to the previous video frame in the video file, and then obtaining the video frame data packets after the previous video frame one by one from the video file, decoding them one by one. After decoding one video frame data packet and obtaining the timestamp of the video frame data packet, the timestamp obtained is compared with the expected time position. Based on whether the above conditions are met, it is determined whether the video frame corresponding to the decoded video frame data packet is the next video frame.
[0055] In an optional embodiment of the first aspect of the present invention, the step of implementing variable speed playback control by means of video seek frame skipping and frame dropping if the variable speed value is greater than the first threshold and less than the second threshold includes:
[0056] When entering variable speed playback mode, the expected time position of the next video frame is calculated based on the frame number of the previous video frame, the inter-frame interval of video playback, and the variable speed value each time the next video frame is read. In the case of implementing variable speed playback control through video seek frame skipping and frame dropping, the calculation method of the expected time position is consistent with the calculation method of the expected time position in the variable speed playback control through sequential frame reading and frame dropping.
[0057] Scan the video frame data packets near the desired time position to obtain the key frame data packet closest to the desired time position, and decode the key frame. In the case of implementing variable speed playback control through video seek frame skipping and frame dropping, the difference from sequential frame reading is that decoding no longer starts from the time position of the previous video frame, but jumps to the time position of the key frame data packet obtained based on the desired time position to decode the subsequent video data packets in the video file. This can save some video frame data packets that do not need to be decoded. Since the number of video data packets that need to be decoded is reduced, the comparison rate is improved.
[0058] Starting with the keyframe, subsequent video frames are decoded frame by frame sequentially. For each decoded subsequent video frame, a timestamp is obtained. If the timestamp is less than the expected time position, and the difference between the expected time position and the timestamp is greater than the inter-frame interval, the subsequent video frame is discarded. If the timestamp is greater than the expected time position, or the difference between the expected time position and the timestamp is less than the inter-frame interval, the subsequent video frame is played as the next video frame. In this invention, the method for comparing the playback time of each subsequent video data packet in the video file, obtained by decoding the keyframe data packet based on the expected time position, to determine if the decoded video frame is the expected next video frame is fixed and will not be explained in detail here.
[0059] In an optional embodiment of the first aspect of the present invention, the step of implementing variable speed playback control by skipping frames to interpret keyframes if the variable speed value is greater than or equal to the second threshold includes:
[0060] When entering variable speed playback mode, the expected time position of the next video frame is calculated based on the frame number of the previous video frame, the inter-frame interval of video playback, and the variable speed value each time the next video frame is read. In the case of implementing variable speed playback control by reading keyframes by skipping frames, the calculation method of the expected time position is consistent with the calculation method of the expected time position described in the above two methods, and will not be repeated here.
[0061] Scanning video frame data packets near the desired time position, obtaining the keyframe data packet closest to the desired time position, decoding the keyframe, and using the keyframe as the next video frame for playback. In the case of implementing variable speed playback control by skipping frames to decode keyframes, the difference from implementing variable speed playback control by video seek skipping frames and dropping frames is that it no longer decodes the video frame data packets following the keyframe to further refine the time accuracy between the obtained next video frame and the desired time position.
[0062] To facilitate a better understanding of the technical solution of this invention, the three speed control modes of this invention can be simply understood as follows:
[0063] Scenario 1: When the speed change value s is less than or equal to the first threshold s1, speed playback control is achieved by dropping video frames. Because the speed change value is relatively small, fewer frames need to be dropped, the time consumption is relatively short, the response speed is fast, and it will not cause stuttering issues.
[0064] The specific plan is as follows:
[0065] (1) After each frame is read, record the time position t1 (timestamp of this frame) and the frame number n1. If it is the first frame, the position is 0 and the frame number is 0.
[0066] (2) Calculate the current expected frame reading time position t2=(n1+1)×i×s, where i represents the interval between two frames, which can be calculated from the frame rate, i=1000 / fps, the frame rate fps can be read from the information in the video file, and s represents the current speed change value.
[0067] (3) If t2 is less than or equal to t1, it means that the video frame displayed last time is also the frame expected this time. You can directly return to play. This usually happens when the speed value s is less than 1, that is, when playing slowly.
[0068] (4) If t2 is greater than t1, then read the next frame and decode it to obtain its time position t3. If t3 is less than the expected time position t2 and the difference is greater than i, that is, the interval between the two frames, then discard this frame and continue to obtain the time position of the next frame until this value is greater than t2 or the difference between t2 and t2 is less than i. Then it means that the expected video frame has been found and can be played and displayed.
[0069] Scenario 2: When the speed change value s is greater than the first threshold s1 and less than or equal to the second threshold s2, speed playback control is achieved through seek. Seek refers to changing the position of the current frame read in the audio / video stream. Because as the speed change value increases, the number of video frames that need to be dropped also increases, resulting in longer playback time and potentially causing stuttering issues and desynchronization with the audio, directly changing the current position of the video stream in this case will result in a faster response speed.
[0070] The specific plan is as follows:
[0071] Calculate the current expected frame reading time position t2 in the same way as in case 1.
[0072] t2 is specified as the read frame position of the video stream, but the actual position of the video stream may not necessarily change to t2. This is because after each change in the position of the video stream, decoding should start from the keyframe. Otherwise, complete video frame data cannot be obtained, and the screen will be distorted during playback. Since t2 is not necessarily a keyframe, the video stream will usually change to a keyframe position less than t2.
[0073] Get the time position t3 of the next frame and compare it with t2. If it is less than t2 and the difference is greater than the frame interval i, discard it. Continue until the position of the next frame is greater than t2 or the difference between t2 and i is less than i, then play and display it.
[0074] Although the method of controlling playback speed through seek also requires frame drops in the end, the video stream position will be closer to the desired position after seeking, so the number of dropped frames will be less, and the response speed will be faster.
[0075] Scenario 3: When the speed change value s is greater than the second threshold s2, speed control is achieved by reading keyframes. Because when the speed change value is large, the desired time position is also farther from the current position, so changing the position of the video stream will take more time and more video frames will be dropped, which will significantly reduce the response speed of the entire process. Therefore, the solutions of the previous two scenarios cannot be used.
[0076] However, when the speed change value is large, the picture changes very quickly, the sound changes greatly and it is difficult to identify the specific content. So for users, even if the accuracy of the picture playback is reduced to a certain extent, it is difficult to perceive whether the audio and video are synchronized. Therefore, speed can be achieved by playing key frames.
[0077] Typically, a GOP contains one keyframe. A GOP stands for Group of Images, which consists of a set of video frames with image differences less than a certain threshold. The keyframe is the first frame in this group of images and contains complete information. Other frames directly or indirectly depend on the keyframe. If this keyframe is not decoded, the entire GOP's video frames cannot be decoded to obtain complete information. Therefore, changing the position of the video stream usually involves changing it to the time position of the keyframe. If the keyframe is played directly, there is no need to drop frames, which can greatly improve the response speed. Moreover, since the difference between video frames in a GOP is less than a certain threshold, the accuracy of the image is guaranteed, although it is slightly reduced. After multiple experiments, when the speed change value 's' is greater than 10, it is difficult to perceive differences or desynchronization between audio and video when using this method.
[0078] The specific plan is as follows:
[0079] Calculate the current expected frame reading time position t2 in the same way as in case 1.
[0080] Specify t2 as the read frame position of the video stream, read the frame at the current position of the video stream (replace it with a keyframe near t2; in the special case where there is no keyframe, obtain the video frame at time position t2 in the manner of case 1), and then decode and play it for display.
[0081] See Figure 2 A second aspect of the present invention provides a video speed control system, the video speed control system comprising:
[0082] The speed value receiving module 10 is used to receive the speed value set by the user;
[0083] The gear shift value comparison module 20 is used to compare the gear shift value with a preset first threshold and a second threshold, wherein the first threshold is less than the second threshold;
[0084] The first speed control module 30 is used to implement speed playback control by sequentially reading and dropping frames if the speed value is less than or equal to the first threshold.
[0085] The second speed control module 40 is used to control the playback speed by means of video seek frame skipping and frame dropping if the speed value is greater than the first threshold and less than the second threshold.
[0086] The third speed control module 50 is used to implement speed control by skipping frames and reading keyframes if the speed value is greater than or equal to the second threshold.
[0087] In an optional embodiment of the second aspect of the present invention, the first speed control module 30 includes:
[0088] The first expected time calculation unit is used to enter the variable speed playback mode and calculate the expected time position of the next video frame based on the frame number of the previous video frame, the inter-frame interval of video playback, and the variable speed value each time the next video frame is read.
[0089] The first next video frame determination unit is used to compare the expected time position with the past time position of the previous video frame. If the expected time position is less than or equal to the past time position, the previous video frame is played as the next video frame.
[0090] And it is configured to, if the expected time position is greater than the past time position, sequentially decode the subsequent video frames of the previous video frame frame by frame; for each subsequently video frame decoded, obtain the timestamp of the subsequently video frame; if the timestamp is less than the expected time position, and the difference between the expected time position and the timestamp is greater than the inter-frame interval, then discard the subsequently video frame; if the timestamp is greater than the expected time position, or the difference between the expected time position and the timestamp is less than the inter-frame interval, then play the subsequently video frame as the next video frame.
[0091] In an optional embodiment of the first aspect of the present invention, the second speed control module 40 includes:
[0092] The second expected time position calculation unit is used to enter the variable speed playback mode and calculate the expected time position of the next video frame based on the frame number of the previous video frame, the inter-frame interval of the video playback, and the variable speed value each time the next video frame is read.
[0093] The first keyframe scanning unit is used to scan each video frame data packet near the desired time position, obtain the keyframe data packet closest to the desired time position, and decode the keyframe.
[0094] The second next video frame determination unit is used to decode the subsequent video frames of the key frame sequentially, starting from the key frame. For each subsequent video frame decoded, the timestamp of the subsequent video frame is obtained. If the timestamp is less than the expected time position and the difference between the expected time position and the timestamp is greater than the inter-frame interval, the subsequent video frame is discarded. If the timestamp is greater than the expected time position, or the difference between the expected time position and the timestamp is less than the inter-frame interval, the subsequent video frame is played as the next video frame.
[0095] In an optional embodiment of the first aspect of the present invention, the third speed control module 50 includes:
[0096] The third expected time position calculation unit is used to enter the variable speed playback mode. When reading the next video frame each time, it calculates the expected time position of the next video frame based on the frame number of the previous video frame, the inter-frame interval of the video playback, and the variable speed value.
[0097] The second keyframe scanning unit is used to scan each video frame data packet near the desired time position to obtain the keyframe data packet closest to the desired time position.
[0098] The third next video frame determination unit plays the key frame as the next video frame.
[0099] In an optional embodiment of the second aspect of the present invention, calculating the desired time position of the next video frame based on the frame number of the previous video frame, the inter-frame interval of video playback, and the speed change value includes:
[0100] The frame rate of the video playback is obtained from the file information of the video file;
[0101] The inter-frame interval is calculated based on the frame rate and using a preset inter-frame interval calculation formula.
[0102] The desired time position is obtained by multiplying the inter-frame interval by the speed change value by (the number of frames + 1).
[0103] In an optional embodiment of the second aspect of the present invention, for any single reading of a video frame, the number of frames of the video frame = the number of readings to which the video frame belongs - 1.
[0104] In an optional embodiment of the second aspect of the present invention, the first threshold value ranges from (0, 2], and the second threshold value ranges from [8, 12].
[0105] Figure 3This is a schematic diagram of a video speed control device according to an embodiment of the present invention. The video speed control device can vary significantly due to different configurations or performance characteristics. It may include one or more processors 110 (central processing units, CPUs) (e.g., one or more processors) and memory 120, and one or more storage media 130 (e.g., one or more mass storage devices) for storing application programs or data. The memory and storage media can be temporary or persistent storage. The program stored in the storage media may include one or more modules (not shown in the diagram), each module including a series of instruction operations on the video speed control device. Furthermore, the processor may be configured to communicate with the storage media and execute the series of instruction operations stored in the storage media on the video speed control device.
[0106] The video speed control device of the present invention may further include one or more power supplies 140, one or more wired or wireless network interfaces 150, one or more input / output interfaces 160, and / or one or more operating systems, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc. Those skilled in the art will understand that... Figure 3 The illustrated video speed control device structure does not constitute a specific limitation on the video speed control device of the present invention. It may include more or fewer components than illustrated, or combine certain components, or have different component arrangements.
[0107] The present invention also provides a computer-readable storage medium, which can be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium, wherein the computer-readable storage medium stores instructions that, when the instructions are executed on a computer, cause the computer to perform the steps of the video speed control method.
[0108] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system or system / unit described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0109] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a video speed control device, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0110] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A video speed control method, characterized in that, Includes the following steps: Receives the speed setting set by the user; The speed change value is compared with a preset first threshold and a second threshold, wherein the first threshold is less than the second threshold, the value range of the first threshold is (0, 2], the value range of the second threshold is [8, 12], and the first threshold and the second threshold divide the video speed change range into a slow low speed segment, a medium speed segment and a high speed segment. If the speed change value is less than or equal to the first threshold, speed playback control is achieved by sequentially reading and dropping frames, entering speed playback mode. Each time the next video frame is read, the expected time position of the next video frame is calculated based on the frame number of the previous video frame, the inter-frame interval of the video playback, and the speed change value. The expected time position is compared with the past time position of the previous video frame. If the expected time position is less than or equal to the past time position, the previous video frame is played as the next video frame. If the expected time position is greater than the past time position, the subsequent video frames of the previous video frame are decoded frame by frame. For each decoded subsequent video frame, a timestamp is obtained. If the timestamp is less than the expected time position, and the difference between the expected time position and the timestamp is greater than the inter-frame interval, the subsequent video frame is discarded. If the timestamp is greater than the expected time position, or the difference between the expected time position and the timestamp is less than the inter-frame interval, the subsequent video frame is played as the next video frame. If the speed change value is greater than the first threshold but less than the second threshold, speed playback control is achieved through video seek frame skipping and frame dropping, entering speed playback mode. Each time the next video frame is read, the expected time position of the next video frame is calculated based on the frame number of the previous video frame, the inter-frame interval of the video playback, and the speed change value. The video frame data packets near the expected time position are scanned to obtain the keyframe data packet closest to the expected time position, and the keyframe is decoded. Starting from the keyframe, subsequent video frames are decoded frame by frame sequentially. For each subsequently video frame decoded, its timestamp is obtained. If the timestamp is less than the expected time position, and the difference between the expected time position and the timestamp is greater than the inter-frame interval, the subsequent video frame is discarded. If the timestamp is greater than the expected time position, or the difference between the expected time position and the timestamp is less than the inter-frame interval, the subsequent video frame is played as the next video frame. If the speed change value is greater than or equal to the second threshold, speed playback control is achieved by skipping frames to read keyframes, and the speed playback mode is entered. When reading the next video frame each time, the expected time position of the next video frame is calculated based on the frame number of the previous video frame, the inter-frame interval of video playback, and the speed change value. The video frame data packets near the expected time position are scanned to obtain the keyframe data packet closest to the expected time position, and the keyframe is decoded and played as the next video frame.
2. The video speed control method according to claim 1, characterized in that, The calculation of the desired time position of the next video frame based on the frame number of the previous video frame, the inter-frame interval of video playback, and the speed change value includes: The frame rate of the video playback is obtained from the file information of the video file; The inter-frame interval is calculated based on the frame rate and using a preset inter-frame interval calculation formula. The desired time position is obtained by multiplying the inter-frame interval by the speed change value by (the number of frames + 1).
3. The video speed control method according to claim 2, characterized in that, For any given reading of a video frame, the frame number of the video frame is equal to the number of readings of the video frame minus 1.
4. A video speed control system, characterized in that, The video speed control system includes: The speed change value receiving module is used to receive the speed change value set by the user; The speed comparison module is used to compare the speed value with a preset first threshold and a second threshold, wherein the first threshold is less than the second threshold, the value range of the first threshold is (0, 2], the value range of the second threshold is [8, 12], and the first threshold and the second threshold divide the video speed range into a slow low speed segment, a medium speed segment and a high speed segment. The first speed control module is used to implement speed playback control by sequentially reading and dropping frames if the speed value is less than or equal to the first threshold, and enter the speed playback mode. When reading the next video frame, the module calculates the expected time position of the next video frame based on the frame number of the previous video frame, the inter-frame interval of the video playback, and the speed value. The module compares the expected time position with the past time position of the previous video frame. If the expected time position is less than or equal to the past time position, the module plays the previous video frame as the next video frame. If the desired time position is greater than the past time position, then the subsequent video frames of the previous video frame are decoded frame by frame sequentially; for each subsequent video frame decoded, the timestamp of the subsequent video frame is obtained; if the timestamp is less than the desired time position, and the difference between the desired time position and the timestamp is greater than the inter-frame interval, then the subsequent video frame is discarded; if the timestamp is greater than the desired time position, or the difference between the desired time position and the timestamp is less than the inter-frame interval, then the subsequent video frame is played as the next video frame; The second speed control module is used to implement speed playback control and enter speed playback mode by using video seek frame skipping and frame dropping methods if the speed value is greater than the first threshold and less than the second threshold. When reading the next video frame, it calculates the expected time position of the next video frame based on the frame number of the previous video frame, the inter-frame interval of the video playback, and the speed value; scans the video frame data packets near the expected time position to obtain the keyframe data packet closest to the expected time position and decodes the keyframe; starting from the keyframe, it decodes the subsequent video frames frame by frame, obtaining the timestamp of each subsequent video frame; if the timestamp is less than the expected time position and the difference between the expected time position and the timestamp is greater than the inter-frame interval, the subsequent video frame is discarded; if the timestamp is greater than the expected time position, or the difference between the expected time position and the timestamp is less than the inter-frame interval, the subsequent video frame is played as the next video frame. The third speed control module is used to implement speed playback control by skipping frames and decoding keyframes if the speed value is greater than or equal to the second threshold, and enter the speed playback mode. When reading the next video frame each time, the desired time position of the next video frame is calculated based on the frame number of the previous video frame, the inter-frame interval of video playback, and the speed value; the data packets of each video frame near the desired time position are scanned to obtain the keyframe data packet closest to the desired time position, and the keyframe is decoded and played as the next video frame.
5. A video speed control device, characterized in that, The video speed control device includes: a memory and at least one processor, wherein the memory stores instructions, and the memory and the at least one processor are interconnected via a line; The at least one processor invokes the instructions in the memory to cause the video speed control device to perform the video speed control method as described in any one of claims 1-3.
6. A computer-readable storage medium storing a computer program thereon, characterized in that, When the computer program is executed by the processor, it implements the video speed control method as described in any one of claims 1-3.