Video playback method, device, storage medium and electronic device
By determining the playback method based on the time difference when the video progress bar is dragged, the problem of video cannot be played continuously is solved, and the continuous playback effect of video during the dragging process is achieved.
Patent Information
- Application Number
- CN202411807501.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2044-12-10
AI Technical Summary
During the process of dragging the video progress bar, the video cannot be played continuously, and the existing technology has not yet proposed an effective solution.
When the progress bar of the target video is dragged, the time difference between the target progress position and the current progress position is determined, and whether to play frame by frame or skip frame is determined based on the time difference to ensure the continuity of the video.
It realizes continuous playback of video when dragging the video progress bar, solves the problem that video cannot be continuously played and improves the user experience.
Smart Images

Figure CN119299788B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of communications, and in particular, to a video playback method, device, storage medium and electronic device. Background Art
[0002] In the related art, when the progress bar of a video is dragged, the video cannot be played continuously.
[0003] It can be seen from this that the related art has the problem that the video cannot be played continuously during the process of dragging the video progress bar.
[0004] Currently, no effective solution has been proposed for the above-mentioned problems existing in the related technologies. Summary of the invention
[0005] The embodiments of the present invention provide a video playback method, device, storage medium and electronic device to at least solve the problem in the related art that the video cannot be played continuously during the process of dragging the video progress bar.
[0006] According to one embodiment of the present invention, a method for playing a video is provided, comprising: determining a target progress position to which a progress bar of a target video is moved during dragging of the progress bar; determining a first time difference between the target progress position and a current progress position; when the first time difference is less than a predetermined time difference, determining a first video frame to be played included in the target video, determining a playback speed for playing the first video frame, and playing the first video frame at the playback speed; when the first time difference is greater than or equal to a predetermined time difference, determining a frame to be played included in the target video based on the target progress position, and playing the target video from the frame to be played.
[0007] According to another embodiment of the present invention, a video playback device is provided, comprising: a first determination module, used to determine a target progress position to which a progress bar of a target video is moved during the process of dragging the progress bar; a second determination module, used to determine a first time difference between the target progress position and a current progress position; a first playback module, used to determine a first video frame to be played included in the target video, determine a playback speed for playing the first video frame, and play the first video frame at the playback speed when the first time difference is less than a predetermined time difference; and a second playback module, used to determine a frame to be played included in the target video based on the target progress position, and play the target video from the frame to be played when the first time difference is greater than or equal to the predetermined time difference.
[0008] According to yet another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any one of the above method embodiments when run.
[0009] According to yet another embodiment of the present invention, there is provided an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0010] According to yet another embodiment of the present invention, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps of the method described in each embodiment of the present application are implemented.
[0011] Through the present invention, in the process of dragging the progress bar of the target video, the target progress position to which the progress bar is moved can be determined; and the first time difference between the target progress position and the current progress position can be determined; when the first time difference is less than the predetermined time difference, the first video frame to be played included in the target video is determined, the playing speed of playing the first video frame is determined, and the first video frame is played according to the playing speed; when the first time difference is greater than or equal to the predetermined time difference, the frame to be played included in the target video is determined based on the target progress position, and the target video is played from the frame to be played. Since the first time difference between the target progress position and the current progress position is less than the predetermined time difference, the first video frame can be played at the playing speed to ensure the continuity of the video playback. When the first time difference between the target progress position and the current progress position is greater than or equal to the predetermined time difference, the frame to be played can be determined according to the target progress position, and the target video can be played from the frame to be played to ensure the continuity of the video playback. Therefore, the problem that the video cannot be played continuously during the process of dragging the video progress bar in the related art can be solved, and the effect of playing the video continuously during the process of dragging the video progress bar can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Figure 1 It is a hardware structure block diagram of a mobile terminal of a video playback method according to an embodiment of the present invention;
[0013] Figure 2 is a flowchart of a video playback method according to an embodiment of the present invention;
[0014] Figure 3 is a flow chart of a video playback method according to a specific embodiment of the present invention;
[0015] Figure 4 is a flowchart of short-distance dragging continuous playback according to a specific embodiment of the present invention;
[0016] Figure 5 4 is a structural block diagram of a video playback device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0017] Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings and in combination with the embodiments.
[0018] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0019] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 FIG. 1 is a hardware structure block diagram of a mobile terminal of a video playback method according to an embodiment of the present invention. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the mobile terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0020] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the video playback method in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the mobile terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0021] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0022] In this embodiment, a video playback method is provided. Figure 2 is a flow chart of a video playback method according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:
[0023] Step S202, during the process of dragging the progress bar of the target video, determining the target progress position to which the progress bar is moved;
[0024] In this embodiment, the target video may be an online video, and the target video may be requested through the network to play the target video. The progress bar may be a progress bar displayed in a player that plays the target video. The progress bar may be dragged by a drag operation. The progress bar may be dragged by touching, by clicking with a mouse, a stylus, etc., or by a specific gesture. The target progress position to which the progress bar is moved may be the final position of the drag operation. It may also be the position of the progress bar at the time of triggering the playback operation of the video during the dragging process. For example, the processor may execute the video playback method at a predetermined time interval, and when the predetermined time interval is Δt and the time to start executing the video playback method is t1, the target progress position may be the position of the progress bar at t1+nΔt, where n may be a positive integer.
[0025] Step S204, determining a first time difference between the target progress position and the current progress position;
[0026] In this embodiment, the current progress position may be the position of the progress bar at the time when the dragging operation is started. For example, when the target video is played to t2, the progress bar starts to be dragged, and the current progress position is t2. The target progress position may be t3, and the first time difference may be t3-t2.
[0027] Step S206, when the first time difference is less than a predetermined time difference, determining a first video frame to be played included in the target video, determining a playing speed for playing the first video frame, and playing the first video frame at the playing speed;
[0028] Step S208: When the first time difference is greater than or equal to a predetermined time difference, determine the to-be-played frames included in the target video based on the target progress position, and play the target video from the to-be-played frames.
[0029] In this embodiment, the predetermined time difference may be determined according to the decoding performance of the video player. When the first time difference is less than the predetermined time difference, it indicates that the video to be played does not exceed the decoding capability of the video player, and the first video frame may be played frame by frame. When the first time difference is greater than or equal to the predetermined time difference, it indicates that the video to be played exceeds the decoding capability of the video player, and therefore, the target video may be played in a frame skipping manner.
[0030] In the above embodiment, the position of the expected dragged playback point can be calculated based on the user's dragging distance, that is, the first time difference, and the position offset, that is, the first time difference, can be used to determine whether to use the continuous playback method of fast video decoding or request the I frame (key frame) to play in a second-skipping manner. If the current dragging range is too large, such as more than 5 minutes, it is limited by the decoding performance of the PC machine and cannot be played quickly to the specified position without frame extraction at double speed. Therefore, a critical value will be set internally. If it is less than 16 seconds, the speed control strategy will be used to implement continuous video decoding; if it exceeds 16 seconds, the second-skipping method will be considered to re-request the video starting from the I frame at the expected playback position for playback.
[0031] Through the present invention, in the process of dragging the progress bar of the target video, the target progress position to which the progress bar is moved can be determined; and the first time difference between the target progress position and the current progress position can be determined; when the first time difference is less than the predetermined time difference, the first video frame to be played included in the target video is determined, the playing speed of playing the first video frame is determined, and the first video frame is played according to the playing speed; when the first time difference is greater than or equal to the predetermined time difference, the frame to be played included in the target video is determined based on the target progress position, and the target video is played from the frame to be played. Since the first time difference between the target progress position and the current progress position is less than the predetermined time difference, the first video frame can be played at the playing speed to ensure the continuity of the video playback. When the first time difference between the target progress position and the current progress position is greater than or equal to the predetermined time difference, the frame to be played can be determined according to the target progress position, and the target video can be played from the frame to be played to ensure the continuity of the video playback. Therefore, the problem that the video cannot be played continuously during the process of dragging the video progress bar in the related art can be solved, and the effect of playing the video continuously during the process of dragging the video progress bar can be achieved.
[0032] Optionally, the executor of the above steps may be a background processor, or other devices with similar processing capabilities, or a machine that integrates at least a video playback device and a data processing device, wherein the video playback device may include a video playback module such as a video player, and the data processing device may include terminals such as computers and mobile phones, but is not limited to these.
[0033] In an exemplary embodiment, determining the first video frame to be played included in the target video includes: determining the dragging direction of the progress bar; when the dragging direction is the same as the playback direction of the target video, determining the second video frame from the current progress position to the target progress position, and determining the second video frame as the first video frame; when the dragging direction is opposite to the playback direction of the target video, determining the third video frame located within a preset time period after the current progress position in the playback direction, determining the second video frame from the current progress position to the target progress position, and determining the third video frame and the second video frame as the first video frame. In this embodiment, when the playback direction and the dragging direction are the same, the video frame from the current progress position to the target progress position can be directly determined as the first video frame. When the playback direction is opposite to the dragging direction, to ensure that the picture is smooth and coherent when the dragging direction changes, frame matching logic can be used. The video within a preset time period after this moment (ensuring that the reverse direction gives a stream greater than one GOP unit to ensure no frame skipping) can be requested as the start playback position. If the preset time period is 2s (this value is only an exemplary description, the present invention does not limit the value of the preset time period, and the preset time period can also be 1s, 3s, 5s, etc.), the video playing time period is in the interval [00:00:00~01:59:59], and the current forward playback is to time t, and dragging is performed backward, then the reverse video stream of [t+2, 00:00:00] is requested. If the reverse playback is to time t, and dragging is performed forward, then the forward video stream of [t-2, 01:59:59] is requested. The frame number is judged according to the time returned by the request. When it is close to or equal to the frame number corresponding to time t, the subsequent video stream is sent to the decoding module to ensure the continuity of the video picture.
[0034] In an exemplary embodiment, determining the playback speed of playing the first video frame includes: determining a first duration used to drag the progress bar from the current progress position to the target progress position; determining a second duration of the first video frame; and when the first duration is less than or equal to a preset duration, determining a first ratio of the second duration to the first duration as the playback speed. In this embodiment, the playback speed of each frame of the image included in the first video frame may be the same. If the current progress position is x1, the target progress position is x2, the time when the progress bar starts to be dragged is t1, and the time when it is dragged to the target progress position is t2, then the first duration is Δt=t2-t1, and the second duration is Δx=x2-x1. When the first duration is less than or equal to the preset duration, that is, Δt≤T, the playback speed of each frame of the image v0=Δx / Δt, that is, the playback speed is (x2-x1) / (t2-t1). Wherein, T may represent a preset duration, and the preset duration may be an ideal maximum drag delay, a value determined according to the performance of a video player or a client for playing a video, or a pre-set value.
[0035] In an exemplary embodiment, after determining the second duration of the first video frame, the method further includes: determining a first ratio of the second duration to the first duration when the first duration is greater than a preset duration; determining a second ratio of the preset duration to the first duration; determining a first difference between a first constant and the second ratio; determining a first product of the first difference and a preset compensation speed; and determining a first sum of the first ratio and the first product as the playback speed. In this embodiment, when the first duration is greater than the preset duration, that is, Δt>T, the first ratio can be expressed as v0=Δx / Δt, the second ratio can be expressed as T / Δt, the first difference can be expressed as 1-T / Δt, the preset compensation speed can be expressed as v1, the first product can be expressed as v1(1-T / Δt), and the playback speed can be expressed as v0+ v1(1-T / Δt).
[0036] In an exemplary embodiment, determining the playback speed of the first video frame includes: performing the following operations for any first image frame included in the first video frame to determine the playback sub-speed of the first image frame: determining a second image frame included in the first video frame that is adjacent to the first image frame and is located after the first image frame in the dragging direction of the progress bar, determining a third duration used to drag the progress bar from the first image frame to the second image frame, determining a fourth duration between the first image frame and the second image frame, and when the third duration is less than or equal to a preset duration, determining a third ratio of the fourth duration to the third duration as the playback sub-speed, and when the third duration is greater than a preset duration, determining a fourth ratio of the preset duration to the fourth duration, determining a second difference between a second constant and the fourth ratio, determining a first product of a preset compensation speed and the second difference, and determining a second sum of the first product and the third ratio as the playback sub-speed; and determining the playback sub-speeds of all the first image frames as the playback speed. In this embodiment, the speed of each frame image included in the first video frame can be the same or different. The fourth duration between two adjacent image frames and the third duration used to drag the progress bar from the first image frame to the second image frame can be determined respectively. When the third duration is less than or equal to the preset duration, the third ratio of the fourth duration to the third duration is determined as the playback speed of the first image frame. The first image frame can be any image frame included in the first video frame, and the above operation can be performed for each first image frame to determine the playback speed of each first image frame. For example, the first video frame includes image frames A, B, C, D, and E. When the first image frame is A, the second image frame is B, and when the first image frame is B, the second image frame is C. The fourth duration between the first image frame and the second image frame, such as the fourth duration between A and B, can be determined, and the third duration used to drag the progress bar from A to B can be determined. When the third duration is less than or equal to the preset duration, the ratio of the two is determined as the playback sub-speed.
[0037] In the above embodiment, when the third duration is less than or equal to the preset duration, the playback sub-speed can be determined as v0+v1(1-T / Δt), wherein v0 represents the third ratio, v1 represents the preset compensation speed, T represents the preset duration, and Δt represents the third duration.
[0038] In the above embodiment, determining the playback speed frame by frame can make the playback speed match the dragging speed, so that the video playback effect is better.
[0039] In an exemplary embodiment, determining the frame to be played included in the target video based on the target progress position includes: determining the key frame included in the target video that is closest to the target progress position; and determining the key frame as the frame to be played. In this embodiment, when the first time difference is greater than or equal to the predetermined time difference, it can be determined that the dragging range is large and the current video decoding capability is insufficient to support frame-by-frame playback, so frame skipping can be used for playback. Determine the key frame closest to the target progress position, and start playing the video from the closest key frame.
[0040] In the above embodiment, in order to solve the problem that when the progress bar is dragged for a long distance, the picture cannot reach the user's dragging position in time through speed control, the system switches to the I frame positioning strategy for frame skipping playback (when the progress bar position and the picture position exceed 16s), that is, only the code stream starting from this I frame is pulled from the service for playback.
[0041] In an exemplary embodiment, before playing the first video frame at the playback speed, the method further includes: obtaining the first video frame at a target speed, wherein the target speed is greater than the playback speed. In this embodiment, in order to maintain the smoothness of the picture when the speed is frequently sent down, the video player, such as the client, can only send 16 times or -16 times the speed to the streaming media service according to the direction of dragging and whether the direction changes, so as to achieve the goal of quickly obtaining the video, and the direction does not change and does not repeat the sending, so as to avoid repeated switching of the playback direction and causing system performance problems. At the same time, the decoding speed is calculated based on the mouse drag speed and the relative distance between the progress bar and the millisecond frame time of the picture, and is limited to 16 times the speed (on the one hand, it is ensured that the video stream speed is greater than the playback decoding speed, and on the other hand, the conventional video decoding performance of the PC is generally not higher than 16 times the speed), so as to ensure that the code stream is always sufficient when the picture is dragged for playback, so that the advance amount of the online environment to send the stream is greater than the local decoding requirements.
[0042] It should be noted that the above 16x speed and -16x speed are only exemplary descriptions, and the target speed may also be 8x speed, -8x speed, 32x speed, -32x speed, etc. The present invention does not limit this.
[0043] In an exemplary embodiment, after playing the first video frame at the playback speed, the method further includes: determining the number of image frames included between the image frame being played and the last image frame included in the first video frame; and when the number of image frames is less than a predetermined threshold, obtaining the video included in the target video and located after the first video frame. In this embodiment, when the number of image frames between the image frame being played and the last frame of the first video frame is less than a predetermined threshold, the video after the first video frame can be obtained in advance, thereby ensuring that the code stream is always sufficient when the screen is dragged for playback, so that the advance amount of the online environment stream delivery is greater than the local decoding requirement.
[0044] In the above embodiment, according to the video player, such as the client business design, the program will monitor the event when the recording progress bar drag position changes with a minimum step length of 40ms, and record the current progress bar time and the system current time in this event, respectively calculate the speed requested to the streaming media service and set the decoding speed, so as to control the recording screen to change with the progress bar drag speed. At the same time, the client also needs to detect the playback frame time, which is used to compare the code stream frame time and the expected drag time of the progress bar, and determine whether the playback screen is paused (if it is dragged backward, it will be paused when the code stream frame time ≥ the progress bar time, and if it is dragged forward, it will be paused when the code stream frame time is less than or equal to the progress bar time), so that the picture stops at the correct position, and the difference between the picture after stopping and the progress bar position is close to the frame level (the test video is a 25hz video).
[0045] The following is an explanation of the video playback method in conjunction with a specific implementation method:
[0046] Figure 3 is a flow chart of a video playback method according to a specific embodiment of the present invention. Figure 3 As shown, the process includes:
[0047] Step S302: requesting a video through the network.
[0048] Step S304, drag the play position (corresponding to the above-mentioned dragging progress bar).
[0049] Step S306, determining whether the dragging distance (corresponding to the first time difference) is less than the set number of seconds (corresponding to the predetermined time difference). If the determination result is yes, executing step S308; if the determination result is no, executing step S310.
[0050] Step S308, calculating the offset speed by dragging the position (continuous playback, corresponding to the above step S206).
[0051] Step S310, requesting I frame of video at a specified position (skipping frame playback, corresponding to the above step S208).
[0052] Step S312: video decoding and rendering.
[0053] Figure 4 is a flowchart of short-distance dragging continuous playback according to a specific embodiment of the present invention, such as Figure 4 As shown, the process includes:
[0054] Step S402: the user drags the video progress bar.
[0055] Step S404, determining whether the dragging direction is the same as the playing direction, if they are the same, executing step S406, if they are different, executing step S414.
[0056] Step S406, requesting a same-direction video stream at a double speed.
[0057] Step S408, recording the target dragging time point.
[0058] Step S410, calculating the playback speed based on the dragging distance.
[0059] Step S412: Video decoding and fast playback.
[0060] Step S414, record the current playback position frame number.
[0061] Step S416, requesting the reverse video stream at double speed after 2 seconds.
[0062] Step S418, match the playback position frame number and send the stream.
[0063] Step S420, determine whether to play to the dragging time point, if the judgment result is yes, execute step S422, if the judgment result is no, execute step S412.
[0064] Step S422, pause the playing picture.
[0065] In the above embodiment, according to the client business design, the program will monitor the event when the recording progress bar drag position changes with a minimum step length of 40ms, and record the current progress bar time and the system current time in this event, respectively calculate the speed requested to the streaming media service and set the decoding speed, so as to control the recording screen to change with the progress bar drag speed. At the same time, the client also needs to detect the playback frame time, which is used to compare the code stream frame time and the expected drag time of the progress bar, and determine whether the playback screen is paused (if it is dragged backward, it will be paused when the code stream frame time ≥ the progress bar time, and vice versa), so that the picture stops at the correct position, and the difference between the picture after the stop and the progress bar position is close to the frame level (the test video is 25hz video).
[0066] In order to maintain the smoothness of the picture when sending multiple speeds frequently, the client can send only 16x or -16x speed to the streaming media service according to the direction of dragging and whether the direction changes, so as to achieve the goal of quickly obtaining the video, and do not send it repeatedly if the direction does not change, so as to avoid repeated switching of the playback direction and causing system performance problems. At the same time, the decoding speed is calculated based on the mouse drag speed and the relative distance between the progress bar and the millisecond frame time of the picture, and is limited to 16x speed (on the one hand, it ensures that the video stream speed is greater than the playback decoding speed, and on the other hand, the conventional video decoding performance of the PC is generally not higher than 16x speed), so as to ensure that the bitstream is always sufficient when the picture is dragged for playback, so that the advance amount of the online environment to send the stream is greater than the local decoding requirements.
[0067] To ensure smooth and coherent images when the dragging direction changes, you can use frame matching logic to request the video 2 seconds after this moment (make sure the reverse stream is larger than one GOP unit to ensure no frame skipping) as the start position. For example, if the video is played in the time period [00:00:00~01:59:59] and is currently playing forward to time t and dragging backward, request the reverse video stream of [t+2, 00:00:00]. If it is played backward to time t and dragging forward, request the forward video stream of [t-2, 01:59:59]. The frame number is determined based on the time requested. When it is close to or equal to the frame number corresponding to time t, the subsequent video stream is sent to the decoding module to ensure the continuity of the video image.
[0068] In order to solve the problem that the speed control cannot make the picture reach the user's dragging position in time when the progress bar is dragged for a long distance, the system switches to the I-frame positioning strategy for frame skipping playback (when the progress bar position and the picture position are more than 16 seconds apart), that is, only the code stream starting from this I frame is pulled from the service for playback.
[0069] For h264 2k / h265 4k videos, the dragging speed is smooth within 16 times (note that the 3D performance of the graphics card is different from the video decoding performance). The dragging and coherent effect of the recorded video can give users a more friendly interaction, improve user viewing efficiency, and enhance product user experience.
[0070] In the aforementioned embodiment, the method of controlling the speed change to achieve continuous dragging of the recorded video screen is used, and then the frame time comparison method is used to ensure that the screen stops near the dragging position, thereby achieving a frame-level recording dragging experience. The method of using a stream pulling speed greater than the playback speed and a method of not repeatedly sending speed control signals to the platform in the same direction ensures sufficient flow during the dragging process, improves the smoothness of the dragging screen, and reduces the pressure and error probability of the service responding to the speed change signal. When the video is dragged in the opposite direction, the frame number matching method is used to ensure the continuity of the screen connection, and the phenomenon of screen jump seconds will not occur.
[0071] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0072] In the present embodiment, a video playback device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0073] Figure 5 is a structural block diagram of a video playback device according to an embodiment of the present invention. Figure 5 As shown, the device comprises:
[0074] A first determining module 52, configured to determine a target progress position to which the progress bar is moved when the progress bar of the target video is dragged;
[0075] A second determining module 54, configured to determine a first time difference between the target progress position and the current progress position;
[0076] A first playback module 56 is configured to determine a first video frame to be played included in the target video, determine a playback speed for playing the first video frame, and play the first video frame at the playback speed when the first time difference is less than a predetermined time difference;
[0077] The second playing module 58 is used to determine the to-be-played frames included in the target video based on the target progress position and play the target video from the to-be-played frames when the first time difference is greater than or equal to a predetermined time difference.
[0078] In an exemplary embodiment, the first playback module 56 can determine the first video frame to be played included in the target video in the following manner: determine the dragging direction of the progress bar; when the dragging direction is the same as the playback direction of the target video, determine the second video frame between the current progress position and the target progress position, and determine the second video frame as the first video frame; when the dragging direction is opposite to the playback direction of the target video, determine the third video frame within a preset time period after the current progress position in the playback direction, determine the second video frame between the current progress position and the target progress position, and determine the third video frame and the second video frame as the first video frame.
[0079] In an exemplary embodiment, the first playback module 56 can determine the playback speed of the first video frame in the following manner: determine a first duration used to drag the progress bar from the current progress position to the target progress position; determine a second duration of the first video frame; and when the first duration is less than or equal to a preset duration, determine a first ratio of the second duration to the first duration as the playback speed.
[0080] In an exemplary embodiment, the device can be used to determine a first ratio of the second duration to the first duration after determining the second duration of the first video frame, if the first duration is greater than a preset duration; determine a second ratio of the preset duration to the first duration; determine a first difference between a first constant and the second ratio; determine a first product of the first difference and a preset compensation speed; and determine a first sum of the first ratio and the first product as the playback speed.
[0081] In an exemplary embodiment, the first playback module 56 can determine the playback speed of the first video frame in the following manner: perform the following operations for any first image frame included in the first video frame to determine the playback sub-speed of the first image frame: determine a second image frame included in the first video frame that is adjacent to the first image frame and is located after the first image frame in the dragging direction of the progress bar, determine a third duration used to drag the progress bar from the first image frame to the second image frame, determine a fourth duration between the first image frame and the second image frame, and when the third duration is less than or equal to a preset duration, determine a third ratio of the fourth duration to the third duration as the playback sub-speed; when the third duration is greater than the preset duration, determine a fourth ratio of the preset duration to the fourth duration, determine a second difference between a second constant and the fourth ratio, determine a first product of a preset compensation speed and the second difference, and determine a second sum of the first product and the third ratio as the playback sub-speed; determine the playback sub-speed of all the first image frames as the playback speed.
[0082] In an exemplary embodiment, the second playback module 58 can determine the frame to be played included in the target video based on the target progress position in the following manner: determine the key frame included in the target video that is closest to the target progress position; and determine the key frame as the frame to be played.
[0083] In an exemplary embodiment, the apparatus may be configured to acquire the first video frame at a target speed before playing the first video frame at the playing speed, wherein the target speed is greater than the playing speed.
[0084] In an exemplary embodiment, the device can also be used to determine the number of image frames between the image frame being played and the last image frame included in the first video frame after playing the first video frame at the playback speed; when the number of image frames is less than a predetermined threshold, obtain the video included in the target video and located after the first video frame.
[0085] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0086] An embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0087] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0088] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0089] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0090] An embodiment of the present invention further provides a computer program product, including a computer program, which implements the steps of the method in each embodiment of the present application when the computer program is executed by a processor.
[0091] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0092] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0093] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A video playback method, characterized in that: include: During the process of dragging the progress bar of the target video, determining the target progress position to which the progress bar is moved; Determining a first time difference between the target progress position and the current progress position; In the case where the first time difference is less than a predetermined time difference, determining a first video frame to be played included in the target video, determining a playback speed for playing the first video frame, and playing the first video frame in a frame-by-frame manner and at the playback speed, wherein the predetermined time difference is determined based on a decoding performance of a video player; In a case where the first time difference is greater than or equal to a predetermined time difference, determining a to-be-played frame included in the target video based on the target progress position, and playing the target video from the to-be-played frame in a frame skipping playback manner; Determining the playback speed of the first video frame includes: determining a first duration used to drag the progress bar from the current progress position to the target progress position; determining a second duration of the first video frame; and when the first duration is less than or equal to a preset duration, determining a first ratio of the second duration to the first duration as the playback speed; or, The following operations are performed for any first image frame included in the first video frame to determine the playback sub-speed of playing the first image frame: determine a second image frame included in the first video frame that is adjacent to the first image frame and is located after the first image frame in the dragging direction of dragging the progress bar, determine a third duration used to drag the progress bar from the first image frame to the second image frame, determine a fourth duration between the first image frame and the second image frame, and when the third duration is less than or equal to a preset duration, determine a third ratio of the fourth duration to the third duration as the playback sub-speed, and when the third duration is greater than a preset duration, determine a fourth ratio of the preset duration to the fourth duration, determine a second difference between a second constant and the fourth ratio, determine a first product of a preset compensation speed and the second difference, and determine a second sum of the first product and the third ratio as the playback sub-speed; and determine the playback sub-speeds of all the first image frames as the playback speed.
2. The method according to claim 1, characterized in that Determining a first video frame to be played included in the target video includes: Determine the dragging direction of the progress bar; In a case where the dragging direction is the same as the play direction of the target video, determining a second video frame between the current progress position and the target progress position, and determining the second video frame as the first video frame; When the dragging direction is opposite to the playback direction of the target video, determine a third video frame within a preset time period after the current progress position in the playback direction, determine a second video frame between the current progress position and the target progress position, and determine the third video frame and the second video frame as the first video frame.
3. The method according to claim 1, characterized in that After determining the second duration of the first video frame, the method further includes: When the first duration is greater than a preset duration, determining a first ratio of the second duration to the first duration; Determining a second ratio of the preset duration to the first duration; determining a first difference between a first constant and the second ratio; Determine a first product of the first difference and a preset compensation speed; A first sum of the first ratio and the first product is determined as the play speed.
4. The method according to claim 1, characterized in that: Determining the to-be-played frames included in the target video based on the target progress position includes: Determine a key frame included in the target video that is closest to the target progress position; The key frame is determined as the frame to be played.
5. The method according to claim 1, characterized in that Before playing the first video frame at the playing speed, the method further includes: The first video frame is acquired at a target speed, wherein the target speed is greater than the playback speed.
6. The method according to claim 1, characterized in that After playing the first video frame at the playing speed, the method further includes: Determine the number of image frames included between the image frame being played and the last image frame included in the first video frame; When the number of image frames is less than a predetermined threshold, a video included in the target video and located after the first video frame is acquired.
7. A video playback device, characterized in that: include: A first determining module, used to determine a target progress position to which the progress bar is moved when the progress bar of the target video is dragged; A second determining module, configured to determine a first time difference between the target progress position and the current progress position; A first playback module, configured to determine a first video frame to be played included in the target video, determine a playback speed for playing the first video frame, and play the first video frame in a frame-by-frame manner and at the playback speed, when the first time difference is less than a predetermined time difference, wherein the predetermined time difference is determined based on a decoding performance of a video player; A second playback module is configured to determine, when the first time difference is greater than or equal to a predetermined time difference, a to-be-played frame included in the target video based on the target progress position, and to play the target video from the to-be-played frame in a frame skipping playback manner; The first playback module determines the playback speed of the first video frame by: determining a first duration used to drag the progress bar from the current progress position to the target progress position; determining a second duration of the first video frame; and when the first duration is less than or equal to a preset duration, determining a first ratio of the second duration to the first duration as the playback speed; or, The following operations are performed for any first image frame included in the first video frame to determine the playback sub-speed of playing the first image frame: determine a second image frame included in the first video frame that is adjacent to the first image frame and is located after the first image frame in the dragging direction of dragging the progress bar, determine a third duration used to drag the progress bar from the first image frame to the second image frame, determine a fourth duration between the first image frame and the second image frame, and when the third duration is less than or equal to a preset duration, determine a third ratio of the fourth duration to the third duration as the playback sub-speed, and when the third duration is greater than a preset duration, determine a fourth ratio of the preset duration to the fourth duration, determine a second difference between a second constant and the fourth ratio, determine a first product of a preset compensation speed and the second difference, and determine a second sum of the first product and the third ratio as the playback sub-speed; and determine the playback sub-speeds of all the first image frames as the playback speed.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the method according to any one of claims 1 to 6 when executed.
9. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method described in any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Video positioning playing method and device
CN107801100A