Video playback method, device, electronic device, and computer-readable storage medium
By responding to the video replay event in the video playback method, performing decapsulation processing and updating the timestamp of the video frame, the problem of stuck and delay during video replay in the existing technology is solved, and the smoothness and efficiency of video playback are improved.
Patent Information
- Application Number
- CN202410139907.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-31
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2044-01-31
AI Technical Summary
Existing video playback methods are prone to freezes and delays during replay, resulting in low video playback efficiency.
Obtain the video frame obtained by decoding the target video by the decoder, perform decapsulation processing in response to the video replay event, and add the total continuous playback time to the first video frame playback timestamp of the decapsulated video frame and update it to the second video The frame playback timestamp is used to decode and play the decoded video frame based on the second video frame playback timestamp to avoid reloading the video and clearing the cache.
It improves the smoothness of video replay, reduces user waiting time, achieves seamless playback, and improves video playback efficiency.
Smart Images

Figure CN118018795B
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and in particular to a video playback method, device, electronic device and computer-readable storage medium. Background Art
[0002] With the rapid development of Internet technology, short videos have become an indispensable part of people's daily life. However, in the existing video playback method, when the short video player is replayed, problems such as freezing and delay are very likely to occur, resulting in low video playback efficiency. Summary of the invention
[0003] The embodiments of the present application provide a video playback method, device, electronic device and computer-readable storage medium, which can improve the smoothness of video replay and thus improve the efficiency of video playback.
[0004] The present application provides a video playback method, including:
[0005] Obtain the video frame obtained by the decoder decoding the target video for playback;
[0006] In response to a video replay event of the target video, obtaining the target video for decapsulation processing to obtain a decapsulated video frame;
[0007] Obtain the total continuous playback time of the target video when the video replay event occurs;
[0008] Adding the total continuous playback time to the first video frame playback timestamp of the decapsulated video frame to update it to the second video frame playback timestamp;
[0009] Decoding the decapsulated video frame based on the second video frame playback timestamp by the decoder to obtain a decoded video frame;
[0010] Based on the second video frame playback timestamp, video playback processing is performed on the decoded video frame.
[0011] Accordingly, an embodiment of the present application provides a video playback device, including:
[0012] A first playback unit, used to obtain a video frame obtained by decoding a target video by a decoder for playback;
[0013] A video processing unit, configured to, in response to a video replay event of the target video, obtain the target video for decapsulation processing to obtain a decapsulated video frame;
[0014] An information acquisition unit, used to acquire the total continuous playback time of the target video when the video replay event occurs;
[0015] A time correction unit, configured to add the total continuous playback time to the first video frame playback timestamp of the decapsulated video frame to update it to the second video frame playback timestamp;
[0016] A video decoding unit, configured to decode the decapsulated video frame based on the second video frame playback timestamp through the decoder to obtain a decoded video frame;
[0017] The second playback unit is configured to perform video playback processing on the decoded video frame based on the playback timestamp of the second video frame.
[0018] In one embodiment, the video replay event includes a replay event triggered by the end of playing of the target video, and the video playback device further includes:
[0019] a replay count updating unit, configured to, in response to a video replay event of the target video, increase the replay count of the target video by 1;
[0020] The information acquisition unit is used to:
[0021] Obtain the number of replays of the target video and the video duration of the target video;
[0022] The total continuous playback time of the target video is obtained by multiplying the number of replays by the video duration.
[0023] In one embodiment, the video replay event includes a replay event triggered by a user during the playback of the target video, and the information acquisition unit is used to:
[0024] Obtain the historical continuous playback time of the target video before the current playback, and the playback time of the target video during the current playback;
[0025] The historical online playback duration and the played duration are accumulated to obtain the total continuous playback duration of the target video when the video replay event occurs.
[0026] In one embodiment, the video playback device further includes a decoded video frame storage unit, which is used to:
[0027] Based on the second video frame playback timestamp of the decoded video frame, the decoded video frame is stored in a decoded video frame queue, wherein if a target video frame having the same playback timestamp as the second video frame exists in the decoded video frame queue, the target video frame is deleted before the decoded video frame is stored in the decoded video frame queue;
[0028] The second playback unit is used to:
[0029] Reading the decoded video frame from the decoded video frame queue;
[0030] The read decoded video frame is played based on the second video frame playback timestamp.
[0031] In one embodiment, the video processing unit includes:
[0032] A read reset subunit is used to call a file read position reset function to reset the read position of the target video to the start position of the target video in response to a video replay event of the target video, read and decapsulate data from the start position of the target video, and obtain a decapsulated video frame;
[0033] The decapsulated video frame storage subunit is used to put the decapsulated video frame into a decapsulated queue so that the decoder can read the decapsulated video frame for decoding.
[0034] In one embodiment, the read-reset subunit is used to:
[0035] In response to a video replay event of the target video, generating a video play position reset request;
[0036] In response to the video playback position reset request, a reset operation in the video playback position reset operation is performed, and a file read position reset function is called to reset the read position of the target video to the start position of the target video;
[0037] The video playback device further includes a data clearing operation intercepting unit for intercepting a data clearing operation in the video playback position resetting operation.
[0038] In one embodiment, the video playback device further includes:
[0039] A time information acquisition unit, used to acquire the master clock time information of the master clock corresponding to the target video;
[0040] A target playback duration determination unit, configured to determine a target playback duration of the target video corresponding to the current playback according to the master clock time information and the total continuous playback duration;
[0041] The playback progress update display unit is used to update and display the playback progress information displayed for the target video during the current playback based on the target playback duration.
[0042] In one embodiment, the target playback duration determination unit is used to:
[0043] The master clock time information is subtracted from the total continuous playback duration to obtain the target playback duration of the target video in this playback.
[0044] In addition, an embodiment of the present application further provides a computer-readable storage medium, which stores a computer program, and the computer program is suitable for loading by a processor to execute the steps in any video playback method provided in the embodiment of the present application.
[0045] In addition, an embodiment of the present application also provides an electronic device, including a processor and a memory, wherein the memory stores an application program, and the processor is used to run the application program in the memory to implement the video playback method provided in the embodiment of the present application.
[0046] An embodiment of the present application also provides a computer program product, which includes a computer program, and the computer program is stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device performs the steps in the video playback method provided in the embodiment of the present application.
[0047] The embodiment of the present application plays the video frame obtained by obtaining the decoder to decode the target video; in response to the video replay event of the target video, the target video is obtained for decapsulation processing to obtain the decapsulated video frame; the total continuous playback time of the target video when the video replay event occurs is obtained; the total continuous playback time is added to the first video frame playback timestamp of the decapsulated video frame, and updated to the second video frame playback timestamp; the decapsulated video frame is decoded by the decoder based on the second video frame playback timestamp to obtain the decoded video frame; based on the second video frame playback timestamp, the decoded video frame is subjected to video playback processing. In this way, by responding to the video replay event of the target video, obtaining the target video for decapsulation processing, and obtaining the total continuous playback time of the target video when the video replay event occurs, the total continuous playback time is added to the first video frame playback timestamp of the decapsulated video frame to correct the first video frame playback timestamp to obtain the corrected second video frame playback timestamp, thereby decoding the decapsulated video frame based on the second video frame playback timestamp, and performing video playback processing on the decoded video frame based on the second video frame playback timestamp, it is possible to forge the replayed target video to continue playing the target video based on the last played target video, thereby avoiding the need to reload the video and various cache clearing operations when replaying the video, improving the smoothness of video replay, and thus improving video playback efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0049] Figure 1 This is a schematic diagram of an implementation scenario of a video playback method provided in an embodiment of the present application;
[0050] Figure 2 It is a flowchart of a video playback method provided in an embodiment of the present application;
[0051] Figure 3 It is a schematic diagram of a specific architecture of a video playback method provided in an embodiment of the present application;
[0052] Figure 4 It is a schematic diagram of the overall process of a video playback method provided by an embodiment of the present application;
[0053] Figure 5 is a structural schematic diagram of a video playback device provided in an embodiment of the present application;
[0054] Figure 6 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0055] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0056] The embodiments of the present application provide a video playback method, device, electronic device and computer-readable storage medium. The video playback device can be integrated in an electronic device, which can be a server or a terminal.
[0057] Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, network acceleration services (Content Delivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms. Terminals may include but are not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc. Terminals and servers can be directly or indirectly connected via wired or wireless communications, and this application does not limit this.
[0058] See also Figure 1 , taking the video playback device integrated into an electronic device as an example, Figure 1 A schematic diagram of an implementation scenario of the video playback method provided in an embodiment of the present application, wherein the electronic device can be a computer device, for example, a server or a terminal, and the electronic device can obtain a video frame obtained by decoding a target video by a decoder for playback; in response to a video replay event of the target video, obtain the target video for decapsulation processing to obtain a decapsulated video frame; obtain the total continuous playback time of the target video when the video replay event occurs; add the total continuous playback time to the first video frame playback timestamp of the decapsulated video frame and update it to a second video frame playback timestamp; decode the decapsulated video frame based on the second video frame playback timestamp by a decoder to obtain a decoded video frame; and perform video playback processing on the decoded video frame based on the second video frame playback timestamp.
[0059] It should be noted that Figure 1 The implementation environment scenario diagram of the video playback method shown is only an example. The implementation environment scenario of the video playback method described in the embodiment of the present application is to more clearly illustrate the technical solution of the embodiment of the present application, and does not constitute a limitation on the technical solution provided by the embodiment of the present application. It is known to those skilled in the art that with the evolution of data processing and the emergence of new business scenarios, the technical solution provided by the present application is also applicable to similar technical problems.
[0060] The solutions provided by the embodiments of the present application are specifically described by the following embodiments. It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments.
[0061] This embodiment will be described from the perspective of a video playback device, which may be integrated into an electronic device, which may be a computer device, which may be a server and / or a terminal, and this application does not limit this.
[0062] See also Figure 2 , Figure 2 : is a flow chart of a video playback method provided in an embodiment of the present application. The video playback method includes:
[0063] In step 101, a video frame obtained by decoding a target video by a decoder is obtained and played.
[0064] The decoder may be a component for decoding a video. Optionally, the decoder may be a component configured in a player for decoding a video, or may be a different component that exists independently of the player. The specific configuration may be based on actual conditions, and the present application embodiment does not limit this. The target video may be a currently playing video.
[0065] Optionally, the target video can be the short video currently being played. Short video can be understood as a short video, which is a way of disseminating Internet content. It is a short video that can be disseminated on new Internet media. With the popularization of mobile terminals and the improvement of network speed, short video-type dissemination content has gradually gained favor from major platforms and users.
[0066] In step 102, in response to a video replay event of a target video, the target video is obtained for decapsulation processing to obtain a decapsulated video frame.
[0067] Among them, the video replay event can be an event that triggers the replay of the target video. The decapsulated video frame can be a video frame in the target video obtained by decapsulating the media file of the reacquired target video. The decapsulation process can be a process of separating the streaming media file of the input encapsulation format video into audio stream compression encoding data and video stream compression encoding data. The main function of the encapsulation format is to store the video code stream and the audio code stream in a file according to a certain format. It should be noted that in an embodiment of the present application, the decapsulated video frame can include a decapsulated video frame of a visual modality (i.e., a video frame) and a decapsulated video frame of an audio modality (i.e., an audio frame). The cache clearing operation can be an operation of clearing the cache of a decoder.
[0068] Optionally, the video replay event may include at least one of a replay event triggered when the target video is played and a replay event triggered by a user during the playback of the target video. Among them, the replay event triggered when the target video is played can be a replay event automatically triggered after the target video is played, or a replay event triggered by a user after the target video is played. For example, assuming that the video duration of the target video is 1 minute, the video replay event of the target video can be triggered when the target video is played to the 60th second. Optionally, in order to further reduce the waiting time of the user during video replay and improve the smoothness of video replay, the video replay time of the target video can be triggered when the target video is about to end. For example, assuming that the video duration of the target video is 1 minute, the video replay event of the target video can be triggered when the target video is played to the 59th second. The replay event triggered by the user during the playback of the target video can be a replay event triggered by the user during the playback of the target video. For example, assuming that the video length of the target video is 1 minute, when the target video is played to the 30th second, the user can control the playback of the target video to trigger a video replay event for the target video, etc.
[0069] Optionally, in order to further improve the fluency of video replay, the cache of the decapsulated queue may not be cleared. Specifically, in response to the video replay event of the target video, the cache clearing operation of the decapsulated queue may not be performed, wherein the decapsulated queue may be used to store the decapsulated video frames.
[0070] Accordingly, in response to the video replay event of the target video, the target video is obtained for decapsulation processing, and there can be multiple ways to obtain the decapsulated video frame. For example, in response to the video replay event of the target video, the file read position reset function can be called to reset the read position of the target video to the starting position of the target video, and data is read and decapsulated from the starting position of the target video to obtain the decapsulated video frame, and the decapsulated video frame is placed in the post-decapsulation queue for the decoder to read the decapsulated video frame for decoding processing.
[0071] The file read position reset function may be a function for resetting the read position of the media file of the video, the read position may be a position for reading the media file of the target video, and the start position may be a start read position of the media file of the target video.
[0072] Among them, there can be multiple ways to call a file read position reset function to reset the read position of the target video to the start position of the target video in response to a video replay event of the target video. For example, a video play position reset request can be generated in response to the video replay event of the target video, and a reset operation in the video play position reset operation can be performed in response to the video play position reset request, and a file read position reset function can be called to reset the read position of the target video to the start position of the target video; and, a data clearing operation in the video play position reset operation can also be intercepted.
[0073] Among them, the video playback position reset request (seek request) can be a request to reset the playback position of the target video to replay the target video. The video playback position reset operation (seek operation) can be an operation for responding to the video playback position reset request, that is, it can be an operation for resetting the playback position of the target video to replay the target video. The reset operation can be an operation for resetting the read position of the target video to the start position of the target video in the video playback position reset operation, and the data clearing operation can be an operation for clearing data in the video playback position reset operation. Based on the data clearing operation, cache data related to video playback is cleared, for example, it can include clearing the decoder's cache, the cache in the queue after decapsulation, and other data, so as to achieve normal replay of the target video.
[0074] Optionally, there may be a variety of ways to intercept the data clearing operation in the video playback position reset operation. For example, a hook function may be used to intercept the data clearing operation in the video playback position reset operation. Alternatively, in response to a video playback position reset request, the code content corresponding to the data clearing operation in the video playback position reset operation may be temporarily deleted or changed so that the data clearing operation in the video playback position reset operation cannot be executed. In a non-video replay scenario, the code content corresponding to the data clearing operation in the video playback position reset operation may be restored so that video playback can proceed normally.
[0075] In one embodiment, when the player detects a request to reset the video playback position, the player's data read thread (read-thread) can be used to process the video playback position reset request, and the reset operation in the video playback position reset operation is performed through the data read thread, and the file read position reset function (avformat_seek_file) is called to reset the read position of the target video to the start position of the target video. In addition, the data clearing operation in the video playback position reset operation can be intercepted, and the clearing operation of the decoder cache, the cache in the decapsulated queue, and the target video is not performed. The decapsulation processing is performed, so that the decapsulated video frame obtained by decapsulation can be stored in the decapsulated queue (Packet queue). Then, the playback thread (video-thread) can be used to call the video data acquisition function (Packet-queue-get) to obtain the decapsulated video frame in the decapsulated queue for decoding processing, so as to replay the target video.
[0076] When the audio and video stream of a video is processed during video playback, since there may be some cached video frames in components such as decoders and queues after decapsulation, if these caches are not cleared after performing a seek operation, it is very likely that video decoding will be wrong when replaying. In addition, since there is often a dependency between video frames, if the cache of the decoder is not cleared, directly performing a decoding operation on the video is very likely to cause decoding errors in some video frames. Therefore, in the existing video playback method, when performing a seek operation on video replay, it is often necessary to perform a reset operation and a data clearing operation, by performing the reset operation in the seek operation, calling a file read position reset function (seek function) to reset the read position of the media file of the video to the starting position of the video, and at the same time, it is necessary to reload the video, and perform a data clearing operation to clear the cached data such as the cache of the decoder and the queue after decapsulation, so that when the video is replayed, the target video can be normally decoded and displayed, thereby realizing the replay of the video. However, in the existing video playback method, in the process of performing a seek operation in response to a video replay event, it takes a long time to reload the video and perform a data clearing operation to clear the cached data in the decoder and the decapsulated queue, which causes the video replay to be stuck and delayed, causing the user to wait too long for the replay, thereby making the video playback efficiency low. In order to solve the above problems, a video playback method provided in an embodiment of the present application optimizes the video replay process, thereby achieving the effect of not having to re-execute various cache clearing operations during video replay, reducing the user's waiting time, thereby achieving a seamless video playback effect, improving the video playback efficiency, and further improving the user's video viewing experience.
[0077] In step 103, the total continuous playback duration of the target video when the video replay event occurs is obtained.
[0078] Among them, the total continuous playback time can be the total continuous playback time of the target video. For example, assuming that the video length of the target video is 120 seconds, when the target video is played and then continued to be played for 10 seconds after the end of the playback, the total continuous playback time of the target video can be 120+10=130 seconds; when the target video is played again twice after the end of the playback, the total continuous playback time of the target video can be 120×3=360 seconds, etc.
[0079] There are multiple ways to obtain the total continuous playback time of the target video when the video replay event occurs. For example, when the video replay event includes a replay event triggered by the end of the playback of the target video, the replay count of the target video can be increased by 1 in response to the video replay event of the target video. The replay count can be the number of times the target video is replayed. When the video replay event of the target video occurs, the replay count of the target video can be increased by 1 to update the replay count of the target video to ensure that the target video can be replayed normally.
[0080] Correspondingly, the step of obtaining the total continuous playback time of the target video when the video replay event occurs may include: obtaining the number of replays of the target video and the video duration of the target video; multiplying the number of replays by the video duration to obtain the total continuous playback time of the target video.
[0081] For example, assuming that the target video has a duration of 100 seconds, when the target video ends and a video replay event is triggered, the target video replay count can be recorded as 1, so that the replay count 1 can be multiplied by the video duration 100 seconds to obtain the target video's total continuous playback duration of 100 seconds. Then, when the target video ends and a video replay event is triggered, the target video replay count can be increased by 1, so that the replay count is 1+1=2, so that the replay count 2 can be multiplied by the video duration 100 seconds to obtain the target video's total continuous playback duration of 200 seconds, etc.
[0082] Optionally, when the video replay event includes a replay event triggered by the user during the playback of the target video, the step of obtaining the total continuous playback duration of the target video when the video replay event occurs may include: obtaining the historical continuous playback duration of the target video before this playback, and the playback duration of the target video during this playback, and accumulating the historical continuous playback duration and the playback duration to obtain the total continuous playback duration of the target video when the video replay event occurs.
[0083] The historical continuous playback time may be the time the target video has been continuously played before the current playback, and the played time may be the time the target video has been played in the current playback when the video replay event occurs.
[0084] For example, assuming that the target video has a duration of 100 seconds, a video replay event is triggered at the end of the first playback of the target video, and during the first replay of the target video, when the target video is played to 40 seconds, the user triggers the video replay event, so that the historical continuous playback duration of the target video before this playback is 100 seconds, and the playback duration of the target video in this playback is 40 seconds. The historical continuous playback duration and the playback duration are accumulated, and the total continuous playback duration of the target video when the video replay event occurs is 140 seconds.
[0085] In one embodiment, taking ffplay as an example, when a video replay operation for the target video occurs, in response to the video replay event of the target video, a file read position reset function (avformat_seek_file) is called to reset the read position of the media file of the video to the start position of the video, so as to re-read the media file of the target video, and at the same time, no cache clearing operation is performed, including the cache clearing operation of the decoder's decoded video frame queue (Frame queue) and the decapsulated queue (Packet queue). In this way, the time-consuming replay caused by calling the cache clearing function (flush function) and performing the cache clearing operation can be avoided, so that the target video can be replayed quickly and smoothly, and the video playback efficiency can be improved.
[0086] In step 104, the total continuous playback time is added to the first video frame playback timestamp of the decapsulated video frame to update it to the second video frame playback timestamp.
[0087] Among them, the first video frame playback timestamp can be the playback timestamp corresponding to the video frame in the target video obtained after decapsulating the media file of the target video, and the playback timestamp can be the timestamp used to play the video frame in the target video. The playback timestamp can include a decoding timestamp (Decoding Time Stamp, referred to as DTS) and a presentation timestamp (Presentation Time Stamp, referred to as PTS). The decoding timestamp can be used to determine the time to decode the decapsulated video frame, and the presentation timestamp can be used to determine the time to display the decapsulated video frame. The second video frame playback timestamp can be a playback timestamp that is corrected based on the total continuous playback time, so that the player can replay the target video quickly and smoothly based on the corrected second video frame playback timestamp. The total continuous playback time is added to the playback timestamp of the first video frame of the decapsulated video frame to obtain the corrected playback timestamp of the second video frame, thereby achieving a positive increase in the playback timestamp of the target video in principle. The target video is then replayed based on the playback timestamp of the second video frame, and the replayed target video can be forged to continue playing the target video based on the last played target video, thereby avoiding the need to reload the video and various cache clearing operations when replaying the video, thereby improving the smoothness of video replay and further improving video playback efficiency.
[0088] In step 105, the decapsulated video frame is decoded by a decoder based on the second video frame playback timestamp to obtain a decoded video frame.
[0089] Among them, the decoded video frame can be a video frame obtained after the decoder decodes the decapsulated video frame based on the second video frame playback timestamp. Similar to the decapsulated video frame, in an embodiment of the present application, the decoded video frame may include a decoded video frame of a visual modality (i.e., a video frame) and a decoded video frame of an audio modality (i.e., an audio frame), and the video playback processing of the decoded video frame may include processing of the decoded video frame and audio frame corresponding to the target video.
[0090] Optionally, the decoder decodes the decapsulated video frame based on the playback timestamp of the second video frame, and there may be multiple ways to obtain the decoded video frame. For example, the decoder may decode the decapsulated video frame based on the decoding timestamp in the playback timestamp of the second video frame to obtain the decoded video frame. Then, the decoded video frame obtained by decoding may be stored in a decoded video frame queue of the decoder. The decoded video frame queue may be a queue for storing decoded video frames in preparation for subsequent video playback processes.
[0091] In step 106, based on the second video frame playback timestamp, video playback processing is performed on the decoded video frame.
[0092] The decoded video frame may be processed for video playback based on the display timestamp in the playback timestamp of the second video frame to achieve replay of the target video.
[0093] Optionally, before playing the decoded video frame based on the second video frame playback timestamp, the decoded video frame may be stored in a decoded video frame queue based on the second video frame playback timestamp of the decoded video frame, wherein if a target video frame having the same playback timestamp as the second video frame exists in the decoded video frame queue, the target video frame is deleted before storing the decoded video frame in the decoded video frame queue;
[0094] Correspondingly, the step of playing the decoded video frame based on the second video frame playback timestamp may include: reading the decoded video frame from the decoded video frame queue; and playing the read decoded video frame based on the second video frame playback timestamp.
[0095] Among them, the target video frame can be a video frame whose playback timestamp is the same as the playback timestamp of the second video frame. Since the cache clearing operation of the decoder cache is not performed in the embodiment of the present application, the data such as the cached video frames in the decoded video frame queue are not deleted. If there is a target video frame whose decoding timestamp is the same as the decoding timestamp in the playback timestamp of the second video frame in the decoded video frame queue at this time, it will affect the video decoding process during the replay of the target video, thereby causing abnormal decoding during the replay of the target video, and thus the target video cannot be replayed normally. Therefore, it is necessary to delete the target video frame so that the decapsulated video frame of the target video can be normally decoded during the replay of the target video, thereby realizing the replay of the target video.
[0096] Optionally, in order to implement the correct display of the playback progress of the replayed target video in the video playback method provided in the embodiment of the present application, the master clock time information under the master clock corresponding to the target video can be obtained, and the target playback time corresponding to the target video in this playback can be determined based on the master clock time information and the total continuous playback time; based on the target playback time, the playback progress information displayed for the target video in this playback is updated and displayed.
[0097] The master clock may be a clock used for audio and video synchronization during the target video playback process, the master clock time information may be the time information of the master clock, and the target playback duration may be the playback duration of the target video being played this time. The playback progress information may be information displayed in the video playback interface to indicate the playback progress of the target video in this playback, for example, information such as a playback progress bar and a playback progress circular graph to indicate the playback progress.
[0098] Among them, there are many ways to determine the target playback time corresponding to the target video in this playback based on the main clock time information and the total continuous playback time. For example, the main clock time information can be subtracted from the total continuous playback time to obtain the target playback time corresponding to the target video in this playback.
[0099] For example, assuming that the video length of the target video is 100 seconds, at the end of the first playback of the target video, the video replay event of the target video can be triggered, thereby starting the first replay of the target video, and determining in real time the target playback time corresponding to the target video in this playback, and based on the target playback time, updating and displaying the playback progress information displayed for the target video in this playback, wherein, when the target video is replayed to the 10th second, the main clock time information of the main clock corresponding to the target video in the player can be obtained as 110 seconds, based on the main clock time information of 110 seconds and the total continuous playback time of 100 seconds, it can be determined that the target playback time corresponding to the target video in this playback is 10 seconds, thereby based on the target video The target playback time is determined, and the playback progress information displayed by the player for the target video in this playback is updated and displayed as 10 seconds. When the main clock time information under the main clock corresponding to the target video in the player is obtained as 122 seconds, according to the main clock time information of 122 seconds and the total continuous playback time of 100 seconds, it can be determined that the target playback time corresponding to the target video in this playback is 22 seconds. Based on the target playback time, the playback progress information displayed by the player for the target video in this playback is updated and displayed as 22 seconds, etc. In this way, the playback progress information of the target video in the current playback process can be correctly updated and displayed during each replay of the target video, thereby further improving the video playback efficiency.
[0100] In one embodiment, please refer to Figure 3 , Figure 3This is a specific architecture diagram of a video playback method provided by an embodiment of the present application. When the video replay event includes a replay event triggered by the end of the target video playback, the master clock time information (masterclock) under the master clock corresponding to the target video in the player, as well as the number of replays and the video duration (duration) of the target video can be obtained through the current position acquisition function (getCurrentPosition) in each playback of the target video, so as to determine the total continuous playback duration according to the number of replays and the video duration of the target video, and determine the target playback duration corresponding to the target video in this playback according to the master clock time information and the total continuous playback duration. For example, when the target video is played for the first time, the number of replays of the target video is 0, and the target playback duration of the target video is the master clock time information masterclock. When the target video is played for the second time, the number of replays of the target video is 1, and the target playback duration of the target video is masterclock-duration×1. When the target video is played for the third time, the target playback duration of the target video is masterclock-duration×2. By analogy, when the target video is played for the Nth time, the target playback duration of the target video is masterclock-duration×(N-1). In this way, the playback progress information displayed by the player for the target video during the current playback can be updated and displayed based on the target playback duration.
[0101] In one embodiment, when the video replay event is a replay event triggered by the end of the target video playback, the replay count of the target video can be increased by 1 in response to the video replay event of the target video each time the target video is replayed, and the target video is obtained for decapsulation processing, and the decapsulated video frame is stored in the decapsulated queue, and the number of play times and video duration of the target video when the video replay event occurs are obtained, and the total online playback duration of the target video is obtained by multiplying the number of play times and the video duration, and then, the total continuous playback duration can be added to the first video frame playback timestamp of the decapsulated video frame to update the first video frame playback timestamp of the decapsulated video frame to the second video frame playback timestamp, so that the decapsulated video frames required in the replay process of the target video can be read in the decapsulated queue. The decoder decodes the read decapsulated video frame based on the second video frame playback timestamp, and obtains the decoded video frame and stores it in the decoded video frame queue. Then, the decoded video frame can be read out from the decoded video frame queue, and the decoded video frame can be displayed based on the second video frame playback timestamp, so as to realize the replay of the target video after the current playback of the target video ends. At the same time, during the replay of the target video, the master clock time information under the master clock corresponding to the target video can be obtained, and the target playback time of the target video in the current replay process can be obtained by subtracting the total continuous playback time of the target video from the master clock time information, so as to update and display the playback progress bar displayed for the target video in this playback according to the target playback time. In this way, the target video can be replayed smoothly at the end of the playback of the target video, and the playback progress bar of the target video in the current playback process can be correctly updated and displayed during each replay of the target video, so as to further improve the video playback efficiency.
[0102] In one embodiment, when the video replay event is a replay event triggered by a user during the playback of a target video, when the user triggers the replay operation on the target video, in response to the video replay event on the target video, the target video is obtained for decapsulation processing, and the decapsulated video frame is stored in the decapsulated queue, and the total historical continuous playback time of the target video when the video replay event occurs and the playback time during this playback process can be obtained, and the total online playback time of the target video is obtained by accumulating the total historical continuous playback time and the playback time, and then the total continuous playback time can be added to the playback timestamp of the first video frame of the decapsulated video frame to update the playback timestamp of the first video frame of the decapsulated video frame. The new is the second video frame playback timestamp, so that the decapsulated video frame required for the replay process of the target video can be read in the decapsulated queue, and the decoder decodes the decapsulated video frame based on the second video frame playback timestamp to obtain the decoded video frame and store it in the decoded video frame queue, wherein, if there is a target video frame with the same playback timestamp as the second video frame in the decoded video frame queue, the target video frame can be deleted before the decoded video frame is stored in the decoded video frame queue, and then, the decoded video frame can be read from the decoded video frame queue, and the read decoded video frame can be displayed based on the second video frame playback timestamp to achieve the replay of the target video during the playback process of the target video. At the same time, during the replay process of the target video, the master clock time information under the master clock corresponding to the target video can be obtained, and the target playback time of the target video in this replay process can be obtained by subtracting the total continuous playback time of the target video from the master clock time information, so that the playback progress bar displayed for the target video in this playback can be updated and displayed according to the target playback time. In this way, the target video can be smoothly replayed based on the user's trigger during the playback of the target video. At the same time, during the replay of the target video, the playback progress bar of the target video during the current playback can be correctly updated and displayed, further improving the video playback efficiency.
[0103] In one embodiment, please refer to Figure 4 , Figure 4The present invention is a schematic diagram of the overall process of a video playback method provided by an embodiment of the present application. The video playback method provided by the embodiment of the present application plays the video frame obtained by decoding the target video by acquiring the decoder. When a video replay event occurs, the target video can be re-read and decapsulated in response to the video replay event of the target video, and the decoder cache clearing operation is not performed to obtain the decapsulated video frame, so that the decapsulated video frame can be stored in the decapsulated queue, and the total continuous playback time of the target video when the video replay event occurs is obtained, and then the total continuous playback time is added to the first video frame playback timestamp of the decapsulated video frame to update the first video frame playback timestamp to the second video frame playback timestamp. Then, the decoder can decode the decapsulated video frame based on the decoding timestamp in the second video frame playback timestamp to obtain the decoded video frame, and the decoded video frame is played based on the display timestamp in the second video frame playback timestamp. In this way, the decoded video frame is not cleared when the video is replayed, thereby achieving smooth video replay of the target video and improving video playback efficiency.
[0104] As can be seen from the above, the embodiment of the present application plays the video frame obtained by obtaining the decoder to decode the target video; in response to the video replay event of the target video, the target video is obtained for decapsulation processing to obtain the decapsulated video frame; the total continuous playback time of the target video when the video replay event occurs is obtained; the total continuous playback time is added to the first video frame playback timestamp of the decapsulated video frame, and updated to the second video frame playback timestamp; the decapsulated video frame is decoded by the decoder based on the second video frame playback timestamp to obtain the decoded video frame; based on the second video frame playback timestamp, the decoded video frame is subjected to video playback processing. In this way, by responding to the video replay event of the target video, obtaining the target video for decapsulation processing, and obtaining the total continuous playback time of the target video when the video replay event occurs, the total continuous playback time is added to the first video frame playback timestamp of the decapsulated video frame to correct the first video frame playback timestamp to obtain the corrected second video frame playback timestamp, thereby decoding the decapsulated video frame based on the second video frame playback timestamp, and performing video playback processing on the decoded video frame based on the second video frame playback timestamp, it is possible to forge the replayed target video to continue playing the target video based on the last played target video, thereby avoiding the need to reload the video and various cache clearing operations when replaying the video, improving the smoothness of video replay, and thus improving video playback efficiency.
[0105] In order to better implement the above method, an embodiment of the present invention further provides a video playback device, which can be integrated in an electronic device, and the electronic device can be a terminal or a server.
[0106] For example, Figure 5 As shown, it is a schematic diagram of the structure of the video playback device provided in an embodiment of the present application. The video playback device may include a first playback unit 201, a video processing unit 202, an information acquisition unit 203, a time correction unit 204, a video decoding unit 205, and a second playback unit 206, as follows:
[0107] The first playback unit 201 is used to obtain a video frame obtained by decoding a target video by a decoder for playback;
[0108] The video processing unit 202 is used to obtain the target video for decapsulation processing in response to the video replay event of the target video to obtain a decapsulated video frame;
[0109] The information acquisition unit 203 is used to acquire the total continuous playback time of the target video when the video replay event occurs;
[0110] The time correction unit 204 is used to add the total continuous playback time to the first video frame playback timestamp of the decapsulated video frame to update it to the second video frame playback timestamp;
[0111] The video decoding unit 205 is used to decode the decapsulated video frame based on the second video frame playback timestamp through a decoder to obtain a decoded video frame;
[0112] The second playback unit 206 is configured to perform video playback processing on the decoded video frame based on the second video frame playback timestamp.
[0113] In one embodiment, the video replay event includes a replay event triggered by the end of playing of the target video, and the video playback device further includes:
[0114] A replay count updating unit, configured to respond to a video replay event of a target video and increase the replay count of the target video by 1;
[0115] The information acquisition unit 203 is used to:
[0116] Get the number of replays of the target video and the video duration of the target video;
[0117] Multiply the number of replays by the video duration to get the total continuous playback duration of the target video.
[0118] In one embodiment, the video replay event includes a replay event triggered by a user during the playback of the target video. The information acquisition unit 203 is used to:
[0119] Get the historical continuous playback time of the target video before the current playback, and the playback time of the target video during the current playback;
[0120] The historical online playback time and the played time are accumulated to obtain the total continuous playback time of the target video when the video replay event occurs.
[0121] In one embodiment, the video playback device further includes a decoded video frame storage unit, which is used to:
[0122] Based on the second video frame playback timestamp of the decoded video frame, the decoded video frame is stored in a decoded video frame queue, wherein if a target video frame having the same playback timestamp as the second video frame exists in the decoded video frame queue, the target video frame is deleted before the decoded video frame is stored in the decoded video frame queue;
[0123] The second playback unit 206 is used for:
[0124] Read the decoded video frame from the decoded video frame queue;
[0125] The read decoded video frame is played based on the second video frame playback timestamp.
[0126] In one embodiment, the video processing unit 202 includes:
[0127] The read reset subunit is used to respond to the video replay event of the target video, call the file read position reset function to reset the read position of the target video to the start position of the target video, read and decapsulate the data from the start position of the target video, and obtain the decapsulated video frame;
[0128] The decapsulated video frame storage subunit is used to put the decapsulated video frame into the decapsulated queue so that the decoder can read the decapsulated video frame for decoding processing.
[0129] In one embodiment, the read-reset subunit is used to:
[0130] In response to a video replay event of a target video, generating a video playback position reset request;
[0131] In response to the video playback position reset request, a reset operation in the video playback position reset operation is performed, and a file read position reset function is called to reset the read position of the target video to the start position of the target video;
[0132] The video playback device also includes a data clearing operation intercepting unit for intercepting a data clearing operation in a video playback position resetting operation.
[0133] In one embodiment, the video playback device further includes:
[0134] A time information acquisition unit, used to acquire the master clock time information of the master clock corresponding to the target video;
[0135] A target playback duration determination unit, used to determine the target playback duration corresponding to the current playback of the target video according to the main clock time information and the total continuous playback duration;
[0136] The playback progress update display unit is used to update and display the playback progress information displayed for the target video in this playback based on the target playback duration.
[0137] In one embodiment, the target playback duration determination unit is used to:
[0138] The main clock time information is subtracted from the total continuous playback duration to obtain the target playback duration of the target video in this playback.
[0139] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can refer to the previous method embodiments, which will not be repeated here.
[0140] As can be seen from the above, the embodiment of the present application obtains the video frame obtained by decoding the target video by the decoder through the first playback unit 201 for playback; the video processing unit 202 responds to the video replay event of the target video, obtains the target video for decapsulation processing, and obtains the decapsulated video frame; the information acquisition unit 203 obtains the total continuous playback time of the target video when the video replay event occurs; the time correction unit 204 adds the total continuous playback time to the first video frame playback timestamp of the decapsulated video frame, and updates it to the second video frame playback timestamp; the video decoding unit 205 decodes the decapsulated video frame based on the second video frame playback timestamp through the decoder to obtain the decoded video frame; the second playback unit 206 performs video playback processing on the decoded video frame based on the second video frame playback timestamp. In this way, by responding to the video replay event of the target video, obtaining the target video for decapsulation processing, and obtaining the total continuous playback time of the target video when the video replay event occurs, the total continuous playback time is added to the first video frame playback timestamp of the decapsulated video frame to correct the first video frame playback timestamp to obtain the corrected second video frame playback timestamp, thereby decoding the decapsulated video frame based on the second video frame playback timestamp, and performing video playback processing on the decoded video frame based on the second video frame playback timestamp, it is possible to forge the replayed target video to continue playing the target video based on the last played target video, thereby avoiding the need to reload the video and various cache clearing operations when replaying the video, improving the smoothness of video replay, and thus improving video playback efficiency.
[0141] The present application also provides an electronic device, such as Figure 6As shown, it shows a schematic diagram of the structure of an electronic device involved in an embodiment of the present application, and the electronic device may be a server or a terminal. Specifically:
[0142] The electronic device may include components such as a processor 301 with one or more processing cores, a memory 302 with one or more computer-readable storage media, a power supply 303, and an input unit 304. Those skilled in the art will appreciate that Figure 6 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0143] The processor 301 is the control center of the electronic device, which uses various interfaces and lines to connect various parts of the entire electronic device, and executes various functions of the electronic device and processes data by running or executing software programs and / or modules stored in the memory 302, and calling data stored in the memory 302. Optionally, the processor 301 may include one or more processing cores; preferably, the processor 301 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 301.
[0144] The memory 302 can be used to store software programs and modules. The processor 301 executes various functional applications and data processing by running the software programs and modules stored in the memory 302. The memory 302 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 302 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 302 may also include a memory controller to provide the processor 301 with access to the memory 302.
[0145] The electronic device also includes a power supply 303 for supplying power to each component. Preferably, the power supply 303 can be logically connected to the processor 301 through a power management system, so that the power management system can manage charging, discharging, power consumption and other functions. The power supply 303 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators and other arbitrary components.
[0146] The electronic device may further include an input unit 304, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0147] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 301 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 302 according to the following computer program, and the processor 301 will run the application programs stored in the memory 302, thereby realizing various functions, as follows:
[0148] Obtain a video frame obtained by decoding a target video by a decoder for playback; in response to a video replay event of the target video, obtain the target video for decapsulation processing to obtain a decapsulated video frame; obtain the total continuous playback time of the target video when the video replay event occurs; add the total continuous playback time to the first video frame playback timestamp of the decapsulated video frame and update it to the second video frame playback timestamp; decode the decapsulated video frame based on the second video frame playback timestamp through the decoder to obtain a decoded video frame; and perform video playback processing on the decoded video frame based on the second video frame playback timestamp.
[0149] The specific implementation of each of the above operations can be found in the previous embodiments, which will not be described in detail here. It should be noted that the electronic device provided in the embodiment of the present application and the video playback method in the above embodiment belong to the same concept, and its specific implementation process is detailed in the above method embodiment, which will not be described in detail here.
[0150] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by a computer program, or by controlling related hardware through a computer program. The computer program may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0151] To this end, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored, and the computer program can be loaded by a processor to execute the steps in any video playback method provided in the embodiment of the present application. For example, the computer program can execute the following steps:
[0152] Obtain a video frame obtained by decoding a target video by a decoder for playback; in response to a video replay event of the target video, obtain the target video for decapsulation processing to obtain a decapsulated video frame; obtain the total continuous playback time of the target video when the video replay event occurs; add the total continuous playback time to the first video frame playback timestamp of the decapsulated video frame and update it to the second video frame playback timestamp; decode the decapsulated video frame based on the second video frame playback timestamp through the decoder to obtain a decoded video frame; and perform video playback processing on the decoded video frame based on the second video frame playback timestamp.
[0153] The computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0154] Since the computer program stored in the computer-readable storage medium can execute the steps in any one of the video playback methods provided in the embodiments of the present application, the beneficial effects that can be achieved by any one of the video playback methods provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0155] Among them, according to one aspect of the present application, a computer program product is provided, which includes a computer program, and the computer program is stored in a computer-readable storage medium; when the processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device performs the steps in the video playback method provided in an embodiment of the present application.
[0156] The above is a detailed introduction to a video playback method, device, electronic device and computer-readable storage medium provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A video playback method, characterized in that: include: Obtain the video frame obtained by the decoder decoding the target video for playback; In response to a video replay event of the target video, obtaining the target video for decapsulation processing to obtain a decapsulated video frame; Obtaining the total continuous playback duration of the target video when the video replay event occurs, wherein the total continuous playback duration includes the duration of the target video that has been continuously played before the current playback and the duration of the target video that has been played during the current playback; Adding the total continuous playback time to the first video frame playback timestamp of the decapsulated video frame to update it to the second video frame playback timestamp; Decoding the decapsulated video frame based on the second video frame playback timestamp by the decoder to obtain a decoded video frame; Based on the second video frame playback timestamp of the decoded video frame, the decoded video frame is stored in a decoded video frame queue, wherein if a target video frame having the same playback timestamp as the second video frame exists in the decoded video frame queue, the target video frame is deleted before the decoded video frame is stored in the decoded video frame queue; Reading the decoded video frame from the decoded video frame queue; The read decoded video frame is played based on the second video frame playback timestamp.
2. The video playback method according to claim 1, wherein: The video replay event includes a replay event triggered by the end of playing the target video; the method further includes: In response to a video replay event of the target video, adding 1 to the number of replays of the target video; The obtaining of the total continuous playback duration of the target video when the video replay event occurs includes: Obtain the number of replays of the target video and the video duration of the target video; The total continuous playback time of the target video is obtained by multiplying the number of replays by the video duration.
3. The video playback method according to claim 1, wherein: The video replay event includes a replay event triggered by a user during the playback of the target video, and obtaining the total continuous playback time of the target video when the video replay event occurs includes: Obtain the historical continuous playback time of the target video before the current playback, and the playback time of the target video during the current playback; The historical continuous play time and the played time are accumulated to obtain the total continuous play time of the target video when the video replay event occurs.
4. The video playback method according to claim 1, wherein: The step of obtaining the target video for decapsulation in response to the video replay event of the target video to obtain a decapsulated video frame includes: In response to a video replay event of the target video, calling a file read position reset function to reset the read position of the target video to the start position of the target video, reading and decapsulating data from the start position of the target video, and obtaining a decapsulated video frame; The decapsulated video frame is placed in a decapsulated queue so that the decoder can read the decapsulated video frame for decoding.
5. The video playback method according to claim 4, characterized in that: In response to the video replay event of the target video, calling a file read position reset function to reset the read position of the target video to the start position of the target video includes: In response to a video replay event of the target video, generating a video play position reset request; In response to the video playback position reset request, a reset operation in the video playback position reset operation is performed, and a file read position reset function is called to reset the read position of the target video to the start position of the target video; The method further includes: intercepting a data clearing operation in the video playback position resetting operation.
6. The video playback method according to any one of claims 1 to 5, characterized in that: The method further comprises: Get the master clock time information under the master clock corresponding to the target video; Determine the target playback time of the target video in this playback according to the master clock time information and the total continuous playback time; Based on the target playback duration, the playback progress information displayed for the target video during this playback is updated and displayed.
7. The video playback method according to claim 6, characterized in that: The determining, according to the master clock time information and the total continuous playback duration, a target playback duration corresponding to the current playback of the target video includes: The master clock time information is subtracted from the total continuous playback duration to obtain the target playback duration of the target video in this playback.
8. A video playback device, characterized in that: include: A first playback unit, used to obtain a video frame obtained by decoding a target video by a decoder for playback; A video processing unit, configured to, in response to a video replay event of the target video, obtain the target video for decapsulation processing to obtain a decapsulated video frame; An information acquisition unit, used to acquire the total continuous playback time of the target video when the video replay event occurs, wherein the total continuous playback time includes the duration of the target video being continuously played before the current playback and the duration of the target video being played during the current playback; A time correction unit, configured to add the total continuous playback time to the first video frame playback timestamp of the decapsulated video frame to update it to the second video frame playback timestamp; A video decoding unit, configured to decode the decapsulated video frame based on the second video frame playback timestamp through the decoder to obtain a decoded video frame; a decoded video frame storage unit, configured to store the decoded video frame in a decoded video frame queue based on a second video frame playback timestamp of the decoded video frame, wherein if a target video frame having the same playback timestamp as the second video frame exists in the decoded video frame queue, the target video frame is deleted before the decoded video frame is stored in the decoded video frame queue; The second playback unit is configured to read the decoded video frame from the decoded video frame queue, and perform playback processing on the read decoded video frame based on the second video frame playback timestamp.
9. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of any one of the methods of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: It includes a computer program. When the computer program is run on an electronic device, the computer program is used to enable the electronic device to execute the steps of any method described in claims 1 to 7.
