Disclosure of Invention
The embodiment of the invention provides a method and a device for acquiring a real-time poster from a live stream, which can reduce the load of an HLS live stream server.
In a first aspect, an embodiment of the present invention provides a method for obtaining a real-time poster from a live stream, including:
acquiring an m3u8 file of a live stream from a live stream server;
analyzing the m3u8 file to generate a ts file;
determining a real-time poster file in the ts file;
and processing the real-time poster file to generate a real-time poster.
Preferably, the first and second electrodes are formed of a metal,
the ts file, comprising: three subfiles;
the determining a real-time poster file in the ts file comprises:
acquiring a standard size of a picture;
determining a code rate of the live stream;
determining a target subfile closest to the current moment in the three subfiles;
determining a target duration according to the standard size of the picture and the code rate of the live stream;
and extracting the real-time poster file from the target subfile according to the target duration.
In a second aspect, an embodiment of the present invention provides an apparatus for obtaining a real-time poster from a live stream, including:
the acquisition unit is used for acquiring an m3u8 file of the live stream from the live stream server;
the analyzing unit is used for analyzing the m3u8 file acquired by the acquiring unit to generate a ts file;
a determining unit configured to determine a real-time poster file in the ts file generated by the parsing unit;
and the processing unit is used for processing the real-time poster file determined by the determining unit to generate a real-time poster.
Preferably, the first and second electrodes are formed of a metal,
the ts file, comprising: three subfiles;
the determining unit is used for acquiring the standard size of the picture; determining a code rate of the live stream; determining a target subfile closest to the current moment in the three subfiles; determining a target duration according to the standard size of the picture and the code rate of the live stream; and extracting the real-time poster file from the target subfile according to the target duration.
In a third aspect, an embodiment of the present invention provides a readable medium, which includes an execution instruction, and when a processor of a storage controller executes the execution instruction, the storage controller executes a method described in any one of the above embodiments.
In a fourth aspect, an embodiment of the present invention provides a storage controller, including: a processor, a memory, and a bus;
the memory is used for storing execution instructions, the processor is connected with the memory through the bus, and when the storage controller runs, the processor executes the execution instructions stored in the memory, so that the storage controller executes the method of any one of the above embodiments.
The embodiment of the invention provides a method and a device for acquiring a real-time poster from a live stream, wherein the method acquires an m3u8 file of the live stream from a live stream server, analyzes the m3u8 file, determines a real-time poster file according to a ts file obtained by analysis, processes the real-time poster file and generates the real-time poster. The method does not need the HLS live streaming server to download the live streaming real-time screenshot in advance, and can reduce the load of the HLS live streaming server.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer and more complete, the technical solutions in the embodiments of the present invention will be described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention, and based on the embodiments of the present invention, all other embodiments obtained by a person of ordinary skill in the art without creative efforts belong to the scope of the present invention.
As shown in fig. 1, an embodiment of the present invention provides a method for obtaining a real-time poster from a live stream, which may include the following steps:
step 101: acquiring an m3u8 file of a live stream from a live stream server;
step 102: analyzing the m3u8 file to generate a ts file;
step 103: determining a real-time poster file in the ts file;
step 104: and processing the real-time poster file to generate a real-time poster.
The method includes the steps of obtaining an m3u8 file of a live stream from a live stream server, analyzing the m3u8 file, determining a real-time poster file according to a ts file obtained through analysis, processing the real-time poster file, and generating a real-time poster. The method does not need the HLS live streaming server to download the live streaming real-time screenshot in advance, and can reduce the load of the HLS live streaming server.
In one embodiment of the present invention, in order to obtain a real-time poster file in a ts file, the ts file includes: three subfiles;
the determining a real-time poster file in the ts file comprises:
acquiring a standard size of a picture;
determining a code rate of the live stream;
determining a target subfile closest to the current moment in the three subfiles;
determining a target duration according to the standard size of the picture and the code rate of the live stream;
and extracting the real-time poster file from the target subfile according to the target duration.
The standard size of the picture is the size of the minimum volume picture, for example, if the minimum volume of one picture is 100K, the standard size of the picture is 100K. the ts file comprises three parts, and the embodiment of the invention extracts the real-time poster file from one subfile closest to the current moment and extracts from the head of the target subfile.
As shown in fig. 2, in the embodiment of the present invention, a ts file includes three subfiles, and a method for obtaining a real-time poster from a live stream is described in detail, where the method includes:
step 201: and acquiring an m3u8 file of the live stream from the live stream server.
Step 202: analyzing the m3u8 file to generate a ts file, wherein the ts file comprises: three subfiles.
Step 203: and acquiring the standard size of the picture.
Step 204: and determining the code rate of the live stream.
Step 205: and determining a target subfile closest to the current moment in the three subfiles.
Step 206: and determining the target duration according to the standard size of the picture and the code rate of the live stream.
Step 207: and extracting the real-time poster file from the target subfile according to the target duration.
Step 208: and processing the real-time poster file to generate a real-time poster.
As shown in fig. 3, an embodiment of the present invention provides an apparatus for obtaining a real-time poster from a live stream, including:
an obtaining unit 301, configured to obtain an m3u8 file of a live stream from a live stream server;
an analyzing unit 302, configured to analyze the m3u8 file acquired by the acquiring unit 301, and generate a ts file;
a determining unit 303, configured to determine a real-time poster file in the ts file generated by the parsing unit 302;
a processing unit 304, configured to process the real-time poster file determined by the determining unit 303, and generate a real-time poster.
In one embodiment of the present invention, the ts file includes: three subfiles;
the determining unit is used for acquiring the standard size of the picture; determining a code rate of the live stream; determining a target subfile closest to the current moment in the three subfiles; determining a target duration according to the standard size of the picture and the code rate of the live stream; and extracting the real-time poster file from the target subfile according to the target duration.
The embodiment of the invention provides a readable medium, which comprises an execution instruction, and when a processor of a storage controller executes the execution instruction, the storage controller executes the method of any one of the above embodiments.
An embodiment of the present invention provides a storage controller, including: a processor, a memory, and a bus;
the memory is used for storing execution instructions, the processor is connected with the memory through the bus, and when the storage controller runs, the processor executes the execution instructions stored in the memory, so that the storage controller executes the method of any one of the above embodiments.
Because the information interaction, execution process, and other contents between the units in the device are based on the same concept as the method embodiment of the present invention, specific contents may refer to the description in the method embodiment of the present invention, and are not described herein again.
In summary, the embodiments of the present invention have at least the following effects:
1. in the embodiment of the invention, the method acquires an m3u8 file of a live stream from a live stream server, analyzes the m3u8 file, determines a real-time poster file according to a ts file obtained by analysis, processes the real-time poster file, and generates a real-time poster. The method does not need the HLS live streaming server to download the live streaming real-time screenshot in advance, and can reduce the load of the HLS live streaming server.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising a" does not exclude the presence of other similar elements in a process, method, article, or apparatus that comprises the element.
Those of ordinary skill in the art will understand that: all or part of the steps for realizing the method embodiments can be completed by hardware related to program instructions, the program can be stored in a computer readable storage medium, and the program executes the steps comprising the method embodiments when executed; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it is to be noted that: the above description is only a preferred embodiment of the present invention, and is only used to illustrate the technical solutions of the present invention, and not to limit the protection scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.