CN112887755A - Method and device for playing video - Google Patents

Method and device for playing video Download PDF

Info

Publication number
CN112887755A
CN112887755A CN201911207115.7A CN201911207115A CN112887755A CN 112887755 A CN112887755 A CN 112887755A CN 201911207115 A CN201911207115 A CN 201911207115A CN 112887755 A CN112887755 A CN 112887755A
Authority
CN
China
Prior art keywords
video
data
code rate
acquired
playing
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.)
Pending
Application number
CN201911207115.7A
Other languages
Chinese (zh)
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 Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom 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 Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201911207115.7A priority Critical patent/CN112887755A/en
Publication of CN112887755A publication Critical patent/CN112887755A/en
Pending legal-status Critical Current

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/234Processing of video elementary streams, e.g. splicing of video streams, manipulating MPEG-4 scene graphs
    • H04N21/23406Processing of video elementary streams, e.g. splicing of video streams, manipulating MPEG-4 scene graphs involving management of server-side video buffer
    • 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/234Processing of video elementary streams, e.g. splicing of video streams, manipulating MPEG-4 scene graphs
    • H04N21/23418Processing of video elementary streams, e.g. splicing of video streams, manipulating MPEG-4 scene graphs involving operations for analysing video streams, e.g. detecting features or characteristics
    • 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/234Processing of video elementary streams, e.g. splicing of video streams, manipulating MPEG-4 scene graphs
    • H04N21/2343Processing of video elementary streams, e.g. splicing of video streams, manipulating MPEG-4 scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements
    • H04N21/234309Processing of video elementary streams, e.g. splicing of video streams, manipulating MPEG-4 scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements by transcoding between formats or standards, e.g. from MPEG-2 to MPEG-4 or from Quicktime to Realvideo
    • 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/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/44004Processing 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 video buffer management, e.g. video decoder buffer or video display buffer
    • 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/44008Processing 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 operations for analysing video streams, e.g. detecting features or characteristics in the video stream
    • 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/440218Processing 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 transcoding between formats or standards, e.g. from MPEG-2 to MPEG-4
    • 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/45Management operations performed by the client for facilitating the reception of or the interaction with the content or administrating data related to the end-user or to the client device itself, e.g. learning user preferences for recommending movies, resolving scheduling conflicts
    • H04N21/462Content or additional data management, e.g. creating a master electronic program guide from data received from the Internet and a Head-end, controlling the complexity of a video stream by scaling the resolution or bit-rate based on the client capabilities
    • H04N21/4621Controlling the complexity of the content stream or additional data, e.g. lowering the resolution or bit-rate of the video stream for a mobile client with a small screen
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/80Generation or processing of content or additional data by content creator independently of the distribution process; Content per se
    • H04N21/85Assembly of content; Generation of multimedia applications
    • H04N21/854Content authoring
    • H04N21/8547Content authoring involving timestamps for synchronizing content

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Databases & Information Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)

Abstract

The embodiment of the disclosure discloses a method and a device for playing videos. One embodiment of the method comprises: in response to receiving a code rate switching instruction for switching a first code rate to a second code rate, acquiring video information of a video with the second code rate from a server according to a pre-stored resource address of the video with the second code rate, wherein the second code rate is different from the first code rate; determining the position of data to be acquired of the video with the second code rate according to the video information and the playing progress of the currently played video; acquiring video data of the video with the second code rate from the server according to the position of the data to be acquired; and playing the video based on the acquired video data. The embodiment realizes the switching of the video from the first code rate to the second code rate.

Description

Method and device for playing video
Technical Field
The embodiment of the disclosure relates to the technical field of computers, in particular to a method and a device for playing videos.
Background
During the video playing process, the user may generate the requirement of video definition switching. In order to meet the requirement of the user, the server side generally generates videos with different code rates through transcoding and sends the videos, and the terminal device can select to play the videos with different code rates to improve the viewing experience. At present, a mainstream mobile player can use an existing open source computer program FFmpeg to realize functions of audio and video decapsulation, demultiplexing, decoding and the like, and the function FFmpeg for switching videos with different code rates in a playing process is not supported. In practice, the bitrate switching can be realized by recording the current bitrate playing progress, restarting the player and quickly searching (seek) to the designated progress, but this switching manner causes severe stuck and CPU (central processing unit) consumption. In addition, a dynamic code rate self-adaptive technology can be adopted to realize code rate switching, the server side cuts the video into a plurality of slices, the addresses of different slices are different, and the mobile equipment player requests the slices in the time periods corresponding to the videos with different code rates to realize code rate switching. However, only the video format supporting slices supports changing the request path when a different slice is requested, and this approach is complicated to operate.
Disclosure of Invention
The embodiment of the disclosure provides a method and a device for playing a video.
In a first aspect, an embodiment of the present disclosure provides a method for playing a video, where the method includes: in response to receiving a code rate switching instruction for switching a first code rate to a second code rate, acquiring video information of a video with the second code rate from a server according to a pre-stored resource address of the video with the second code rate, wherein the second code rate is different from the first code rate; determining the position of data to be acquired of the video with the second code rate according to the video information and the playing progress of the currently played video; acquiring video data of the video with the second code rate from the server according to the position of the data to be acquired; and playing the video based on the acquired video data.
In some embodiments, the playing the video based on the acquired video data includes: storing the acquired video data to a first buffer; for the video data of the first buffer area, updating decoder information according to the video information corresponding to the video data for decoding, and removing repeated frame data obtained by decoding; and storing the decoded data without the repeated frame data into a second buffer area, and acquiring data from the second buffer area for playing.
In some embodiments, the determining, according to the video information and the playing progress of the currently played video, a position of data to be acquired for the video with the second bitrate includes: determining a target frame from the video with the second code rate according to the video information and the playing progress of the currently played video; and in response to determining that the target frame is not a key frame, determining the position of a previous key frame of the target frame as the position of the data to be acquired.
In some embodiments, the determining, according to the video information and the playing progress of the currently played video, a position of data to be acquired for the video with the second bitrate further includes: and in response to the fact that the target frame is determined to be the key frame, determining the position of the target frame to be the position of the data to be acquired.
In some embodiments, the above method further comprises: and responding to the situation that no code rate switching instruction is received, and acquiring video data from a server according to the playing progress of the currently played video with the first code rate and the pre-stored resource address of the video with the first code rate.
In a second aspect, an embodiment of the present disclosure provides an apparatus for playing a video, where the apparatus includes: a first obtaining unit, configured to, in response to receiving a rate switching instruction for switching a first rate to a second rate, obtain, from a server, video information of a video at the second rate according to a pre-stored resource address of the video at the second rate, where the second rate is different from the first rate; the determining unit is configured to determine a position of data to be acquired of the video with the second code rate according to the video information and the playing progress of the currently played video; a second obtaining unit configured to obtain video data of the video at the second code rate from the server according to the position of the data to be obtained; a playing unit configured to play a video based on the acquired video data.
In some embodiments, the above-mentioned playback unit is further configured to: storing the acquired video data to a first buffer; for the video data of the first buffer area, updating decoder information according to the video information corresponding to the video data for decoding, and removing repeated frame data obtained by decoding; and storing the decoded data without the repeated frame data into a second buffer area, and acquiring data from the second buffer area for playing.
In some embodiments, the determining unit is further configured to: determining a target frame from the video with the second code rate according to the video information and the playing progress of the currently played video; and in response to determining that the target frame is not a key frame, determining the position of a previous key frame of the target frame as the position of the data to be acquired.
In some embodiments, the determining unit is further configured to: and in response to the fact that the target frame is determined to be the key frame, determining the position of the target frame to be the position of the data to be acquired.
In some embodiments, the above apparatus further comprises: and the third obtaining unit is configured to respond to that no code rate switching instruction is received, and obtain the video data from the server according to the playing progress of the currently played video with the first code rate and the pre-stored resource address of the video with the first code rate.
In a third aspect, an embodiment of the present disclosure provides a terminal device, where the terminal device includes: one or more processors; a storage device, on which one or more programs are stored, which, when executed by the one or more processors, cause the one or more processors to implement the method as described in any implementation manner of the first aspect.
In a fourth aspect, the disclosed embodiments provide a computer-readable medium on which a computer program is stored, wherein the computer program, when executed by a processor, implements the method as described in any implementation manner of the first aspect.
According to the method and the device for playing the video, provided by the embodiment of the disclosure, if a code rate switching instruction for switching a first code rate to a second code rate is received, video information of the video with the second code rate is acquired from a server according to a pre-stored resource address of the video with the second code rate. And then, determining the position of the data to be acquired of the video with the second code rate according to the video information and the playing progress of the currently played video. And then, according to the position of the data to be acquired, acquiring the video data of the video with the second code rate from the server. And finally, playing the video based on the acquired video data. Therefore, the switching of the video from the first code rate to the second code rate is realized.
Drawings
Other features, objects and advantages of the disclosure will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is an exemplary system architecture diagram in which one embodiment of the present disclosure may be applied;
FIG. 2 is a flow diagram of one embodiment of a method for playing a video according to the present disclosure;
FIG. 3 is a schematic diagram of one application scenario of a method for playing a video according to the present disclosure;
FIG. 4 is a flow diagram of yet another embodiment of a method for playing a video according to the present disclosure;
fig. 5 is a schematic diagram of processing video data of a first buffer and storing the processing result to a second buffer;
FIG. 6 is a schematic block diagram illustrating one embodiment of an apparatus for playing video in accordance with the present disclosure;
FIG. 7 is a block diagram of a computer system suitable for use in implementing a terminal device of an embodiment of the disclosure.
Detailed Description
The present disclosure is described in further detail below with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that, in the present disclosure, the embodiments and features of the embodiments may be combined with each other without conflict. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
Fig. 1 illustrates an exemplary system architecture 100 of a method for playing a video or an apparatus for playing a video to which embodiments of the present disclosure may be applied.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may have various communication client applications installed thereon, such as a video playing application, a web browser application, a shopping application, a search application, an instant messaging tool, a mailbox client, social platform software, and the like.
The terminal apparatuses 101, 102, and 103 may be hardware or software. When the terminal devices 101, 102, 103 are hardware, they may be various electronic devices having a display screen and supporting video playing, including but not limited to smart phones, tablet computers, MP4(Moving Picture Experts Group Audio Layer IV) players, laptop portable computers, desktop computers, and the like. When the terminal apparatuses 101, 102, 103 are software, they can be installed in the electronic apparatuses listed above. It may be implemented as multiple pieces of software or software modules (e.g., to provide distributed services) or as a single piece of software or software module. And is not particularly limited herein.
The server 105 may be a server providing various services, such as a background server providing support for video playing on the terminal devices 101, 102, 103. The backend server may perform processing such as analysis on data such as the received video data request, and feed back a processing result (e.g., video data) to the terminal apparatuses 101, 102, 103.
The server 105 may be hardware or software. When the server 105 is hardware, it may be implemented as a distributed server cluster composed of a plurality of servers, or may be implemented as a single server. When the server 105 is software, it may be implemented as multiple pieces of software or software modules (e.g., to provide distributed services), or as a single piece of software or software module. And is not particularly limited herein.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
It should be noted that the method for playing back the video provided by the embodiment of the present disclosure is generally executed by the terminal devices 101, 102, 103, and accordingly, the apparatus for playing back the video is generally disposed in the terminal devices 101, 102, 103.
With continued reference to fig. 2, a flow 200 of one embodiment of a method for playing a video in accordance with the present disclosure is shown. The method for playing the video comprises the following steps:
step 201, in response to receiving a code rate switching instruction for switching a first code rate to a second code rate, acquiring video information of a video with the second code rate from a server according to a pre-stored resource address of the video with the second code rate.
In this embodiment, the execution main body (for example, the terminal devices 101, 102, 103 shown in fig. 1) of the method for playing the video may store the resource addresses of the videos with a plurality of different bitrate in advance. Here, the video contents of the plurality of videos with different bit rates are the same, for example, the same movie. The execution body can also receive a code rate switching instruction sent by a user. The code rate switching instruction is used for switching the first code rate to a second code rate, wherein the second code rate is different from the first code rate. The first bitrate may be a bitrate of a video being played by a currently executing subject. Generally, different code rates correspond to different definitions, a high code rate can provide a clearer video effect, and a low code rate can provide a smoother playing effect. In this way, the execution main body can obtain the video information of the video with the second bitrate from the server according to the pre-stored resource address of the video with the second bitrate. Here, the video information of the video at the second bitrate may be information describing a video file, and for example, the video information may include header information. Taking the video as an MP4 file as an example, the video information may be MOOV information. As an example, the header information may include a coding level, a resolution, a code rate, a frame rate, a duration, and the like. Here, the video information of the video of the second bitrate may record which video frames are included in the video of the second bitrate, a timestamp of each video frame, and the like.
Generally, a user plays a video by using a video application installed on a terminal device, and when the user wants to switch definition in the process of playing the video, for example, wants to switch from standard definition to high definition, the user can send a switching instruction by clicking a preset button on a video playing interface. Because different definitions correspond to different code rates, the terminal device can use the received switching instruction as a code rate switching instruction.
Step 202, determining the position of the data to be acquired of the video with the second code rate according to the video information and the playing progress of the currently played video.
In this embodiment, the executing body may determine the position of the data to be acquired for the video with the second bitrate according to the video information of the video with the second bitrate acquired in step 201 and the playing progress of the currently played video. In practice, since the video content of the video with the first bitrate is the same as the video content of the video with the second bitrate, and a part of the video with the first bitrate is already played at the current moment, the played content does not need to be acquired from the video with the second bitrate, and therefore, the position of data to be acquired needs to be determined from the video with the second bitrate. As an example, the executing body may first determine the playing progress of the currently played video, which may be a time, i.e., a few seconds after playing. Then, the execution main body can calculate a corresponding video frame when the video with the second code rate is played to the playing progress according to the video information of the video with the second code rate, and since only the video data with the playing sequence after the video frame needs to be acquired when the video data with the second code rate is acquired, the position of the video frame can be determined as the position of the data to be acquired.
In some optional implementations of this embodiment, step 203 may specifically include the following:
firstly, according to the video information and the playing progress of the currently played video, a target frame is determined from the video with the second code rate.
In this implementation, the execution main body may determine the target frame from the video with the second bitrate according to the video information of the video with the second bitrate and the playing progress of the currently played video. As an example, the executing body may determine the target frame from the video with the second bitrate according to the playing progress of the currently played video, for example, a timestamp of the currently played video frame. For example, a video frame with the same timestamp as the currently played video frame in the video of the second code rate may be used as the target frame.
Then, in response to determining that the target frame is not a key frame, determining the position of a key frame previous to the target frame as the position of the data to be acquired.
In this implementation, the execution main body may determine whether the target frame is a key frame, and if the target frame is not a key frame, the execution main body may determine a position where a previous key frame of the target frame is located as a position of the data to be acquired.
In practice, in a video coding sequence, there are mainly three types of coded frames: an I frame (Intra-coded picture, Intra-coded image frame), a P frame (Predictive-coded picture), and a B frame (bidirectional Predictive coded image frame), wherein the I frame does not refer to other image frames, and is coded only by using information of the frame. The P frame is inter-frame predictive encoded using the previous I frame or P frame by means of motion prediction. B provides the highest compression ratio that requires both the previous video frame (I-frame or P-frame) and the subsequent image frame (P-frame), and uses motion prediction for inter-frame bi-directional predictive coding. The I-frame, also called a key frame, is usually the first frame of each GOP (Group of pictures). In the process of video playing, if I frames are lacked, the following P frames cannot be analyzed, and the phenomenon of video picture black screen can occur. Therefore, when the target frame is determined not to be the key frame, the position of the previous key frame of the target frame needs to be determined as the position of the data to be acquired.
In some optional implementations, step 203 may further specifically include the following: and in response to the fact that the target frame is determined to be the key frame, determining the position of the target frame to be the position of the data to be acquired.
In this implementation, if it is determined that the target frame is a key frame, the execution subject may determine the position where the target frame is located as the position of the data to be acquired.
And step 203, acquiring the video data of the video with the second code rate from the server according to the position of the data to be acquired.
In this embodiment, the executing entity may obtain the video data of the video with the second bitrate from the server according to the position of the data to be obtained determined in step 202. Here, the video data of the video of the second bitrate can be used for data for video playback.
And step 204, playing the video based on the acquired video data.
In this embodiment, the execution body may play the video with the second bitrate based on the acquired video data, thereby implementing the switching from the video with the first bitrate to the video with the second bitrate.
In some optional implementations of this embodiment, the method for playing a video may further include the following: and responding to the situation that no code rate switching instruction is received, and acquiring video data from the server according to the playing progress of the currently played video with the first code rate and the pre-stored resource address of the video with the first code rate.
In this implementation manner, if the code rate switching instruction is not received, the execution main body may obtain the video data with the first code rate from the server storing the video with the first code rate according to the playing progress of the currently played video with the first code rate and the resource address of the video with the first code rate. Here, the server storing the video with the first bitrate and the server storing the video with the second bitrate may be the same server or different servers, and are not limited herein.
With continued reference to fig. 3, fig. 3 is a schematic diagram of an application scenario of the method for playing a video according to the present embodiment. In the application scenario of fig. 3, a user initiates a code rate switching instruction for switching a first code rate to a second code rate by clicking a "high definition" button during playing a video using the terminal device 301, and in response to receiving the code rate switching instruction, the terminal device 301 may obtain video information of the video at the second code rate from the server 302 according to a pre-stored resource address of the video at the second code rate. Then, the terminal device 301 determines the position of the data to be acquired for the video with the second bitrate according to the video information of the video with the second bitrate and the playing progress of the currently played video. Then, the terminal device 301 acquires video data of a video of the second code rate from the server 302 according to the position of the data to be acquired. And finally, playing the video based on the acquired video data.
The method provided by the above embodiment of the present disclosure acquires the video data of the video with the second code rate from the server based on the determined position of the data to be acquired of the video with the second code rate, and plays the video based on the acquired video data, thereby implementing the switching of the video from the first code rate to the second code rate.
With further reference to fig. 4, a flow 400 of yet another embodiment of a method for playing a video is shown. The process 400 of the method for playing a video includes the following steps:
step 401, in response to receiving a code rate switching instruction for switching the first code rate to the second code rate, acquiring video information of a video with the second code rate from a server according to a pre-stored resource address of the video with the second code rate.
In this embodiment, step 401 is similar to step 201 of the embodiment shown in fig. 2, and is not described here again.
And step 402, determining the position of the data to be acquired of the video with the second code rate according to the video information and the playing progress of the currently played video.
In this embodiment, step 402 is similar to step 202 of the embodiment shown in fig. 2, and is not described herein again.
And step 403, acquiring video data of the video with the second code rate from the server according to the position of the data to be acquired.
In this embodiment, step 403 is similar to step 203 of the embodiment shown in fig. 2, and is not described herein again.
Step 404, storing the acquired video data in a first buffer.
In this embodiment, a first buffer may be preset in the execution body, and the first buffer may be used to store video data downloaded from the server. The video data stored in the first buffer is data before decoding, and as an example, each piece of video data downloaded from the server without decoding may be used to parse a video frame. In this way, the execution body may store the video data acquired in step 403 in the first buffer.
It is understood that the video data stored in the first buffer may include video data of a video with a first bitrate, and may also include video data of a video with a second bitrate. That is, the execution body may store the video data of the video of each bitrate downloaded from the server to the first buffer in the order of the playing time.
Step 405, for the video data in the first buffer, updating the decoder information according to the video information corresponding to the video data to perform decoding, and removing the repeated frame data obtained by decoding.
In this embodiment, video data of various video formats needs to be parsed using corresponding decoders. The execution main body may have a plurality of decoders preset therein, and the plurality of decoders are used for analyzing video data in a plurality of video formats. In addition, a scheduling rule for scheduling the corresponding decoder according to the video format of each piece of video data may be predefined in the execution body. By way of example, video formats include, but are not limited to, MP4 format, Rmvb (RealMedia Variable Bitrate) format, and the like. In this way, for each piece of video data in the first buffer, the execution main body may update the decoder information according to the video format included in the video information corresponding to the piece of video data and decode the video data. That is, the decoder information is updated based on the video format of the video data so that the video data is parsed using the decoder corresponding to the updated decoder information. The execution body may also remove the decoded repeated frames afterwards.
The first buffer may contain the downloaded video data of the video with multiple bit rates. During downloading, in order to ensure that the video data can be analyzed, there may be repeated frames between the video data of the videos with different code rates. For example, in order to make a video data that is not an I frame available for parsing, the video data before the video data up to the corresponding I frame needs to be downloaded together. As shown in fig. 5, taking video 1(video1) and video 2(video2) with different bitrate as an example, the first buffer may include six video frames from v1p1 to v1p6 from video1 and four video frames from v2p5 to v2p8 from video 2. The contents of v1p5 and v2p5, and the contents of v1p6 and v2p6 are the same, namely, the repeated frames. However, since v2p5 is a key frame, it is necessary to download v2p5 and v2p6 together to the first buffer in order to parse v2p7 and v2p 8. In order to repeatedly play the same video frame, the data v2f5 and v2f6 obtained by parsing the v2p5 and v2p6 need to be removed after the parsing is completed.
And step 406, storing the decoded data from which the repeated frame data is removed into a second buffer, and obtaining data from the second buffer for playing.
In this embodiment, the execution body may store the decoded data from which the repeated frame data is removed into the second buffer (as shown in fig. 5), and retrieve the data from the second buffer for playing.
As can be seen from fig. 4, compared with the embodiment corresponding to fig. 2, the flow 400 of the method for playing back video in this embodiment highlights the step of playing back video based on the first buffer and the second buffer. Therefore, the scheme described in this embodiment can store the downloaded video data in the first buffer, correspondingly decode the video data in the first buffer and store the decoded video data in the second buffer after removing the decoded repeat frame data, and directly acquire the decoded data from the second buffer for playing during playing. Therefore, the video switching from the first code rate to the second code rate is smoother, and seamless switching is realized.
With further reference to fig. 6, as an implementation of the methods shown in the above-mentioned figures, the present disclosure provides an embodiment of an apparatus for playing a video, where the embodiment of the apparatus corresponds to the embodiment of the method shown in fig. 2, and the apparatus may be specifically applied to various electronic devices.
As shown in fig. 6, the apparatus 600 for playing a video of the present embodiment includes: a first acquisition unit 601, a determination unit 602, a second acquisition unit 603, and a playback unit 604. The first obtaining unit 601 is configured to, in response to receiving a rate switching instruction for switching a first rate to a second rate, obtain, from a server, video information of a video at the second rate according to a pre-stored resource address of the video at the second rate, where the second rate is different from the first rate; the determining unit 602 is configured to determine, according to the video information and a playing progress of a currently played video, a position of data to be acquired for the video with the second bitrate; the second obtaining unit 603 is configured to obtain video data of the video at the second code rate from the server according to the position of the data to be obtained; the playing unit 604 is configured to play a video based on the acquired video data.
In this embodiment, specific processes of the first obtaining unit 601, the determining unit 602, the second obtaining unit 603, and the playing unit 604 of the apparatus 600 for playing a video and technical effects brought by the specific processes can refer to the related descriptions of step 201, step 202, step 203, and step 204 in the corresponding embodiment of fig. 2, which are not repeated herein.
In some optional implementations of the present embodiment, the playing unit 604 is further configured to: storing the acquired video data to a first buffer; for the video data of the first buffer area, updating decoder information according to the video information corresponding to the video data for decoding, and removing repeated frame data obtained by decoding; and storing the decoded data without the repeated frame data into a second buffer area, and acquiring data from the second buffer area for playing.
In some optional implementations of the present embodiment, the determining unit 602 is further configured to: determining a target frame from the video with the second code rate according to the video information and the playing progress of the currently played video; and in response to determining that the target frame is not a key frame, determining the position of a previous key frame of the target frame as the position of the data to be acquired.
In some optional implementations of the present embodiment, the determining unit 602 is further configured to: and in response to the fact that the target frame is determined to be the key frame, determining the position of the target frame to be the position of the data to be acquired.
In some optional implementations of this embodiment, the apparatus 600 further includes: and a third obtaining unit (not shown in the figure) configured to, in response to not receiving the code rate switching instruction, obtain video data from the server according to a playing progress of a currently played video with the first code rate and a pre-stored resource address of the video with the first code rate.
Referring now to fig. 7, shown is a schematic diagram of an electronic device (e.g., terminal device in fig. 1) 700 suitable for use in implementing embodiments of the present disclosure. The terminal device shown in fig. 7 is only an example, and should not bring any limitation to the functions and the use range of the embodiments of the present disclosure.
As shown in fig. 7, electronic device 700 may include a processing means (e.g., central processing unit, graphics processor, etc.) 701 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)702 or a program loaded from storage 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data necessary for the operation of the electronic apparatus 700 are also stored. The processing device 701, the ROM 702, and the RAM 703 are connected to each other by a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
Generally, the following devices may be connected to the I/O interface 705: input devices 706 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 707 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 708 including, for example, magnetic tape, hard disk, etc.; and a communication device 709. The communication means 709 may allow the electronic device 700 to communicate wirelessly or by wire with other devices to exchange data. While fig. 7 illustrates an electronic device 700 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided. Each block shown in fig. 7 may represent one device or may represent multiple devices as desired.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such embodiments, the computer program may be downloaded and installed from a network via the communication means 709, or may be installed from the storage means 708, or may be installed from the ROM 702. The computer program, when executed by the processing device 701, performs the above-described functions defined in the methods of embodiments of the present disclosure.
It should be noted that the computer readable medium described in the embodiments of the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In embodiments of the disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In embodiments of the present disclosure, however, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device. The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: in response to receiving a code rate switching instruction for switching a first code rate to a second code rate, acquiring video information of a video with the second code rate from a server according to a pre-stored resource address of the video with the second code rate, wherein the second code rate is different from the first code rate; determining the position of data to be acquired of the video with the second code rate according to the video information and the playing progress of the currently played video; acquiring video data of the video with the second code rate from the server according to the position of the data to be acquired; and playing the video based on the acquired video data.
Computer program code for carrying out operations for embodiments of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a first acquisition unit, a determination unit, a second acquisition unit, and a playback unit. Here, the names of these units do not constitute a limitation to the unit itself in some cases, and for example, a playback unit may also be described as a "unit that plays back video based on acquired video data".
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention in the embodiments of the present disclosure is not limited to the specific combination of the above-mentioned features, but also encompasses other embodiments in which any combination of the above-mentioned features or their equivalents is made without departing from the inventive concept as defined above. For example, the above features and (but not limited to) technical features with similar functions disclosed in the embodiments of the present disclosure are mutually replaced to form the technical solution.

Claims (12)

1. A method for playing a video, comprising:
in response to receiving a code rate switching instruction for switching a first code rate to a second code rate, acquiring video information of a video with the second code rate from a server according to a pre-stored resource address of the video with the second code rate, wherein the second code rate is different from the first code rate;
determining the position of data to be acquired of the video with the second code rate according to the video information and the playing progress of the currently played video;
acquiring video data of the video with the second code rate from the server according to the position of the data to be acquired;
and playing the video based on the acquired video data.
2. The method of claim 1, wherein the playing a video based on the obtained video data comprises:
storing the acquired video data to a first buffer;
for the video data of the first buffer area, updating decoder information according to the video information corresponding to the video data for decoding, and removing repeated frame data obtained by decoding;
and storing the decoded data from which the repeated frame data is removed into a second buffer area, and acquiring data from the second buffer area for playing.
3. The method of claim 1, wherein the determining, according to the video information and the playing progress of the currently played video, a position of data to be acquired for the video with the second bitrate comprises:
determining a target frame from the video with the second code rate according to the video information and the playing progress of the currently played video;
and in response to determining that the target frame is not a key frame, determining the position of a previous key frame of the target frame as the position of the data to be acquired.
4. The method according to claim 3, wherein the determining, according to the video information and the playing progress of the currently played video, a position of data to be acquired for the video with the second bitrate further comprises:
and in response to the fact that the target frame is determined to be the key frame, determining the position of the target frame to be the position of the data to be acquired.
5. The method of claim 1, wherein the method further comprises:
and responding to the situation that no code rate switching instruction is received, and acquiring video data from a server according to the playing progress of the currently played video with the first code rate and the pre-stored resource address of the video with the first code rate.
6. An apparatus for playing video, comprising:
a first obtaining unit configured to, in response to receiving a rate switching instruction for switching a first rate to a second rate, obtain, from a server, video information of a video of the second rate according to a pre-stored resource address of the video of the second rate, where the second rate is different from the first rate;
the determining unit is configured to determine a position of data to be acquired of the video with the second code rate according to the video information and the playing progress of the currently played video;
a second obtaining unit configured to obtain, from the server, video data of the video with the second code rate according to the position of the data to be obtained;
a playing unit configured to play a video based on the acquired video data.
7. The apparatus of claim 6, wherein the playback unit is further configured to:
storing the acquired video data to a first buffer;
for the video data of the first buffer area, updating decoder information according to the video information corresponding to the video data for decoding, and removing repeated frame data obtained by decoding;
and storing the decoded data from which the repeated frame data is removed into a second buffer area, and acquiring data from the second buffer area for playing.
8. The apparatus of claim 6, wherein the determination unit is further configured to:
determining a target frame from the video with the second code rate according to the video information and the playing progress of the currently played video;
and in response to determining that the target frame is not a key frame, determining the position of a previous key frame of the target frame as the position of the data to be acquired.
9. The apparatus of claim 8, wherein the determining unit is further configured to:
and in response to the fact that the target frame is determined to be the key frame, determining the position of the target frame to be the position of the data to be acquired.
10. The apparatus of claim 6, wherein the apparatus further comprises:
and the third obtaining unit is configured to respond to that no code rate switching instruction is received, and obtain the video data from the server according to the playing progress of the currently played video with the first code rate and the pre-stored resource address of the video with the first code rate.
11. A terminal, comprising:
one or more processors;
a storage device having one or more programs stored thereon,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-5.
12. A computer-readable medium, on which a computer program is stored, wherein the program, when executed by a processor, implements the method of any one of claims 1-5.
CN201911207115.7A 2019-11-29 2019-11-29 Method and device for playing video Pending CN112887755A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911207115.7A CN112887755A (en) 2019-11-29 2019-11-29 Method and device for playing video

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911207115.7A CN112887755A (en) 2019-11-29 2019-11-29 Method and device for playing video

Publications (1)

Publication Number Publication Date
CN112887755A true CN112887755A (en) 2021-06-01

Family

ID=76039175

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911207115.7A Pending CN112887755A (en) 2019-11-29 2019-11-29 Method and device for playing video

Country Status (1)

Country Link
CN (1) CN112887755A (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103517143A (en) * 2013-08-29 2014-01-15 小米科技有限责任公司 Method, device and terminal device for playing network video
CN105657520A (en) * 2014-11-18 2016-06-08 乐视网信息技术(北京)股份有限公司 Video definition switching method and video player
CN106375836A (en) * 2016-09-27 2017-02-01 广东小天才科技有限公司 Resolution switching method and device of video
CN108965907A (en) * 2018-07-11 2018-12-07 北京字节跳动网络技术有限公司 For playing the methods, devices and systems of video
CN109168078A (en) * 2018-09-10 2019-01-08 苏宁智能终端有限公司 A kind of video definition switching method and device
CN109495761A (en) * 2017-09-13 2019-03-19 杭州海康威视系统技术有限公司 Video switching method and device
CN110139148A (en) * 2019-05-22 2019-08-16 武汉瓯越网视有限公司 A kind of method and relevant apparatus of video switching clarity
US20190272088A1 (en) * 2018-03-05 2019-09-05 Qingdao Hisense Media Network Technology Co., Ltd. Playing media
CN110401858A (en) * 2019-08-05 2019-11-01 北京达佳互联信息技术有限公司 A kind of video broadcasting method, device, electronic equipment and storage medium

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103517143A (en) * 2013-08-29 2014-01-15 小米科技有限责任公司 Method, device and terminal device for playing network video
CN105657520A (en) * 2014-11-18 2016-06-08 乐视网信息技术(北京)股份有限公司 Video definition switching method and video player
CN106375836A (en) * 2016-09-27 2017-02-01 广东小天才科技有限公司 Resolution switching method and device of video
CN109495761A (en) * 2017-09-13 2019-03-19 杭州海康威视系统技术有限公司 Video switching method and device
US20190272088A1 (en) * 2018-03-05 2019-09-05 Qingdao Hisense Media Network Technology Co., Ltd. Playing media
CN108965907A (en) * 2018-07-11 2018-12-07 北京字节跳动网络技术有限公司 For playing the methods, devices and systems of video
CN109168078A (en) * 2018-09-10 2019-01-08 苏宁智能终端有限公司 A kind of video definition switching method and device
CN110139148A (en) * 2019-05-22 2019-08-16 武汉瓯越网视有限公司 A kind of method and relevant apparatus of video switching clarity
CN110401858A (en) * 2019-08-05 2019-11-01 北京达佳互联信息技术有限公司 A kind of video broadcasting method, device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
US10187668B2 (en) Method, system and server for live streaming audio-video file
CN105814900B (en) System and method for managing adjacent channel in adaptive streaming environment
WO2020233142A1 (en) Multimedia file playback method and apparatus, electronic device, and storage medium
CN111277869B (en) Video playing method, device, equipment and storage medium
CN108965907B (en) Method, device and system for playing video
WO2013008867A1 (en) Transmission device, method for controlling transmission device, control program, and recording medium
CN106998485B (en) Video live broadcasting method and device
US20230224545A1 (en) Video playback method and apparatus, storage medium, and electronic device
US9998513B2 (en) Selecting bitrate to stream encoded media based on tagging of important media segments
JP2017519406A (en) Network video playback method and apparatus
CN112423140A (en) Video playing method and device, electronic equipment and storage medium
CN111356023B (en) Playing mode determining method and device
CN112995698A (en) Video playing method, client, service platform and intelligent conference system
CN113542856B (en) Method, device, equipment and computer readable medium for reverse playing of online video
CN114040245A (en) Video playing method and device, computer storage medium and electronic equipment
CN111010620B (en) Method and device for multimedia resource carousel, electronic equipment and storage medium
JP6294527B2 (en) Transmission device, transmission method, reproduction device, and reproduction method
CN112887755A (en) Method and device for playing video
US10826838B2 (en) Synchronized jitter buffers to handle codec switches
CN113139090A (en) Interaction method, interaction device, electronic equipment and computer-readable storage medium
CN111131845A (en) Method, electronic device and storage medium for multimedia resource carousel
WO2024046124A1 (en) Video processing method and apparatus, and server
CN112887742B (en) Live stream processing method, device, equipment and storage medium
CN113225583B (en) Cloud game progress processing method and device and electronic equipment
CN112995780B (en) Network state evaluation method, device, 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
RJ01 Rejection of invention patent application after publication

Application publication date: 20210601

RJ01 Rejection of invention patent application after publication