A video playing method, device and storage medium
By pre-downloading the keyframe list file and directly reading and decoding the keyframes from it during the progress bar drag event, the problem of excessively long video buffering time was solved, thus improving the user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TENCENT MUSIC ENTERTAINMENT TECH (SHENZHEN) CO LTD
- Filing Date
- 2023-11-09
- Publication Date
- 2026-07-24
AI Technical Summary
During video playback, when the user drags the progress bar, the seek point is not in the keyframe, causing excessively long video buffering time.
Download the keyframe list file in advance, and read the corresponding keyframes from the downloaded keyframe list file for decoding and playback when the progress bar is dragged.
This reduces video buffering time and improves the user's viewing experience.
Smart Images

Figure CN117459799B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of video playback, and in particular to a video playback method, device, and storage medium. Background Technology
[0002] During video playback, regardless of the chosen video format, each format contains several keyframes. Since each keyframe contains all the data for that frame and can be decoded independently, the video decoder can only begin decoding from a keyframe. If the user drags the video progress bar, causing a seek, and assuming the seek point is not a keyframe, the decoder needs to find the nearest previous keyframe and begin decoding from that keyframe until the seek point is reached. However, this involves two steps: first, downloading streaming media data from the nearest keyframe until the seek point; second, decoding from the nearest keyframe until the seek point before buffering is complete and playback resumes. This process can easily lead to long buffering times. Summary of the Invention
[0003] In view of this, the purpose of this invention is to provide a video playback method, device, and storage medium that can pre-download a keyframe list file so that when a progress bar dragging event occurs, the corresponding keyframes can be directly read from the downloaded keyframe list file and decoded for playback, reducing video buffering time and improving the user viewing experience. The specific solution is as follows:
[0004] Firstly, this application provides a video playback method, including:
[0005] When a video playback request for the target video file is detected, a first download event for the keyframe list file is triggered; the keyframe list file is used to record each keyframe in the target video file.
[0006] If a progress bar dragging event is detected during video playback, the corresponding drag end point is determined on the video progress bar of the target video file;
[0007] If the downloaded keyframe list file corresponding to the first download event already contains the target keyframe corresponding to the drag end point, then the target keyframe is read from the downloaded keyframe list file; the target keyframe is the keyframe in the target video file that is closest to the drag end point and whose timestamp is less than or equal to the drag end point timestamp.
[0008] Based on the read target keyframe, a target decoding process and video playback operation corresponding to the progress bar drag event are triggered; the target decoding process is a decoding process with the target keyframe as the decoding start frame.
[0009] Optionally, before triggering the first download event for the keyframe list file, the method further includes:
[0010] The original video file is encoded by a backend server to obtain the target video file, and a keyframe list file is generated based on each keyframe extracted from the target video file and its corresponding timestamp.
[0011] Optionally, generating the keyframe list file based on each keyframe extracted from the target video file and its corresponding timestamp includes:
[0012] Determine the current video frame to be decoded from all video frames of the target video file;
[0013] Decode the current video frame to be decoded to obtain the video frame description information corresponding to the current video frame to be decoded;
[0014] The video frame type of the current video frame to be decoded is determined based on the video frame description information corresponding to the current video frame to be decoded. If the video frame type of the current video frame to be decoded is a keyframe, the current video frame to be decoded and the corresponding timestamp are saved to the keyframe list file.
[0015] The next video frame in the target video file is identified as the current video frame to be decoded, and the process jumps back to the step of decoding the current video frame to be decoded until all video frames in the target video file have been decoded.
[0016] Optionally, determining the video frame type of the current video frame to be decoded based on the video frame description information corresponding to the current video frame to be decoded includes:
[0017] The video frame identifier corresponding to the current video frame to be decoded is determined based on the bit information contained in the video frame description information.
[0018] If the video frame identifier corresponding to the current video frame to be decoded is consistent with the pre-configured keyframe identifier, then the video frame type of the current video frame to be decoded is determined as a keyframe.
[0019] If the video frame identifier corresponding to the current video frame to be decoded is inconsistent with the pre-configured key frame identifier, then the video frame type of the current video frame to be decoded is determined to be a non-key frame.
[0020] Optionally, determining the video frame identifier corresponding to the current video frame to be decoded based on the bit information contained in the video frame description information includes:
[0021] Based on a preset number system conversion rule, the target bit information corresponding to the pre-specified bit in the video frame description information is converted to a new number system to obtain the converted value corresponding to the current video frame to be decoded.
[0022] The converted value corresponding to the current video frame to be decoded is determined as the video frame identifier corresponding to the current video frame to be decoded.
[0023] Optionally, after detecting a video playback request for the target video file, the method further includes:
[0024] Trigger a second download event for the target video file;
[0025] Accordingly, the target decoding process and video playback operation triggered based on the read target keyframe and the progress bar drag event include:
[0026] The first decoding process is triggered to decode the read target keyframe, and the decoded keyframe is displayed as an image.
[0027] If the downloaded video frame file corresponding to the second download event already contains the subsequent video frame corresponding to the target keyframe, then a second decoding process is triggered to decode the subsequent video frames sequentially according to the timestamp order, and video playback is performed when the decoding progress of the second decoding process reaches the target video frame corresponding to the drag end point.
[0028] Optionally, the first download event and the second download event are events triggered by an asynchronous thread.
[0029] Optionally, after determining the corresponding drag end point on the video progress bar of the target video file, the method further includes:
[0030] If the downloaded video frame file corresponding to the second download event already contains the target video frame corresponding to the drag end point, then determine the target keyframe from the downloaded video frame file that is closest to the drag end point and whose timestamp is less than or equal to the drag end point timestamp.
[0031] The target keyframe is decoded, and the decoded keyframe is displayed as an image.
[0032] The subsequent video frames corresponding to the target keyframe are decoded sequentially according to the timestamp order, and the video is played when the target video frame is decoded.
[0033] Secondly, this application provides an electronic device, comprising:
[0034] Memory, used to store computer programs;
[0035] A processor for executing the computer program to implement the aforementioned video playback method.
[0036] Thirdly, this application provides a computer-readable storage medium for storing a computer program, which, when executed by a processor, implements the aforementioned video playback method.
[0037] In this application, when a video playback request for a target video file is detected, a first download event for a keyframe list file is triggered; the keyframe list file is used to record each keyframe in the target video file; if a progress bar drag event is detected during video playback, a corresponding drag end point is determined on the video progress bar of the target video file; if the downloaded keyframe list file corresponding to the first download event already contains the target keyframe corresponding to the drag end point, the target keyframe is read from the downloaded keyframe list file; the target keyframe is the keyframe in the target video file that is closest to the drag end point and whose timestamp is less than or equal to the timestamp of the drag end point; based on the read target keyframe, a target decoding process and a video playback operation corresponding to the progress bar drag event are triggered; the target decoding process is a decoding process that uses the target keyframe as the decoding start frame. Therefore, when this application detects a video playback request for the target video file, it begins downloading a pre-generated keyframe list file that records all keyframes in the target video file. This allows it to directly locate the target keyframe corresponding to the end point of the drag when a progress bar drag event occurs, thus directly decoding and displaying the target keyframe. Since keyframes contain all the data of that frame of video, real-time keyframe download is time-consuming. Therefore, by downloading keyframes in advance and decoding them directly when needed, the time spent downloading keyframes when a progress bar drag event occurs is saved, reducing video buffering time and improving the user's viewing experience. Attached Figure Description
[0038] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0039] Figure 1A schematic diagram of the system framework applicable to the video playback method disclosed in this application;
[0040] Figure 2 This is a flowchart of a video playback method disclosed in this application;
[0041] Figure 3 This is a flowchart of a keyframe determination method disclosed in this application;
[0042] Figure 4 This application discloses a video playback flowchart;
[0043] Figure 5 This is a flowchart of a specific video playback method disclosed in this application;
[0044] Figure 6 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation
[0045] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0046] During video playback, if the user drags the video progress bar, causing a seek, and assuming the seek point is not a keyframe, the nearest preceding keyframe needs to be found. The video then needs to be downloaded and decoded from this keyframe until the seek point is reached, completing video buffering and resuming playback. This process suffers from a long buffering wait time. To address this, this application provides a video playback method that pre-downloads a keyframe list file. When a progress bar dragging event occurs, the corresponding keyframe is directly read from the downloaded keyframe list file and decoded for playback, reducing buffering time and improving the user viewing experience.
[0047] The system framework used in the video playback method of this application can be found in [reference needed]. Figure 1 As shown, it may specifically include: client 01 and backend server 02 that establishes a communication connection with client 01.
[0048] In this application, the client 01 is used to execute the steps of the video playback method, including triggering a first download event for a keyframe list file when a video playback request for a target video file is detected; wherein, the keyframe list file is used to record each keyframe in the target video file; if a progress bar drag event is detected during video playback, the corresponding drag end point is determined on the video progress bar of the target video file; if the downloaded keyframe list file corresponding to the first download event already contains the target keyframe corresponding to the drag end point, the target keyframe is read from the downloaded keyframe list file; wherein, the target keyframe is the keyframe in the target video file that is closest to the drag end point and whose timestamp is less than or equal to the timestamp of the drag end point; and triggering a target decoding process and a video playback operation corresponding to the progress bar drag event based on the read target keyframe; wherein, the target decoding process is a decoding process with the target keyframe as the decoding start frame.
[0049] Furthermore, when client 01 detects a video playback request for the target video file, it triggers a first download event for the keyframe list file and a second download event for the target video file. Prior to this, the original video file needs to be pre-obtained through backend server 02 and encoded to obtain the target video file. Then, a keyframe list file is generated based on the keyframes extracted from the target video file and their corresponding timestamps. When backend server 02 receives the download request from client 01, it sends the target video file and the corresponding keyframe list file to client 01; that is, client 01 downloads the target video file and the corresponding keyframe list file from backend server 02.
[0050] See Figure 2 As shown, an embodiment of the present invention discloses a video playback method, including:
[0051] Step S11: When a video playback request for the target video file is detected, a first download event for the keyframe list file is triggered; the keyframe list file is used to record each keyframe in the target video file.
[0052] In this embodiment, the user clicks on the desired video on the client's interactive interface. Simultaneously, the client obtains a video playback request for the target video file through a preset interface. When the client detects the video playback request for the target video file, it triggers not only a first download event for the keyframe list file (which records all keyframes in the target video file) but also a second download event for the target video file itself. It should be noted that the first and second download events for the keyframe list file and the target video file are triggered asynchronously, meaning that the download operations for both can be performed simultaneously. Furthermore, both the target video file and the keyframe list file are downloaded while the video is playing; they do not need to be fully downloaded before playback begins. This asynchronous thread-triggered download of the first and second download events for the keyframe list file improves download speed, reduces video buffering time, and ensures a balance between bandwidth consumption and buffering time.
[0053] In this embodiment, before triggering the first download event for the keyframe list file and the second download event for the target video file, the original video file needs to be encoded in advance by the backend server to obtain the target video file. A keyframe list file is then generated based on the keyframes extracted from the target video file and their corresponding timestamps. It is understood that the backend server obtains the original video file in advance and encodes it to acquire information about each video frame, such as the timestamp and frame type, to obtain the encoded target video file. Further, the backend server extracts all keyframes and their corresponding timestamps from the target video file to encode them into a single keyframe list file; and stores the target video file and the corresponding keyframe list file.
[0054] The process of generating a keyframe list file based on keyframes extracted from the target video file and their corresponding timestamps can include: determining the current video frame to be decoded from all video frames in the target video file; decoding the current video frame to obtain its corresponding video frame description information; determining the video frame type of the current video frame based on its description information; if the video frame type is a keyframe, saving the current video frame and its corresponding timestamp to the keyframe list file; determining the next video frame in the target video file as the current video frame to be decoded, and then returning to the previous steps of decoding the current video frame, until all video frames in the target video file have been decoded. It is understood that, as... Figure 3 As shown, the backend server opens the target video file and first identifies the first video frame among all video frames in the target video file as the current video frame to be decoded. Decoding the current video frame yields its corresponding video frame description information. Based on this description information, the server determines whether the video frame type is a keyframe. If the video frame type is not a keyframe, the next video frame in the target video file is identified as the new current video frame to be decoded, and the process returns to the previous steps of decoding the current video frame until all video frames in the target video file have been decoded. A non-keyframe only contains the difference data between this video frame and the previous video frame. If the video frame type is a keyframe, the current video frame and its corresponding timestamp are saved to a keyframe list file. Then, the next video frame in the target video file is identified as the new current video frame to be decoded, and the process returns to the previous steps of decoding the current video frame until all video frames in the target video file have been decoded.
[0055] In this embodiment, triggering the first download event for the keyframe list file and the second download event for the target video file specifically includes: the client sending a first download request for the keyframe list file and a second download request for the target video file to the backend server. Upon receiving the first and second download requests, the backend server sends the keyframe list file corresponding to the first download request and the target video file corresponding to the second download request to the client; that is, the client downloads the target video file and the keyframe list file from the backend server.
[0056] Step S12: If a progress bar dragging event is detected during video playback, determine the corresponding drag end point on the video progress bar of the target video file.
[0057] In this embodiment, if a user drags the video progress bar through the client's interactive interface during video playback, that is, if the client detects the progress bar drag event through a preset interface in the interactive interface, then the current video playback is paused when the progress bar drag ends, and the drag end point corresponding to the progress bar drag event is determined on the video progress bar of the target video file; wherein, the progress bar drag event can be either a progress bar forward event or a progress bar backward event.
[0058] It should be noted that if no progress bar dragging event is detected during video playback, the video frames in the target video file are downloaded in the order of timestamps, the downloaded video frames are decoded, and the decoded video frames are rendered and displayed.
[0059] Step S13: If the downloaded keyframe list file corresponding to the first download event already contains the target keyframe corresponding to the drag end point, then read the target keyframe from the downloaded keyframe list file; the target keyframe is the keyframe in the target video file that is closest to the drag end point and whose timestamp is less than or equal to the drag end point timestamp.
[0060] In this embodiment, after a progress bar drag event occurs, if the downloaded video frame file corresponding to the second download event does not contain the target video frame corresponding to the drag end point (i.e., the target video frame corresponding to the drag end point has not yet been downloaded in the second download event for the target video file), then the target keyframe closest to the drag end point and with a timestamp less than or equal to the drag end point's timestamp is determined from the target video file, and it is determined whether the downloaded keyframe list file corresponding to the first download event contains the target keyframe. If the downloaded keyframe list file corresponding to the first download event does not contain the target keyframe (i.e., the target keyframe has not yet been downloaded in the first download event for the keyframe list file), then the target keyframe and subsequent video frames in the target video file are downloaded and decoded according to their timestamp order, and video playback is resumed when the target video frame corresponding to the drag end point is decoded. If the downloaded keyframe list file corresponding to the first download event already contains the target keyframe, then the target keyframe is directly read from the downloaded keyframe list file. In this way, by directly reading the target keyframe that is closest to the end of the drag and whose timestamp is no greater than the end of the drag, the problem of long video buffering time caused by downloading keyframes after the progress bar drag event can be alleviated.
[0061] It should be noted that if the downloaded video frame file corresponding to the second download event already contains the target video frame corresponding to the drag end point, then the target keyframe closest to the drag end point and with a timestamp less than or equal to the drag end point's timestamp is found in the downloaded video frame file. This target keyframe is then decoded to obtain a decoded keyframe, which is then rendered and displayed so that the user can see the video frame change immediately, improving the user's viewing experience. Furthermore, subsequent video frames corresponding to the target keyframe are decoded in chronological order of their timestamps, and video playback resumes when the target video frame corresponding to the drag end point is decoded.
[0062] Step S14: Based on the read target keyframe, trigger the target decoding process and video playback operation corresponding to the progress bar drag event; the target decoding process is a decoding process with the target keyframe as the decoding start frame.
[0063] In this embodiment, after reading the target keyframe from the downloaded keyframe list file corresponding to the first download event, the read target keyframe is decoded, and the decoded keyframe is displayed as an image. This allows the user to see the video immediately when the progress bar dragging operation ends, improving the user's video viewing experience. Furthermore, if the downloaded video frame file corresponding to the second download event already contains subsequent video frames corresponding to the target keyframe, these subsequent video frames are decoded sequentially according to their timestamps, and video playback resumes when the decoding progress reaches the target video frame corresponding to the drag end point.
[0064] like Figure 4As shown, when a video playback request for the target video file is detected, a first download event for the keyframe list file and a second download event for the target video file are triggered. If a progress bar drag event is detected during video playback, i.e., a seek event is detected, the current video playback is paused, and the corresponding drag end point is determined on the video progress bar of the target video file, i.e., the current seek time point is determined. Then, the target keyframe closest to the drag end point and with a timestamp less than or equal to the drag end point's timestamp is determined from the target video file, and it is checked whether the target keyframe is contained in the downloaded keyframe list file corresponding to the first download event. If it is not contained, the target keyframe and subsequent video frames in the target video file are downloaded and decoded sequentially according to their timestamps, and video playback is resumed when the target video frame corresponding to the drag end point is decoded. If it is contained, the target keyframe is read from the downloaded keyframe list file corresponding to the first download event, decoded, and the decoded keyframe is displayed as an image. Then, when the downloaded video frame file corresponding to the second download event contains subsequent video frames corresponding to the target keyframe, the subsequent video frames corresponding to the target keyframe are decoded sequentially according to the timestamp order, and video playback is resumed when the decoding progress reaches the target video frame corresponding to the end point of the drag, thus completing this seek.
[0065] Therefore, when this application detects a video playback request for the target video file, it begins downloading a pre-generated keyframe list file that records all keyframes in the target video file. This allows it to directly locate the target keyframe corresponding to the end point of the drag when a progress bar drag event occurs, thus directly decoding and displaying the target keyframe. Since keyframes contain all the data of that frame of video, real-time keyframe download is time-consuming. Therefore, by downloading keyframes in advance and decoding them directly when needed, the time spent downloading keyframes when a progress bar drag event occurs is saved, reducing video buffering time and improving the user's viewing experience.
[0066] As can be seen from the previous embodiment, this application describes how to quickly resume the overall process of video playback when a progress bar dragging event is detected during video playback. Next, this application will elaborate on how to determine whether the video frame type corresponding to the video frame in the target video file is a keyframe.
[0067] See Figure 5 As shown, this embodiment of the invention discloses a keyframe determination process, including:
[0068] Step S21: Determine the video frame identifier corresponding to the current video frame to be decoded based on the bit information contained in the video frame description information.
[0069] In this embodiment, when the background server performs H.264 encoding on the original video file to obtain the target video file, the client determines the current video frame to be decoded from all video frames contained in the target video file, and decodes the current video frame to obtain the video frame description information corresponding to the current video frame to be decoded. This video frame description information is the Network Abstract Layer (NAL) unit. Then, the client determines the video frame identifier corresponding to the current video frame to be decoded based on the bit information contained in the video frame description information. Specifically, the target bit information corresponding to the lower five bits in the video frame description information is converted to decimal to obtain the converted value corresponding to the current video frame to be decoded, and this converted value is determined as the video frame identifier corresponding to the current video frame to be decoded.
[0070] Step S22: If the video frame identifier corresponding to the current video frame to be decoded is consistent with the pre-configured keyframe identifier, then the video frame type of the current video frame to be decoded is determined as a keyframe.
[0071] In this embodiment, by pre-configuring the keyframe identifier as 5, if it is found that the video frame identifier corresponding to the current video frame to be decoded is consistent with the pre-configured keyframe identifier "5", then the video frame type corresponding to the current video frame to be decoded is determined as a keyframe.
[0072] Step S23: If the video frame identifier corresponding to the current video frame to be decoded is inconsistent with the pre-configured key frame identifier, then the video frame type of the current video frame to be decoded is determined to be a non-key frame.
[0073] In this embodiment, if the video frame identifier corresponding to the current video frame to be decoded is found to be inconsistent with the pre-configured keyframe identifier "5", then the video frame type corresponding to the current video frame to be decoded is determined to be a non-keyframe. It should be noted that the method for determining whether a video frame type is a keyframe for video files obtained through other encoding methods is similar.
[0074] Therefore, this application extracts all keyframes from the target video file and constructs a keyframe list file based on all keyframes. When a video playback request for the target video file is detected, the keyframe list file is downloaded immediately. Thus, when a progress bar dragging event occurs during video playback, the target keyframe corresponding to the drag end point can be directly found from the downloaded keyframe list file, and the target keyframe can be directly decoded and rendered. This saves the time of downloading keyframes when a progress bar dragging event occurs, reduces video buffering time, and improves the user's viewing experience.
[0075] Furthermore, embodiments of this application also disclose an electronic device, Figure 6 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.
[0076] Figure 6 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the video playback method disclosed in any of the foregoing embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0077] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0078] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0079] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the video playback method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include a computer program capable of performing other specific tasks.
[0080] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned disclosed video playback method. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0081] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0082] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0083] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0084] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0085] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A video playback method, characterized in that, include: When a video playback request for the target video file is detected, the first download event for the keyframe list file is triggered. The keyframe list file is used to record each keyframe in the target video file; If a progress bar dragging event is detected during video playback, the corresponding drag end point is determined on the video progress bar of the target video file; If the downloaded keyframe list file corresponding to the first download event already contains the target keyframe corresponding to the drag end point, then the target keyframe is read from the downloaded keyframe list file. The target keyframe is the keyframe in the target video file that is closest to the end point of the drag and has a timestamp that is less than or equal to the timestamp of the end point of the drag. Based on the read target keyframe, trigger the target decoding process and video playback operation corresponding to the progress bar drag event; The target decoding process is a decoding process that takes the target keyframe as the decoding start frame.
2. The video playback method according to claim 1, characterized in that, Before triggering the first download event for the keyframe list file, the following is also included: The original video file is encoded by a backend server to obtain the target video file, and a keyframe list file is generated based on each keyframe extracted from the target video file and its corresponding timestamp.
3. The video playback method according to claim 2, characterized in that, The process of generating the keyframe list file based on each keyframe extracted from the target video file and its corresponding timestamp includes: Determine the current video frame to be decoded from all video frames of the target video file; Decode the current video frame to be decoded to obtain the video frame description information corresponding to the current video frame to be decoded; The video frame type of the current video frame to be decoded is determined based on the video frame description information corresponding to the current video frame to be decoded. If the video frame type of the current video frame to be decoded is a keyframe, the current video frame to be decoded and the corresponding timestamp are saved to the keyframe list file. The next video frame in the target video file is identified as the current video frame to be decoded, and the process jumps back to the step of decoding the current video frame to be decoded until all video frames in the target video file have been decoded.
4. The video playback method according to claim 3, characterized in that, Determining the video frame type of the current video frame to be decoded based on the video frame description information corresponding to the current video frame to be decoded includes: The video frame identifier corresponding to the current video frame to be decoded is determined based on the bit information contained in the video frame description information. If the video frame identifier corresponding to the current video frame to be decoded is consistent with the pre-configured keyframe identifier, then the video frame type of the current video frame to be decoded is determined as a keyframe. If the video frame identifier corresponding to the current video frame to be decoded is inconsistent with the pre-configured key frame identifier, then the video frame type of the current video frame to be decoded is determined to be a non-key frame.
5. The video playback method according to claim 4, characterized in that, The step of determining the video frame identifier corresponding to the current video frame to be decoded based on the bit information contained in the video frame description information includes: Based on a preset number system conversion rule, the target bit information corresponding to the pre-specified bit in the video frame description information is converted to a new number system to obtain the converted value corresponding to the current video frame to be decoded. The converted value corresponding to the current video frame to be decoded is determined as the video frame identifier corresponding to the current video frame to be decoded.
6. The video playback method according to any one of claims 1 to 5, characterized in that, The process of detecting a video playback request for the target video file further includes: Trigger a second download event for the target video file; Accordingly, the target decoding process and video playback operation triggered based on the read target keyframe and the progress bar drag event include: The first decoding process is triggered to decode the read target keyframe, and the decoded keyframe is displayed as an image. If the downloaded video frame file corresponding to the second download event already contains the subsequent video frame corresponding to the target keyframe, then a second decoding process is triggered to decode the subsequent video frames sequentially according to the timestamp order, and video playback is performed when the decoding progress of the second decoding process reaches the target video frame corresponding to the drag end point.
7. The video playback method according to claim 6, characterized in that, The first download event and the second download event are events triggered by an asynchronous thread.
8. The video playback method according to claim 6, characterized in that, After determining the corresponding drag end point on the video progress bar of the target video file, the method further includes: If the downloaded video frame file corresponding to the second download event already contains the target video frame corresponding to the drag end point, then determine the target keyframe from the downloaded video frame file that is closest to the drag end point and whose timestamp is less than or equal to the drag end point timestamp. The target keyframe is decoded, and the decoded keyframe is displayed as an image. The subsequent video frames corresponding to the target keyframe are decoded sequentially according to the timestamp order, and the video is played when the target video frame is decoded.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the video playback method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, Used to store a computer program, which, when executed by a processor, implements the video playback method as described in any one of claims 1 to 7.