Synchronous playing method and related device
By calculating the expected playback start time and delay time of the video data frame, and selecting appropriate playback strategies to deal with data push rate fluctuations, solving the problem of poor playback caused by unstable rate in multimedia playback and improving user experience.
Patent Information
- Application Number
- CN202510356517.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-24
- Publication Date
- 2025-08-08
AI Technical Summary
In multimedia playback, poor playback experience caused by unstable data push rate, such as fast data push speed and slow decoding may lead to long-term black screen or video loss.
By obtaining the play start time of the current cached data frame, compute the expected play start time with the data segment information in the playback pipeline, and select a suitable playback strategy, such as delayed playback or instant playback, to adapt to the change in the data push rate based on the comparison results of the expected delay time and the dynamic delay time.
It reduces the impact of unstable data push rate on the playback experience and improves the smoothness and stability of video playback.
Smart Images

Figure CN120455729A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of audio and video playback, and in particular to a synchronous playback method and related devices. Background Art
[0002] With the development of multimedia technology, video playback scenarios are becoming increasingly diverse. However, in scenarios involving non-real-time sources (e.g., reading and playing media from a file) or streaming media (e.g., live streaming, in-car connectivity), the speed at which data is pushed by the front-end is often uneven. This results in a poor playback experience if data is decoded and played at the same speed as the data push. For example, when the data push speed is fast and the decoding is slow, a long black screen or the loss of a certain video segment may occur due to continuous frame loss. Summary of the Invention
[0003] The main purpose of this application is to provide a synchronous playback method and related devices, which can reduce the impact of unstable push rate of data to be played and improve the user's playback experience.
[0004] The first technical solution adopted by this application is to provide a synchronous playback method. The method includes receiving a currently cached data frame and obtaining a playback start time for the currently cached data frame; obtaining an expected playback start time for the currently cached data frame based on the playback start time of the currently cached data frame and the playback start time of the current data segment in the playback pipeline; obtaining an expected delay time based on the expected playback start time and the current system time; and executing a corresponding playback strategy for the currently cached data frame based on the value of the expected delay time and a comparison result with the dynamic delay time.
[0005] The second technical solution adopted by this application is to provide a playback device. The playback device includes a receiving module for obtaining a currently cached data frame; a control module for implementing the synchronous playback method described in the first technical solution; and a playback module for playing the currently cached data frame according to instructions from the control module.
[0006] The third technical solution adopted by the present application is to provide an electronic device comprising a memory and a processor, wherein the memory is used to store program data, and the program data can be executed by the processor to implement the method described in the first technical solution.
[0007] The fourth technical solution adopted by this application is to provide a computer-readable storage medium / computer program product. The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, implement the method described in the first technical solution. The computer program product includes program data, and the computer program, when executed by the processor, implements the method described in the first technical solution.
[0008] The beneficial effects of the present application are as follows: by obtaining the current cached data frame and the playback start time when the current cached data frame should start playing, and then obtaining the expected playback start time of the current cached data frame relative to the system clock based on the playback start time and the playback start time of the current data segment. The expected delay time is obtained according to the expected playback start time and the current system time. The numerical value of the expected delay time and the comparison result with the dynamic delay time are used as the basis for judging the arrival timing of the current cached data frame, and are used to judge whether the arrival timing of the current cached data frame is appropriate, so as to select the corresponding playback strategy according to the judgment result, reduce the impact of the unstable push rate of the data to be played, and improve the user's playback experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0010] Figure 1 This is a flowchart of the first embodiment of the synchronous playback method of the present application;
[0011] Figure 2 This is a schematic diagram of the start time of playing the current cached data frame;
[0012] Figure 3 This is a flowchart of the second embodiment of the synchronous playback method of the present application;
[0013] Figure 4 This is a flowchart of the third embodiment of the synchronous playback method of the present application;
[0014] Figure 5 This is a flowchart of the fourth embodiment of the synchronous playback method of the present application;
[0015] Figure 6 This is a flowchart of the fifth embodiment of the synchronous playback method of the present application;
[0016] Figure 7 This is a flowchart of the sixth embodiment of the synchronous playback method of the present application;
[0017] Figure 8 This is a flowchart of the seventh embodiment of the synchronous playback method of the present application;
[0018] Figure 9 This is a flow chart of an embodiment of the playback device of the present application;
[0019] Figure 10 This is a structural diagram of an embodiment of an electronic device of the present application;
[0020] Figure 11 This is a schematic structural diagram of an embodiment of a computer-readable storage medium of the present application;
[0021] Figure 12 It is a structural diagram of an embodiment of the computer program product of the present application. DETAILED DESCRIPTION
[0022] The following embodiments of the technical solution of the present application will be described in detail with reference to the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present application and are therefore only examples and are not intended to limit the scope of protection of the present application.
[0023] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned figure descriptions are intended to cover non-exclusive inclusions.
[0024] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0025] In the description of the embodiments of this application, the technical terms "first" and "second" are used only to distinguish different objects and should not be understood to indicate or imply relative importance or implicitly specify the quantity, specific order, or primary and secondary relationship of the indicated technical features. In the description of the embodiments of this application, the meaning of "plurality" is more than two, unless otherwise clearly and specifically defined.
[0026] In the description of the embodiments of this application, the term "and / or" is simply a description of the association relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can represent the following three situations: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in this document generally indicates that the associated objects are in an "or" relationship.
[0027] In the description of the embodiments of the present application, the term "multiple" refers to more than two (including two). Similarly, "multiple groups" refers to more than two groups (including two groups), and "multiple pieces" refers to more than two pieces (including two pieces).
[0028] In the description of the embodiments of the present application, unless otherwise expressly specified or limited, technical terms such as "installed," "connected," "connected," and "fixed" should be understood in a broad sense. For example, they can refer to fixed connections, detachable connections, or integration; mechanical connections or electrical connections; direct connections or indirect connections through an intermediate medium; internal connections between two components or interactions between two components. Those skilled in the art can understand the specific meanings of the above terms in the embodiments of the present application based on specific circumstances.
[0029] Reference Figure 1 , Figure 1 This is a flowchart of the first embodiment of the synchronous playback method of the present application, which includes but is not limited to the following steps.
[0030] S11: Receive the current cached data frame and obtain the playback start time of the current cached data frame.
[0031] When the device receives the current cached data frame, it can calculate the playback start time of the current data segment of the current cached data frame in the playback pipeline based on the relevant information of the current cached data frame. The playback pipeline is a multi-level system for playing cached data frames. During data playback, it is usually played in segments of media streams or data segments. Before playing the data segment, the relevant information of the segment of data, such as the start time, end time, duration, playback speed, etc., will be sent to the playback device. After each data segment is played, the relevant information of the newly sent data segment will continue to be sent for playback. The playback start time of the current cached data frame refers to the time when the current cached data frame should be played in the current data segment.
[0032] In one embodiment, the playback start time of the current cached data frame can be determined by the timestamp of the current cached data frame. The timestamp is a way of recording time, which is used to indicate the time when a certain time occurs. Here, it is used to indicate the time when the current cached data frame should be played. Obtaining the playback start time of the current cached data frame includes obtaining the playback start time of the current cached data frame based on the timestamp of the current cached data frame, the playback start time of the current data segment in the playback pipeline, and the playback speed. Specifically, it includes subtracting the playback start time of the current data segment from the timestamp to obtain the target time; and dividing the target time by the playback speed to obtain the playback start time of the current cached data frame.
[0033] Reference Figure 2 , Figure 2 This is a diagram showing the start time of playback of the current cached data frame. The playback start time of the current cached data frame, PT, is calculated as (B.timestamp – S.start) / ABS(S.rate). B.timestamp is the timestamp of the current cached data frame, S.start is the start time of the current data segment, and ABS(S.rate) is the playback speed of the current data segment. ABS is calculated as an absolute value.
[0034] In some embodiments, when in reverse playback, S.rate<0, and the playback start time PT of the current cached data frame is PT=(S.stop-B.timestamp) / ABS(S.rate).
[0035] S12: Obtaining an expected playback start time of the current cached data frame based on the playback start time of the current cached data frame and the playback start time of the current data segment in the playback pipeline.
[0036] After obtaining the playback start time of the current cached data frame in the current data segment, the expected playback start time of the current cached data frame relative to the system clock can be obtained by combining it with the playback start time of the current data segment. Specifically, after obtaining the playback start time of the current cached data frame, it is added to the playback start time of the current data segment to obtain the expected playback start time of the current cached data frame relative to the system clock, because the playback start time of the current data segment is the playback start time relative to the system clock. The system clock is a preset clock that serves as the reference time for various software programs.
[0037] S13: Obtaining an expected delay time based on the expected playback start time and the current system time.
[0038] After obtaining the expected playback start time for the current buffered data frame, we compare it with the current system time and calculate the difference between the expected playback start time and the current system time, which is the expected latency. This difference reflects the real-time nature of the system and the timeliness of the buffer. This difference allows us to assess whether the buffered data frame is displayed in a timely manner and determine whether the display strategy needs to be adjusted or optimized to ensure smooth and seamless playback.
[0039] S14: Based on the numerical value of the expected delay time and the comparison result with the dynamic delay time, a corresponding playback strategy is executed on the current cached data frame.
[0040] The expected delay value reflects whether the arrival time of the current cached data frame is earlier or later than expected. If the current cached data frame arrives late, the dynamic delay time can be used to further determine the extent of the late arrival of the current cached data frame, thereby further subdividing the playback strategy to make it more suitable for the arrival timing of the current cached data frame. Setting appropriate multi-level playback strategies based on the arrival of the current cached data frame can reduce the impact of unstable push rates of the data to be played and improve the user's playback experience.
[0041] In this embodiment, the current cached data frame and the playback start time at which the current cached data frame should begin playback are obtained, and then the expected playback start time of the current cached data frame relative to the system clock is obtained based on the playback start time and the playback start time of the current data segment. The expected delay time is then obtained based on the expected playback start time. The numerical value of the expected delay time and the comparison result with the dynamic delay time are used as the basis for determining the arrival timing of the current cached data frame, and are used to determine whether the arrival timing of the current cached data frame is appropriate. Based on the judgment result, a corresponding playback strategy is selected, thereby reducing the impact of unstable push rate of the to-be-played data and improving the user's playback experience.
[0042] Reference Figure 3 , Figure 3 This is a flow chart of the second embodiment of the synchronous playback method of the present application, which includes but is not limited to the following steps.
[0043] S21: Obtaining an expected delay time based on the expected playback start time and the current system time.
[0044] After obtaining the expected delay time, the expected delay time is compared with zero and the dynamic delay time, and a playback strategy is determined based on the comparison results. Based on the numerical value of the expected delay time and the comparison result with the dynamic delay time, executing the corresponding playback strategy for the current cached data frame includes the following steps.
[0045] When the expected delay time is less than zero, step S22 is executed. When the expected delay time is greater than or equal to zero and less than the dynamic delay time, step S23 is executed. When the expected delay time is greater than or equal to the dynamic delay time, step S24 is executed.
[0046] S22: Delay playing the current cached data frame.
[0047] When the expected delay time is less than zero, it means that the arrival time of the current cached frames is earlier than expected. In this case, the cached data needs to be delayed and played after a period of time.
[0048] S23: Instantly play the current cached data frame.
[0049] The dynamic delay time is the acceptable data delay time during the data stream processing.
[0050] When the expected delay time is greater than or equal to zero and less than the dynamic delay time, it means that the arrival timing of the current cached data frame is later than expected. Although the arrival timing is slightly late, it is within an acceptable range, so it can be played and displayed immediately.
[0051] S24: Determine whether to play the current cached data frame based on a comparison result between the expected play start time and the play time of the last cached data frame.
[0052] If the expected delay is greater than or equal to the dynamic delay, the arrival time of the currently buffered data frame is significantly later than expected. The expected playback start time of the currently buffered data frame is then compared with the playback time of the previously buffered data frame. The playback strategy for the currently buffered data frame is determined based on the time difference, determining whether to discard the currently buffered frames or play them.
[0053] This application obtains the playback start time when the current cached data frame should start playing in the current playback data segment through the timestamp of the current cached data frame and the playback time and playback speed of the current data segment in the playback pipeline. Then the playback start time and the playback start time of the current data segment are added to obtain the expected playback start time of the current cached data frame relative to the system clock. Then, based on the expected playback start time, it is judged whether the arrival timing of the current cached data frame is appropriate, and the corresponding playback strategy is selected according to the comparison result to play the current cached data frame immediately or delay the playback of the current cached data frame. In the above manner, it is judged whether the arrival timing of the current cached data frame is appropriate based on the current system time, thereby executing the corresponding playback strategy, reducing the impact of the unstable push rate of the data to be played, and improving the user's playback experience.
[0054] Reference Figure 4 , Figure 4This is a flow chart of the third embodiment of the synchronous playback method of the present application. This method is a further extension of the dynamic delay time acquisition step, which includes but is not limited to the following steps.
[0055] S31: Obtaining playback start time differences of a preset number of adjacent pairs of currently cached data frames before the start of the currently cached data frame.
[0056] When obtaining the dynamic delay time, for each currently cached data frame, its corresponding dynamic delay time needs to be obtained.
[0057] S32: Calculate the average value of all play time differences.
[0058] S33: Add the average value to the basic delay time to obtain the dynamic delay time.
[0059] First, obtain the difference in playback start time between the previous adjacent cached data frames played starting from the current cached data frame. After obtaining a preset number of differences, obtain the average value of these differences. Add this average value to the basic delay time as the dynamic delay time of the current cached data frame, as its maximum acceptable playback delay time.
[0060] Specifically, a sliding average window algorithm may be used to calculate the average of the PT differences between two frames, and this average is called avg_in_diff.
[0061] First, set a window size m and initialize avg_in_diff. m is equivalent to the preset number mentioned above.
[0062] Then the PT difference of the current cached data frame is calculated, the PT difference between it and the previous frame is calculated, and then it is included in the calculation of the sliding window.
[0063] The delay time is updated using the following formula: avg_in_diff(n)=(PTn+(m-1)*avg_in_diff(n-1)) / m, where PTn is the PT value of the current buffered data frame, and avg_in_diff(n-1) is the average value calculated from the previous buffered data frame played.
[0064] Add the basic delay time to avg_in_diff(n) to get the dynamic delay time of the current cached data frame.
[0065] In this application, when determining the delay of the cached data frame, the adaptive delay time of each cached data frame is flexibly calculated according to the difference in the playback start time of the data frames that have been sent for display, thereby avoiding frequent clock calibration and reducing resource consumption.
[0066] Reference Figure 5 , Figure 5This is a flowchart of the fourth embodiment of the synchronous playback method of the present application. This method is a further extension of the step of determining whether to play the current cached data frame based on the comparison result of the expected playback start time and the playback time of the previous cached data frame, which includes but is not limited to the following steps.
[0067] S41: Obtain the maximum playback interval time of the current cached data frame.
[0068] When determining whether to play the current cached data frame based on the comparison result of the expected playback start time and the playback time of the previous cached data frame, the maximum playback interval time is obtained. This time can be pre-set according to actual conditions and represents the maximum acceptable interval time between the playback times of data frames.
[0069] When the time difference between the expected playback start time and the playback time of the last cached data frame is greater than the maximum playback interval, step S42 is executed. When the time difference between the expected playback start time and the playback time of the last cached data frame is less than or equal to the maximum playback interval, step S43 is executed.
[0070] S42: Instantly play the current cached data frame.
[0071] When the time difference between the expected playback start time and the playback time of the previous cached data frame is greater than the maximum playback interval, it means that the time difference between the expected playback start time and the playback time of the previous cached data frame is acceptable, and the current cached data frame is played immediately.
[0072] S43: Do not play the currently cached data frame.
[0073] When the time difference between the expected playback start time and the playback time of the previous cached data frame is less than or equal to the maximum playback interval, it means that the difference between the expected playback start time of the current cached data frame and the playback time of the previous cached data frame is unacceptable, and the current cached data frame is not played and is discarded.
[0074] Reference Figure 6 , Figure 6 This is a flowchart of the fifth embodiment of the synchronous playback method of the present application. This method is a further extension of the step of delaying the playback of the current cached data frame, and includes but is not limited to the following steps.
[0075] S51: Obtain the single maximum waiting time.
[0076] When it is determined that the expected delay time is less than zero and the current cached data frame needs to be played back later, the maximum single waiting time is first obtained. This event is the maximum waiting time for each delay wait.
[0077] S52: When the expected delay time is greater than the single maximum waiting time, wait for the system time to pass the single maximum waiting time, and subtract the single maximum waiting time from the expected delay time to update the expected delay time.
[0078] S53: Continue updating the expected delay time until the expected delay time is less than the single maximum waiting time, and play the currently cached data frame after the system time passes the expected delay time.
[0079] Based on the expected delay time calculated previously—the difference between the expected playback start time and the current system time—we need to determine whether this difference exceeds the maximum allowable single wait time. If the expected delay time exceeds the maximum allowable single wait time, it means the buffer arrived much earlier than expected. Simply waiting in this situation would cause the video pipeline to be blocked for an extended period of time, potentially affecting smooth video playback and preventing the system from responding to other commands from the front-end.
[0080] Therefore, the delay waiting process is processed in segments, and the expected delay time is updated every time a single maximum waiting time is delayed. After the update, the judgment is performed again and a new delay waiting process is performed.
[0081] As the number of loop waits increases, the expected delay time decreases until the remaining time is less than the maximum allowed single wait time. During this process, we can observe that the buffer's expected playback start time is gradually approaching the scheduled time.
[0082] When the expected delay time is less than the maximum single wait time, the currently cached data frame is played after the system clock passes the expected delay time. If the expected delay time is already less than the maximum single wait time, there is no need to wait multiple times or update, and the currently cached data frame is played directly after the system clock passes the expected delay time.
[0083] When the expected playback start time is close to the current system time, the direct waiting method simplifies processing logic, improves system response efficiency, and provides a smoother user experience. The entire process ensures the stability of the video stream, allowing users to enjoy the smoothest possible playback experience.
[0084] Reference Figure 7 , Figure 7 This is a flowchart of the sixth embodiment of the synchronous playback method of the present application. This method is a further extension of the above embodiment, and includes but is not limited to the following steps.
[0085] S61: Waiting for the system time to pass the single maximum waiting time.
[0086] S62: Determine whether other execution instructions are received.
[0087] During the current buffered data frame waiting delay playback process, each time after the single maximum waiting time is delayed, the acceptance judgment of the execution instruction is performed. When other execution instructions are received, step S63 is executed. When no other execution instructions are received, step S64 is executed.
[0088] S63: Exit the expected delay time update process and execute other execution instructions.
[0089] S64: Subtract the single maximum waiting time from the expected delay time to update the expected delay time.
[0090] In order to avoid the waiting delay time being too long and affecting the response of other instructions, this application divides the expected delay time into segments, and the waiting time of each segment should be limited to the single maximum waiting time. This method allows us to effectively manage the playback of video buffers while maintaining the responsiveness of the system. When we start waiting, after each wait, we immediately check whether the front end has sent other execution instructions. If other execution instructions are received during the waiting process, the current waiting process will be exited first and the instruction-related operations will be executed immediately. This mechanism ensures that the front-end instructions can be processed in a timely manner, preventing possible instruction loss or delay.
[0091] This strategy of segmented waiting and real-time monitoring of front-end instructions not only maintains data stream playback stability but also effectively improves system response speed. This flexible processing approach provides users with a smoother experience, ensuring coordination between data playback and user interaction, making the entire system run more efficiently and smoothly. This processing approach can better adapt to complex and changing usage scenarios and provide users with higher-quality services.
[0092] Reference Figure 8 , Figure 8 This is a flowchart of the seventh embodiment of the synchronous playback method of the present application. This method is a further extension of the above embodiment, and includes but is not limited to the following steps.
[0093] S71: Obtain the start time and end time of the current cached data frame.
[0094] Before determining the playback start time of the current cached data frame based on the timestamp of the current cached data frame, the playback start time of the current data segment in the playback pipeline, and the playback speed, the start and end times of the current cached data frame are first obtained. The start time is the timestamp of the current cached data frame, and the end time is the start time plus the duration of the frame. The duration of the frame can be obtained from the relevant information of the current data segment sent in advance.
[0095] When processing data streams, it is necessary to compare the start time and end time of the current cached data frame with the time range of the current data segment to ensure the order and timeliness of playback.
[0096] When the start time of the current cached data frame is greater than the playback end time of the current data segment, step S72 is executed. When the end time of the current cached data frame is less than the playback start time of the current data segment, step S73 is executed. When the start time of the current cached data frame is less than the playback start time of the current data segment, and the end time of the current cached data frame is greater than the playback start time of the current data segment, step S74 is executed.
[0097] S72: Do not play the currently cached data frame.
[0098] If the start time of the current cached data frame is greater than the end time of the current data segment, it indicates that the start time of the current cached data frame has exceeded the end time of the current data segment. This may indicate that the data of the next data stream has arrived early, while the current data stream has not yet been fully transmitted. In this case, the cached data frame is discarded and not played to avoid misalignment or incoherence during playback.
[0099] S73: Do not play the currently cached data frame.
[0100] If the end time of the current cached data frame is less than the start time of the current data segment, this indicates that the end time of the current cached data frame is earlier than the start time of the current data segment. This usually means that the data of the previous data stream arrived too late, which may cause playback delay. Therefore, for such cached data frames, the cached data frame is discarded and not played to maintain smooth and consistent playback.
[0101] S74: Update the timestamp of the current cached data frame based on the playback start time of the current data segment to obtain the playback start time of the current cached data frame.
[0102] When the start time of the current cached data frame is less than the playback start time of the current data segment, and the end time of the current cached data frame is greater than the playback start time of the current data segment, it means that the current cached data frame and the current data segment have time overlaps, and they can be processed for playback. Before playing it, the timestamp of the current cached data frame is adjusted first, and the timestamp of the current cached data frame is updated with the playback start time of the current data segment. The current cached data frame calculates the playback start time with the updated timestamp, and the current cached data frame discards the frame data before the updated timestamp. This is to crop the code stream to ensure that the time range of the cached data frame is completely within the effective playback time of the current data segment. This can avoid unnecessary time deviations and ensure the continuity and accuracy of playback.
[0103] Reference Figure 9 , Figure 9 This is a flowchart of an embodiment of the playback device of the present application.
[0104] The playback device includes a receiving module 110 , a control module 120 and a playback module 130 .
[0105] The receiving module 110 is used to obtain the current cached data frame. The control module 120 is used to implement the method provided by any embodiment and possible combination of the above-mentioned synchronous playback method. The playback module 130 is used to play the current cached data frame according to the instruction of the control module.
[0106] In one embodiment, the control module 120 obtains the playback start time of the current cached data frame; obtains the expected playback start time of the current cached data frame based on the playback start time of the current cached data frame and the playback start time of the current data segment in the playback pipeline; obtains the expected delay time based on the expected playback start time and the current system time; and executes a corresponding playback strategy for the current cached data frame based on the numerical value of the expected delay time and the comparison result with the dynamic delay time.
[0107] In one embodiment, when the control module 120 obtains the playback start time of the current cached data frame, it obtains the playback start time of the current cached data frame based on the timestamp of the current cached data frame, the playback start time of the current data segment in the playback pipeline, and the playback speed. Specifically, it subtracts the playback start time of the current data segment from the timestamp to obtain a target time; and then divides the target time by the playback speed to obtain the playback start time of the current cached data frame.
[0108] In one embodiment, the control module 120 executes a corresponding playback strategy for the current cached data frame based on the numerical value of the expected delay time and the comparison result with the dynamic delay time, including delaying the playback of the current cached data frame when the expected delay time is less than zero, immediately playing the current cached data frame when the expected delay time is greater than or equal to zero and less than the dynamic delay time, and determining whether to play the current cached data frame based on the comparison result of the expected playback start time and the playback time of the previous cached data frame when the expected delay time is greater than or equal to the dynamic delay time.
[0109] In one embodiment, the step of the control module 120 obtaining the dynamic delay time includes obtaining the playback start time difference of a preset number of adjacent current cached data frame pairs before the start of the current cached data frame; calculating the average of all playback time differences; and adding the average value to the basic delay time to obtain the dynamic delay time.
[0110] In one embodiment, the control module 120 determines whether to play the current cached data frame based on a comparison between the expected playback start time and the playback time of the previous cached data frame, including obtaining a maximum playback interval for the current cached data frame; when the time difference between the expected playback start time and the playback time of the previous cached data frame is greater than the maximum playback interval, the current cached data frame is played immediately; and when the time difference between the expected playback start time and the playback time of the previous cached data frame is less than or equal to the maximum playback interval, the current cached data frame is not played.
[0111] In one embodiment, when the control module 120 delays playing the current cached data frame, it includes obtaining the single maximum waiting time; when the expected delay time is greater than the single maximum waiting time, waiting for the system time to pass the single maximum waiting time, subtracting the single maximum waiting time from the expected delay time to update the expected delay time; continuing to update the expected delay time until the expected delay time is less than the single maximum waiting time, waiting for the system time to pass the expected delay time to play the current cached data frame.
[0112] In one embodiment, when waiting for the system time to pass the maximum single wait time, the control module 120 includes the following steps: waiting for the system time to pass the maximum single wait time; determining whether another execution instruction has been received; and determining whether the execution instruction has been received each time the maximum single wait time has been exceeded while the currently cached data frame is waiting for delayed playback. If another execution instruction is received, the expected delay time update process is exited and the other execution instruction is executed. If no other execution instruction is received, the expected delay time is updated by subtracting the maximum single wait time from the expected delay time.
[0113] In one embodiment, the control module 120 obtains the playback start time of the current cached data frame based on the timestamp of the current cached data frame, the playback start time of the current data segment in the playback pipeline, and the playback speed, including obtaining the start time and end time of the current cached data frame; when the start time of the current cached data frame is greater than the playback end time of the current data segment, the current cached data frame is not played. When the end time of the current cached data frame is less than the playback start time of the current data segment, the current cached data frame is not played. When the start time of the current cached data frame is less than the playback start time of the current data segment and the end time of the current cached data frame is greater than the playback start time of the current data segment, the timestamp of the current cached data frame is updated based on the playback start time of the current data segment to obtain the playback start time of the current cached data frame.
[0114] like Figure 10 As shown, Figure 10 This is a structural diagram of an embodiment of an electronic device of the present application.
[0115] The electronic device includes a processor 210 and a memory 220 .
[0116] The processor 210 controls the operation of the electronic device and may also be referred to as a CPU (Central Processing Unit). The processor 210 may be an integrated circuit chip with the ability to process signal sequences. The processor 210 may also be a general-purpose processor, a digital signal sequence processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. The general-purpose processor may be a microprocessor or any conventional processor.
[0117] The memory 220 stores instructions and program data required for the processor 210 to operate.
[0118] The processor 210 is configured to execute instructions to implement the method provided by any one of the embodiments and possible combinations of the aforementioned synchronous playback method of the present application.
[0119] like Figure 11 As shown, Figure 11 This is a structural diagram of an embodiment of a computer-readable storage medium of the present application.
[0120] An embodiment of the readable storage medium of the present application includes a memory 310, which stores computer-executable instructions. When the computer-executable instructions are executed, the method provided by any embodiment and possible combination of the method for synchronous playback of files of the present application is implemented.
[0121] The memory 310 may include a medium that can store program instructions, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, or it may be a server that stores the program instructions. The server can send the stored program instructions to other devices for execution, or it can also execute the stored program instructions itself.
[0122] like Figure 12 As shown, Figure 12 This is a schematic structural diagram of an embodiment of the computer program product of the present application.
[0123] An embodiment of the computer program product of the present application includes a memory 410, which stores a computer program. When the computer program is executed, the method provided by any embodiment and possible combination of the synchronous playback method of the present application is implemented.
[0124] The memory 410 may include a medium that can store program instructions, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, or it may be a server that stores the program instructions. The server may send the stored program instructions to other devices for execution, or it may execute the stored program instructions itself.
[0125] In summary, by obtaining the current cached data frame and the playback start time when the current cached data frame should start playing, and then based on the playback start time and the playback start time of the current data segment, the expected playback start time of the current cached data frame relative to the system clock is obtained. The expected delay time is obtained according to the expected playback start time and the current system time. The numerical value of the expected delay time and the comparison result with the dynamic delay time are used as the basis for judging the arrival timing of the current cached data frame, and are used to judge whether the arrival timing of the current cached data frame is appropriate, so as to select the corresponding playback strategy according to the judgment result, reduce the impact of the unstable push rate of the data to be played, and improve the user's playback experience.
[0126] In the several embodiments provided in this application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the modules or units is merely a logical functional division. In actual implementation, other division methods may be used, such as combining or integrating multiple units or components into another system, or ignoring or not implementing certain features.
[0127] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of this embodiment.
[0128] In addition, each functional unit in each embodiment of the present application may be integrated into a processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The above-mentioned integrated units may be implemented in the form of hardware or software functional units.
[0129] If the integrated units in the above other embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0130] The above description is merely an embodiment of the present application and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A synchronous playback method, characterized in that: The method comprises: Receive a currently cached data frame and obtain a playback start time of the currently cached data frame; Obtaining an expected playback start time of the current cached data frame based on the playback start time of the current cached data frame and the playback start time of the current data segment in the playback pipeline; Obtaining an expected delay time based on the expected playback start time and the current system time; Based on the numerical value of the expected delay time and the comparison result with the dynamic delay time, a corresponding playback strategy is executed on the current cached data frame.
2. The method according to claim 1, characterized in that The executing a corresponding playback strategy for the current cached data frame based on the numerical value of the expected delay time and the comparison result with the dynamic delay time includes: When the expected delay time is less than zero, delaying the playing of the currently cached data frame; When the expected delay time is greater than or equal to zero and less than the dynamic delay time, immediately playing the current cached data frame; When the expected delay time is greater than or equal to the dynamic delay time, it is determined whether to play the current cached data frame based on a comparison result between the expected playback start time and the playback time of the last cached data frame.
3. The method according to claim 1 or 2, characterized in that The step of obtaining the dynamic delay time includes: Obtaining playback start time differences of a preset number of adjacent currently cached data frame pairs before the start of the currently cached data frame; Calculating an average of all the play time differences; The dynamic delay time is obtained by adding the average value to the basic delay time.
4. The method according to claim 2, characterized in that The determining whether to play the current cached data frame based on a comparison result between the expected playback start time and the playback time of the last cached data frame includes: Get the maximum playback interval of the current cached data frame; When the time difference between the expected playback start time and the playback time of the last cached data frame is greater than the maximum playback interval, the current cached data frame is played immediately; When the time difference between the expected playback start time and the playback time of the last cached data frame is less than or equal to the maximum playback interval, the current cached data frame is not played; Or when the expected delay time is less than zero, delaying the playing of the currently cached data frame comprises: Get the maximum single waiting time; When the expected delay time is greater than the single maximum waiting time, wait for the system time to pass the single maximum waiting time, and subtract the single maximum waiting time from the expected delay time to update the expected delay time; The expected delay time is continuously updated until the expected delay time is less than the single maximum waiting time, and the currently cached data frame is played after the system time passes the expected delay time.
5. The method according to claim 4, characterized in that When the expected delay time is less than zero, the waiting system time after the single maximum waiting time exceeds includes: Determine whether other execution instructions are received; When receiving the other execution instruction, exiting the update process of the expected delay time and executing the other execution instruction; When no other execution instruction is received, the expected delay time is subtracted from the single maximum waiting time to update the expected delay time.
6. The method according to claim 1, wherein The obtaining of the playback start time of the currently cached data frame includes: The playback start time of the current cached data frame is obtained based on the timestamp of the current cached data frame, the playback start time of the current data segment in the playback pipeline, and the playback speed.
7. The method according to claim 6, characterized in that Before obtaining the playback start time of the current cached data frame based on the timestamp of the current cached data frame, the playback start time of the current data segment in the playback pipeline, and the playback speed, the method includes: Obtain the start time and end time of the currently cached data frame; When the start time of the current cached data frame is greater than the play end time of the current data segment, the current cached data frame is not played; When the end time of the current cached data frame is less than the play start time of the current data segment, the current cached data frame is not played; When the start time of the current cached data frame is less than the playback start time of the current data segment, and the end time of the current cached data frame is greater than the playback start time of the current data segment, updating the timestamp of the current cached data frame based on the playback start time of the current data segment to obtain the playback start time of the current cached data frame; And / or, obtaining the playback start time of the current cached data frame based on the timestamp of the current cached data frame, the playback start time of the current data segment in the playback pipeline, and the playback speed includes: Subtract the playback start time of the current data segment from the timestamp to obtain the target time; The target time is divided by the playback speed to obtain the playback start time of the current buffered data frame.
8. A playback device, characterized in that: include: Receiving module, used to obtain the current cache data frame; A control module, configured to implement the synchronous playback method according to any one of claims 1 to 7; The playing module is used to play the currently cached data frame according to the instruction of the control module.
9. An electronic device, characterized in that: The system comprises a memory and a processor, wherein the memory is used to store program data, and the program data can be executed by the processor to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium / computer program product, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor; The computer program product comprises a computer program, which implements the method according to any one of claims 1 to 7 when executed by a processor.