Online audio / video playback method and electronic device - Patents.com

The method improves online audio/video playback by using two buffers and batch synchronization to address frame freezing in non-uniformly interleaved streams, ensuring efficient and consistent playback across different interleaving degrees.

JP7534031B2Active Publication Date: 2024-08-14HUAWEI TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
JP2023524568
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Priority Date
2020-10-22
Filing Date
2021-09-02
Publication Date
2024-08-14
Estimated Expiration
2041-09-02

AI Technical Summary

Technical Problem

Existing online audio/video playback methods experience significant frame freezing due to non-uniformly interleaved audio/video streams, affecting user experience.

Method used

An online audio/video playback method that uses two buffers to store data packets and performs audio and video synchronization in batches, detecting non-uniformly interleaved streams by adjusting a regulation factor n based on playback status to improve synchronization efficiency.

Benefits of technology

Reduces frame freezing during online playback by enhancing audio and video synchronization efficiency, applicable to various stream sizes and types, and preventing different playback effects for streams with varying degrees of interleaving.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 0007534031000006
    Figure 0007534031000006
  • Figure 0007534031000012
    Figure 0007534031000012
  • Figure 0007534031000003
    Figure 0007534031000003
Patent Text Reader

Abstract

An embodiment of the present application provides an online audio / video playback method and an electronic device. The electronic device allocates at least two buffers to a client. When the electronic device plays an audio / video stream online, the at least two buffers are used to separately store audio / video streams downloaded multiple times. For example, a second buffer unit is used to store a first segment of the audio / video stream obtained using a first request, and a third buffer unit is used to store a second segment of the audio / video stream obtained using a second request. The electronic device then performs audio and video synchronization on the audio / video streams in the at least two buffers in batches. The embodiment of the present application can improve the audio and video synchronization efficiency of the client and reduce frame freezes during online audio / video playback.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS This application claims priority to Chinese Patent Application No. 202011138720.6, entitled "ONLINE AUDIO / VIDEO PLAY METHOD AND ELECTRONIC DEVICE," filed with the State Intellectual Property Office of the People's Republic of China on October 22, 2020, the entire contents of which are incorporated herein by reference.

[0002] The present application relates to the field of Internet technology, in particular to an online audio / video playing method and electronic device. [Background technology]

[0003] Play online is an online audio / video playback method that allows users to play audio and video files online directly without downloading them to their local devices. By using online playback technology, a user can establish a network connection to a server through a client at any time, request audio and video files from the server, and play the audio and video provided by the server. However, if the audio and video files requested by the client are non-uniformly interleaved audio / video streams, significant frame freezing will occur during playback on the client. As a result, the user experience will be affected. Summary of the Invention [Problem to be solved by the invention]

[0004] The embodiments of the present application provide an online audio / video playback method and electronic device, which improves synchronization efficiency of audio / video streams and reduces frame freezing during online audio / video playback. [Means for solving the problem]

[0005] According to a first aspect, an online audio / video playback method is provided. The method includes: an electronic device sends a first request to a network device; the electronic device receives a first segment of an audio / video stream fed back by the network device based on the first request, and stores the first segment of the audio / video stream in a first buffer unit; where the first segment of the audio / video stream includes a preset number of data packets, and the data packets of the first segment of the audio / video stream include audio packets and / or video packets; if the first segment of the audio / video stream is a non-uniformly interleaved audio / video stream, the electronic device reads M data packets from the first buffer unit and stores the M data packets in a second buffer unit; where M is a positive integer greater than 1, and the non-uniformly interleaved audio / video stream means that the number of audio packets and video packets included in the first segment of the audio / video stream, which have the same presentation timestamp PTS, and whose storage positions exceed a specified distance threshold, exceeds a specified number threshold; the electronic device clears the data packets of the first buffer unit and sends a second request to the network device. The electronic device receives a second segment of the audio / video stream fed back by the network device based on the second request, and stores the second segment of the audio / video stream in a first buffer unit, where the second segment of the audio / video stream includes a preset number of data packets, and the data packets of the second segment of the audio / video stream include audio packets and / or video packets. The electronic device reads Y data packets from the first buffer unit, and stores the Y data packets in a third buffer unit, where Y is a positive integer greater than 1.The electronic device matches the data packets of the second buffer unit with the data packets of the third buffer unit, finds a pair of audio packets and video packets having the same PTS, and then controls the player to play the pair of audio packets and video packets having the same PTS.

[0006] In this embodiment of the present application, the electronic device allocates two buffers (i.e., a second buffer unit and a third buffer unit) to store the data packets downloaded twice, and performs audio-video synchronization on the data packets in the two buffers in a batch. Compared with the conventional solution of performing audio-video synchronization by repeatedly downloading data packets in a stream multiple times, the embodiment of the present application can improve the audio-video synchronization efficiency of a client (such as a player). Compared with the technical solution using a local buffer, the embodiment of the present application can reduce the buffer time. Therefore, the embodiment of the present application can be applied to online playback of audio and video of any size, and can reduce frame freeze during online playback of all audio and video.

[0007] In a possible design, the electronic device may use the following method to detect whether the first segment of the audio / video stream is a non-uniformly interleaved audio / video stream: for each audio packet in the first segment of the audio / video stream, the electronic device detects whether the first segment of the audio / video stream has a video packet with the same PTS as the audio packet. If the first segment of the audio / video stream has a video packet with the same PTS as the audio packet, the electronic device records the audio packet as an interleaved audio packet a1. If the first segment of the audio / video stream does not have a video packet with the same PTS as the audio packet, the electronic device records the audio packet as a non-interleaved audio packet a2. For each video packet in the first segment of the audio / video stream, the electronic device detects whether the first segment of the audio / video stream has an audio packet with the same PTS as the video packet. If the first segment of the audio / video stream has an audio packet with the same PTS as the video packet, the electronic device records the video packet as an interleaved video packet v1. If there is no audio packet with the same PTS as the video packet in the first segment of the audio / video stream, the electronic device records the video packet as a non-interleaved video packet v2. If the ratio of the total number of a1 and v1 to the total number of a1, v1, a2, and v2 in the first segment of the audio / video stream is less than a preset value n, the electronic device determines that the first segment of the audio / video stream is a non-uniformly interleaved audio / video stream. This design method allows the electronic device to more accurately detect a non-uniformly interleaved stream.

[0008] In a possible design, the electronic device may determine the value of n based on the playback status of the player playing the historical audio / video streams. If the ratio of the total number of a1 and v1 to the total number of a1, v1, a2, and v2 in the historical audio / video streams is less than n, the playback status of the player may be frame freeze. It should be understood that the value of n may be different for different players or different audio / video streams played by the same player.

[0009] In this design method, the electronic device can determine the value of the regulating coefficient n based on the actual playback effect of streams with different interleaving degrees to prevent certain determination conditions from causing different playback effects for audio / video streams with different interleaving degrees.

[0010] In a possible design, if the first segment of the audio / video stream includes a first audio packet, the electronic device determines that the first segment of the audio / video stream does not include a video packet having the same PTS as the first audio packet and sends a second request to the network device, where the second request is used to request a video packet having the same PTS as the first audio packet.

[0011] In this design method, the electronic device may request a second segment of the audio / video stream based on a matching status between audio packets and video packets in the first segment of the audio / video stream, where the second segment of the audio / video stream includes video packets that are not in the first segment of the audio / video stream, thereby further improving the audio and video synchronization efficiency of the player.

[0012] In a possible design, all M data packets are audio packets and all Y data packets are video packets, alternatively all M data packets are video packets and all Y data packets are audio packets, alternatively the M data packets are the first M data packets of a first segment of the audio / video stream and the Y data packets are the first Y data packets of a second segment of the audio / video stream.

[0013] This design method can further improve the efficiency of audio and video synchronization.

[0014] In a possible design, the electronic device may first perform matching on the data packets of the first buffer unit before reading the M data packets from the first buffer unit, and after finding a pair of audio packets and video packets with the same PTS, control the player to play the pair of audio packets and video packets with the same PTS. Then, the electronic device stores the audio packets in the first buffer unit that do not have a matching video packet with the same PTS as the audio packet in the second buffer unit, or stores the video packets in the first buffer unit that do not have a matching audio packet with the same PTS as the video packet in the second buffer unit.

[0015] In a possible design, M may be equal to Y.

[0016] In a possible design, the method further includes: if the first segment of the audio / video stream is a uniformly interleaved audio / video stream, the electronic device reads data packets of the first buffer unit in order based on the stream sequence, and controls a player to play a pair of audio packets and video packets having the same PTS after the pair of audio packets and video packets having the same PTS is read.

[0017] In this design method, the electronic device may use different methods of audio and video synchronization for uniformly interleaved audio / video streams and non-uniformly interleaved audio / video streams, which can further improve the audio and video synchronization efficiency of the player.

[0018] According to a second aspect, an embodiment of the present application provides an electronic device including one or more processors and a memory, the memory storing program instructions, which, when executed by the electronic device, realizes a method according to the first aspect of the embodiment of the present application and any possible design of the first aspect.

[0019] According to a third aspect, an embodiment of the present application provides a chip, the chip being coupled to a memory in a device such that the chip, when executed, invokes program instructions stored in the memory to implement a method according to the first aspect and any possible design of the first aspect in the embodiment of the present application.

[0020] According to a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, where the computer-readable storage medium stores program instructions that, when executed on an electronic device, enable the electronic device to perform a method according to the first aspect and any possible design of the first aspect in the embodiment of the present application.

[0021] According to a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on an electronic device, enables the electronic device to execute a method according to the first aspect of the embodiment of the present application and any possible design of the first aspect.

[0022] In addition, for the technical effects brought about by any possible design methods in the second to fifth aspects, please refer to the technical effects brought about by different design methods in the method part, which are not described in detail here. [Brief description of the drawings]

[0023] [Figure 1] FIG. 2 is a possible schematic diagram of a uniformly interleaved audio / video stream. [Diagram 2] FIG. 2 is an example of a possible schematic diagram of non-uniformly interleaved audio / video streams. [Diagram 3] 1 is a flowchart of a possible method for audio and video synchronization of non-uniformly interleaved audio / video streams. [Figure 4] FIG. 1 is a schematic architecture diagram of an online playback system applicable to an embodiment of the present application. [Diagram 5] FIG. 2 is a schematic architecture diagram of another online playback system applicable to an embodiment of the present application. [Figure 6] 2 is a schematic diagram illustrating a hardware structure of an electronic device 200 according to an embodiment of the present application. [Figure 7] FIG. 2 is a block diagram showing the software structure of an electronic device 200 according to an embodiment of the present application. [Figure 8] 1 is a flowchart of an online audio / video playing method according to an embodiment of the present application. [Figure 9] 1 is a flowchart of a method for detecting a non-uniformly interleaved stream according to an embodiment of the present application. [Figure 10] FIG. 2 is a schematic diagram of an audio / video stream. [Figure 11] FIG. 2 is a schematic diagram of a specific method for synchronizing audio and video; [Figure 12] FIG. 2 is a schematic diagram of another specific method of audio and video synchronization; [Figure 13]4 is another flowchart of an online audio / video playing method according to an embodiment of the present application. [Figure 14] 14 is a schematic diagram illustrating a structure of an electronic device 1400 according to an embodiment of the present application. [Figure 15] 15 is a schematic diagram illustrating a structure of an electronic device 1500 according to an embodiment of the present application. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0024] Audio and video streams for online playback (simply referred to as audio / video streams) are usually stored in a uniformly interleaved manner in MP4 media files. Figure 1 is a possible schematic diagram of a uniformly interleaved audio / video stream. A represents an audio data packet (simply referred to as audio packet), and V represents a video data packet (simply referred to as video packet). In Figure 1, the audio and video packets (simply referred to as audio and video packets) are interleaved in the following order: first audio packet A0, first video packet V0, second audio packet A1, second video packet V1, third audio packet A2, third video packet V2, ... and so on. Audio and video packets with the same playback time in the stream are adjacent. Audio and video packets with the same playback time have the same Presentation Timestamp (PTS). The PTS is used to indicate when the client should display (or export or play) the data. That is, audio and video packets that have the same PTS must be played (or exported or displayed) in sync.

[0025] For example, in FIG. 1, a first audio packet A0 is adjacent to a first video packet V0. The first audio packet A0 and the first video packet V0 have the same PTS and need to be played synchronously. A second audio packet A1 is adjacent to a second video packet V1. The second audio packet A1 and the second video packet V1 have the same PTS and need to be played synchronously. The PTS of A1 and V1 are later than the PTS of A0 and V0.

[0026] The client downloads the audio / video stream from the server in segments. Specifically, the client downloads a segment of the audio / video stream each time (containing a pre-set number of audio and video packets). The client reads the data of each segment of the audio / video stream in order from front to back. This allows the audio and video data to be read synchronously and played synchronously.

[0027] However, after long-term development of online playback technology, the audio stream and video stream in the MP4 media file provided by a certain audio / video website will be non-uniformly interleaved. For example, in some short video portal sites (such as TikTok, Kwai, etc.), users may use the client to create and upload videos, or watch videos uploaded by other users. Usually, when users create videos, they apply effects (such as shake, zoom, time reversal, action repeat, etc.) to the video to enhance the video playback effect. As a result, the operations performed by users on the video may cause the audio stream and video stream to be non-uniformly interleaved.

[0028] In the technique of detecting a non-uniformly interleaved audio / video stream, the client performs a position analysis on the audio / video stream before playing the audio / video stream, and checks whether the distance between the storage locations of audio packets and video packets with the same PTS exceeds a specific distance. If the distance between the storage locations of most pairs of audio packets and video packets with the same PTS among the detected audio packets and video packets exceeds the specified distance, the interleaving performance of the audio / video stream is relatively low. In this case, the audio / video stream is a non-uniformly interleaved audio / video stream (non-uniformly interleaved audio / video streams are alternatively called non-uniformly interleaved audio / video streams, non-uniformly interleaved streams, non-uniformly interleaved streams, uniformly non-interleaved streams, non-interleaved audio / video streams, non-interleaved streams, etc. In this application, the names are not limited in the specification.). If the distance between the storage locations of most pairs of audio and video packets with the same PTS among the detected audio and video packets does not exceed a specified distance, the interleaving performance of the audio / video stream is relatively good. In this case, the audio / video stream is a uniformly interleaved audio / video stream (the uniformly interleaved audio / video stream is alternatively called a uniformly interleaved audio / video stream, a uniformly interleaved stream, a uniformly interleaved stream, an interleaved audio / video stream, an interleaved stream, etc., and the names are not limited in this application).

[0029] FIG. 2 is a possible schematic diagram of a non-uniformly interleaved audio / video stream. In FIG. 2, audio and video packets are interleaved in the following order: first audio packet A0, second audio packet A1, third audio packet A2, fourth audio packet A3, fifth audio packet A4, first video packet V0, second video packet V1, third video packet V2, ... and so on. Audio packets do not alternate with audio packets. Therefore, there may be cases where audio and video packets with the same PTS are separated. For example, the "specified distance" is the distance of two data packets. In this case, A0 and V0 are separated by four data packets, A1 and V1 by four data packets, and A2 and V2 by four data packets, all of which exceed the specified distance of two data packets. Thus, the audio / video stream is non-uniformly interleaved.

[0030] However, the "specific distance" and "almost" in the above solutions are empirical values ​​that are manually set. When the values ​​of "specific distance" and "almost" are set, they become fixed decision criteria. However, in practical applications, there is no clear definition (or clear boundary) between uniformly interleaved streams and non-uniformly interleaved streams. Streams with different interleaving states have different playback effects for different clients due to different client performance. Therefore, a fixed criterion cannot guarantee the desired playback effect of all streams with different interleaving states.

[0031] Furthermore, after a client downloads a non-uniformly interleaved audio / video stream from a server, but still reads data from the stream using a uniformly interleaved audio / video stream reading method, i.e., by reading data in the stream from front to back based on the stream sequence, the audio and video synchronization requirements cannot be met during reading.

[0032] A solution to audio and video synchronization of a non-uniformly interleaved audio / video stream is to repeatedly download data packets of the stream.

[0033] FIG. 3 is a possible flow chart of a method for audio and video synchronization of non-uniformly interleaved audio / video streams.

[0034] Step 1: The client initiates a first Hypertext Transfer Protocol (HTTP) request (recorded as HTTP1) to the server to obtain a first data segment (the data size of the data segment is less than or equal to the size of a buffer on the client), and stores the first data segment in the buffer, where the first data segment includes three audio packets, A1, A2, and A3. The client reads the first audio packet A1 from the buffer, and searches the buffer for a video packet whose PTS is the same as A1. If the first data segment does not include a video packet whose PTS is the same as A1, step 2 is executed.

[0035] Step 2: The client clears the first data segment currently stored in the buffer, initiates a second HTTP request (recorded as HTTP2) to the server to get the second data segment, and stores the second data segment in the buffer. Now, the second data segment contains three video packets, V1, V2, and V3. The client reads the video packet V1 whose PTS is equal to A1 from the buffer. After A1 is aligned with V1, the client continues to read the next data packet, i.e., video packet V2, from the buffer, and searches the buffer for an audio packet whose PTS is equal to V2. If it is found that the second data segment does not contain an audio packet whose PTS is equal to V2, step 3 is executed.

[0036] Step 3: The client clears the second data segment currently stored in the buffer, initiates a third HTTP request (recorded as HTTP3) to the server to get the third data segment, and stores the third data segment in the buffer. The third data segment contains three audio packets: A2, A3, and A4. The client reads audio packet A2, whose PTS is equal to V2, from the buffer. After A2 is aligned with V2, the client continues to read the next data packet, i.e., audio packet A3, from the buffer, and searches the buffer for a video packet whose PTS is equal to A3. If it is found that the third data segment does not contain a video packet whose PTS is equal to A3, step 4 is executed.

[0037] Step 4: The client clears the third data segment currently stored in the buffer, initiates a fourth HTTP request (recorded as HTTP4) to the server to get the fourth data segment, and stores the fourth data segment in the buffer. Now, the fourth data segment contains three video packets, V2, V3, and V4. The client reads the video packet V3 whose PTS is the same as A3 from the buffer. After A3 is aligned with V3, the client continues to read the next data packet, i.e., the video packet V4, from the buffer, and searches the buffer for an audio packet whose PTS is the same as V4. If it is found that the fourth data segment does not contain an audio packet whose PTS is the same as V4, execute step 5.

[0038] The above process is performed in polling mode until all audio and video have been played.

[0039] From the above process, we can learn that in this solution, the client needs to repeatedly download data packets of the stream for audio and video synchronization, which takes a long time and has relatively low reading efficiency. Also, the audio and video data that need to be played synchronously cannot be read in a timely manner, which will cause frame freeze during audio / video playback.

[0040] Another solution to audio-video synchronization for non-uniformly interleaved audio / video streams is to use a local buffering technique. In this solution, before audio / video playback, the client gets the size of the audio / video streams using HTTP requests, downloads and buffers all audio / video streams whose size is within a certain range, and plays the audio / video streams on the local device after the audio / video streams are downloaded to the local device. This technique reduces the time consumed in initiating multiple HTTP requests for audio-video synchronization when the client is playing the audio / video streams while downloading them, thus reducing frame freezing.

[0041] However, this solution of buffering the audio / video streams in the local device takes a relatively long time. Therefore, the playback starts slowly. That is, the user has to wait a relatively long time until the playback starts. The user experience is poor. In addition, this solution is only applicable to frame freezing that occurs during playback of non-uniformly interleaved audio / video streams whose data size is within a threshold range (for example, data size is less than 2G). Since this solution is not applicable to frame freezing that occurs during playback of non-uniformly interleaved audio / video streams whose data size is outside the threshold range, it cannot fundamentally solve the frame freezing problem that occurs during playback of all non-uniformly interleaved audio / video streams.

[0042] In order to solve one or more of the above technical problems, the embodiments of the present application provide an online audio / video playback method and electronic device. In this solution, the size of buffered data requested by the client each time is used as the distance for detecting the same PTS. This precisely defines the distance between audio packets and video packets that are non-uniformly interleaved. The criterion for determining a non-uniformly interleaved audio / video stream is regulated by a regulating factor n, which can be dynamically adjusted by the client based on different video conditions. This prevents a certain determination condition from generating different playback effects for audio / video streams with different interleaving degrees. Furthermore, the client allocates at least two buffers to store data packets that are downloaded multiple times using an HTTP request. Then, the client performs audio and video synchronization on the data packets in the at least two buffers in batches. This improves the audio and video synchronization efficiency of the client and reduces frame freezing during online audio / video playback.

[0043] The technical solutions in the embodiments of the present application are described below with reference to the accompanying drawings in the embodiments of the present application.

[0044] In the description of the embodiments of the present application, the terms "first" and "second" are used for descriptive purposes only and shall not be understood as an indication or implication of relative importance or an implicit indication of the number of technical features shown. Thus, a feature qualified by "first" or "second" may explicitly or implicitly include one or more features. In the description of the embodiments of the present application, unless otherwise specified, "plurality" means two or more.

[0045] 4 is a schematic architecture diagram of an online playback system applicable to the embodiments of the present application. The system includes: a server 101 and an electronic device 102.

[0046] The server 101 stores media files. The media files may be in MP4 format or another format, which is not limited in this application. The server 101 may provide audio / video streams, such as various media streams such as movies, television, short videos, etc., to the electronic device 102. The server 101 may be any electronic device with computing capabilities, such as a tablet, a laptop, a server, a wearable device, or an audio / video playback device, or may be an electronic device system including multiple such electronic devices. This is not particularly limited in this embodiment of the present invention.

[0047] A client corresponding to the server 101 is installed on the electronic device 102. The client, also called a user end, is a program corresponding to the server, and provides local audio and video services to a user. For example, if the server 101 is a Huawei server, the client may be a "HUAWEI Video" app installed on the electronic device 102. The electronic device 102 can establish a communication connection with the server 101 by executing the client, and decode and play audio / video streams, etc. from the server 101. In some possible implementations, the client may specifically be a media player (Media Renderer, MR).

[0048] For example, the electronic device 102 can request an audio / video stream from the server 101 via a client, and use the technical solutions provided in this application to detect the non-uniformly interleaved stream and play the audio and video online.

[0049] 4 takes one electronic device 102 as an example, in a practical application, there may be multiple electronic devices 102 in the online playback system.

[0050] 5 is a schematic architecture diagram of another online playback system applicable to an embodiment of the present application. The system includes a server, a mobile phone, and a smart TV. The server can provide audio / video streams. A client (such as a player) corresponding to the server is installed on the mobile phone. The mobile phone can request the audio / video streams from the server through the client, detect the non-uniformly interleaved streams, and play the audio and video online using the technical solution provided in the present application.

[0051] When the mobile phone and the smart TV are in the same local area network, for example, when the mobile phone and the smart TV are connected to the same Wireless Fidelity (Wi-Fi), the mobile phone can use a screen projection protocol to send data to the smart TV and control the smart TV to play audio and video. The screen projection protocol may be a Digital Living Network Alliance (DLNA) protocol, an AirPlay push protocol, a Lelink protocol, etc. This is not limited in this application.

[0052] For example, when playing an audio / video stream obtained from a server, the mobile phone detects a screen projection operation. In response to the screen projection operation, the mobile phone searches for an electronic device that supports the screen projection service in the Wi-Fi network. After finding the smart TV, the mobile phone sends the video address of the currently played audio / video stream to the smart TV. Upon receiving the address, the smart TV requests the corresponding audio / video stream from the server based on the address and plays the audio / video stream. In this way, screen projection from the mobile phone to the smart TV is realized.

[0053] During screen projection, the mobile phone can control the playback progress of the smart TV. For example, the mobile phone can command the smart TV to pause playback, play the next episode, adjust the volume, etc. The mobile phone can be understood to function as a control point in the screen projection process. The mobile phone initializes and sets up the connection between the smart TV and the server, but is not directly involved in the content transmission in a real sense. The content transmission is realized by the server and the smart TV.

[0054] In the screen projection process, after the smart TV downloads the audio / video stream, it can further use the technical solution provided in this application to detect the non-uniformly interleaved stream and play the audio and video online.

[0055] It should be understood that the electronic device in the embodiment of the present application is any electronic device that has a function of connecting to a network and a function of playing audio and video. For example, the electronic device in the embodiment of the present application may be a mobile phone, a tablet, Tablet ), computers with wireless transceiver capabilities, virtual reality (VR) devices, augmented reality (AR) devices, wireless devices in industrial control, unmanned driving ( unmanned wireless devices in driving, telemedicine ( Telemedicine The wireless device may be a wireless device in a smart grid, a wireless device in transportation safety, a wireless device in a smart city, a wireless device in a smart home, and the like.

[0056] In the following, a schematic diagram of the structure of an electronic device applied to one embodiment of the present application is described using an example in which the electronic device is a mobile phone.

[0057] FIG. 6 is a schematic diagram showing a hardware structure of an electronic device 200 according to an embodiment of the present application.

[0058] The electronic device 200 may include a processor 210, an external memory interface 220, an internal memory 221, a universal serial bus (USB) interface 230, a charging management module 240, a power management module 241, a battery 242, an antenna 1, an antenna 2, a mobile communication module 250, a wireless communication module 260, an audio module 270, a speaker 270A, a receiver 270B, a microphone 270C, a headset interface 270D, a sensor module 280, buttons 290, a motor 291, an indicator 292, a camera 293, a display screen 294, a subscriber identification module (SIM) card interface 295, and the like. The sensor module 280 may include a pressure sensor 280A, a gyro sensor 280B, an air pressure sensor 280C, a magnetic sensor 280D, an acceleration sensor 280E, a distance sensor 280F, an optical proximity sensor 280G, a fingerprint sensor 280H, a temperature sensor 280J, a touch sensor 280K, an ambient light sensor 280L, a bone conduction sensor 280M, and the like.

[0059] It may be understood that the structure shown in this embodiment of the present application does not constitute a limitation of electronic device 200. In some other embodiments of the present application, electronic device 200 may include more or fewer components than those shown in the figures, may combine some components, may split some components, or may have a different component arrangement. The components shown in the figures may be implemented by hardware, software, or a combination of software and hardware.

[0060] The processor 210 may include one or more processing units. For example, the processor 210 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural processing unit (NPU). Different processing units may be independent components or may be integrated into one or more processors. In this embodiment of the present application, the execution of the online audio / video playback method may be controlled by the processor 210 or may be completed by the processor 210 by calling another component. For example, the processor 210 calls a processing program stored in the internal memory 221 in this embodiment of the present application, or uses the external memory interface 220 to call a processing program stored in a third-party device in this embodiment of the present application to dynamically adjust the determinant of the non-uniformly interleaved stream. This prevents a fixed decision condition from causing different playback effects for audio / video streams with different interleaving degrees. In addition, the processor 210 allocates two buffers for the client to read the video and audio packets of the downloaded data in batches. This improves the audio and video synchronization efficiency of the client.

[0061] The internal memory 221 may include a program storage area and a data storage area. The program storage area may store an operating system, an application required for at least one function (such as an audio playback function or a video playback function), and the like. The data storage area may store data (such as audio data, video data, playback logs, and the like) created in a process using the electronic device 200. In addition, the internal memory 221 may include a high-speed random access memory, and may further include a non-volatile memory, for example, at least one magnetic disk storage device, flash memory, or universal flash storage (UFS). The internal memory 221 may be configured to store computer-executable program code of the online audio / video playback solution provided in this embodiment of the present application, where the executable program code includes instructions. The processor 210 is an interface switching solution and may execute the computer-executable program code stored in the internal memory 221, so that the electronic device 200 can realize the online audio / video playback solution provided in this embodiment of the present application.

[0062] The electronic device 200 realizes display functions using a GPU, a display screen 294, an application processor, etc. For example, the electronic device 200 displays video data in an audio / video stream obtained from a server. The GPU is a microprocessor for image processing and is connected to the display screen 294 and the application processor. The GPU is configured to perform mathematical and geometric calculations and render images. The processor 210 can include one or more GPUs that execute program instructions to generate or modify display information.

[0063] The electronic device 200 may further implement image capture functions using an ISP, a camera 293, a video codec, a GPU, a display screen 294, an application processor, and the like.

[0064] The SIM card interface 295 is configured to connect to a SIM card. The SIM card can be inserted into or removed from the SIM card interface 295 to contact or separate from the electronic device 200. The electronic device 200 can support one or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 295 can support a nano-SIM card, a micro-SIM card, a SIM card, etc. Multiple cards can be inserted into the same SIM card interface 295 at the same time. The multiple cards can be of the same type or different types. The SIM card interface 295 can be compatible with different types of SIM cards. The SIM card interface 295 can be compatible with an external storage card. The electronic device 200 interacts with a network by using the SIM card to implement functions such as calling and data communication. In some embodiments, the electronic device 200 uses an eSIM, i.e., an embedded SIM card.

[0065] The wireless communication function of the electronic device 200 can be implemented using an antenna 1, an antenna 2, a mobile communication module 250, a wireless communication module 260, a modem processor, a baseband processor, etc. The antenna 1 and the antenna 2 are configured to transmit and receive electromagnetic wave signals. Each antenna of the electronic device 200 can be configured to cover one or more communication frequency bands. To improve the antenna utilization, different antennas can be further multiplexed. For example, the antenna 1 can be multiplexed as a diversity antenna of a wireless local area network. In some other embodiments, the antennas can be used in combination with a tuning switch.

[0066] The mobile communication module 250 can provide a wireless communication solution, such as a 2G / 3G / 4G / 5G communication solution, applied to the electronic device 200. The mobile communication module 250 can include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 250 can receive electromagnetic waves via the antenna 1, process the received electromagnetic waves, such as filtering and amplifying, and transmit the processed electromagnetic waves to the modem processor for demodulation. The mobile communication module 250 can further amplify the signal modulated by the modem processor, convert it to electromagnetic waves, and radiate it via the antenna 1. In some embodiments, at least some of the functional modules in the mobile communication module 250 can be disposed in the processor 210. In some embodiments, at least some of the functional modules in the mobile communication module 250 can be disposed in the same component as at least some of the modules in the processor 210.

[0067] The wireless communication module 260 can be applied to the electronic device 200 to provide wireless communication solutions including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite systems (GNSS), frequency modulation (FM), near field communication (NFC) technology, and infrared radiation (IR) technology. The wireless communication module 260 may be one or more components integrating at least one communication processor module. The wireless communication module 260 receives electromagnetic waves through the antenna 2, performs frequency modulation and filtering on the electromagnetic wave signals, and transmits the processed signals to the processor 210. The wireless communication module 260 can further receive signals transmitted from the processor 210, perform frequency modulation and amplification on the signals, and convert them into electromagnetic waves and radiate them through the antenna 2.

[0068] In some embodiments, in the electronic device 200, the antenna 1 is coupled to the mobile communication module 250, and the antenna 2 is coupled to the wireless communication module 260. In this manner, the electronic device 200 can communicate with a network or other devices using wireless communication technologies, including global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, IR technologies, and the like.

[0069] In some other embodiments of the present application, electronic device 200 may include more or fewer components than those shown in the figures, combine some components, split some components, or have a different arrangement of components. The components shown in the figures may be implemented by hardware, software, or a combination of software and hardware.

[0070] The software system of the electronic device 200 can use a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. In the embodiment of the present application, the Android system of the layered architecture is used as an example to describe the software structure of the electronic device 200.

[0071] 7 is a block diagram showing a software structure of the electronic device 200 according to an embodiment of the present application. The software modules and / or codes of the software structure may be stored in the internal memory 221. When the processor 210 executes the software modules or codes, it performs the online audio / video playback method provided in the embodiment of the present application.

[0072] In a layered architecture, software is divided into layers, each of which has a clear role and task. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers from top to bottom: the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer.

[0073] The application layer may include a set of application packages.

[0074] As shown in FIG. 7, the application package may include applications such as phone, camera, gallery, calendar, calling, maps, navigation, WLAN, Bluetooth, music, video, and messaging.

[0075] The application framework layer provides an application programming interface (API) and a programming framework for applications in the application layer. The application framework layer contains some predefined functions.

[0076] As shown in FIG. 7, the application framework layer may include a window manager, a content provider, a view system, a telephony manager, a resource manager, a notification manager, and the like.

[0077] A window manager is a program that manages windowed programs. It can do things like get the size of the display screen, determine if there is a status bar, perform screen locking, and take screenshots.

[0078] Content providers are configured to store and retrieve data and make the data accessible to applications, including, for example, audio and video data retrieved from a server, and browsing history and bookmarks for an electronic device.

[0079] The view system contains visual controls, such as controls that display text and controls that display images. The view system can be composed to build applications. A display interface can contain one or more views. For example, a display interface containing a notification icon for an SMS message can contain a view that displays text and a view that displays an image.

[0080] The telephony manager is configured to provide communication functions for the electronic device, such as, for example, managing the status of the connection to the server.

[0081] The resource manager provides various resources of the application, such as localized strings, icons, images, video files, etc.

[0082] The notification manager may be configured to enable applications to display notification information in the status bar and to communicate notification messages. The displayed notification information may disappear automatically after a short time without user interaction. For example, the notification manager may be configured to notify that audio or video has been downloaded, provide message notifications, etc. The notification manager may also display notifications in the system's top status bar in the form of graphs or scrollable text, for example, notifications of applications running in the background, or may display notifications that appear on the screen in the form of dialog boxes. For example, text information may be displayed in the status bar, a prompt tone may be displayed, the electronic device may vibrate, or an indicator light may flash.

[0083] The Android runtime contains the kernel library and the virtual machine, and is responsible for scheduling and managing the Android system.

[0084] The kernel library contains two parts: the functions you need to call in Java, and the Android kernel library.

[0085] The application layer and the application framework layer run on a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is configured to implement functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.

[0086] The system library may include multiple functional modules, such as a surface manager, media libraries, a 3D graphics processing library (such as OpenGL ES), and a 2D graphics engine (such as SGL).

[0087] The surface manager is configured to manage the display subsystem and provide a blend of 2D and 3D layers for multiple applications.

[0088] The Media Library supports playback and recording of multiple commonly used audio and video formats, as well as static image files. The Media Library may support multiple audio and video coding formats, such as MPEG-4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

[0089] The 3D graphics processing library is configured to implement 3D graphics drawing, image rendering, compositing, layer processing, etc.

[0090] The 2D graphics engine is a drawing engine for 2D drawing.

[0091] The kernel layer is a layer between the hardware and the software. The kernel layer includes at least one display driver, a camera driver, an audio driver, and a sensor driver. In the embodiment of the present application, the hardware may refer to various types of sensors, such as an acceleration sensor, a gyro sensor, a touch sensor, and a pressure sensor.

[0092] It may be understood that software programs and / or modules corresponding to the software architecture of FIG. 7 are stored in the internal memory 221 of the electronic device 200 shown in FIG.

[0093] In the following, the solution provided by the embodiment of the present application will be described in detail using an example in which the embodiment of the present application is applied to the electronic device 200.

[0094] 8 shows an online audio / video playing method according to an embodiment of the present application. The method includes the following steps:

[0095] S801: An electronic device sends a first HTTP request to a server via a client, and the server receives the first HTTP request.

[0096] It can be understood that this embodiment of the present application uses an example in which the client communicates with the server based on HTTP protocol. Therefore, the type of request that the electronic device sends to the server through the client is an HTTP request. However, in practical applications, the client may alternatively communicate with the server based on another protocol. That is, the client can also send another type of request to the server, which is not limited in the present application.

[0097] S802: In response to the first HTTP request, the server returns a first segment of the audio / video stream to the electronic device. The electronic device receives the first segment of the audio / video stream and stores the first segment of the audio / video stream in a first buffer unit.

[0098] The first buffer unit is a buffer allocated by the electronic device to store the downloaded audio / video stream. Every time, the data packets downloaded using the HTTP request are stored in the first buffer unit first. It should be understood that every time before the electronic device sends an HTTP request, the electronic device needs to clear the data in the first buffer unit to store the data packets downloaded using the HTTP request. It should be understood that the first buffer unit may be a part of the storage space of the internal memory of the electronic device.

[0099] In an embodiment of the present application, the data size of the audio / video stream requested by the electronic device each time using an HTTP request is preset to a size specified by the HTTP protocol, for example, the data size buffered in one transmission, and the preset size does not exceed the size of the first buffer unit allocated by the electronic device for storing the downloaded audio / video stream.

[0100] For ease of understanding, the first segment of the audio / video stream is recorded as Buffer-1, and Buffer-1 contains at least two data packets. In this embodiment of the present application, the data packets are of two data types: audio and video. The data packets of the audio data type are also called audio packets, and the data packets of the video data type are also called video packets.

[0101] It will be understood that the first segment of the audio / video stream may include only audio packets, only video packets, or both audio and video packets, and the particular data type of the data packets of the first segment of the audio / video stream is determined by the format of the media file stored on the server.

[0102] S803: The electronic device detects whether a first segment of the audio / video stream buffered in the first buffer unit is a non-uniformly interleaved stream.

[0103] If the first segment of the audio / video stream is not a non-uniformly interleaved stream (ie, the first segment of the audio / video stream is a uniformly interleaved stream), S804 is executed.

[0104] If the first segment of the audio / video stream is a non-uniform interleaved stream, steps S805 to S810 are executed.

[0105] S804: The electronic device sequentially reads data packets in the first buffer unit based on a stream sequence, and after reading a pair of audio packets and video packets with the same PTS, plays the pair of audio packets and video packets with the same PTS.

[0106] For example, after determining that the stream corresponding to HTTP3 in the embodiment shown in Figure 10 is a uniformly interleaved stream using the method shown in Figure 9, the electronic device may read and play A9 and V9, A10 and V10, A11 and V11, and A12 and V12 of the stream sequence in front to back order, as will be described later in Figures 9 and 10.

[0107] After S804 is executed, if the current media file for online playback has not been completely played, the electronic device returns to S801, sends the next HTTP request, obtains a new audio / video stream, and performs the aforementioned operation process on the new audio / video stream until all audio / video streams in the current media file for online playback have been obtained and played.

[0108] It may be appreciated that the new audio / video streams may be uniformly interleaved or non-uniformly interleaved, and the particular type of the new audio / video streams is also determined by the format of the media files stored on the server.

[0109] S805: The electronic device reads M data packets from the first buffer unit and stores the M data packets in the second buffer unit, where M is a positive integer greater than 1. M can be a preset value such as 30, 50, 100, etc. This application is not limited to this.

[0110] In this embodiment of the present application, in addition to the first buffer unit, another N buffer units are further disposed in the electronic device to store data downloaded using N adjacent HTTP requests, where N is a positive integer greater than 1, and the N buffer units have a one-to-one correspondence with the data downloaded using the N HTTP requests. It may be necessary to understand that the N buffer units may alternatively be different storage spaces in the internal memory of the electronic device.

[0111] In the following embodiment, for example, N=2. Specifically, a second buffer unit and a third buffer unit are further disposed in the electronic device, and are configured to store data packets acquired using two adjacent HTTP requests (for example, the first HTTP request and the second HTTP request in the following description). The second buffer unit and the third buffer unit may be understood as two different buffer spaces, or as two different buffer areas in the same buffer space. This is not limited in the present application.

[0112] The electronic device reads the M data packets from the first buffer unit (i.e., reads the M data packets from the first segment of the audio / video stream) and stores them in the second buffer unit. It should be understood that the data packets of the second buffer unit (i.e., the M data packets) may include audio packets and video packets, or may include only audio packets or only video packets depending on how the first segment of the audio / video stream is interleaved.

[0113] Optionally, the PTSs of the M data packets are consecutive.

[0114] Optionally, the first segment of the audio / video stream includes a total of S data packets, where S≧M. The M data packets may be the first M data packets (specifically, data packets 1-M) or the last M data packets (specifically, data packets (S-M)) of the first segment of the audio / video stream. M+1)~S).

[0115] Optionally, in S805, before the electronic device reads the M data packets from the first buffer unit, the electronic device can first match the audio packets with the video packets of the first segment of the audio / video stream in the first buffer unit (i.e., detect the audio packets and video packets with the same PTS). After the pair of audio packets and video packets with the same PTS is read, the electronic device plays the pair of audio packets and video packets with the same PTS. Then, the electronic device stores only the M audio packets whose PTS does not match the video packets whose PTS is the same as the audio packets in the second buffer unit (i.e., all the M data packets in the second buffer unit are audio packets). Alternatively, the electronic device stores the M video packets whose PTS does not match the audio packets whose PTS is the same as the video packets in the second buffer unit (i.e., all the M data packets in the second buffer unit are video packets). This can further improve the efficiency of online playback.

[0116] S806: The electronic device detects that the M data packets do not include a video packet (eg, the first video packet) that has the same PTS as the first audio packet in the M data packets.

[0117] The first audio packet may be any audio packet within the M data packets.

[0118] Optionally, the electronic device may sequentially detect whether each audio packet in the M data packets has a corresponding video packet (ie, a video packet whose PTS is the same as that of the audio packet) based on the PTS sequence.

[0119] S807: The electronic device sends a second HTTP request to the server via the client, requesting a video packet whose PTS is the same as that of the first audio packet. The server receives the second HTTP request.

[0120] S808: In response to the second HTTP request, the server returns a second segment of the audio / video stream to the electronic device. The second segment of the audio / video stream includes a video packet (i.e., the first video packet) having the same PTS as the first audio packet. The electronic device receives the second segment of the audio / video stream and stores the second segment of the audio / video stream in the first buffer unit.

[0121] S809: The electronic device reads Y data packets from the first buffer unit, and stores the Y data packets in a third buffer unit, where the Y data packets include a first video packet.

[0122] Y is a positive integer. Optionally, Y=M.

[0123] Note that the above-mentioned S806 to S809 will be described using an example in which, after detecting that there is no video packet (i.e., first video packet) corresponding to an audio packet (i.e., first audio packet), a second HTTP request is initiated to acquire a video packet corresponding to the audio packet. However, in an actual application, after detecting that there is no video packet corresponding to multiple audio packets, a second HTTP request can also be initiated to acquire a video packet corresponding to multiple audio packets.

[0124] Alternatively, if the electronic device detects that the M data packets include A audio packets and that the M data packets do not include video packets having the same PTS as the A audio packets, where A is a positive integer greater than 1, S806 to S809 can also be replaced with the following procedure: The electronic device sends a second HTTP request to the server via the client, where the second HTTP request is used to request video packets having the same PTS as the A audio packets. The server receives the second HTTP request and returns a second segment of the audio / video stream to the electronic device in response to the second HTTP request. Here, the second segment of the audio / video stream includes video packets having the same PTS as the A audio packets (e.g., the second segment of the audio / video stream includes B video packets, where B≧A, and the B video packets include A video packets that correspond one-to-one with the A audio packets). The electronic device reads Y data packets from the first buffer unit and stores the Y data packets in a third buffer unit.

[0125] In some cases, it may be the case that each audio packet in the M data packets does not include a video packet with the same PTS, in which case the electronic device sends a second HTTP request to the server via the client, requesting video packets with the same PTS as all audio packets in the M data packets.

[0126] Also, it may be the case that only some of the audio packets in the M data packets do not have video packets with the same PTS. In this case, the electronic device sends a second HTTP request to the server via the client, requesting video packets with the same PTS as the audio packets.

[0127] For example, M data packets contain a total of seven audio packets (M≧7), three of which contain video packets with the same PTS as the three audio packets in the M data packets. In this case, a second HTTP request is used to request the video packets with the same PTS as the other four audio packets, where: Y is 4 or more.

[0128] Also, note that S806-S809 are provided as an example of detecting whether there is a video packet with the same PTS as the audio packet in the M data packets. However, in a specific implementation, it may also be detected whether there is an audio packet with the same PTS as the video packet in the M data packets. For example, an electronic device that detects that the M data packets do not include an audio packet (e.g., a first audio packet) with the same PTS as a first video packet in the M data packets sends an HTTP request to request an audio packet with the same PTS as the first video packet.

[0129] S810: The electronic device matches the data packets in the second buffer unit with the data packets in the third buffer unit (i.e., detects audio packets and video packets with the same PTS), reads any pair of audio packets and video packets with the same PTS (e.g., a first audio packet and a first video packet), and then plays the pair of audio packets and video packets with the same PTS.

[0130] The electronic device may then clear the data packets in the second buffer unit and the third buffer unit before storing new data packets.

[0131] If the current media file for online playback has not been completely played, the electronic device returns to S801, sends the next HTTP request, obtains a new audio / video stream, and executes S801 to S810 with the new audio / video stream until all audio / video streams in the current media file for online playback have been obtained and played.

[0132] In order to better understand the aforementioned technical solution, a detailed example is given here to further illustrate the aforementioned technical solution.

[0133] See Figure 11. For example, let M=Y=5.

[0134] Step 1: The client initiates a first HTTP request (recorded as HTTP1) to the server and downloads a first data segment (the data size of the data segment is less than or equal to the size of the download buffer on the client, i.e., the first buffer unit). Here, the first data segment contains A0, A1, A2, A3 , and A4. The client downloads A0, A1, A2, A3, A4, and A5 from the download buffer (i.e., the first buffer unit). A3 , and A4, and the first data segment is a non-uniformly interleaved audio / video stream, A3 , and A4 are determined to have no corresponding video packets, and audio packets A0, A1, A2, A3 , and A4 are stored in the second buffer unit.

[0135] Step 2: The client initiates a second HTTP request (recorded as HTTP2) to the server to download a second data segment (the data size of the data segment is less than or equal to the size of the download buffer on the client, i.e., the first buffer unit). Here, the second data segment contains (A0, A1, A2, A3, and A4, respectively) V0, V1, V2, V3 , and V4. The client downloads V0, V1, V2, V3 , and V4 of the second data segment, determine that the second data segment is a non-uniformly interleaved audio / video stream, and V3 , and V4 are stored in the third buffer unit.

[0136] Step 3: The electronic device reads audio packets and video packets with the same PTS from the second buffer unit and the third buffer unit, respectively, and after any pair of audio packets and video packets with the same PTS is read, plays the pair of audio packets and video packets with the same PTS.

[0137] For example, if the electronic device determines that A0 and V0 have the same PTS, it will play A0 and V0 in sync. If the electronic device determines that A1 and V1 have the same PTS, it will play A1 and V1 in sync. If the electronic device determines that A2 and V2 have the same PTS, it will play A2 and V2 in sync. If the electronic device determines that A3 and V3 have the same PTS, it will play A3 and V3 in sync. If the electronic device determines that A4 and V4 have the same PTS, it will play A4 and V4 in sync.

[0138] Step 4: The client initiates a third HTTP request (recorded as HTTP3) to the server to download the third data segment (the data size of the data segment is less than or equal to the size of the client's download buffer), and continues to execute the above-mentioned procedure for the third data segment. For the specific procedure, please refer to steps 1 to 3, and the details will not be described here.

[0139] It should be understood that in the above embodiment, matching is performed on data packets obtained using two adjacent HTTP requests (i.e., N=2). In a real application, matching may also be performed on data packets obtained using three, four, or five adjacent HTTP requests (i.e., N may be equal to 2, 3, 4, etc. instead), which is not limited in this application.

[0140] In this embodiment of the present application, for non-uniformly interleaved audio / video streams, the electronic device can allocate at least two additional buffers for the client to store data packets downloaded multiple times using HTTP requests, and then perform audio and video synchronization on the data packets in the at least two buffers in a batch. Compared with the solution of performing audio and video synchronization by repeatedly downloading data packets of a stream multiple times, this embodiment of the present application can improve the audio and video synchronization efficiency of the client. Compared with the technical solution of using a local buffer, the embodiment of the present application can reduce the buffer time. The embodiment of the present application can be applied to online playback of audio and video of any size, and can fundamentally solve the problem of frame freezing during online playback of all audio and video.

[0141] See Figure 12. For example, assume M=6 and Y=5.

[0142] Step 1: The client initiates a first HTTP request (recorded as HTTP1) to the server and downloads a first data segment (the data size of the data segment is less than or equal to the size of the download buffer on the client, i.e., the first buffer unit). Here, the first data segment contains A0, V0, A1, A2, A3 , and A4. The client downloads A0, V0, A1, A2, A3, A4, and A5 from the download buffer (i.e., the first buffer unit).A3 , and A4, and determines that the first data segment is a non-uniformly interleaved audio / video stream. Since A0 matches V0 (the PTS of A0 and V0 are the same), it plays A0 and V0, and then plays A1, A2, A3 , and A4 does not have a corresponding video packet, so A1, A2, A3 , and A4 are stored in the second buffer unit.

[0143] Step 2: The client initiates a second HTTP request (recorded as HTTP2) to the server and downloads a second data segment (the data size of the data segment is less than or equal to the size of the download buffer on the client, i.e., the first buffer unit). Here, the first data segment contains (A1, A2, A3 , and A4, respectively) V1, V2, V3 , and V4. The client downloads V1, V2, V3 , and V4 of the second data segment, determines that the second data segment is a non-uniformly interleaved audio / video stream, and V3 , and V4 are stored in the third buffer unit.

[0144] Step 3: The electronic device reads the audio packets and video packets with the same PTS from the second buffer unit and the third buffer unit, respectively, and after any pair of audio packets and video packets with the same PTS is read, plays the pair of audio packets and video packets with the same PTS.

[0145] For example, if the electronic device determines that A1 and V1 have the same PTS, it will play A1 and V1 in sync. If the electronic device determines that A2 and V2 have the same PTS, it will play A2 and V2 in sync. If the electronic device determines that A3 and V3 have the same PTS, it will play A3 and V3 in sync. If the electronic device determines that A4 and V4 have the same PTS, it will play A4 and V4 in sync.

[0146] Step 4: The client initiates a third HTTP request (recorded as HTTP3) to the server, downloads the third data segment (the data size of the data segment is less than or equal to the size of the client's download buffer), and continues to execute the above-mentioned procedure for the third data segment. For the specific procedure, please refer to steps 1 to 3, and the details will not be described here.

[0147] Optionally, in a particular implementation, S806 to S809 may alternatively be replaced with the following procedure: after S805 is executed, the electronic device directly sends a second HTTP request, and uses the second HTTP request to obtain a second segment of the audio / video stream, where the first PTS range of the first segment of the audio / video stream and the second PTS range of the second segment of the audio / video stream satisfy a preset condition. The server returns the second segment of the audio / video stream in response to the second HTTP request. The electronic device receives the second segment of the audio / video stream, and stores Y data packets in the second segment of the audio / video stream in the third buffer unit. The first PTS range ranges from the minimum PTS to the maximum PTS of the data packets of the first segment of the audio / video stream, and the second PTS range ranges from the minimum PTS to the maximum PTS of the data packets of the second segment of the audio / video stream.

[0148] Possible preset conditions include a partial overlap between the first PTS range and the second PTS range, the first PTS range being included in the second PTS range, the first PTS range being included in the second PTS range, or the first PTS range being close to the second PTS range (e.g., not exceeding a preset distance).

[0149] That is, the electronic device in this embodiment of the present application does not need to know the exact matching state of the audio and video packets in the M data packets (i.e., it may not be able to perform S806), but directly requests the second segment of the audio / video stream based on the first PTS range of the first segment of the audio / video stream.

[0150] This allows audio and video synchronization to be performed in batches for data packets in at least two buffers, thus improving the efficiency of audio and video synchronization for clients.

[0151] According to this application, a method for detecting non-uniformly interleaved streams is described. As shown in Fig. 9, the method includes the following steps:

[0152] S901: The electronic device uses the size of the buffer data requested by the client each time, such as the size (Buffer-1) of the first segment of the audio / video stream, as the distance for detecting the same PTS. corresponds to each audio packet, and determines whether a video packet having the same PTS as the audio packet of the first segment of the audio / video stream is included in Buffer-1, and if the video packet is included in Buffer-1, records the audio packet as an interleaved audio packet a1, and if the video packet is not included in Buffer-1, records the audio packet as a non-interleaved packet a2. corresponds to each video packet, and determines whether an audio packet having the same PTS as the video packet of the first segment of the audio / video stream is within a length distance of the synchronization window Buffer-1, and if the audio packet is within the length distance of the synchronization window Buffer-1, records the video packet as an interleaved video packet V1, and if the audio packet is not within the length distance of the synchronization window Buffer-1, records the video packet as a non-interleaved video packet V2.

[0153] S902: The electronic device determines whether a ratio of the total number of a1 and v1 to the total number of a1, v1, a2, and v2 in the first segment of the audio / video stream (recorded as (a1+v1)(a1+v1+a2+v2)) is greater than a preset ratio n. If the ratio of the total number of a1 and v1 to the total number of a1, v1, a2, and v2 in the first segment of the audio / video stream is greater than the preset ratio n, the first segment of the audio / video stream becomes a uniformly interleaved audio / video stream. If the ratio of the total number of a1 and v1 to the total number of a1, v1, a2, and v2 in the first segment of the audio / video stream is not greater than the preset ratio n, the first segment of the audio / video stream becomes a non-uniformly interleaved audio / video stream.

[0154] n is an adjustment coefficient, which may also be called a coefficient or have another name. This is not limited to this embodiment of the present application.

[0155] Furthermore, when the historical audio / video stream is played, the electronic device can adjust n based on the client's playback status (for example, whether frame freezes occur). For example, in the case of a historical audio / video stream, when (a1 + v1) / (a1 + v1 + a2 + v2) < p, frame freezes occur during playback on the client, and when (a1 + v1) / (a1 + v1 + a2 + v2) ≧ p, no frame freezes occur during playback on the client. n is determined to be p. For example, when (a1 + v1) / (a1 + v1 + a2 + v2) ≦ q, frame freezes occur during playback on the client, and when (a1 + v1) / (a1 + v1 + a2 + v2) > q, no frame freezes occur during playback on the client. n is determined to be q.

[0156] Certainly, the formulas for adjusting n described above are not limitations but merely examples, and they may be further extended in actual applications. For example, when (a1 + v1) / (a1 + v1 + a2 + v2) < p, frame freezes occur during playback on the client, and when (a1 + v1) / (a1 + v1 + a2 + v2) ≧ p, no frame freezes occur during playback on the client. It is determined that n = p + Δp. Here, Δp is a pre-set coefficient, and 1 - p > Δp ≧ 0. Alternatively, for example, when (a1 + v1) / (a1 + v1 + a2 + v2) ≦ q, frame freezes occur during playback on the client, and when (a1 + v1) / (a1 + v1 + a2 + v2) > q, no frame freezes occur during playback on the client. q It is determined that n = +Δq. Here, Δq is a pre-set coefficient, and 1 - q > Δq ≧ 0.

[0157] Optionally, the initial value of n can be 0.4, 0.5, 0.6, etc. This is not limited here. Δp or Δq can be a specified value such as 0.01, 0.05, 0.1, etc. This is not limited here.

[0158] Also, the electronic device performs interleaved detection separately for each segment of the audio / video stream that the client downloads from the server. Take FIG. 10 as an example. Assume that the client's n is 0.7. For an audio / video stream requested using HTTP1, if (a1+v1) / (a1+v1+a2+v2) = 2 / 9 < 0.7, the electronic device determines that the audio / video stream requested using HTTP1 is a non-uniformly interleaved audio / video stream. For an audio / video stream requested using HTTP2, if (a1+v1) / (a1+v1+a2+v2) = 2 / 9 < 0.7, the electronic device determines that the audio / video stream requested using HTTP1 is a non-uniformly interleaved audio / video stream. 2 For an audio / video stream requested using HTTP3, if (a1+v1) / (a1+v1+a2+v2) = 8 / 9 > 0.7, then the electronic device determines that the requested audio / video stream is a non-uniformly interleaved audio / video stream. 3 to determine that the requested audio / video stream is a uniformly interleaved audio / video stream.

[0159] From the above, it can be seen that the electronic device in this embodiment of the present application can determine the value of the regulating coefficient n based on the actual playback effect of streams with different interleaving degrees, so as to prevent certain decision conditions from causing different playback effects for audio / video streams with different interleaving degrees.

[0160] Based on the above embodiment, Figure 13 shows an online audio / video playback method according to an embodiment of the present application. The method includes the following steps:

[0161] S1301: An electronic device sends a first request to a network device.

[0162] S1302: The electronic device receives a first segment of the audio / video stream fed back from the network device based on the first request, and stores the first segment of the audio / video stream in a first buffer unit, where the first segment of the audio / video stream includes a preset number of data packets, and the data packets of the first segment of the audio / video stream include audio packets and / or video packets.

[0163] S1303: If the first segment of the audio / video stream is a non-uniformly interleaved audio / video stream, the electronic device reads M data packets from the first buffer unit and stores M data packets in the second buffer unit, where M is a positive integer greater than 1.

[0164] A non-uniformly interleaved audio / video stream refers to the number of audio and video packets contained in the first segment of an audio / video stream that have the same presentation timestamp PTS and whose storage location exceeds a specified distance threshold.

[0165] S1304: The electronic device clears the data packet in the first buffer unit and sends a second request to the network equipment.

[0166] S1305: The electronic device receives a second segment of the audio / video stream fed back from the network device based on the second request, and stores the second segment of the audio / video stream in a first buffer unit, where the second segment of the audio / video stream includes a preset number of data packets, and the data packets of the second segment of the audio / video stream include audio packets and / or video packets.

[0167] S1306: The electronic device reads Y data packets from the first buffer unit and stores the Y data packets in a third buffer unit (Y is a positive integer greater than 1).

[0168] S1307: The electronic device matches the data packets of the second buffer unit with the data packets of the third buffer unit, and after finding a pair of audio packets and video packets with the same PTS, controls to play the pair of audio packets and video packets with the same PTS.

[0169] For specific related implementations of the method shown in Figure 13, please refer to the related descriptions of the above embodiments, and details will not be described here.

[0170] The above embodiments in this application can be used separately or in combination to achieve different technical effects.

[0171] In the above embodiments provided in the present application, the methods provided in the embodiments of the present application are described in terms of an electronic device that performs the operations. To implement the functions in the methods provided in the above embodiments of the present application, the electronic device may include a hardware structure and / or a software module, and may implement the functions in the form of a hardware structure, a software module, or a combination of a hardware structure and a software module. Whether the functions of the above functions are implemented using a hardware structure, a software module, or a combination of a hardware structure and a software module depends on the specific application of the technical solution and design constraints.

[0172] Based on the same concept, Fig. 14 shows an electronic device 1400 provided in this application. The electronic device 1400 is configured to execute the method shown in Fig. 8, Fig. 9 or Fig. 13. For example, the electronic device 1400 includes a communication module 1401 and a processing module 1402.

[0173] For example, the communication module 1401 is configured to send a first request to the network device, receive a first segment of the audio / video stream fed back by the network device based on the first request, and store the first segment of the audio / video stream in a first buffer unit, where the first segment of the audio / video stream includes a preset number of data packets, and the data packets of the first segment of the audio / video stream include audio packets and / or video packets.

[0174] The processing module 1402 is configured to, when the first segment of the audio / video stream is a non-uniformly interleaved audio / video stream, read M data packets from the first buffer unit, store the M data packets in the second buffer unit, where M is a positive integer greater than 1, and clear the data packets of the first buffer unit.

[0175] A non-uniformly interleaved audio / video stream refers to the number of audio and video packets contained in the first segment of an audio / video stream that have the same presentation timestamp PTS and whose storage location exceeds a specified distance threshold.

[0176] The communication module 1401 is further configured to send a second request to the network device and receive a second segment of the audio / video stream fed back by the network device based on the second request.

[0177] The processing module 1402 is further configured to store a second segment of the audio / video stream in a first buffer unit, where the second segment of the audio / video stream includes a preset number of data packets, where the data packets of the second segment of the audio / video stream include audio packets and / or video packets. reads Y data packets from the first buffer unit and stores the Y data packets in a third buffer unit, where Y is a positive integer greater than 1. Then, matches the data packets of the second buffer unit with the data packets of the third buffer unit, and after a pair of audio packets and video packets having the same PTS is found, controls a player to play the pair of audio packets and video packets having the same PTS.

[0178] Based on the same concept, Fig. 15 shows an electronic device 1500 provided in the present application. The electronic device 1500 includes a processor 1510 and a memory 1520. The memory 1520 stores program instructions that, when executed, enable the electronic device 1500 to perform the method shown in Fig. 8, Fig. 9 or Fig. 13.

[0179] In this embodiment of the present application, the processor 1510 may be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or another programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. The methods, steps, and logic block diagrams disclosed in the embodiments of the present application may be implemented or performed. The general-purpose processor may be a microprocessor, the processor may be a conventional processor, and the like. The steps of the methods disclosed with reference to the embodiments of the present application may be performed and accomplished directly through a hardware decode processor, or may be performed and accomplished using a combination of hardware and software modules in the decode processor. The software modules may be located in a mature storage medium in the art, such as a random access memory (RAM), a flash memory, a read-only memory (ROM), a programmable read-only memory, an electrically erasable programmable memory, or a register. The storage medium is located in the memory, and the processor reads the instructions in the memory and completes the steps of the above-mentioned method in combination with the processor's hardware.

[0180] In this embodiment of the application, the memory 1520 may be a non-volatile memory such as a hard disk drive (HDD) or a solid-state drive (SSD), or a volatile memory such as a random access memory (RAM). The memory is, but is not limited to, any other medium capable of holding or storing expected program code in the form of instructions or data structures and accessible by a computer. The memory in the embodiment of the application may be a circuit or other device capable of implementing a memory function and configured to store program instructions and / or data.

[0181] For the relevant functions of the specific implementation of the device, please refer to the above method section, and the details will not be described here.

[0182] The above embodiments in this application can be used separately or in combination to achieve different technical effects.

[0183] As mentioned above, the above embodiments are only used to describe the technical solutions of the present application in detail. However, the above description of the embodiments is only used to understand the methods in the embodiments of the present application, and should not be construed as limitations on the embodiments of the present application. Any variations or replacements that can be easily understood by those skilled in the art shall be included in the protection scope of the embodiments of the present application.

[0184] Depending on the context, the term "when" used in the above embodiments may be interpreted as meaning "if," "after," "in response to determining," or "in response to detecting." Similarly, depending on the context, the phrases "when it is determined that" or "if (a stated condition or event) is detected" may be interpreted as meaning "if it is determined that" or "in response to determined" or "when (a stated condition or event) is detected" or "in response to detecting (a stated condition or event)."

[0185] All or part of the above embodiments can be implemented using software, hardware, firmware, or any combination thereof. When the embodiments are implemented using software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded into a computer and executed, the procedures or functions according to the embodiments of the present application are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from a computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website, computer, server, or data center to another website, computer, server, or data center by wire (e.g., coaxial cable, optical fiber, digital subscriber line, etc.) or wirelessly (infrared, radio, microwave, etc.). The computer-readable storage medium may be any available medium accessible by a computer, or a data storage device integrating one or more available media, such as a server or a data center. The usable media may be magnetic media (eg, floppy disks, hard disks, magnetic tapes, etc.), optical media (eg, DVDs), semiconductor media (eg, solid state drives), and the like.

[0186] For purposes of explanation, reference will be made to specific embodiments. However, the description of the above examples is not intended to be exhaustive or to limit the present application to the precise forms disclosed. Many modifications and variations are possible based on the teachings above. The embodiments have been selected and described to fully explain the principles and practical applications of the present application, and to enable those skilled in the art to fully utilize various embodiments with various modifications applicable to the particular uses contemplated.

Claims

1. 1. An online audio / video playback method, comprising: sending a first request to a network device; receiving a first segment of an audio / video stream fed back by the network device based on the first request, and storing the first segment of the audio / video stream in a first buffer unit, wherein the first segment of the audio / video stream includes a predetermined number of data packets, and the data packets of the first segment of the audio / video stream include audio packets and / or video packets; reading M data packets from the first buffer unit and storing the M data packets in a second buffer unit when the first segment of the audio / video stream is a non-uniformly interleaved audio / video stream, where M is a positive integer greater than 1, and the non-uniformly interleaved audio / video stream means that the number of audio packets and video packets included in the first segment of the audio / video stream, which have the same presentation timestamp PTS and are stored at locations that are greater than a specified distance threshold, exceeds a specified number threshold; clearing a first segment of the audio / video stream from the first buffer unit and sending a second request to the network device; receiving a second segment of the audio / video stream fed back by the network device based on the second request, and storing the second segment of the audio / video stream in the first buffer unit, wherein the second segment of the audio / video stream includes a predetermined number of data packets, and the data packets of the second segment of the audio / video stream include audio packets and / or video packets; reading Y data packets from the first buffer unit and storing the Y data packets in a third buffer unit, where Y is a positive integer greater than 1; and matching the data packets of the second buffer unit with the data packets of the third buffer unit, and after finding a pair of audio packets and video packets with the same PTS, controlling a player to play the pair of audio packets and video packets with the same PTS.

2. determining that the first segment of the audio / video stream is a non-uniformly interleaved audio / video stream; detecting, for each audio packet in the first segment of the audio / video stream, whether there is a video packet in the first segment of the audio / video stream that has the same PTS as the audio packet, and recording the audio packet as an interleaved audio packet a1 if there is a video packet in the first segment of the audio / video stream that has the same PTS as the audio packet, or recording the audio packet as a non-interleaved audio packet a2 if there is no video packet in the first segment of the audio / video stream that has the same PTS as the audio packet; and detecting, for each video packet in the first segment of the audio / video stream, whether there is an audio packet in the first segment of the audio / video stream that has the same PTS as the video packet, and recording the video packet as an interleaved video packet v1 if there is an audio packet in the first segment of the audio / video stream that has the same PTS as the video packet, or recording the video packet as a non-interleaved video packet v2 if there is no audio packet in the first segment of the audio / video stream that has the same PTS as the video packet; determining that the first segment of the audio / video stream is a non-uniformly interleaved audio / video stream if a ratio of the total number of a1 and v1 to the total number of a1, v1, a2, and v2 in the first segment of the audio / video stream is less than a predetermined value n.

3. determining a value of n based on a playback status of the playback device playing back historical audio / video streams; 3. The method of claim 2, further comprising the step of: if a ratio of the total number of a1 and v1 to the total number of a1, v1, a2, and v2 in the historical audio / video stream is less than n, the playback status of the player is frame freeze.

4. The step of sending a second request to the network device comprises: determining, if a first segment of the audio / video stream includes a first audio packet, that the first segment of the audio / video stream does not include a video packet having the same PTS as the first audio packet; The method of any one of claims 1 to 3, further comprising: a step of sending the second request to the network device, the second request being used to request a video packet having the same PTS as the first audio packet.

5. the M data packets are all audio packets and the Y data packets are all video packets, or the M data packets are all video packets and the Y data packets are all audio packets, or 5. The method of claim 1, wherein the M data packets are the first M data packets of a first segment of the audio / video stream and the Y data packets are the first Y data packets of a second segment of the audio / video stream.

6. before the step of reading M data packets from the first buffer unit, Further comprising the step of: performing a match on the data packets of the first buffer unit; and after a pair of audio packets and video packets having the same PTS is found, controlling the player to play the pair of audio packets and video packets having the same PTS; The step of reading M data packets from the first buffer unit comprises:

6. The method of claim 1, further comprising the step of: storing audio packets in the first buffer unit that do not have a matching video packet with the same PTS as the audio packet in the second buffer unit; or storing video packets in the first buffer unit that do not have a matching audio packet with the same PTS as the video packet in the second buffer unit.

7. 7. The method according to claim 1, wherein M=Y.

8. 8. The method according to claim 1, further comprising the step of: when the first segment of the audio / video stream is a uniformly interleaved audio / video stream, reading the data packets in the first buffer unit in order based on a stream sequence; and, after a pair of audio and video packets having the same PTS has been read, controlling the player to play the pair of audio and video packets having the same PTS.

9. 1. An electronic device comprising: the electronic device includes a processor and a memory; the memory stores program instructions; An electronic device, wherein the program instructions, when executed, enable the electronic device to carry out the method of any one of claims 1 to 8.

10. 1. A computer-readable storage medium, comprising: The computer-readable storage medium includes program instructions; A computer readable storage medium having program instructions that, when executed on an electronic device, enable the electronic device to perform the method of any one of claims 1 to 8.

11. A chip comprising: The chip is coupled to a memory in a device such that, in operation, the chip invokes program instructions stored in the memory to perform the method of any one of claims 1 to 8.

12. A computer program which, when executed on an electronic device, enables the electronic device to perform a method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Nonlinear editing software audio and video synchronization processing method and device

    CN105280205A

  • Audio and video playing method, device and equipment and storage medium

    CN110248233A

  • Audio and video playing method and device, computer equipment and storage medium

    CN110418186A