Disclosure of Invention
The present application aims to solve at least one of the above technical drawbacks, in particular the problem of time consuming playback of live video.
In a first aspect, an embodiment of the present application provides a method for loading a video slice file, including the following steps:
instantiating a video slice list request and a video slice file request as a first network protocol object and a second network protocol object, respectively;
loading video slice list files by using the first network protocol object, sequentially resolving slice file addresses of the video slice files reversely from the video slice list files, and feeding the slice file addresses back to a play control module in real time;
and receiving the address of the slice file forwarded by the play control module, and starting and loading a corresponding video slice file by using the second network protocol object according to the address of the slice file.
In one embodiment, the step of loading a video slice list file using the first network protocol object comprises:
acquiring the video slice list address through the play control module, and analyzing the video slice list address to obtain a list server where the video slice file list is located;
loading the video slice list file from the list server using the first network protocol object.
In an embodiment, the step of starting and loading the corresponding video slice file according to the slice file address by using the second network protocol object includes:
analyzing the address of the slice file to obtain a slice server where the video slice file is located;
starting and loading the video slice file from the slice server using the second network protocol object.
In an embodiment, the step of sequentially resolving the slice file addresses of the video slice files inversely according to the video slice list file includes:
and on the basis of a streaming media network transmission protocol of a hypertext transfer protocol, sequentially and inversely resolving the slice file address of each video slice file from the video slice list file.
In a second aspect, an embodiment of the present application provides a method for playing a video file, including the following steps:
receiving a playing request of a user, and generating a video slice list request and a video slice file request for loading video slice data according to the playing request;
instantiating the video slice list request and the video slice file request as a first network protocol object and a second network protocol object, respectively;
loading video slice list files by using the first network protocol object, sequentially resolving slice file addresses of the video slice files reversely from the video slice list files, and feeding the slice file addresses back to a play control module in real time;
receiving the address of the slice file forwarded by the play control module, starting and loading a corresponding video slice file by using the second network protocol object according to the address of the slice file;
and analyzing and playing the video streams of the loaded video slice files in sequence.
In an embodiment, the step of sequentially parsing and playing the video stream of the loaded video slice file includes:
continuously analyzing the video slice files in sequence according to an MPEG-2 transport stream protocol to form video streams;
and decoding the video stream and then playing the decoded video stream in real time.
In a third aspect, an embodiment of the present application further provides a device for loading a video slice file, including:
the instantiation module is used for instantiating the video slice list request and the video slice file request into a first network protocol object and a second network protocol object respectively;
the list file loading module is used for loading video slice list files by using the first network protocol object, sequentially and reversely resolving slice file addresses of the video slice list files, and feeding the slice file addresses back to the play control module in real time;
and the slice file loading module is used for receiving the slice file address forwarded by the play control module, starting and loading the corresponding video slice file according to the slice file address by using the second network protocol object.
In a fourth aspect, an embodiment of the present application further provides a device for playing a video file, including:
the playing request receiving module is used for receiving a playing request of a user and generating a video slice list request and a video slice file request for loading video slice data according to the playing request;
an instantiation module, configured to instantiate the video slice list request and the video slice file request into a first network protocol object and a second network protocol object, respectively;
the list file loading module is used for loading video slice list files by using the first network protocol object, sequentially and reversely resolving slice file addresses of the video slice list files, and feeding the slice file addresses back to the play control module in real time;
the slice file loading module is used for receiving the slice file address forwarded by the play control module, starting and loading a corresponding video slice file according to the slice file address by using the second network protocol object;
and the video stream playing module is used for sequentially analyzing and playing the video streams of the loaded video slice files.
In a fifth aspect, the present application further provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor executes the computer program to implement the steps of the method for loading a video slice file or the method for playing a video file according to any of the above embodiments.
In a sixth aspect, the present application further provides a storage medium containing computer-executable instructions, which when executed by a computer processor, are configured to perform the steps of the method for loading a video slice file or the method for playing a video file as mentioned in any of the above embodiments.
The method, the apparatus, the device and the storage medium for loading the video slice file and playing the video file provided by the above embodiments respectively instantiate the video slice list request and the video slice file request as the first network protocol object and the second network protocol object; loading the video slice list file by using a first network protocol object, sequentially resolving the slice file addresses of the video slice files reversely from the video slice list file, and feeding the slice file addresses back to the play control module in real time; and receiving the address of the slice file forwarded by the play control module, starting and loading the corresponding video slice file by using a second network protocol object according to the address of the slice file. In the embodiment, in the process of analyzing the video slice list file to obtain the address of the slice file, the address of the slice file is analyzed and the video slice file is loaded simultaneously by using an object instantiation mode, so that the time consumed for loading the video slice file on the first screen is reduced.
Compared with a serial mode that one video corresponds to one object in the prior art, the embodiment respectively instantiates the video slice list request and the video slice file request into the first network protocol object and the second network protocol object through the parallel pipeline mode, and feeds the address of the slice file back to the play control module in real time in the process of analyzing the video slice list file by using the first network protocol object to obtain the address of the slice file, so that the second network protocol object can simultaneously analyze the address of the slice file and load the video slice file, and thus the time consumption of loading the video slice file on the first screen is reduced.
Additional aspects and advantages of the present application will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the present application.
Detailed Description
Reference will now be made in detail to embodiments of the present application, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the drawings are exemplary only for the purpose of explaining the present application and are not to be construed as limiting 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 will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. 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 also be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. As used herein, the term "and/or" includes all or any element and all combinations of one or more of the associated listed items.
It will be understood by those within the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the prior art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
Fig. 1 is a flowchart of a loading method of a video slice file according to an embodiment, and as shown in fig. 1, the loading method of the video slice file may include the following steps:
and S110, instantiating the video slice list request and the video slice file request into a first network protocol object and a second network protocol object respectively.
For instantiation, in object-oriented programming, the process of creating an object with a class is often referred to as instantiation. In this embodiment, the video slice list request is instantiated as a first network protocol object and the video slice file request is instantiated as a second network protocol object.
S120, loading the video slice list file by using the first network protocol object, sequentially solving the slice file addresses of the video slice files reversely from the video slice list file, and feeding the slice file addresses back to the play control module in real time.
In this embodiment, the play control module carries the video slice list address of the video slice data. The method comprises the steps of obtaining a video slice list address through a play control module, analyzing the video slice list address to obtain a list server where a video slice file list is located, establishing communication connection with the list server, and loading the video slice list file from the list server by utilizing a first network protocol object.
And further decompressing the received video slice list file, continuously and sequentially resolving the slice file address of each video slice file from the received video slice list file based on a streaming media network transmission protocol of a hypertext transfer protocol, and feeding back the resolved slice file address to the play control module in real time. In an embodiment, the playing control module may be a virtual software control module, or may be a software and hardware combined control module.
S130, receiving the slice file address forwarded by the play control module, starting and loading a corresponding video slice file according to the slice file address by using the second network protocol object.
And after receiving the slicing file address fed back by the first network protocol object, the playing control module sends the slicing file address to the second network protocol object. And the second network protocol object is started after receiving the address of the slice file. And analyzing according to the address of the slice file by using a second network protocol object to obtain a slice server where the video slice file is located, establishing communication connection with the slice server, and loading the corresponding video slice file from the slice server.
Fig. 2 is a schematic diagram of a conventional loading method of a video slice file, and as shown in fig. 2, a user sets an address to request playing, where the set address includes a video slice list address. The method comprises the steps of obtaining a video slice list address through a play control module, resolving a list server where a video slice file list is located according to the video slice list address, and establishing a communication request video slice list file for the list server. After the video slice list file is loaded, decompressing the video slice list file, and analyzing the address of the slice file from the video slice list file by a streaming media network transmission protocol based on a hypertext transmission protocol. After the video slice list file is analyzed, the slice server where the video slice file is located is obtained according to the address analysis of the slice file, communication connection is established for the slice server, and the corresponding video slice file is loaded from the slice server. As can be seen from fig. 2, the conventional video slice file is loaded through the network download module based on the serial mode, and the video slice file is parsed after the video slice list file is parsed, and the conventional download method of the video slice file cannot meet the requirement of live playback. Based on the characteristics of live broadcast service, the longer the live broadcast time is, the more transport stream slices stored in the form of m3u8 are, the larger the video slice file list is, the larger the time consumption for downloading the video slice file list is, the higher the resolution and code rate of the live broadcast video are, the larger the video slice file with the same playing time length is, the larger the time consumption for downloading the video slice file is, so that the time consumption of the first screen is large when the live broadcast video is played back on demand, and even video loading is blocked.
In the loading method of a video slice file provided by this embodiment, a video slice list request and a video slice file request are instantiated as a first network protocol object and a second network protocol object, respectively; loading the video slice list file by using a first network protocol object, sequentially resolving the slice file addresses of the video slice files reversely from the video slice list file, and feeding the slice file addresses back to the play control module in real time; and receiving the address of the slice file forwarded by the play control module, starting and loading the corresponding video slice file by using a second network protocol object according to the address of the slice file. Compared with a serial mode that one video corresponds to one object in the prior art, the embodiment respectively instantiates the video slice list request and the video slice file request into the first network protocol object and the second network protocol object through the parallel pipeline mode, and feeds the address of the slice file back to the play control module in real time in the process of analyzing the video slice list file by using the first network protocol object to obtain the address of the slice file, so that the second network protocol object can simultaneously analyze the address of the slice file and load the video slice file, and thus the time consumption of loading the video slice file on the first screen is reduced.
Fig. 3 is a flowchart of a playing method of a video file according to an embodiment, and as shown in fig. 3, the playing method of the video file may include the following steps:
s310, receiving a playing request of a user, and generating a video slice list request and a video slice file request for loading video slice data according to the playing request.
In an embodiment, the video slice data may be a list file of audio-video files saved in the m3u8 protocol format. The user selects the live video for on-demand playback, the client receives a play request sent by the user, wherein the play request comprises a video slice list address of the live video, and a video slice list request and a video slice file request for loading video slice data are generated. And the video slice list address is used for determining the position of the video slice list file.
S320, instantiating the video slice list request and the video slice file request into a first network protocol object and a second network protocol object respectively.
In this embodiment, the video slice list request is instantiated as a first network protocol object and the video slice file request is instantiated as a second network protocol object using the method of instantiating an object.
S330, loading the video slice list file by using the first network protocol object, sequentially resolving the slice file address of each video slice file in an inverse mode for the video slice list file, and feeding the slice file address back to the playing control module in real time.
In this embodiment, the play control module carries the video slice list address of the video slice data. The method comprises the steps of obtaining a video slice list address through a play control module, analyzing the video slice list address to obtain a list server where a video slice file list is located, establishing communication connection with the list server, and loading the video slice list file from the list server by utilizing a first network protocol object.
And further decompressing the received video slice list file, continuously and sequentially resolving the slice file address of each video slice file from the received video slice list file based on a streaming media network transmission protocol of a hypertext transfer protocol, and feeding back the resolved slice file address to the play control module in real time.
S340, receiving the slice file address forwarded by the play control module, starting and loading the corresponding video slice file according to the slice file address by using the second network protocol object.
And after receiving the slicing file address fed back by the first network protocol object, the playing control module sends the slicing file address to the second network protocol object. And the second network protocol object is started after receiving the address of the slice file. And analyzing according to the address of the slice file by using a second network protocol object to obtain a slice server where the video slice file is located, establishing communication connection with the slice server, and loading the corresponding video slice file from the slice server.
And S350, analyzing and playing the video streams of the loaded video slice files in sequence.
Firstly, a loaded video slice file is sent to a decapsulation module to perform decapsulation operation, then the decapsulated slice file is encapsulated according to a set encapsulation format to obtain a coded file, the coded file is decoded to obtain an audio/video file, and the audio/video file is played.
In an embodiment, the video slice file is sequentially and continuously parsed according to an MPEG (Moving Picture Experts Group) transport stream protocol to form a video stream; and decoding the video stream and then playing the decoded video stream in real time. Further, it is possible to independently decode any section of the transport stream corresponding to the slice file using the MPEG2-TS protocol, thereby improving decoding efficiency.
In the video file playing method provided by this embodiment, the video slice list request and the video slice file request are instantiated as the first network protocol object and the second network protocol object, and the slice file address is fed back to the playing control module in real time in the process of analyzing the video slice list file by using the first network protocol object to obtain the slice file address, so that the second network protocol object can simultaneously analyze the slice file address and load the video slice file, thereby reducing the time consumed by loading the video slice file on the first screen. Furthermore, the threshold value of the first screen buffer can be properly increased, the first screen can be ensured to be played for a longer time, and the first screen is prevented from being loaded and blocked.
Fig. 4 is a schematic diagram of a video file playing method according to an embodiment, and as shown in fig. 4, a network download module is abstractly packaged to instantiate a video slice list request and a video slice file request as a first network protocol object and a second network protocol object, respectively. Specifically, the video file playing method may include the following steps:
and S11, the user sets an address to request playing.
Wherein the set address comprises a video slice list file address. The client receives a playing request sent by a user, wherein the playing request comprises a video slice list address of live video, generates a video slice list request and a video slice file request for loading video slice data, and sends the playing request to the playing control module. And the video slice list address is used for determining the position of the video slice list file.
Further, the video slice list request is instantiated as a first network protocol object and the video slice file request is instantiated as a second network protocol object using the method of instantiating an object.
And S12, resolving the list server where the video slice list file is located according to the video slice list address, and establishing a communication request data stream to the list server.
And S13, the decompression list server returns data, and the address of the slice file is resolved according to the streaming media network protocol.
In this step, the address of the slice file obtained by analysis is fed back to the play control module in real time.
Step S12 and step S13 are performed by the first network protocol object. Wherein steps S12 and S13 may be run in parallel.
And S14, resolving the slice server where the video slice file is located according to the slice file address, and establishing communication to the slice server.
This step S14 is executed by the second network protocol object, receives the address of the slice file forwarded by the play control module, starts and obtains the slice server where the video slice file is located according to the address resolution of the slice file by using the second network protocol object, establishes a communication connection to the slice server, and loads the corresponding video slice file from the slice server.
When the second network protocol object is started, steps S12, S13, and S14 may run in parallel.
And S15, sending the data received by the server to a decapsulation module for decapsulation.
And the server transmits the received transmission stream data of the video slice file to a decapsulation module, decapsulates the transmission stream data according to a certain protocol, and transmits the decapsulated video slice file to other layers for subsequent processing.
And S16, synchronizing the sound and picture synchronization module and then decoding and playing.
In this step, the audio and video synchronization module synchronizes audio and video streams obtained by parsing the video slice file, and decodes the audio and video streams into audio and video files for playing.
As can be clearly seen from fig. 4, the video slice list request and the video slice file request are respectively instantiated as a first network protocol object and a second network protocol object, so that in the process of analyzing the video slice list file by using the first network protocol object to obtain a slice file address, the second network protocol object is used to analyze the slice file address and load the video slice file, and the video slice list file and the loaded video slice file are analyzed and loaded at the same time.
Fig. 5 is a schematic structural diagram of a loading apparatus for a video slice file according to an embodiment, and as shown in fig. 5, the loading apparatus 100 for a video slice file may include: an instantiation module 110, a list file loading module 120, and a slice file loading module 130.
The instantiation module 110 is configured to instantiate the video slice list request and the video slice file request into a first network protocol object and a second network protocol object, respectively;
a list file loading module 120, configured to load a video slice list file by using the first network protocol object, sequentially and inversely resolve slice file addresses of the video slice list files, and feed back the slice file addresses to the play control module in real time;
and a slice file loading module 130, configured to receive the slice file address forwarded by the play control module, start and load a corresponding video slice file according to the slice file address by using the second network protocol object.
The loading device for video slice files provided in this embodiment instantiates the video slice list request and the video slice file request into the first network protocol object and the second network protocol object, respectively, so that in the process of analyzing the video slice list file by using the first network protocol object to obtain the address of the slice file, the second network protocol object is used to analyze the address of the slice file and load the video slice file, thereby reducing the time consumed by loading the video slice file on the first screen.
In an embodiment, the list file loading module 120 is configured to obtain the video slice list address through the play control module, and analyze the video slice list address to obtain a list server where the video slice file list is located; loading the video slice list file from the list server using the first network protocol object.
In an embodiment, the slice file loading module 130 is configured to analyze the address of the slice file to obtain a slice server where the video slice file is located; starting and loading the video slice file from the slice server using the second network protocol object.
In an embodiment, the list file loading module 120 is configured to sequentially and inversely resolve the slice file address of each video slice file for the video slice list file based on a streaming media network transport protocol of a hypertext transport protocol.
The loading device for the video slice file can be used for executing the loading method for the video slice file provided by any embodiment, and has corresponding functions and beneficial effects.
Fig. 6 is a schematic structural diagram of a playing apparatus for a video file according to an embodiment, and as shown in fig. 6, the playing apparatus 300 for a video file may include: a play request receiving module 310, an instantiation module 320, a list file loading module 330, a slice file loading module 340, and a video stream playing module 350.
The playing request receiving module 310 is configured to receive a playing request of a user, and generate a video slice list request and a video slice file request for loading video slice data according to the playing request;
an instantiation module 320 for instantiating the video slice list request and the video slice file request into a first network protocol object and a second network protocol object, respectively;
the list file loading module 330 is configured to load a video slice list file by using the first network protocol object, sequentially solve the slice file addresses of the video slice list files reversely, and feed back the slice file addresses to the play control module in real time;
a slice file loading module 340, configured to receive the slice file address forwarded by the play control module, start and load a corresponding video slice file according to the slice file address by using the second network protocol object;
and a video stream playing module 350, configured to sequentially parse and play the video streams of the loaded video slice files.
In the playing device for a video file provided by this embodiment, the video slice list request and the video slice file request are instantiated as the first network protocol object and the second network protocol object, so that in the process of analyzing the video slice list file by using the first network protocol object to obtain the address of the slice file, the second network protocol object is used to analyze the address of the slice file and load the video slice file, and the video slice list file and the loaded video slice file are analyzed and loaded at the same time.
In an embodiment, the video stream playing module 350 is configured to sequentially and continuously parse the video slice file according to an MPEG-2 transport stream protocol to form a video stream; and decoding the video stream and then playing the decoded video stream in real time.
The playing device of the video file can be used for executing the playing method of the video file provided by any embodiment, and has corresponding functions and beneficial effects.
The embodiment of the present application further provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the program, the method for loading a video slice file as in any of the above embodiments is implemented.
The embodiment of the present application further provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor, and when the processor executes the program, the method for playing a video file in any of the above embodiments is implemented.
Optionally, the computer device may be a mobile terminal, a tablet computer, a server, or the like. When the computer device provided by the above embodiment executes the method for loading a video slice file or the method for playing a video file provided by any of the above embodiments, the computer device has corresponding functions and advantages.
Embodiments of the present application also provide a storage medium containing computer-executable instructions, which when executed by a computer processor, are configured to perform a method for processing image segmentation information, including:
instantiating a video slice list request and a video slice file request as a first network protocol object and a second network protocol object, respectively;
loading video slice list files by using the first network protocol object, sequentially resolving slice file addresses of the video slice files reversely from the video slice list files, and feeding the slice file addresses back to a play control module in real time;
and receiving the address of the slice file forwarded by the play control module, and starting and loading a corresponding video slice file by using the second network protocol object according to the address of the slice file.
And, the computer executable instructions, when executed by the computer processor, are further for performing a method of playing a video file, comprising:
receiving a playing request of a user, and generating a video slice list request and a video slice file request for loading video slice data according to the playing request;
instantiating the video slice list request and the video slice file request as a first network protocol object and a second network protocol object, respectively;
loading video slice list files by using the first network protocol object, sequentially resolving slice file addresses of the video slice files reversely from the video slice list files, and feeding the slice file addresses back to a play control module in real time;
receiving the address of the slice file forwarded by the play control module, starting and loading a corresponding video slice file by using the second network protocol object according to the address of the slice file;
and analyzing and playing the video streams of the loaded video slice files in sequence.
Of course, the storage medium provided in the embodiments of the present application includes computer-executable instructions, and the computer-executable instructions are not limited to the operations of the processing method of image segmentation information as described above, and may also perform related operations in a loading method of a video slice file or a playing method of a video file provided in any embodiment of the present application, and have corresponding functions and advantages.
From the above description of the embodiments, it is obvious for those skilled in the art that the present application can be implemented by software and necessary general hardware, and certainly can be implemented by hardware, but the former is a better embodiment in many cases. Based on such understanding, the technical solution of the present application may be embodied in the form of a software product, which may be stored in a computer-readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk, or an optical disk of a computer, and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) to execute the loading method of the video slice file or the playing method of the video file according to any embodiment of the present application.
It should be understood that, although the steps in the flowcharts of the figures are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and may be performed in other orders unless explicitly stated herein. Moreover, at least a portion of the steps in the flow chart of the figure may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
The foregoing is only a partial embodiment of the present application, and it should be noted that, for those skilled in the art, several modifications and decorations can be made without departing from the principle of the present application, and these modifications and decorations should also be regarded as the protection scope of the present application.