CN115643441A - Video playing method, device, equipment, readable storage medium and program product - Google Patents

Video playing method, device, equipment, readable storage medium and program product Download PDF

Info

Publication number
CN115643441A
CN115643441A CN202211271293.8A CN202211271293A CN115643441A CN 115643441 A CN115643441 A CN 115643441A CN 202211271293 A CN202211271293 A CN 202211271293A CN 115643441 A CN115643441 A CN 115643441A
Authority
CN
China
Prior art keywords
video
sequence number
video frame
terminal
frame
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
CN202211271293.8A
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.)
BOE Technology Group Co Ltd
Original Assignee
BOE Technology Group 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 BOE Technology Group Co Ltd filed Critical BOE Technology Group Co Ltd
Priority to CN202211271293.8A priority Critical patent/CN115643441A/en
Publication of CN115643441A publication Critical patent/CN115643441A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)

Abstract

The embodiment of the application provides a video playing method, a video playing device, a readable storage medium and a program product, and relates to the field of media playing control and the like. The method is executed by a terminal and comprises the following steps: receiving a first message sent by a server, wherein the first message is used for informing a terminal to play each video in a video set; based on the first message, playing the video frame of each video, and sending the video sequence number of each video and the video frame sequence number of each video frame to the server; receiving a video frame maximum sequence number and a video frame minimum sequence number sent by a server; based on the video frame serial number, the video frame maximum serial number and the video frame minimum serial number, adjusting the video playing mode of the terminal so as to keep the video playing between the terminal and other terminals synchronous; therefore, the multiple terminals do not depend on time synchronization, and the frame-level playing synchronization is realized, so that the accuracy of the video playing synchronization of the multiple terminals is improved.

Description

Video playing method, device, equipment, readable storage medium and program product
Technical Field
The present application relates to the field of computer technologies, and in particular, to a video playing method, apparatus, device, readable storage medium, and program product.
Background
In the prior art, media playing control needs to perform multi-terminal synchronous video playing in the same space in some service scenes, a server issues programs to each terminal in the multiple terminals for program delivery, and after each terminal downloads the videos to the local, each terminal plays the video contents according to the uniform delivery time. Because the synchronous playing of the video by the multiple terminals depends on the time synchronization between each terminal and the server, but the time synchronization is often incomplete due to network factors, and the time synchronization is difficult to ensure due to the difference of hardware performance between the terminals; for example, differences in hardware performance of each terminal will result in different video decoding times per frame; therefore, the synchronous video playing of multiple terminals is influenced, namely the synchronous video playing accuracy of the multiple terminals is reduced.
Disclosure of Invention
Aiming at the defects of the existing mode, the video playing method, the video playing device, the video playing equipment, the computer readable storage medium and the computer program product are provided, and the problem of how to improve the accuracy of the synchronization of the video played by the multiple terminals is solved.
In a first aspect, the present application provides a video playing method, which is executed by a terminal, and includes:
receiving a first message sent by a server, wherein the first message is used for informing a terminal to play each video in a video set;
based on the first message, playing the video frame of each video, and sending the video sequence number of each video and the video frame sequence number of each video frame to the server; the video sequence number is used for representing the playing sequence of each video, and the video frame sequence number is used for representing the playing sequence of the video frames of each video;
receiving a video frame maximum sequence number and a video frame minimum sequence number sent by a server; the maximum serial number of the video frame is the maximum serial number in the serial numbers of the video frames sent to the server by the terminal and other terminals at a first time point; the minimum sequence number of the video frame is the minimum sequence number in the video frame sequence numbers sent to the server by the terminal and other terminals at the first time point;
and adjusting the video playing mode of the terminal based on the video frame sequence number, the video frame maximum sequence number and the video frame minimum sequence number so as to keep the video playing between the terminal and other terminals synchronous.
In one embodiment, before receiving the first message sent by the server, the method further includes:
receiving a program to be played sent by a server, wherein the program to be played comprises program information and program content, the program information comprises a starting time point of playing the program to be played, and the program content comprises a video set corresponding to the program to be played;
receiving a second message sent by the server at a second time point before the starting time point, wherein the second message is used for informing the terminal of carrying out play preparation;
and based on the second message, decoding a plurality of original video frames in the first video with the front playing order in the video set in a time period formed by the starting time point and the second time point to obtain a plurality of video frames of the first video, and caching the plurality of video frames in a cache queue of the terminal.
In one embodiment, adjusting the video playing mode of the terminal based on the video frame sequence number, the video frame maximum sequence number, and the video frame minimum sequence number includes:
and adjusting the video playing mode of the terminal based on the video frame serial number, the video frame maximum serial number, the video frame minimum serial number and a preset synchronization error threshold.
In one embodiment, the adjusting the video playing mode of the terminal based on the video frame sequence number, the video frame maximum sequence number, the video frame minimum sequence number and the preset synchronization error threshold includes any one of the following:
if the video frame serial number is equal to the video frame maximum serial number, and the difference between the video frame serial number and the video frame minimum serial number is greater than or equal to a preset synchronization error threshold value, rebroadcasting the video frame corresponding to the video frame serial number;
if the video frame serial number is smaller than the video frame maximum serial number and the difference between the video frame maximum serial number and the video frame serial number is larger than or equal to the synchronous error threshold value, playing the video frame corresponding to the video frame maximum serial number after the video frame corresponding to the video frame serial number is played;
and if the video frame serial number is smaller than the video frame maximum serial number and the difference between the video frame maximum serial number and the video frame serial number is smaller than the synchronization error threshold value, playing the next video frame of the video frames corresponding to the video frame serial number after the video frames corresponding to the video frame serial number are played.
In one embodiment, if the terminal is restarted at the third time point, the video sequence numbers of the second videos in the video set played by the other terminals at the third time point and the maximum sequence numbers of the video frames of the other terminals at the third time point are obtained;
and adjusting the video playing mode of the restarted terminal based on the video sequence number of the second video and the maximum sequence number of the video frame of the other terminal at the third time point so as to keep the video playing between the terminal and the other terminal synchronous.
In one embodiment, adjusting the video playing mode of the restarted terminal based on the video sequence number of the second video and the maximum sequence number of the video frame of the other terminal at the third time point includes:
determining a video frame sequence number corresponding to an I frame in the second video based on the video sequence number of the second video and the maximum sequence number of the video frame of the other terminal at the third time point;
if the video frame serial number corresponding to the I frame is larger than the maximum video frame serial numbers of other terminals at a third time point, decoding the I frame to obtain a video frame corresponding to the I frame, and caching the video frame corresponding to the I frame into a cache queue of the terminal;
if the maximum serial number of the video frames of other terminals at the fourth time point is equal to the serial number of the video frame corresponding to the I frame, playing the video frame corresponding to the I frame; the fourth time point is after the third time point.
In a second aspect, the present application provides a video playing method, which is executed by a server, and includes:
sending a first message to at least two terminals, wherein the first message is used for informing the at least two terminals to play each video in the video set;
receiving a video sequence number of each video and a video frame sequence number of a video frame of each video which are sent by each terminal in at least two terminals;
determining a video frame maximum sequence number and a video frame minimum sequence number based on a video sequence number of each video and a video frame sequence number of a video frame of each video which are sent by each terminal; the maximum sequence number of the video frames is the maximum sequence number in the sequence numbers of the video frames sent to the server by at least two terminals at a first time point; the minimum sequence number of the video frames is the minimum sequence number in the sequence numbers of the video frames sent to the server by at least two terminals at a first time point;
sending the maximum serial number of the video frame and the minimum serial number of the video frame to each terminal; and adjusting the video playing mode of each terminal based on the video frame serial number, the video frame maximum serial number and the video frame minimum serial number by each terminal so as to keep the video playing among the terminals synchronous.
In a third aspect, the present application provides a video playing apparatus, which is applied to a terminal, and includes:
the first processing module is used for receiving a first message sent by the server, wherein the first message is used for informing the terminal to play each video in the video set;
the second processing module is used for playing the video frame of each video based on the first message and sending the video sequence number of each video and the video frame sequence number of the video frame of each video to the server; the video sequence number is used for representing the playing sequence of each video, and the video frame sequence number is used for representing the playing sequence of the video frames of each video;
the third processing module is used for receiving the maximum sequence number and the minimum sequence number of the video frame sent by the server; the maximum sequence number of the video frames is the maximum sequence number in the sequence numbers of the video frames sent to the server by the terminal and other terminals at a first time point; the minimum sequence number of the video frames is the minimum sequence number in the sequence numbers of the video frames sent to the server by the terminal and other terminals at a first time point;
and the fourth processing module is used for adjusting the video playing mode of the terminal based on the video frame serial number, the video frame maximum serial number and the video frame minimum serial number so as to keep the video playing between the terminal and other terminals synchronous.
In a fourth aspect, the present application provides a video playing apparatus, which is applied to a server, and includes:
the fifth processing module is used for sending a first message to the at least two terminals, wherein the first message is used for informing the at least two terminals to play each video in the video set;
the sixth processing module is used for receiving the video sequence number of each video and the video frame sequence number of each video frame sent by each terminal in the at least two terminals;
the seventh processing module is used for determining the maximum serial number of the video frame and the minimum serial number of the video frame based on the video serial number of each video and the video frame serial number of the video frame of each video sent by each terminal; the maximum sequence number of the video frames is the maximum sequence number in the sequence numbers of the video frames sent to the server by at least two terminals at a first time point; the minimum sequence number of the video frames is the minimum sequence number in the sequence numbers of the video frames sent to the server by at least two terminals at a first time point;
the eighth processing module is used for sending the maximum serial number of the video frame and the minimum serial number of the video frame to each terminal; and adjusting the video playing mode of each terminal based on the video frame serial number, the video frame maximum serial number and the video frame minimum serial number by each terminal so as to keep the video playing among the terminals synchronous.
In a fifth aspect, the present application provides an electronic device, comprising: a processor, memory, and a bus;
a bus for connecting the processor and the memory;
a memory for storing operating instructions;
and the processor is used for executing the video playing method of the first aspect of the application by calling the operation instruction.
In a sixth aspect, the present application provides a computer-readable storage medium storing a computer program for executing the video playback method of the first aspect of the present application.
In a seventh aspect, the present application provides a computer program product comprising a computer program, which when executed by a processor, implements the steps of the video playback method in the first aspect of the present application.
The technical scheme provided by the embodiment of the application at least has the following beneficial effects:
the method comprises the steps that a terminal receives a first message sent by a server, wherein the first message is used for informing the terminal to play each video in a video set; the terminal plays the video frame of each video based on the first message, and sends the video sequence number of each video and the video frame sequence number of each video frame to the server; a terminal receives a video frame maximum sequence number and a video frame minimum sequence number sent by a server; the terminal adjusts the video playing mode of the terminal based on the video frame serial number, the video frame maximum serial number and the video frame minimum serial number so as to keep the video playing between the terminal and other terminals synchronous; therefore, the multiple terminals do not depend on time synchronization, and the frame-level playing synchronization is realized, so that the accuracy of the video playing synchronization of the multiple terminals is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings used in the description of the embodiments of the present application will be briefly described below.
Fig. 1 is a schematic structural diagram of a video playing system according to an embodiment of the present application;
fig. 2 is a schematic flowchart of a video playing method according to an embodiment of the present application;
fig. 3 is a schematic flowchart of another video playing method according to an embodiment of the present application;
fig. 4 is a schematic flowchart of another video playing method according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of a video playing apparatus according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of another video playing apparatus according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Embodiments of the present application are described below in conjunction with the drawings in the present application. It should be understood that the embodiments set forth below in connection with the drawings are exemplary descriptions for explaining technical solutions of the embodiments of the present application, and do not limit the technical solutions of the embodiments of the present application.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should be further understood that the terms "comprises" and/or "comprising," when used in this specification in connection with embodiments of the present application, specify the presence of stated features, information, data, steps, operations, elements, and/or components, but do not preclude the presence or addition of other features, information, data, steps, operations, elements, components, and/or groups thereof, as embodied in the art. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. The term "and/or" as used herein indicates at least one of the items defined by the term, e.g., "a and/or B" indicates either an implementation as "a", or an implementation as "B", or an implementation as "a and B".
It is understood that in the specific implementation of the present application, the data related to video playing needs to be approved or agreed by the user when the above embodiments of the present application are applied to specific products or technologies, and the collection, use and processing of the related data need to comply with the relevant laws and regulations and standards of the relevant countries and regions.
To make the objects, technical solutions and advantages of the present application more clear, embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
The embodiment of the application relates to a video playing method provided by a video playing system, and relates to the field of media playing control and the like.
For better understanding and description of the embodiments of the present application, some technical terms referred to in the embodiments of the present application will be briefly described below.
I frame: the I frame is an intra-frame coding frame, also called a full-frame compression coding frame; the I-frame, which is typically the first frame of each GOP (a video compression technique used by MPEG), is moderately compressed and serves as a reference point for random access and can be considered a still image.
The scheme provided by the embodiment of the present application relates to a video technology, and the following detailed description is provided for the technical scheme of the present application by using a specific embodiment. These several specific embodiments may be combined with each other below, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present application will be described below with reference to the accompanying drawings.
In order to better understand the scheme provided by the embodiment of the present application, the scheme is described below with reference to a specific application scenario.
In an embodiment, fig. 1 shows an architecture schematic diagram of a video playing system to which the embodiment of the present application is applied, and it can be understood that the video playing method provided by the embodiment of the present application can be applied to, but is not limited to, the application scenario shown in fig. 1.
In the present example, as shown in fig. 1, the architecture of the video playing system in this example may include, but is not limited to, a server 10, a terminal 20, and a database 30. The server 10, the terminal 20 and the database 30 may interact with each other via a network 40.
The terminal 20 receives a first message sent by the server 10, wherein the first message is used for informing the terminal to play each video in the video set; the terminal 20 plays the video frame of each video based on the first message, and sends the video sequence number of each video and the video frame sequence number of the video frame of each video to the server 10; the video sequence number is used for representing the playing sequence of each video, and the video frame sequence number is used for representing the playing sequence of the video frames of each video; the terminal 20 receives the maximum sequence number and the minimum sequence number of the video frame sent by the server 10; the maximum sequence number of the video frame is the maximum sequence number in the sequence numbers of the video frames sent to the server 10 by the terminal 20 and the other terminals 20 at the first time point; the minimum sequence number of the video frame is the minimum sequence number in the sequence numbers of the video frames sent to the server by the terminal 20 and other terminals 20 at the first time point; the terminal 20 adjusts the video playing mode of the terminal 20 based on the video frame sequence number, the video frame maximum sequence number and the video frame minimum sequence number, so that the video playing between the terminal 20 and other terminals 20 is kept synchronous. The server 10 sends the video frame maximum sequence number and the video frame minimum sequence number to the database 30 for storage via the network 40.
It is understood that the above is only an example, and the present embodiment is not limited thereto.
The terminal includes, but is not limited to, a smart phone (such as an Android phone, an iOS phone, etc.), a phone simulator, a tablet computer, a notebook computer, a digital broadcast receiver, an MID (Mobile Internet Devices ), a PDA (personal digital assistant), an intelligent voice interaction device, an intelligent home appliance, a vehicle-mounted terminal, and the like.
The server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server or a server cluster providing basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a Network service, cloud communication, middleware service, a domain name service, a security service, a CDN (Content Delivery Network), a big data and artificial intelligence platform.
Such networks may include, but are not limited to: a wired network, a wireless network, wherein the wired network comprises: a local area network, a metropolitan area network, and a wide area network, the wireless network comprising: bluetooth, wi-Fi, and other networks that enable wireless communication. The determination may also be based on the requirements of the actual application scenario, and is not limited herein.
Referring to fig. 2, fig. 2 shows a schematic flowchart of a video playing method provided in an embodiment of the present application, where the method may be executed by any electronic device, such as a terminal; as an alternative embodiment, the method may be executed by a terminal, and for convenience of description, in the following description of some alternative embodiments, the terminal is taken as an example of the main body for executing the method. As shown in fig. 2, the video playing method provided in the embodiment of the present application includes the following steps:
s201, receiving a first message sent by a server, wherein the first message is used for informing a terminal to play each video in a video set.
Specifically, a web page of the server edits programs to be played, and the server issues the same program to be played to different terminals, namely a plurality of terminals; the program to be played includes at least one video material, and each video material in the at least one video material may be a video, that is, the video set is a video material set. The program to be played comprises program information and program content; the program information includes a starting time point of playing a program to be played (an issuing time of the program to be played, for example, 10 am at # 2/3 in 2022), a playing time length of the program to be played (for example, the playing time length of the program to be played is 2 hours), a playing time length of each video material in the program to be played (for example, the program to be played includes 3 video materials, a total time of completely playing one of the video materials is 30 minutes, the video material can be set to play only for 10 minutes, that is, the playing time length of the video material is 10 minutes), a position of the program to be played in a display of the terminal, and the like; the program content comprises a video set corresponding to the program to be played, and the video set is a video material set.
The starting time point of the playing of the program to be played (the release time of the program to be played) is based on the server time (the date and time displayed on the server); the server sends a second message (a "play ready" message, i.e. a second message for informing the terminals of the preparation of the play) to all terminals at a second point in time before the start point in time, each terminal making play ready upon receiving the second message, wherein the second point in time and the start point in time form a time period Tp, e.g. 100ms (milliseconds). The play preparation work of the terminal includes (1) and (2):
(1) The terminal loads the player in advance, the player is loaded at the corresponding position of the display according to the position of the program to be played in the display of the terminal, the player is loaded in a hidden mode, and the player is not displayed.
(2) The video set can comprise a plurality of videos, and the video sequence number of each video is used for representing the playing order of each video; for example, the video set includes 3 videos, the video sequence numbers of the 3 videos are 1, 2, and 3, respectively, a video corresponding to the video sequence number 1 is played first, then a video corresponding to the video sequence number 2 is played, and finally a video corresponding to the video sequence number 3 is played. Each video comprises a plurality of video frames, and the video frame sequence number of each video frame is used for representing the playing sequence of each video frame; for example, a video includes 100 video frames, the video frame sequence numbers of the 100 video frames are 1, 2 and 3 \8230100, and the video frame corresponding to the video frame sequence number 1, the video frame corresponding to the video frame sequence number 2, the video frame corresponding to the video frame sequence number 3, \8230, and the video frame corresponding to the video frame sequence number 100 are sequentially played according to the sequence.
For example, the video set includes 3 videos, the video sequence numbers of the 3 videos are 1, 2, and 3, respectively, a plurality of original video frames in a first video (for example, a video corresponding to the video sequence number 1) of the program to be played are decoded to obtain a plurality of video frames of the first video, and the plurality of video frames are cached in a cache queue of the terminal; the above steps only carry on the video decoding, but do not display and broadcast the video; the number of the plurality of video frames may be 5-10 frames, that is, a part of original video frames (a plurality of original video frames) in the first video are decoded to obtain a plurality of video frames and buffered, and when the plurality of video frames are played, other original video frames in the first video are decoded.
It should be noted that the number of the multiple video frames is related to the decoding speed of the hardware performance of the terminal, the hardware performance is high, the decoding speed is high, the number of buffered video frames is large, the hardware performance is general or ultra-high definition video, and the number of buffered video frames is small. Tp can be determined according to the decoding speed of the terminal, and if the decoding speed of the terminal is higher, tp can be set to be smaller; if the terminal decoding speed is slow, tp can be set a little larger.
And after the starting time point of the playing of the program to be played arrives, the server sends a first message (a 'playing starting' message, wherein the first message is used for informing the terminal to play each video in the video set) to all the terminals, each terminal displays the player and displays and plays the video frame after receiving the first message, and the player immediately sends the video frame to the display thread to display the video frame.
S202, playing the video frame of each video based on the first message, and sending the video sequence number of each video and the video frame sequence number of each video frame to a server; the video sequence number is used to characterize the playing order of each video, and the video frame sequence number is used to characterize the playing order of the video frames of each video.
Specifically, after the starting time point of the playing of the program to be played arrives, the server sends a first message (a "start playing" message, where the first message is used to notify the terminal to play each video in the video set) to all terminals, and after each terminal receives the first message, each terminal displays the player and performs display playing of the video frame, and the player immediately sends the video frame to the display thread to perform display of the video frame.
It should be noted that, a waiting signal mechanism is added between the video decoding and the video display playing, and the waiting signal mechanism includes: only when each terminal receives a first message (a message of starting playing) sent by the server, the display playing thread of each terminal starts to extract the video frames from the cache queue of each terminal for display playing; therefore, the video frame starting playing time of all the terminals is completely consistent, the display playing starting error caused by the decoding time difference among the terminals is eliminated, and the problem that the accumulated display playing error is larger and larger due to different hardware performances and inconsistent decoding speeds of the terminals is eliminated.
S203, receiving the maximum sequence number and the minimum sequence number of the video frame sent by the server; the maximum serial number of the video frame is the maximum serial number in the serial numbers of the video frames sent to the server by the terminal and other terminals at a first time point; the minimum sequence number of the video frames is the minimum sequence number in the sequence numbers of the video frames sent to the server by the terminal and other terminals at the first time point.
Specifically, after all terminals (terminals and other terminals) start playing, when each terminal in all terminals renders, displays and plays each video frame in the video a in the video set, each terminal sends the video sequence number Vi of the video a and the video frame sequence number Fi of the video frame of the video a to the server. For example, at the same time point (e.g., a first time point), terminal a sends video sequence number 1 of video a and video frame sequence number 100 of the video frame of video a to the server, terminal B sends video sequence number 1 of video a and video frame sequence number 98 of the video frame of video a to the server, and terminal C sends video sequence number 1 of video a and video frame sequence number 95 of the video frame of video a to the server; that is, at the same time point, terminal a plays the 100 th video frame of video a, terminal B plays the 98 th video frame of video a, and terminal C plays the 95 th video frame of video a.
After the server receives the video sequence number of the video A and the video frame sequence number of the video frame of the video A reported by each terminal in all the terminals, the server puts each video frame sequence number into a queue, updates the queue in time after receiving the data reported by each terminal each time, then sequences each video frame sequence number in the queue at intervals of M (such as 40 ms), and determines the maximum sequence number of the video frame and the minimum sequence number of the video frame; the terminal corresponding to the maximum serial number of the video frame is the terminal which plays the video most quickly in all the terminals, and the terminal corresponding to the minimum serial number of the video frame is the terminal which plays the video most slowly in all the terminals. For example, at the same time point (e.g., a first time point), terminal a sends video sequence number 1 of video a and video frame sequence number 100 of the video frame of video a to the server, terminal B sends video sequence number 1 of video a and video frame sequence number 98 of the video frame of video a to the server, and terminal C sends video sequence number 1 of video a and video frame sequence number 95 of the video frame of video a to the service; the server sequences a video frame sequence number 100, a video frame sequence number 98 and a video frame sequence number 95, and determines that the maximum sequence number Fmax of the video frame is 100 and the minimum sequence number Fmin of the video frame is 95; the server sends the video frame maximum sequence number 100 and the video frame minimum sequence number 95 to all terminals.
It should be noted that, a period of time M may be adjusted according to actual conditions, and if the terminal performance has a large difference or the terminal decodes the ultra high definition video, M may be set to be smaller than 40 ms; therefore, multi-terminal synchronization is carried out once at intervals of time M, namely multi-terminal synchronization is triggered in time.
S204, based on the video frame serial number, the video frame maximum serial number and the video frame minimum serial number, adjusting the video playing mode of the terminal so as to keep the video playing between the terminal and other terminals synchronous.
Specifically, based on a video frame serial number Fi, a video frame maximum serial number Fmax and a video frame minimum serial number Fmin, the video playing mode of the terminal is adjusted, so that each terminal can always keep a synchronization error not more than 2 frames; because the terminal playing faster waits for the terminal playing slower, the video fast-forward playing phenomenon caused by catching up playing all the time can not occur for the terminal with lower hardware performance.
In the embodiment of the application, a terminal receives a first message sent by a server, wherein the first message is used for informing the terminal to play each video in a video set; the terminal plays the video frame of each video based on the first message, and sends the video sequence number of each video and the video frame sequence number of each video frame to the server; a terminal receives a video frame maximum sequence number and a video frame minimum sequence number sent by a server; the terminal adjusts the video playing mode of the terminal based on the video frame serial number, the video frame maximum serial number and the video frame minimum serial number so as to keep the video playing between the terminal and other terminals synchronous; therefore, the multiple terminals do not depend on time synchronization, and the frame-level playing synchronization is realized, so that the accuracy of the video playing synchronization of the multiple terminals is improved.
In one embodiment, before receiving the first message sent by the server, the method further includes steps A1-A3:
step A1, receiving a program to be played sent by a server, wherein the program to be played comprises program information and program content, the program information comprises a starting time point of playing the program to be played, and the program content comprises a video set corresponding to the program to be played.
Specifically, the server issues the same program to be played to different terminals, namely a plurality of terminals; the program to be played includes at least one video material, and each of the at least one video material may be a video, that is, the video set is a video material set. The program to be played comprises program information and program content; the program information includes a starting time point of playing a program to be played (an issuing time of the program to be played, for example, 10 am at # 2/3 in 2022), a playing time length of the program to be played (for example, the playing time length of the program to be played is 2 hours), a playing time length of each video material in the program to be played (for example, the program to be played includes 3 video materials, a total time of completely playing one of the video materials is 30 minutes, the video material can be set to play only for 10 minutes, that is, the playing time length of the video material is 10 minutes), a position of the program to be played in a display of the terminal, and the like; the program content comprises a video set corresponding to the program to be played, and the video set is a video material set.
And step A2, receiving a second message sent by the server at a second time point before the starting time point, wherein the second message is used for informing the terminal of play preparation.
Specifically, the starting time point of the playing of the program to be played (the release time of the program to be played) is based on the server time (the date and time displayed on the server); the server sends a second message (a "play ready" message, i.e. a second message for informing the terminals of the preparation of the play) to all terminals at a second point in time before the start point in time, each terminal making play ready upon receiving the second message, wherein the second point in time and the start point in time form a time period Tp, e.g. 100ms (milliseconds). The play preparation of the terminal includes (1) and (2):
(1) The terminal loads the player in advance, the player is loaded at the corresponding position of the display according to the position of the program to be played in the display of the terminal, the player is loaded in a hidden mode, and the player is not displayed.
(2) The video set can comprise a plurality of videos, and the video sequence number of each video is used for representing the playing order of each video; for example, the video set includes 3 videos, the video sequence numbers of the 3 videos are 1, 2, and 3, respectively, a video corresponding to the video sequence number 1 is played first, then a video corresponding to the video sequence number 2 is played, and finally a video corresponding to the video sequence number 3 is played. Each video comprises a plurality of video frames, and the video frame sequence number of each video frame is used for representing the playing sequence of each video frame; for example, a video includes 100 video frames, the video frame serial numbers of the 100 video frames are 1, 2 and 3 \8230100respectively, and the video frame corresponding to the video frame serial number 1, the video frame corresponding to the video frame serial number 2, the video frame corresponding to the video frame serial number 3, \8230, and the video frame 100 corresponding to the video frame serial number 100 are sequentially played according to the sequence.
For example, the video set includes 3 videos, the video sequence numbers of the 3 videos are 1, 2, and 3, respectively, a plurality of original video frames in a first video (for example, a video corresponding to the video sequence number 1) of the program to be played are decoded to obtain a plurality of video frames of the first video, and the plurality of video frames are cached in a cache queue of the terminal; the above steps only perform video decoding, but do not display the playing video. The number of the plurality of video frames may be 5-10 frames, that is, a part of original video frames (a plurality of original video frames) in the first video are decoded to obtain a plurality of video frames and buffered, and when the plurality of video frames are played, other original video frames in the first video are decoded.
And A3, decoding a plurality of original video frames in the first video with the front playing order in the video set in a time period formed by the starting time point and the second time point based on the second message to obtain a plurality of video frames of the first video, and caching the plurality of video frames in a cache queue of the terminal.
Specifically, for example, the video set includes 3 videos, the video sequence numbers of the 3 videos are 1, 2, and 3, and the playing order of the 3 videos is, in order, the video corresponding to the video sequence number 1, the video corresponding to the video sequence number 2, and the video corresponding to the video sequence number 3; the terminal firstly plays a video corresponding to the video sequence number 1, namely the video corresponding to the video sequence number 1 is a first video; after the terminal plays the video corresponding to the video sequence number 1, the terminal plays the video corresponding to the video sequence number 2 again, that is, the video corresponding to the video sequence number 2 is the first video. Decoding a plurality of original video frames in a first video of a program to be played to obtain a plurality of video frames of the first video, and caching the plurality of video frames into a cache queue of a terminal; the above steps only perform video decoding, but do not display the playing video. The number of the plurality of video frames may be 5-10 frames, that is, a part of original video frames (a plurality of original video frames) in the first video is decoded to obtain a plurality of video frames and buffered, and when the plurality of video frames are played, other original video frames in the first video are decoded.
In one embodiment, adjusting the video playing mode of the terminal based on the video frame sequence number, the video frame maximum sequence number, and the video frame minimum sequence number includes:
and adjusting the video playing mode of the terminal based on the video frame serial number, the video frame maximum serial number, the video frame minimum serial number and a preset synchronization error threshold.
Specifically, the video playing mode of the terminal is adjusted based on a video frame serial number Fi, a video frame maximum serial number Fmax, a video frame minimum serial number Fmin and a preset synchronization error threshold; the preset synchronization error threshold may be 2, so that each terminal can always keep a synchronization error of no more than 2 frames.
In one embodiment, the adjusting the video playing mode of the terminal based on the video frame sequence number, the video frame maximum sequence number, the video frame minimum sequence number and the preset synchronization error threshold includes any one of the following:
if the video frame serial number is equal to the video frame maximum serial number, and the difference between the video frame serial number and the video frame minimum serial number is greater than or equal to a preset synchronization error threshold value, rebroadcasting the video frame corresponding to the video frame serial number;
if the video frame serial number is smaller than the video frame maximum serial number and the difference between the video frame maximum serial number and the video frame serial number is larger than or equal to the synchronous error threshold value, playing the video frame corresponding to the video frame maximum serial number after the video frame corresponding to the video frame serial number is played;
and if the video frame serial number is smaller than the video frame maximum serial number and the difference between the video frame maximum serial number and the video frame serial number is smaller than the synchronous error threshold, playing the next video frame of the video frame corresponding to the video frame serial number after the video frame corresponding to the video frame serial number is played.
Specifically, the terminal receives a maximum sequence number Fmax and a minimum sequence number Fmin of a video frame sent by the server, and the terminal compares the sequence number Fi of the video frame with the sequence numbers Fmax and Fmin respectively.
If Fi = Fmax and Fi-Fmin > = the synchronization error threshold (for example, the synchronization error threshold is 2), that is, fi-Fmin > =2, the terminal plays the video faster than other terminals, and when the Fi-th video frame (video frame serial number Fi) of the terminal is completely played, the terminal repeatedly plays the Fi-th video frame to wait for other terminals that play the video slower.
If Fi < Fmax and Fmax-Fi > = the synchronization error threshold (for example, the synchronization error threshold is 2), that is, fmax-Fi > =2, the terminal plays the video slower than other terminals, discards the corresponding frame to catch up with other terminals that play faster, the terminal finishes playing the Fi-th video frame, and the terminal directly jumps to playing the Fmax-th video frame.
If Fi is less than Fmax and Fmax-Fi is less than the synchronization error threshold (for example, the synchronization error threshold is 2), that is, fmax-Fi is less than 2, the terminal finishes playing the Fi-th video frame, and the terminal normally plays the next frame, that is, fi + 1-th video frame.
For example, 3 terminals (terminal 1, terminal 2 and terminal 3) play video synchronously, the server puts each video frame sequence number into a queue, and the data change in the queue can reflect the synchronization process of the 3 terminals, as shown in table 1 below:
table 1 synchronization procedure for multiple terminals (3 terminals)
Figure BDA0003894118810000151
Figure BDA0003894118810000161
It should be noted that the video playing mode of the terminal is adjusted based on the video frame sequence number Fi, the video frame maximum sequence number Fmax, the video frame minimum sequence number Fmin and the synchronization error threshold 2; therefore, each terminal can always keep the synchronization error of no more than 2 frames; because the terminal playing faster waits for the terminal playing slower, the video fast-forward playing phenomenon caused by catching up playing all the time can not occur for the terminal with lower hardware performance.
In one embodiment, if the terminal is restarted at a third time point, the video sequence numbers of a second video in a video set played by other terminals at the third time point and the maximum sequence numbers of video frames of other terminals at the third time point are obtained;
and adjusting the video playing mode of the restarted terminal based on the video sequence number of the second video and the maximum sequence number of the video frame of the other terminal at the third time point so as to keep the video playing between the terminal and the other terminal synchronous.
Specifically, the terminal is offline in the playing process, and if the terminal is restarted to be online, the terminal and other terminals already playing need to be kept playing synchronously, and the implementation process includes (1) and (2):
(1) After the terminal is restarted to be on line, the terminal loads a player at a corresponding position of a display according to the position of a program to be played in the display of the terminal, the player is loaded in a hidden mode, and the player is not displayed; the terminal acquires a video sequence number Vi (a video sequence number of a second video) of a video played in a program to be played at present (a third time point) and maximum sequence numbers Fmax of video frames of other terminals at present (the third time point) from the server.
(2) The terminal decodes the Vi-th video, and the terminal does not start decoding from the 1 st video frame in the Vi-th video but starts decoding from the I frame; for example, the maximum sequence number Fmax of the video frame of the other terminal at the current (third time point) is 100, the terminal plays the 50 th video frame of the Vi-th video offline, the terminal needs to synchronize with the other terminal when online again, the other terminal plays the 100 th video frame (the maximum sequence number Fmax of the video frame is 100), but the 100 th video frame is not an I frame, and the terminal needs to determine the backward I frame (for example, the I frame is the 102 th video frame) closest to the Fmax-th frame (the 100 th video frame) for decoding, because the video decoding must start from the I frame. And decoding the original I frame to obtain a first video frame (I frame), and putting the first video frame into a buffer queue to be not displayed. If Fmax (the maximum sequence number of the video frames of the other terminals at the fourth time point is 102, that is, fmax is 102) sent by the server to the terminal is equal to the sequence number of the video frame of the first video frame in the buffer queue (the sequence number of the video frame of the I frame 102), the terminal starts playing the video, and the terminal and the other terminals playing the fastest currently keep playing synchronization.
In one embodiment, adjusting the video playing mode of the restarted terminal based on the video sequence number of the second video and the maximum sequence number of the video frame of the other terminal at the third time point includes:
determining a video frame sequence number corresponding to the I frame in the second video based on the video sequence number of the second video and the maximum sequence number of the video frame of the other terminal at the third time point;
if the serial number of the video frame corresponding to the I frame is larger than the maximum serial number of the video frame of other terminals at the third time point, decoding the I frame to obtain the video frame corresponding to the I frame, and caching the video frame corresponding to the I frame into a cache queue of the terminal;
if the maximum sequence number of the video frame of the other terminals at the fourth time point is equal to the sequence number of the video frame corresponding to the I frame, playing the video frame corresponding to the I frame; the fourth time point is after the third time point.
Specifically, the terminal acquires, from the server, a video sequence number Vi (a video sequence number of a second video) of a video played in a program to be played currently (at a third time point), and maximum sequence numbers Fmax of video frames of other terminals at the current (third time point); for example, the maximum sequence number Fmax of the video frame of the other terminal at the current (third time point) is 100, the terminal plays the 50 th video frame of the Vi-th video offline, the terminal needs to synchronize with the other terminal when online again, the other terminal plays the 100 th video frame (the maximum sequence number Fmax of the video frame is 100), but the 100 th video frame is not an I frame, and the terminal needs to determine the backward I frame (for example, the I frame is the 102 th video frame) closest to the Fmax-th frame (the 100 th video frame) for decoding, because the video decoding must start from the I frame.
And decoding the original I frame to obtain a first video frame (I frame), and putting the first video frame into a buffer queue to be not displayed.
If Fmax (the maximum sequence number of the video frame of the other terminals at the fourth time point is 102, that is, fmax is 102) sent to the terminal by the server is equal to the sequence number of the video frame of the first video frame in the buffer queue (the sequence number of the video frame of the I frame 102), the terminal starts playing the video, and the terminal and the other terminals playing the fastest currently keep playing synchronization.
In one embodiment, when a program to be played contains a plurality of videos, during the process of playing the first video, when the 1 st video is 100ms (the time is 100ms consistent with Tp), that is, before the 2 nd video starts 100ms, the terminal needs to perform preparation for playing the 2 nd video in a new thread, and the preparation for playing the second video is the same as the preparation for playing the first video. And if the terminal detects that the playing of the first video is finished, the terminal extracts the video frame of the second video from the buffer queue of the terminal and plays the video frame of the second video.
The application of the embodiment of the application has at least the following beneficial effects:
the video frame playing starting time of all the terminals is completely consistent, so that the display playing starting error caused by the decoding time difference among the terminals is eliminated, and the problem that the accumulated display playing error is larger and larger due to different hardware performances and inconsistent decoding speeds of the terminals is eliminated. The terminal adjusts the video playing mode of the terminal based on the video frame serial number, the video frame maximum serial number and the video frame minimum serial number so as to keep the video playing between the terminal and other terminals synchronous; therefore, the multiple terminals do not depend on time synchronization, and the frame-level playing synchronization is realized, so that the accuracy of the video playing synchronization of the multiple terminals is improved. For the terminal restarted in the playing process, decoding by jumping to a key frame (I frame) near the fastest playing frame, and waiting for other video frames played by the playing terminal to arrive, and synchronously playing; therefore, the frame synchronization playing of the restarted terminal and other broadcasting terminals is ensured.
Referring to fig. 3, fig. 3 shows a schematic flowchart of a video playing method provided in the embodiment of the present application, where the method may be executed by any electronic device, such as a server; as an alternative embodiment, the method may be executed by a server, and for convenience of description, in the following description of some alternative embodiments, the server is taken as an example for the execution subject of the method. As shown in fig. 3, the video playing method provided in the embodiment of the present application includes the following steps:
s301, sending a first message to at least two terminals, wherein the first message is used for informing the at least two terminals to play each video in the video set.
Specifically, a web page of the server edits a program to be played, and the server issues the same program to be played to different terminals, that is, at least two terminals. After the starting time point of the playing of the program to be played is reached, the server sends a first message (a "start playing" message, which is used for informing the terminal to play each video in the video set) to all terminals.
S302, receiving a video sequence number of each video and a video frame sequence number of a video frame of each video which are sent by each terminal in at least two terminals.
Specifically, for example, at the same time point (e.g., a first time point), the server receives the video sequence number 1 of the video a and the video frame sequence number 100 of the video a sent by the terminal a, the video sequence number 1 of the video a and the video frame sequence number 98 of the video a sent by the terminal B, and the video sequence number 1 of the video a and the video frame sequence number 95 of the video a sent by the terminal C.
S303, determining a maximum sequence number of a video frame and a minimum sequence number of the video frame based on a video sequence number of each video and a video frame sequence number of a video frame of each video which are sent by each terminal; the maximum sequence number of the video frames is the maximum sequence number in the sequence numbers of the video frames sent to the server by at least two terminals at a first time point; the minimum sequence number of the video frames is the minimum sequence number in the sequence numbers of the video frames sent to the server by at least two terminals at the first time point.
Specifically, after the server receives the video sequence number of the video a and the video frame sequence number of the video frame of the video a reported by each terminal in all the terminals, the server puts each video frame sequence number into a queue, updates the queue in time after receiving the data reported by each terminal each time, and then sorts each video frame sequence number in the queue at intervals of time M (M, for example, 40 ms) to determine the maximum video frame sequence number and the minimum video frame sequence number.
S304, sending the maximum serial number of the video frame and the minimum serial number of the video frame to each terminal; and adjusting the video playing mode of each terminal based on the video frame serial number, the video frame maximum serial number and the video frame minimum serial number by each terminal so as to keep the video playing among the terminals synchronous.
Specifically, the terminal adjusts the video playing mode of the terminal based on the video frame serial number Fi, the video frame maximum serial number Fmax and the video frame minimum serial number Fmin, so that each terminal can always keep a synchronization error of no more than 2 frames; because the terminal playing faster waits for the terminal playing slower, the video fast-forward playing phenomenon caused by catching up playing for the terminal with lower hardware performance can not occur.
In the embodiment of the application, a server sends a first message to at least two terminals; the method comprises the steps that a server receives a video sequence number of each video and a video frame sequence number of a video frame of each video, which are sent by each terminal in at least two terminals; the server determines the maximum sequence number of the video frame and the minimum sequence number of the video frame based on the video sequence number of each video and the video frame sequence number of the video frame of each video which are sent by each terminal; the server sends the maximum serial number of the video frame and the minimum serial number of the video frame to each terminal; adjusting the video playing mode of each terminal based on the video frame serial number, the video frame maximum serial number and the video frame minimum serial number by each terminal so as to keep the video playing among the terminals synchronous; therefore, the multiple terminals do not depend on time synchronization, and the frame-level playing synchronization is realized, so that the accuracy of the video playing synchronization of the multiple terminals is improved.
In order to better understand the method provided by the embodiment of the present application, the following further describes the scheme of the embodiment of the present application with reference to an example of a specific application scenario.
In a specific application scenario embodiment, for example, a video scenario is played by multiple terminals synchronously, referring to fig. 4, a processing flow of a video playing method is shown, as shown in fig. 4, the processing flow of the video playing method provided in the embodiment of the present application includes the following steps:
s401, the server sends the same program to be played to a plurality of terminals.
S402, a plurality of terminals receive the program to be played sent by the server.
S403, the server sends a second message to the plurality of terminals at a second time point before the starting time point of the to-be-played program.
Specifically, the second message is a "play preparation" message, and the second message is used to notify each terminal of the preparation for play. The second point in time and the start point in time constitute a time period Tp, for example 100ms.
S404, each of the plurality of terminals receives the second message and performs a play preparation operation within the time period Tp.
Specifically, each terminal loads a player in advance, and according to the position of the program to be played in the display of each terminal, the player is loaded at the corresponding position of the display, and the player is loaded in a hidden manner and is not displayed. For example, a video set corresponding to a program to be played includes 3 videos, the video sequence numbers of the 3 videos are 1, 2, and 3, a plurality of original video frames in a first video (for example, a video corresponding to the video sequence number 1) of the program to be played are decoded to obtain a plurality of video frames of the first video, and the plurality of video frames are cached in a cache queue of the terminal; the above steps only carry on the video decoding, but do not display and broadcast the video; the number of the plurality of video frames may be 5-10 frames, that is, a part of original video frames (a plurality of original video frames) in the first video is decoded to obtain a plurality of video frames and buffered, and when the plurality of video frames are played, other original video frames in the first video are decoded.
S405, after the starting time point of the program to be played arrives, the server sends a first message to a plurality of terminals.
Specifically, the first message is a "start playing" message, and the first message is used to notify each terminal to play each video in the video set.
S406, each terminal receives the first message sent by the server, plays (renders and displays) a video frame in a certain video based on the first message, and sends the video serial number of the video and the video frame serial number of the video frame to the server.
S407, the server receives the video sequence number of the video and the video frame sequence number of the video frame sent by each terminal, puts the video frame sequence number sent by each terminal into a queue, and updates the queue.
S408, at intervals, the server sequences the sequence numbers of the video frames in the queue, and determines the maximum sequence number and the minimum sequence number of the video frames.
S409, the server sends the video frame maximum sequence number and the video frame minimum sequence number to a plurality of terminals.
S410, each terminal adjusts the video playing mode based on the video frame serial number, the video frame maximum serial number and the video frame minimum serial number so as to keep the video playing among a plurality of terminals synchronous.
Specifically, any one of the terminals receives a video frame maximum sequence number Fmax and a video frame minimum sequence number Fmin sent by the server, and the terminal compares the video frame sequence numbers Fi with Fmax and Fmin respectively.
If Fi = Fmax and Fi-Fmin > = a synchronization error threshold (for example, the synchronization error threshold is 2), that is, fi-Fmin > =2, the terminal plays the video faster than the other terminals, and when the Fi-th video frame (video frame serial number Fi) of the terminal is completely played, the terminal repeatedly plays the Fi-th video frame to wait for the other terminals that are slower to play.
If Fi < Fmax and Fmax-Fi > = the synchronization error threshold (for example, the synchronization error threshold is 2), that is, fmax-Fi > =2, the terminal plays the video slower than other terminals, discards the corresponding frame to catch up with other terminals that play faster, the terminal finishes playing the Fi-th video frame, and the terminal directly jumps to playing the Fmax-th video frame.
If Fi is less than Fmax and Fmax-Fi is less than the synchronization error threshold (for example, the synchronization error threshold is 2), that is, fmax-Fi is less than 2, the terminal finishes playing the Fi-th video frame, and the terminal normally plays the next frame, that is, fi + 1-th video frame.
The application of the embodiment of the application has at least the following beneficial effects:
the video frame starting playing time of the terminals is completely consistent, so that the display playing starting error caused by the decoding time difference among the terminals in the terminals is eliminated, and the problem that the accumulated display playing error is larger and larger due to different hardware performance and inconsistent decoding speed of the terminals is solved. Each terminal adjusts the respective video playing mode based on the video frame serial number, the video frame maximum serial number and the video frame minimum serial number so as to keep the video playing among a plurality of terminals synchronous; therefore, the plurality of terminals do not depend on time synchronization, and the frame-level playing synchronization is realized, so that the accuracy of the video playing synchronization of the plurality of terminals is improved.
The embodiment of the present application further provides a video playing apparatus, which is applied to a terminal, and a schematic structural diagram of the video playing apparatus is shown in fig. 5, where the video playing apparatus 50 includes a first processing module 501, a second processing module 502, a third processing module 503, and a fourth processing module 504.
A first processing module 501, configured to receive a first message sent by a server, where the first message is used to notify a terminal to play each video in a video set;
the second processing module 502 is configured to play the video frame of each video based on the first message, and send the video sequence number of each video and the video frame sequence number of the video frame of each video to the server; the video sequence number is used for representing the playing sequence of each video, and the video frame sequence number is used for representing the playing sequence of the video frames of each video;
a third processing module 503, configured to receive a maximum sequence number of a video frame and a minimum sequence number of the video frame sent by a server; the maximum serial number of the video frame is the maximum serial number in the serial numbers of the video frames sent to the server by the terminal and other terminals at a first time point; the minimum sequence number of the video frame is the minimum sequence number in the video frame sequence numbers sent to the server by the terminal and other terminals at the first time point;
the fourth processing module 504 is configured to adjust a video playing mode of the terminal based on the video frame sequence number, the video frame maximum sequence number, and the video frame minimum sequence number, so that video playing between the terminal and another terminal is kept synchronous.
In one embodiment, the first processing module 501 is further configured to:
receiving a program to be played sent by a server, wherein the program to be played comprises program information and program content, the program information comprises a starting time point of playing of the program to be played, and the program content comprises a video set corresponding to the program to be played;
receiving a second message sent by the server at a second time point before the starting time point, wherein the second message is used for informing the terminal of carrying out play preparation;
and based on the second message, decoding a plurality of original video frames in the first video with the front playing order in the video set in a time period formed by the starting time point and the second time point to obtain a plurality of video frames of the first video, and caching the plurality of video frames in a cache queue of the terminal.
In an embodiment, the fourth processing module 504 is specifically configured to:
and adjusting the video playing mode of the terminal based on the video frame serial number, the video frame maximum serial number, the video frame minimum serial number and a preset synchronization error threshold.
In an embodiment, the fourth processing module 504 is specifically configured to perform any one of the following:
if the video frame serial number is equal to the video frame maximum serial number, and the difference between the video frame serial number and the video frame minimum serial number is greater than or equal to a preset synchronization error threshold value, rebroadcasting the video frame corresponding to the video frame serial number;
if the video frame serial number is smaller than the video frame maximum serial number and the difference between the video frame maximum serial number and the video frame serial number is larger than or equal to the synchronous error threshold value, playing the video frame corresponding to the video frame maximum serial number after the video frame corresponding to the video frame serial number is played;
and if the video frame serial number is smaller than the video frame maximum serial number and the difference between the video frame maximum serial number and the video frame serial number is smaller than the synchronization error threshold value, playing the next video frame of the video frames corresponding to the video frame serial number after the video frames corresponding to the video frame serial number are played.
In one embodiment, the fourth processing module 504 is further configured to:
if the terminal is restarted at a third time point, acquiring video sequence numbers of second videos in a video set played by other terminals at the third time point and the maximum sequence numbers of video frames of other terminals at the third time point;
and adjusting the video playing mode of the restarted terminal based on the video sequence number of the second video and the maximum sequence number of the video frame of the other terminal at the third time point so as to keep the video playing between the terminal and the other terminal synchronous.
In an embodiment, the fourth processing module 504 is specifically configured to:
determining a video frame sequence number corresponding to the I frame in the second video based on the video sequence number of the second video and the maximum sequence number of the video frame of the other terminal at the third time point;
if the video frame serial number corresponding to the I frame is larger than the maximum video frame serial numbers of other terminals at a third time point, decoding the I frame to obtain a video frame corresponding to the I frame, and caching the video frame corresponding to the I frame into a cache queue of the terminal;
if the maximum serial number of the video frames of other terminals at the fourth time point is equal to the serial number of the video frame corresponding to the I frame, playing the video frame corresponding to the I frame; the fourth time point is after the third time point.
The application of the embodiment of the application has at least the following beneficial effects:
the method comprises the steps that a terminal receives a first message sent by a server, wherein the first message is used for informing the terminal to play each video in a video set; the terminal plays the video frame of each video based on the first message, and sends the video sequence number of each video and the video frame sequence number of each video frame to the server; a terminal receives a maximum sequence number and a minimum sequence number of a video frame sent by a server; the terminal adjusts the video playing mode of the terminal based on the video frame serial number, the video frame maximum serial number and the video frame minimum serial number so as to keep the video playing between the terminal and other terminals synchronous; therefore, the multiple terminals do not depend on time synchronization, and the frame-level playing synchronization is realized, so that the accuracy of the video playing synchronization of the multiple terminals is improved.
The embodiment of the present application further provides a video playing apparatus, which is applied to a server, and a schematic structural diagram of the video playing apparatus is shown in fig. 6, where the video playing apparatus 60 includes a fifth processing module 601, a sixth processing module 602, a seventh processing module 603, and an eighth processing module 604.
A fifth processing module 601, configured to send a first message to the at least two terminals, where the first message is used to notify the at least two terminals to play each video in the video set;
a sixth processing module 602, configured to receive a video sequence number of each video and a video frame sequence number of a video frame of each video sent by each terminal of the at least two terminals;
a seventh processing module 603, configured to determine a maximum sequence number of a video frame and a minimum sequence number of the video frame based on a video sequence number of each video and a video frame sequence number of a video frame of each video sent by each terminal; the maximum sequence number of the video frames is the maximum sequence number in the sequence numbers of the video frames sent to the server by at least two terminals at a first time point; the minimum sequence number of the video frames is the minimum sequence number in the sequence numbers of the video frames sent to the server by at least two terminals at a first time point;
an eighth processing module 604, configured to send a maximum sequence number of a video frame and a minimum sequence number of the video frame to each terminal; and adjusting the video playing mode of each terminal based on the video frame serial number, the video frame maximum serial number and the video frame minimum serial number by each terminal so as to keep the video playing among the terminals synchronous.
The application of the embodiment of the application has at least the following beneficial effects:
the server sends a first message to at least two terminals; the method comprises the steps that a server receives a video sequence number of each video and a video frame sequence number of a video frame of each video, which are sent by each terminal in at least two terminals; the server determines the maximum sequence number of the video frame and the minimum sequence number of the video frame based on the video sequence number of each video and the video frame sequence number of the video frame of each video which are sent by each terminal; the server sends the maximum serial number of the video frame and the minimum serial number of the video frame to each terminal; adjusting the video playing mode of each terminal based on the video frame serial number, the video frame maximum serial number and the video frame minimum serial number by each terminal so as to keep the video playing among the terminals synchronous; therefore, the multiple terminals do not depend on time synchronization, and the frame-level playing synchronization is realized, so that the accuracy of the video playing synchronization of the multiple terminals is improved.
An embodiment of the present application further provides an electronic device, a schematic structural diagram of the electronic device is shown in fig. 7, and an electronic device 4000 shown in fig. 7 includes: a processor 4001 and a memory 4003. Processor 4001 is coupled to memory 4003, such as via bus 4002. Optionally, the electronic device 4000 may further include a transceiver 4004, and the transceiver 4004 may be used for data interaction between the electronic device and other electronic devices, such as transmission of data and/or reception of data. It should be noted that the transceiver 4004 is not limited to one in practical applications, and the structure of the electronic device 4000 is not limited to the embodiment of the present application.
The Processor 4001 may be a CPU (Central Processing Unit), a general-purpose Processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other Programmable logic device, a transistor logic device, a hardware component, or any combination thereof. Which may implement or perform the various illustrative logical blocks, modules, and circuits described in connection with the disclosure. The processor 4001 may also be a combination that performs a computational function, including, for example, a combination of one or more microprocessors, a combination of a DSP and a microprocessor, or the like.
Bus 4002 may include a path that carries information between the aforementioned components. The bus 4002 may be a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. The bus 4002 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in FIG. 7, but this is not intended to represent only one bus or type of bus.
The Memory 4003 may be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical Disc storage, optical Disc storage (including Compact Disc, laser Disc, optical Disc, digital versatile Disc, blu-ray Disc, etc.), a magnetic Disc storage medium, other magnetic storage devices, or any other medium that can be used to carry or store a computer program and that can be Read by a computer, without limitation.
The memory 4003 is used for storing computer programs for executing the embodiments of the present application, and execution is controlled by the processor 4001. The processor 4001 is used to execute computer programs stored in the memory 4003 to implement the steps shown in the foregoing method embodiments.
Wherein, the electronic device includes but is not limited to: terminals, servers, etc.
The application of the embodiment of the application has at least the following beneficial effects:
the multi-terminal does not depend on time synchronization, and frame-level playing synchronization is achieved, so that the accuracy of video playing synchronization of the multi-terminal is improved.
Embodiments of the present application provide a computer-readable storage medium, on which a computer program is stored, and when being executed by a processor, the computer program may implement the steps and corresponding contents of the foregoing method embodiments.
Embodiments of the present application further provide a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps and corresponding contents of the foregoing method embodiments may be implemented.
Based on the same principle as the method provided by the embodiment of the present application, the embodiment of the present application also provides a computer program product or a computer program, and the computer program product or the computer program comprises computer instructions, and the computer instructions are stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to cause the computer device to perform the method provided in any of the alternative embodiments of the present application.
It should be understood that, although each operation step is indicated by an arrow in the flowchart of the embodiment of the present application, the implementation order of the steps is not limited to the order indicated by the arrow. In some implementation scenarios of the embodiments of the present application, the implementation steps in the flowcharts may be performed in other sequences as needed, unless explicitly stated otherwise herein. In addition, some or all of the steps in each flowchart may include multiple sub-steps or multiple stages based on an actual implementation scenario. Some or all of these sub-steps or stages may be performed at the same time, or each of these sub-steps or stages may be performed at different times, respectively. In a scenario where execution times are different, an execution sequence of the sub-steps or the phases may be flexibly configured according to requirements, which is not limited in the embodiment of the present application.
The foregoing is only an optional implementation manner of a part of implementation scenarios in this application, and it should be noted that, for those skilled in the art, other similar implementation means based on the technical idea of this application are also within the protection scope of the embodiments of this application without departing from the technical idea of this application.

Claims (12)

1. A video playing method executed by a terminal is characterized by comprising the following steps:
receiving a first message sent by a server, wherein the first message is used for informing the terminal to play each video in a video set;
based on the first message, playing the video frame of each video, and sending the video sequence number of each video and the video frame sequence number of the video frame of each video to the server; the video sequence number is used for representing the playing order of each video, and the video frame sequence number is used for representing the playing order of the video frames of each video;
receiving a video frame maximum sequence number and a video frame minimum sequence number sent by a server; the maximum sequence number of the video frames is the maximum sequence number in the sequence numbers of the video frames sent to the server by the terminal and other terminals at a first time point; the minimum sequence number of the video frame is the minimum sequence number in the video frame sequence numbers sent to the server by the terminal and other terminals at the first time point;
and adjusting the video playing mode of the terminal based on the video frame sequence number, the video frame maximum sequence number and the video frame minimum sequence number so as to keep the video playing between the terminal and the other terminals synchronous.
2. The method of claim 1, wherein before the receiving the first message sent by the server, further comprising:
receiving a program to be played sent by the server, wherein the program to be played comprises program information and program content, the program information comprises a starting time point of playing of the program to be played, and the program content comprises the video set corresponding to the program to be played;
receiving a second message sent by the server at a second time point before the starting time point, wherein the second message is used for informing the terminal to prepare for playing;
and decoding a plurality of original video frames in a first video with a front playing order in the video set in a time period formed by the starting time point and the second time point based on the second message to obtain a plurality of video frames of the first video, and caching the plurality of video frames in a cache queue of the terminal.
3. The method according to claim 1, wherein the adjusting the video playing mode of the terminal based on the video frame sequence number, the video frame maximum sequence number, and the video frame minimum sequence number comprises:
and adjusting the video playing mode of the terminal based on the video frame serial number, the video frame maximum serial number, the video frame minimum serial number and a preset synchronization error threshold value.
4. The method according to claim 3, wherein the adjusting the video playing mode of the terminal based on the video frame sequence number, the video frame maximum sequence number, the video frame minimum sequence number and a preset synchronization error threshold comprises any one of:
if the video frame sequence number is equal to the video frame maximum sequence number, and the difference between the video frame sequence number and the video frame minimum sequence number is greater than or equal to a preset synchronization error threshold value, replaying the video frame corresponding to the video frame sequence number;
if the video frame sequence number is smaller than the video frame maximum sequence number and the difference between the video frame maximum sequence number and the video frame sequence number is larger than or equal to the synchronization error threshold, playing the video frame corresponding to the video frame maximum sequence number after the video frame corresponding to the video frame sequence number is played;
and if the video frame sequence number is smaller than the video frame maximum sequence number and the difference between the video frame maximum sequence number and the video frame sequence number is smaller than the synchronization error threshold, playing the next video frame of the video frame corresponding to the video frame sequence number after the video frame corresponding to the video frame sequence number is played.
5. The method of claim 1, further comprising:
if the terminal is restarted at a third time point, acquiring a video sequence number of a second video in the video set played by the other terminals at the third time point and a maximum sequence number of video frames of the other terminals at the third time point;
and adjusting the video playing mode of the restarted terminal based on the video sequence number of the second video and the maximum sequence number of the video frames of the other terminals at the third time point so as to keep the video playing between the terminal and the other terminals synchronous.
6. The method according to claim 5, wherein the adjusting the video playing mode of the restarted terminal based on the video sequence number of the second video and the maximum sequence number of the video frame of the other terminal at the third time point comprises:
determining a video frame sequence number corresponding to an I frame in the second video based on the video sequence number of the second video and the maximum sequence number of the video frame of the other terminal at the third time point;
if the serial number of the video frame corresponding to the I frame is greater than the maximum serial number of the video frame of the other terminal at the third time point, decoding the I frame to obtain the video frame corresponding to the I frame, and caching the video frame corresponding to the I frame into a cache queue of the terminal;
if the maximum sequence number of the video frame of the other terminals at the fourth time point is equal to the sequence number of the video frame corresponding to the I frame, playing the video frame corresponding to the I frame; the fourth point in time is after the third point in time.
7. A video playing method executed by a server, comprising:
sending a first message to at least two terminals, wherein the first message is used for informing the at least two terminals to play each video in a video set;
receiving the video sequence number of each video and the video frame sequence number of the video frame of each video which are sent by each terminal in the at least two terminals;
determining a video frame maximum sequence number and a video frame minimum sequence number based on the video sequence number of each video and the video frame sequence number of the video frame of each video sent by each terminal; the maximum sequence number of the video frames is the maximum sequence number in the sequence numbers of the video frames sent to the server by the at least two terminals at a first time point; the minimum sequence number of the video frames is the minimum sequence number in the video frame sequence numbers sent to the server by the at least two terminals at the first time point;
sending the video frame maximum sequence number and the video frame minimum sequence number to each terminal; and adjusting the video playing mode of each terminal based on the video frame sequence number, the video frame maximum sequence number and the video frame minimum sequence number by each terminal so as to keep the video playing among the terminals synchronous.
8. A video playing device applied to a terminal is characterized by comprising:
the first processing module is used for receiving a first message sent by a server, wherein the first message is used for informing the terminal to play each video in a video set;
the second processing module is used for playing the video frame of each video based on the first message and sending the video sequence number of each video and the video frame sequence number of the video frame of each video to the server; the video sequence number is used for representing the playing order of each video, and the video frame sequence number is used for representing the playing order of the video frames of each video;
the third processing module is used for receiving the maximum sequence number and the minimum sequence number of the video frame sent by the server; the maximum sequence number of the video frames is the maximum sequence number in the sequence numbers of the video frames sent to the server by the terminal and other terminals at a first time point; the minimum sequence number of the video frame is the minimum sequence number in the video frame sequence numbers sent to the server by the terminal and other terminals at the first time point;
and the fourth processing module is used for adjusting the video playing mode of the terminal based on the video frame sequence number, the video frame maximum sequence number and the video frame minimum sequence number so as to keep the video playing between the terminal and the other terminals synchronous.
9. A video playing device applied to a server is characterized by comprising:
a fifth processing module, configured to send a first message to at least two terminals, where the first message is used to notify the at least two terminals to play each video in a video set;
a sixth processing module, configured to receive a video sequence number of each video and a video frame sequence number of a video frame of each video sent by each terminal of the at least two terminals;
a seventh processing module, configured to determine a maximum sequence number of a video frame and a minimum sequence number of the video frame based on the video sequence number of each video and the video frame sequence number of the video frame of each video sent by each terminal; the maximum sequence number of the video frames is the maximum sequence number in the sequence numbers of the video frames sent to the server by the at least two terminals at a first time point; the minimum sequence number of the video frames is the minimum sequence number in the video frame sequence numbers sent to the server by the at least two terminals at the first time point;
an eighth processing module, configured to send the maximum sequence number of the video frame and the minimum sequence number of the video frame to each terminal; and adjusting the video playing mode of each terminal based on the video frame sequence number, the video frame maximum sequence number and the video frame minimum sequence number by each terminal so as to keep the video playing among the terminals synchronous.
10. An electronic device comprising a memory, a processor and a computer program stored on the memory, characterized in that the processor executes the computer program to implement the steps of the method of any of claims 1-7.
11. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 7.
12. A computer program product comprising a computer program, characterized in that the computer program realizes the steps of the method of any one of claims 1-7 when executed by a processor.
CN202211271293.8A 2022-10-17 2022-10-17 Video playing method, device, equipment, readable storage medium and program product Pending CN115643441A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211271293.8A CN115643441A (en) 2022-10-17 2022-10-17 Video playing method, device, equipment, readable storage medium and program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211271293.8A CN115643441A (en) 2022-10-17 2022-10-17 Video playing method, device, equipment, readable storage medium and program product

Publications (1)

Publication Number Publication Date
CN115643441A true CN115643441A (en) 2023-01-24

Family

ID=84945301

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211271293.8A Pending CN115643441A (en) 2022-10-17 2022-10-17 Video playing method, device, equipment, readable storage medium and program product

Country Status (1)

Country Link
CN (1) CN115643441A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117201854A (en) * 2023-11-02 2023-12-08 广东朝歌智慧互联科技有限公司 Method and system for accurate seek video frames applied to video synchronous playing system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117201854A (en) * 2023-11-02 2023-12-08 广东朝歌智慧互联科技有限公司 Method and system for accurate seek video frames applied to video synchronous playing system

Similar Documents

Publication Publication Date Title
US9961398B2 (en) Method and device for switching video streams
CN106454434B (en) Bullet screen playing method and device
EP3253064A1 (en) Frame loss method for video frame and video sending apparatus
CN108200447B (en) Live broadcast data transmission method and device, electronic equipment, server and storage medium
CN106998485B (en) Video live broadcasting method and device
CN108174280B (en) Audio and video online playing method and system
CN106791994B (en) Low-delay quick broadcasting method and device
CN107517400B (en) Streaming media playing method and streaming media player
CN106604064A (en) Rapid broadcasting method and device
US20160308923A1 (en) Method and system for playing live broadcast streaming media
CN106791988B (en) Multimedia data carousel method and terminal
EP3142381A1 (en) Network video playing method and device
CN108900855B (en) Live content recording method and device, computer readable storage medium and server
CN107333163A (en) A kind of method for processing video frequency and device, a kind of terminal and storage medium
CN109218745B (en) Live broadcast method, server, client and readable storage medium
CN115643441A (en) Video playing method, device, equipment, readable storage medium and program product
CN112104909A (en) Interactive video playing method and device, computer equipment and readable storage medium
CN113490055A (en) Data processing method and device
US10999646B2 (en) Information presenting method, terminal device, server and system
CN111436009B (en) Real-time video stream transmission and display method and transmission and play system
CN113507639A (en) Channel fast switching method, player and readable storage medium
CN106657172A (en) Method and device for realizing information push
CN112073823B (en) Frame loss processing method, video playing terminal and computer readable storage medium
CN116546262A (en) Data processing method, device, equipment and storage medium
CN112449209B (en) Video storage method and device, cloud server and computer readable 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