CN110213653B - Method and device for playing video - Google Patents

Method and device for playing video Download PDF

Info

Publication number
CN110213653B
CN110213653B CN201910515996.2A CN201910515996A CN110213653B CN 110213653 B CN110213653 B CN 110213653B CN 201910515996 A CN201910515996 A CN 201910515996A CN 110213653 B CN110213653 B CN 110213653B
Authority
CN
China
Prior art keywords
video
file
code rate
mapping address
virtual
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910515996.2A
Other languages
Chinese (zh)
Other versions
CN110213653A (en
Inventor
颜明
田巍
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN201910515996.2A priority Critical patent/CN110213653B/en
Publication of CN110213653A publication Critical patent/CN110213653A/en
Application granted granted Critical
Publication of CN110213653B publication Critical patent/CN110213653B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/238Interfacing the downstream path of the transmission network, e.g. adapting the transmission rate of a video stream to network bandwidth; Processing of multiplex streams
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/238Interfacing the downstream path of the transmission network, e.g. adapting the transmission rate of a video stream to network bandwidth; Processing of multiplex streams
    • H04N21/23805Controlling the feeding rate to the network, e.g. by controlling the video pump
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/25Management operations performed by the server for facilitating the content distribution or administrating data related to end-users or client devices, e.g. end-user or client device authentication, learning user preferences for recommending movies
    • H04N21/266Channel or content management, e.g. generation and management of keys and entitlement messages in a conditional access system, merging a VOD unicast channel into a multicast channel
    • H04N21/2662Controlling the complexity of the video stream, e.g. by scaling the resolution or bitrate of the video stream based on the client capabilities
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/438Interfacing the downstream path of the transmission network originating from a server, e.g. retrieving MPEG packets from an IP network
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream, rendering scenes according to MPEG-4 scene graphs
    • H04N21/4402Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream, rendering scenes according to MPEG-4 scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display
    • H04N21/440281Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream, rendering scenes according to MPEG-4 scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display by altering the temporal resolution, e.g. by frame skipping

Abstract

The embodiment of the application provides a method and a device for playing a video, which relate to the technical field of computers, and the method comprises the following steps: when the player is detected to play the video, a virtual m3u8 file is generated. And downloading a first Transport Stream (TS) file corresponding to the first video mapping address according to the first video mapping address in the virtual m3u8 file, wherein the first video mapping address is the video mapping address of the first TS file in the remote server. And when the first TS file is played completely, if the first video code rate is determined to be switched to the second video code rate, determining a second video mapping address corresponding to the second video code rate. And downloading a second TS file corresponding to the second video mapping address, and storing the second TS file into the virtual m3u8 file, so that the player reads the second TS file from the virtual m3u8 file and plays the second TS file. By the method and the device, the video code rate can be dynamically switched when the user watches the video, the purpose of smoothly playing the video is achieved, and the user experience is greatly improved.

Description

Method and device for playing video
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for playing a video.
Background
Currently, a user can install an application program for playing a video in a terminal, and the application program can play the video online when connecting to the internet. Due to poor network environment, the electronic device may encounter the situation of playing video not smoothly when playing video, so that the electronic device can achieve the purpose of playing video smoothly by automatically adjusting video code rate.
In the prior art, an m3u8 file is a video file and can be used to store download addresses of a plurality of TS (Transport Stream) files, where a TS file is a file containing video data, and a TS file in an m3u8 file is a TS file with the same video bitrate. When the electronic device plays the video, it needs to download the m3u8 file with a certain code rate, then download the TS file through the download address in the m3u8 file, and then play the corresponding TS file according to the video playing sequence to play the video.
However, when the electronic device plays a video through the m3u8 file containing the TS file download address, the m3u8 file can be acquired only once per play of the video. In the process of playing the video, if the video bitrate needs to be switched, the electronic device must restart the player to retrieve the m3u8 file corresponding to other bitrate. In the process of restarting the player and acquiring the m3u8 file again, the user can see the video interface in the black screen state, so that the video playing is not smooth.
Disclosure of Invention
An object of the embodiments of the present application is to provide a method and an apparatus for playing a video, so as to improve user experience. The specific technical scheme is as follows:
in a first aspect, a method for playing a video is provided, where the method is applied to an electronic device, and the method includes:
when the player is detected to play the video, generating a virtual m3u8 file;
downloading a first Transport Stream (TS) file corresponding to a first video mapping address according to the first video mapping address in the virtual m3u8 file, wherein the first video mapping address is a video mapping address of the first TS file in a remote server;
when the first TS file is played completely, if the first video code rate is determined to be switched to the second video code rate, determining a second video mapping address corresponding to the second video code rate;
and downloading a second TS file corresponding to the second video mapping address, and storing the second TS file into the virtual m3u8 file, so that the player reads the second TS file from the virtual m3u8 file and plays the second TS file.
Optionally, when it is detected that the player plays a video, generating a virtual m3u8 file includes:
and when a video playing request transmitted by the player is received, generating a virtual m3u8 file.
Optionally, if it is determined that the first video code rate is switched to the second video code rate, determining a second video mapping address corresponding to the second video code rate includes:
when the first TS file is played, determining a first average downloading speed of the electronic equipment for downloading the first TS file;
determining a second video code rate corresponding to the first average downloading speed according to a preset corresponding relation between the average downloading speed and the video code rate;
and if the first video code rate is different from the second video code rate, determining a second video mapping address corresponding to the second video code rate.
Optionally, if it is determined that the first video code rate is switched to the second video code rate, determining a second video mapping address corresponding to the second video code rate includes:
if the first video code rate is determined to be switched to the second video code rate, sending an acquisition request of a video mapping address to a remote server, wherein the acquisition request carries the second video code rate and a preset file identifier of a second TS (transport stream) file, so that the remote server determines the second video mapping address according to the second video code rate and the file identifier;
receiving the second video mapping address sent by the remote server.
In a second aspect, an apparatus for playing a video is provided, where the apparatus is applied to an electronic device, and the apparatus includes:
the generating module is used for generating a virtual m3u8 file when the fact that the player plays the video is detected;
a first downloading module, configured to download, according to a first video mapping address in the virtual m3u8 file, a first transport stream TS file corresponding to the first video mapping address, where the first video mapping address is a video mapping address of the first TS file in a remote server;
a determining module, configured to determine, when the first TS file is completely played, a second video mapping address corresponding to the second video code rate if it is determined that the first video code rate is switched to the second video code rate;
and the second downloading module is configured to download a second TS file corresponding to the second video mapping address, and store the second TS file in the virtual m3u8 file, so that the player reads the second TS file from the virtual m3u8 file and plays the second TS file.
Optionally, the generating module is specifically configured to:
and when a video playing request transmitted by the player is received, generating a virtual m3u8 file.
Optionally, the determining module is specifically configured to:
when the first TS file is played, determining a first average downloading speed of the electronic equipment for downloading the first TS file;
determining a second video code rate corresponding to the first average downloading speed according to a preset corresponding relation between the average downloading speed and the video code rate;
and if the first video code rate is different from the second video code rate, determining a second video mapping address corresponding to the second video code rate.
Optionally, the determining module is specifically configured to:
if the first video code rate is determined to be switched to the second video code rate, sending an acquisition request of a video mapping address to a remote server, wherein the acquisition request carries the second video code rate and a preset file identifier of a second TS (transport stream) file, so that the remote server determines the second video mapping address according to the second video code rate and the file identifier;
receiving the second video mapping address sent by the remote server.
In a third aspect, an electronic device is provided, which includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of the first aspect when executing the program stored in the memory.
In a fourth aspect, a computer-readable storage medium is provided, having stored thereon a computer program which, when being executed by a processor, carries out the method steps of the first aspect.
In a fifth aspect, there is provided a computer program product comprising instructions which, when run on a computer, cause the computer to perform the method of the first aspect described above.
According to the method and the device for playing the video, when the proxy component detects that the player plays the video, the virtual m3u8 file is generated. And downloading a first TS file corresponding to a first video mapping address according to the first video mapping address in the virtual m3u8 file by the proxy component, wherein the first video mapping address is the video mapping address of the first TS file in a remote server. And when the first TS file is played completely, if the agent component determines to switch the first video code rate to the second video code rate, determining a second video mapping address corresponding to the second video code rate. And downloading a second TS file corresponding to the second video mapping address by the proxy component, and transmitting the second TS file to the virtual m3u8 file, so that the player reads the second TS file from the virtual m3u8 file and plays the second TS file. Thus, when the player plays the video, the proxy component generates a virtual m3u8 file to be provided to the player, and the proxy component can determine the mapping addresses of the TS file corresponding to different video bitrate rates. Therefore, the proxy component can realize the switching of files with different video code rates without acquiring the m3u8 file again, and the video code rate can be switched on the premise of not restarting the player. When watching the video, the user can play the video smoothly, and the user experience is greatly improved.
Of course, not all advantages described above need to be achieved at the same time in the practice of any one product or method of the present application.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a method for playing a video according to an embodiment of the present application;
fig. 2 is a flowchart of a method for playing a video according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of an apparatus for playing a video according to an embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The embodiment of the application provides a method for playing a video, which can be applied to an agent component, wherein the agent component is a software module in electronic equipment, and a player is a software module in the electronic equipment for playing the video.
A method for playing a video provided in an embodiment of the present application will be described in detail below with reference to specific embodiments, as shown in fig. 1, the specific steps are as follows:
step 101, when detecting that the player plays a video, generating a virtual m3u8 file.
The virtual m3u8 file is a video file, the virtual m3u8 file can store a plurality of video mapping addresses, the video mapping addresses can map download addresses of TS files in a remote server, and the TS files can be a plurality of files containing video data at a certain video bitrate. In practical application, one video may have TS files with multiple video bit rates, and each video bit rate has a TS file with a corresponding bit rate. The video code rate is the number of data bits transmitted in unit time during data transmission, the common unit is kbps (kilobits per second), the larger the number of data bits transmitted in unit time is, the higher the precision is, and the closer the processed video file is to the original file.
In the embodiment of the application, a client for playing a video may be installed in the electronic device, and the client may include a player and a proxy component. The user can select the video to be played at the client, and the client can receive the playing instruction corresponding to the video and transmit the playing instruction to the player, so that the player performs video playing processing after receiving the playing instruction. At this time, the proxy component may detect that the player plays a video, send a request for obtaining a file with a preset video bitrate to the remote server, and obtain a video mapping address of a TS file with a certain video bitrate from the remote server, and at the same time, the proxy component may create a file, and store a plurality of video mapping addresses obtained by the remote server into the file, so as to form a virtual m3u8 file.
Optionally, when it is detected that the player plays a video, a specific processing procedure of the step of generating the virtual m3u8 file may be: when a video playing request transmitted by a player is received, a virtual m3u8 file is generated.
In the embodiment of the application, when the player receives a video playing instruction transmitted by the client, a video playing request is transmitted to the proxy component. The player transmits a request to play the video with the purpose of obtaining a virtual m3u8 file. When the agent component receives the request transmitted by the player, a virtual m3u8 file may be generated, the virtual m3u8 file contains a plurality of preset video mapping addresses, and each video mapping address may be a download address of the TS file in a remote server. Therefore, the agent component may download a TS file, which is a file containing video data, through the video mapping address in the virtual m3u8 file, and a plurality of TS files downloaded through the video mapping address in the virtual m3u8 file may constitute a complete piece of video. And when the player acquires the virtual m3u8 file, the video can be played.
And 102, downloading a first Transport Stream (TS) file corresponding to the first video mapping address according to the first video mapping address in the virtual m3u8 file.
The first video mapping address is a video mapping address of a first TS file in a remote server.
In this embodiment of the application, after the player acquires the virtual m3u8 file, the proxy component may determine, according to the sequence of playing the TS files, a first video mapping address corresponding to a first TS file in the virtual m3u8 file, and download, to the local, the first TS file in the remote server corresponding to the first video mapping address.
And 103, when the first TS file is played completely, if the first video code rate is determined to be switched to the second video code rate, determining a second video mapping address corresponding to the second video code rate.
In the embodiment of the application, when the first TS file is played, the agent component may determine whether the video played by the player should switch the code rate according to the current network environment. The purpose of the judgment is to match TS files with suitable code rates for the player according to the network environment, so that the video with the highest code rate is played on the premise that the player can play the video smoothly. If the agent component judges that the first video code rate is switched to the second video code rate, the agent component can switch the first video code rate to the second video code rate in a mode of switching the video mapping address.
Optionally, the process of determining whether to switch the code rate may specifically include the following steps:
step one, when the first TS file is played, determining a first average downloading speed of the electronic equipment for downloading the first TS file.
In this embodiment of the application, when the first TS file is completely played, the agent component may determine the size of the data size of the first TS file and the time for downloading the first TS file, and calculate a ratio of the data size to the time to obtain an average downloading speed of the electronic device for downloading the first TS file. The average download speed reflects the current network environment, and the agent component can judge whether to switch the code rate according to the average download speed.
And step two, determining a second video code rate corresponding to the first average downloading speed according to the corresponding relation between the preset average downloading speed and the video code rate.
In the embodiment of the present application, the corresponding relationship between the average downloading speed and the video bitrate is as follows: one download speed interval corresponds to one video bitrate. And the proxy component determines a downloading speed interval where the current average downloading speed is located, and further determines a second video code rate corresponding to the downloading speed interval according to the corresponding relation between the preset average downloading speed and the video code rate.
An example of a corresponding relationship between an average download speed and a video bitrate is provided in an embodiment of the present application, and specific examples may include: in this example, there are two code rates: 350Kbps (fluent bitrate) and 800Kbps (high definition bitrate). When the average downloading speed determined by the proxy component is greater than the smooth code rate and less than the high-definition code rate, the proxy component can switch the current video code rate to the smooth code rate, and when the average downloading speed determined by the proxy component is greater than the high-definition code rate, the proxy component can switch the current video code rate to the high-definition code rate. If the average download speed determined by the proxy component is 560K/S (560Kbps per second), the current situation is that the average download speed determined by the proxy component is greater than the smooth bitrate and less than the high definition bitrate, and the proxy component can switch the current video bitrate to the smooth bitrate.
And step three, if the first video code rate is different from the second video code rate, determining a second video mapping address corresponding to the second video code rate.
In the embodiment of the application, if the first video code rate is different from the second video code rate, the agent component determines to switch the first video code rate to the second video code rate. After determining that the first video code rate is switched to the second video code rate, the proxy component may send a request for obtaining a second TS file to the remote server, and after receiving the request, the remote server sends a second video mapping address corresponding to the second video code rate to the proxy component.
Optionally, the process of obtaining the second video mapping address may specifically include the following steps:
step one, if the first video code rate is determined to be switched to the second video code rate, sending an acquisition request of a video mapping address to a remote server.
The obtaining request carries a second video code rate and a preset file identifier of a second TS file, so that the remote server determines a second video mapping address according to the second video code rate and the file identifier.
In the embodiment of the application, when the proxy component determines to switch the first video bitrate to the second video bitrate, a request is made to a remote server for obtaining a second TS file corresponding to the second video bitrate, and the obtaining request carries the second video bitrate and a preset file identifier of the second TS file. When the remote server receives the request, the remote server retrieves the second TS file according to the identifier provided by the proxy component and determines a second video mapping address of the second TS file.
And step two, receiving a second video mapping address sent by the remote server.
In this embodiment of the application, after determining the second video mapping address of the second TS file, the remote server may send the second video mapping address of the second TS file to the proxy component, and after obtaining the second video mapping address of the second TS file, the proxy component may download the second TS file through the second video mapping address.
And 104, downloading a second TS file corresponding to the second video mapping address, and transmitting the second TS file to the virtual m3u8 file, so that the player reads the second TS file from the virtual m3u8 file and plays the second TS file.
In this embodiment of the application, after the agent component determines the second video mapping address, the second TS file may be downloaded through the second video mapping address, and after the agent component downloads the second TS file, the player may read the second TS file from the virtual m3u8 file and play the second TS file. The player plays the TS files sequentially while playing the video, so that after the first TS file is played, the player can obtain the most suitable second TS file from the virtual m3u8 file to achieve the purpose of smooth playing.
As shown in fig. 2, an embodiment of the present application provides a specific example of playing a video, and the specific steps may include:
as shown in table one, an example of a corresponding relationship between the average download speed and the video bitrate is provided for this example, where the corresponding relationship is a preset corresponding relationship, and the proxy component can match the average download speed with the appropriate bitrate according to the preset relationship.
Watch 1
Code rate name Code rate (bps)
Fluency 350K
High definition
800K
Super clean 1.5M
Step 201, when detecting that the player plays a video, generating a virtual m3u8 file.
Step 202, downloading a first TS file corresponding to the first video mapping address according to the first video mapping address in the virtual m3u8 file.
Step 203, when the playing of the first TS file is finished, obtaining a first average speed when the first TS file is downloaded.
And 204, judging a second video code rate corresponding to the first average downloading speed according to the preset corresponding relation. If the first average download speed is less than 800K/bps, step 205 is executed, if the first average download speed is greater than 800K/bps and less than 1.5M/bps, step 206 is executed, and if the first average download speed is greater than 1.5M, step 207 is executed.
Step 205, sending a request for obtaining the smooth rate mapping address to the remote server.
And step 206, sending a request for acquiring the high-definition code rate mapping address to the remote server.
And step 207, sending a request for acquiring the super clear rate mapping address to the remote server.
And step 208, receiving a second video mapping address sent by the remote server.
And step 209, downloading a second TS file corresponding to the second video mapping address, and storing the second TS file in the virtual m3u8 file, so that the player reads the second TS file from the virtual m3u8 file and plays the second TS file.
According to the method and the device for playing the video, when the proxy component detects that the player plays the video, the virtual m3u8 file is generated. And downloading a first TS file corresponding to a first video mapping address according to the first video mapping address in the virtual m3u8 file by the proxy component, wherein the first video mapping address is the video mapping address of the first TS file in a remote server. And when the first TS file is played completely, if the agent component determines to switch the first video code rate to the second video code rate, determining a second video mapping address corresponding to the second video code rate. And downloading a second TS file corresponding to the second video mapping address by the proxy component, and transmitting the second TS file to the virtual m3u8 file, so that the player reads the second TS file from the virtual m3u8 file and plays the second TS file. Thus, when the player plays the video, the proxy component generates a virtual m3u8 file to be provided to the player, and the proxy component can determine the mapping address of the TS file corresponding to different video rate for downloading. Therefore, the proxy component can realize the switching of files with different video code rates without acquiring the m3u8 file again, and the video code rate can be switched on the premise of not restarting the player. When watching the video, the user can play the video smoothly, and the user experience is greatly improved.
Based on the same technical concept, an embodiment of the present application further provides an apparatus for playing a video, as shown in fig. 3, the apparatus includes:
a generating module 301, configured to generate a virtual m3u8 file when it is detected that the player plays a video;
a first downloading module 302, configured to download, according to a first video mapping address in the virtual m3u8 file, a first transport stream TS file corresponding to the first video mapping address, where the first video mapping address is a video mapping address of the first TS file in a remote server;
a determining module 303, configured to determine, when the first TS file is completely played, a second video mapping address corresponding to the second video bitrate if it is determined that the first video bitrate is switched to the second video bitrate;
a second downloading module 304, configured to download a second TS file corresponding to the second video mapping address, and store the second TS file in the virtual m3u8 file, so that the player reads the second TS file from the virtual m3u8 file and plays the second TS file.
Optionally, the generating module 301 is specifically configured to:
and when a video playing request transmitted by the player is received, generating a virtual m3u8 file.
Optionally, the determining module 303 is specifically configured to:
when the first TS file is played, determining a first average downloading speed of the electronic equipment for downloading the first TS file;
determining a second video code rate corresponding to the first average downloading speed according to a preset corresponding relation between the average downloading speed and the video code rate;
and if the first video code rate is different from the second video code rate, determining a second video mapping address corresponding to the second video code rate.
Optionally, the determining module 303 is specifically configured to:
if the first video code rate is determined to be switched to the second video code rate, sending an acquisition request of a video mapping address to a remote server, wherein the acquisition request carries the second video code rate and a preset file identifier of a second TS (transport stream) file, so that the remote server determines the second video mapping address according to the second video code rate and the file identifier;
receiving the second video mapping address sent by the remote server.
According to the method and the device for playing the video, when the proxy component detects that the player plays the video, the virtual m3u8 file is generated. And downloading a first TS file corresponding to a first video mapping address according to the first video mapping address in the virtual m3u8 file by the proxy component, wherein the first video mapping address is the video mapping address of the first TS file in a remote server. And when the first TS file is played completely, if the agent component determines to switch the first video code rate to the second video code rate, determining a second video mapping address corresponding to the second video code rate. And downloading a second TS file corresponding to the second video mapping address by the proxy component, and transmitting the second TS file to the virtual m3u8 file, so that the player reads the second TS file from the virtual m3u8 file and plays the second TS file. Thus, when the player plays the video, the proxy component generates a virtual m3u8 file to be provided to the player, and the proxy component can determine the mapping address of the TS file corresponding to different video rate for downloading. Therefore, the proxy component can realize the switching of files with different video code rates without acquiring the m3u8 file again, and the video code rate can be switched on the premise of not restarting the player. When watching the video, the user can play the video smoothly, and the user experience is greatly improved.
The embodiment of the present application further provides an electronic device, as shown in fig. 4, which includes a processor 401, a communication interface 402, a memory 403, and a communication bus 404, where the processor 401, the communication interface 402, and the memory 403 complete mutual communication through the communication bus 404,
a memory 403 for storing a computer program;
the processor 401, when executing the program stored in the memory 403, implements the following steps:
when the player is detected to play the video, generating a virtual m3u8 file;
downloading a first Transport Stream (TS) file corresponding to a first video mapping address according to the first video mapping address in the virtual m3u8 file, wherein the first video mapping address is a video mapping address corresponding to the downloading address of the first TS file in a remote server;
when the first TS file is played completely, if the first video code rate is determined to be switched to the second video code rate, determining a second video mapping address corresponding to the second video code rate;
and downloading a second TS file corresponding to the second video mapping address, and storing the second TS file into the virtual m3u8 file, so that the player reads the second TS file from the virtual m3u8 file and plays the second TS file.
Optionally, when it is detected that the player plays a video, generating a virtual m3u8 file includes:
and when a video playing request transmitted by the player is received, generating a virtual m3u8 file.
Optionally, if it is determined that the first video code rate is switched to the second video code rate, determining a second video mapping address corresponding to the second video code rate includes:
when the first TS file is played, determining a first average downloading speed of the electronic equipment for downloading the first TS file;
determining a second video code rate corresponding to the first average downloading speed according to a preset corresponding relation between the average downloading speed and the video code rate;
and if the first video code rate is different from the second video code rate, determining a second video mapping address corresponding to the second video code rate.
Optionally, if it is determined that the first video code rate is switched to the second video code rate, determining a second video mapping address corresponding to the second video code rate includes:
if the first video code rate is determined to be switched to the second video code rate, sending an acquisition request of a video mapping address to a remote server, wherein the acquisition request carries the second video code rate and a preset file identifier of a second TS (transport stream) file, so that the remote server determines the second video mapping address according to the second video code rate and the file identifier;
receiving the second video mapping address sent by the remote server.
The communication bus mentioned in the network device may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the network device and other devices.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; the Integrated Circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA), or other Programmable logic devices, discrete Gate or transistor logic devices, or discrete hardware components.
Based on the same technical concept, embodiments of the present application further provide a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the method steps for playing a video are implemented.
Based on the same technical concept, embodiments of the present application also provide a computer program product containing instructions, which when run on a computer, causes the computer to perform the above method steps for playing a video.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the application to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the apparatus embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only for the preferred embodiment of the present application, and is not intended to limit the scope of the present application. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application are included in the protection scope of the present application.

Claims (10)

1. A method for playing a video, wherein the method is applied to a proxy component in a video client, the video client further comprises a player, and the method comprises:
when the player is detected to play the video, generating a virtual m3u8 file;
downloading a first Transport Stream (TS) file corresponding to a first video mapping address according to the first video mapping address in the virtual m3u8 file, wherein the first video mapping address is a video mapping address of the first TS file in a remote server;
when the first TS file is played completely, if the first video code rate is determined to be switched to the second video code rate, determining a second video mapping address corresponding to the second video code rate;
and downloading a second TS file corresponding to the second video mapping address, and storing the second TS file into the virtual m3u8 file, so that the player reads the second TS file from the virtual m3u8 file and plays the second TS file.
2. The method of claim 1, wherein generating a virtual m3u8 file when the player is detected to play the video comprises:
and when a video playing request transmitted by the player is received, generating a virtual m3u8 file.
3. The method of claim 1, wherein determining a second video mapping address corresponding to the second video bitrate if it is determined to switch the first video bitrate to the second video bitrate comprises:
when the first TS file is played, determining a first average downloading speed of the electronic equipment for downloading the first TS file;
determining a second video code rate corresponding to the first average downloading speed according to a preset corresponding relation between the average downloading speed and the video code rate;
and if the first video code rate is different from the second video code rate, determining a second video mapping address corresponding to the second video code rate.
4. The method of claim 1, wherein determining a second video mapping address corresponding to the second video bitrate if it is determined to switch the first video bitrate to the second video bitrate comprises:
if the first video code rate is determined to be switched to the second video code rate, sending an acquisition request of a video mapping address to a remote server, wherein the acquisition request carries the second video code rate and a preset file identifier of a second TS (transport stream) file, so that the remote server determines the second video mapping address according to the second video code rate and the file identifier;
receiving the second video mapping address sent by the remote server.
5. An apparatus for playing video, wherein the apparatus is applied to a proxy component in a video client, the video client further comprises a player, and the apparatus comprises:
the generating module is used for generating a virtual m3u8 file when the fact that the player plays the video is detected;
a first downloading module, configured to download, according to a first video mapping address in the virtual m3u8 file, a first transport stream TS file corresponding to the first video mapping address, where the first video mapping address is a video mapping address of the first TS file in a remote server;
the determining module is used for determining a second video mapping address corresponding to a second video code rate if the first video code rate is determined to be switched to the second video code rate when the first TS file is played;
and the second downloading module is configured to download a second TS file corresponding to the second video mapping address, and store the second TS file in the virtual m3u8 file, so that the player reads the second TS file from the virtual m3u8 file and plays the second TS file.
6. The apparatus of claim 5, wherein the generating module is specifically configured to:
and when a video playing request transmitted by the player is received, generating a virtual m3u8 file.
7. The apparatus of claim 5, wherein the determining module is specifically configured to:
when the first TS file is played, determining a first average downloading speed of the electronic equipment for downloading the first TS file;
determining a second video code rate corresponding to the first average downloading speed according to a preset corresponding relation between the average downloading speed and the video code rate;
and if the first video code rate is different from the second video code rate, determining a second video mapping address corresponding to the second video code rate.
8. The apparatus of claim 5, wherein the determining module is specifically configured to:
if the first video code rate is determined to be switched to the second video code rate, sending an acquisition request of a video mapping address to a remote server, wherein the acquisition request carries the second video code rate and a preset file identifier of a second TS (transport stream) file, so that the remote server determines the second video mapping address according to the second video code rate and the file identifier;
receiving the second video mapping address sent by the remote server.
9. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of claims 1 to 4 when executing a program stored in the memory.
10. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of claims 1 to 4.
CN201910515996.2A 2019-06-14 2019-06-14 Method and device for playing video Active CN110213653B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910515996.2A CN110213653B (en) 2019-06-14 2019-06-14 Method and device for playing video

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910515996.2A CN110213653B (en) 2019-06-14 2019-06-14 Method and device for playing video

Publications (2)

Publication Number Publication Date
CN110213653A CN110213653A (en) 2019-09-06
CN110213653B true CN110213653B (en) 2022-03-04

Family

ID=67792868

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910515996.2A Active CN110213653B (en) 2019-06-14 2019-06-14 Method and device for playing video

Country Status (1)

Country Link
CN (1) CN110213653B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110677727B (en) * 2019-09-10 2022-05-10 北京奇艺世纪科技有限公司 Audio and video playing method and device, electronic equipment and storage medium
CN112887786B (en) * 2019-11-29 2022-08-02 腾讯科技(深圳)有限公司 Video playing method and device and computer readable medium
CN111417031B (en) * 2020-04-28 2022-05-31 北京金山云网络技术有限公司 File transmission method and device and electronic equipment
CN114189715A (en) * 2021-12-07 2022-03-15 北京奇艺世纪科技有限公司 Download address switching method and related equipment

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104410901A (en) * 2014-11-18 2015-03-11 上海天脉聚源文化传媒有限公司 Play method and play device of M3U8 format live stream
CN104519372A (en) * 2014-12-19 2015-04-15 深圳市九洲电器有限公司 Switching method and switching system for streaming media playing
CN104581207A (en) * 2014-12-23 2015-04-29 乐视致新电子科技(天津)有限公司 Online video playing method and system as well as play application proxy equipment
CN104602032A (en) * 2015-01-13 2015-05-06 乐视致新电子科技(天津)有限公司 Video playing processing method, playing application proxy device and playing server
CN105578201A (en) * 2015-12-23 2016-05-11 武汉市烽视威科技有限公司 System and method for implementing dynamic adjustment of HLS live bit rate number
CN105898408A (en) * 2016-04-28 2016-08-24 乐视控股(北京)有限公司 Video play method and device
CN106658226A (en) * 2015-10-28 2017-05-10 中兴通讯股份有限公司 Play method and apparatus
CN106686036A (en) * 2015-11-10 2017-05-17 中兴通讯股份有限公司 Multimedia data downloading method and system, client and server

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105306966B (en) * 2014-07-30 2018-12-14 深圳国微技术有限公司 A kind of live video data processing method, apparatus and system
US20170164020A1 (en) * 2015-12-08 2017-06-08 Le Holdings (Beijing) Co., Ltd. Content delivery method for content delivery network platform and scheduling proxy server
CN105915945A (en) * 2015-12-08 2016-08-31 乐视云计算有限公司 Content distribution method used for CDN platform and scheduling proxy server thereof

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104410901A (en) * 2014-11-18 2015-03-11 上海天脉聚源文化传媒有限公司 Play method and play device of M3U8 format live stream
CN104519372A (en) * 2014-12-19 2015-04-15 深圳市九洲电器有限公司 Switching method and switching system for streaming media playing
CN104581207A (en) * 2014-12-23 2015-04-29 乐视致新电子科技(天津)有限公司 Online video playing method and system as well as play application proxy equipment
CN104602032A (en) * 2015-01-13 2015-05-06 乐视致新电子科技(天津)有限公司 Video playing processing method, playing application proxy device and playing server
CN106658226A (en) * 2015-10-28 2017-05-10 中兴通讯股份有限公司 Play method and apparatus
CN106686036A (en) * 2015-11-10 2017-05-17 中兴通讯股份有限公司 Multimedia data downloading method and system, client and server
CN105578201A (en) * 2015-12-23 2016-05-11 武汉市烽视威科技有限公司 System and method for implementing dynamic adjustment of HLS live bit rate number
CN105898408A (en) * 2016-04-28 2016-08-24 乐视控股(北京)有限公司 Video play method and device

Also Published As

Publication number Publication date
CN110213653A (en) 2019-09-06

Similar Documents

Publication Publication Date Title
CN110213653B (en) Method and device for playing video
CN107493183B (en) Fault positioning method and device
JP5298331B2 (en) Digital content distribution system and method
US20210160577A1 (en) Method for playing video, electronic device and storage medium
CN110944220B (en) Video screen projection playing method, device, equipment and system
CN112203111B (en) Multimedia resource preloading method and device, electronic equipment and storage medium
CN112787936B (en) Play failure recovery method, device and storage medium under IPv4/IPv6 dual-stack environment
CN111046310A (en) Page processing method, device, server and computer readable storage medium
CN110677714A (en) Video data downloading method and device, electronic equipment and storage medium
CN112584200B (en) Screen projection method, system, electronic equipment and storage medium
CN111309485A (en) Service calling method and device, electronic equipment and computer readable storage medium
WO2023116219A1 (en) Cdn node distribution method and apparatus, electronic device, medium and program product
CN113542904A (en) Video screen projection playing method and device, electronic equipment and storage medium
CN110213671B (en) Hotspot short video determination method and device
CN109194706B (en) Network resource dial testing method and terminal
CN110677683B (en) Video storage and video access method and distributed storage and video access system
CN105306520A (en) Method for operating a cache and corresponding cache
WO2017185632A1 (en) Data transmission method and electronic device
US20210185401A1 (en) Preload hinting for low latency http live streaming system
CN114189715A (en) Download address switching method and related equipment
CN114666609A (en) Video data downloading method and device, electronic equipment and storage medium
CN113626402A (en) Log data acquisition method and device, electronic equipment and storage medium
CN108804195B (en) Page display method and device, server and client
CN111356006A (en) Video playing method, device, server and storage medium
CN113271475B (en) Data processing method, system, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant