[0040] The above and other technical features and advantages of the present invention will be described in more detail below in conjunction with the accompanying drawings.
[0041] First, explain the technical terms of the present invention:
[0042] Player terminal: The client system for streaming media broadcast, including various player software installed on smart phones, PC computers, and set-top boxes.
[0043] Broadcast server: A server system for streaming media broadcasting, which sends multimedia data to the playback terminal according to the request of the playback terminal.
[0044] GOP: Video coding group, one group contains complete video decoding data, no need to refer to the data in other groups.
[0045] File header data: the description data of video and audio coding, which is an important reference for the playback terminal to decode.
[0046] Fragment files: small files divided from a large file. Each small file contains one or more complete GOP data, which can be played independently after adding file header data.
[0047] Header file: The file containing the file header data is a special fragment file.
[0048] Index file: A file that describes a fragment file. The index file contains description information for one or more fragment files. The description information includes but is not limited to file size, playback duration, and playback offset to time.
[0049] Such as Figure 1 to 4 Shown are the flow chart of the streaming media playout method of the present invention, the slicing flow chart of the streaming media playout method of the present invention, the segmented file schematic diagram of the media playout method of the present invention, and the play flow chart of the media playout method of the present invention. .
[0050] The present invention provides a streaming media broadcast method, which includes the following steps:
[0051] Step S1: Divide the continuously played large file or stream into individual small files, which specifically includes the following sub-steps:
[0052] Step S11: Perform format analysis on the large file or stream to be broadcast, which is to divide the large file into fragment files according to the file multiplexing format and video encoding grouping information;
[0053] Step S12: Determine whether a header file needs to be generated according to the file format, and if necessary, output the header file;
[0054] Step S13: The file is sliced according to the GOP grouping, and the segment file is output. The file data of each segment file contains one or more complete video GOP coded data and multiplexed data, as well as audio data corresponding to the video. , The granularity of the slice is determined according to the application needs, you can choose 1 or more GOPs to save as a file; refer to image 3 , Is a schematic diagram of a segmented file of the media broadcast method of the present invention, where h is the file header data; f is the segment file data output by the slice; GOP is the video encoding group.
[0055] Step S14: Describe each segment file, output an index file, use one or more index files to describe the information of all the sliced segment files, set an identification ID for each program, and name the index file with ID: ID.idx ;
[0056] The description information of each segment file includes but is not limited to: 1) the file size in bytes; 2) the broadcast duration in seconds or milliseconds; 3) the segment file in seconds or milliseconds is complete The start and end positions of the broadcast program.
[0057] For some multiplexing formats, such as FLV, MP4, MOV, the file header data containing the video and audio coding description information is saved as an independent segment file when slicing. For the multiplexing format of TS format, there is no need to keep the file header data separately.
[0058] Step S2: Put the segmented file on the broadcast server for storage; the logic of streaming media broadcast runs on the broadcast server. The segmented file is stored in the storage of the playout server, and the playout server sends corresponding play data to the client according to the request of the play client. The communication protocol between the broadcast client and the broadcast server can be http, rtmp, rtsp, udp, etc. Using the method of indexing by natural time, the storage directory structure is: ID/YYYY/MM/DD. ID is a meaningful directory set for live streaming such as broadcast, TV channel or camera. In the method of indexing by relative time, the storage directory location is not limited, and it can be in one directory or in multiple directories.
[0059] Step S3: The broadcast server plays the program according to the request of the broadcast client, which includes the following sub-steps:
[0060] Step S31: Analyze the request parameters;
[0061] Step S32: Retrieve the clip file to be broadcast;
[0062] Step S33: If the broadcast program format needs to send a file header, first send the file header data to the playback client;
[0063] Step S34: Send the clip files to the playback client one by one according to the broadcast order.
[0064] According to the characteristics of streaming media broadcast, the playback client can request to play the entire program, or request to play a certain part of the program. When requesting to play part of the content of a program, the time point of the part of the content to be played in the entire program is used as the request parameter. For example, if the content from the 20th to the 30th second of the program is requested to be played, the two parameters of the start time 20 and the end time 30 are passed to the broadcast server.
[0065] The broadcast server reads the program index file according to the playback request, and reads the information of each clip file from the index file. If the broadcast of the clip file is within the requested broadcast time range, it can determine that the clip file needs Sent to the broadcast client. Finally, one or more fragment files are retrieved and sent to the playback terminal. For some video formats such as FLV, MP4, MOV, etc., the header file data needs to be sent first before sending the fragment file. Most video packaging formats have file headers, such as FLV, MP4, F4V, etc. In this case, the file header needs to be sent to the client at the beginning of the data to be sent, and the file header includes all metadata that meets the media playback.
[0066] The broadcast client uses the channel (or program) ID and broadcast time to request broadcast content.
[0067] For live streaming, the client uses the channel ID, start time, and end time to request broadcast content. If the start time is 0, it means that the content that is being broadcast is requested. If the end time is 0 and the start time is non-zero, it means that content after the start time is requested, which is a time shifting format. Both the start time and the end time are non-zero, indicating that a piece of on-demand content is requested.
[0068] For on-demand streaming, the client uses the program ID to request broadcast content. Add the start time and end time to indicate the relatively beginning of the request.
[0069] After receiving the request, the server retrieves one or more fragmented files according to the requested content, and sends these fragmented files to the client in sequence. From the client's point of view, what the server sends is a continuous file, not fragments.
[0070] The communication protocol between the server and the client is usually HTTP, but it can also be FTP, RTSP, RTMP, etc.
[0071] Such as Figure 5 As shown, it is a block diagram of a streaming media playing system of the present invention. The present invention provides a streaming media playing system, which includes: a segmentation module 101, a storage module 102, and a broadcast module 103, wherein
[0072] The segmentation module 101 is used to segment a large file or stream that is continuously played into small files one by one;
[0073] The storage module 102 is used to store the segmented file on the broadcast server;
[0074] The broadcast module 103 is used for the broadcast server to play the program according to the request of the broadcast client.
[0075] The segmentation module 101 specifically analyzes the format of a large file or stream to be broadcast, and divides the large file into individual fragment files according to the file multiplexing format and video encoding grouping information, and judges whether or not according to the file format The header file needs to be generated, and if necessary, the header file is output; the file is sliced according to the GOP group, and the segment file is output. The file data of each segment file contains one or more complete video GOP coded data and multiplexed data, At the same time, it contains the audio data corresponding to the video. The granularity of the slice is determined according to the needs of the application. The playback length of M3U8 is generally about 10 seconds and saved as a ts file. For f1ash broadcast, you can select 1 or more GOPs to save. A file; refer to image 3 , Is a schematic diagram of a segmented file of the media broadcast method of the present invention, where h is the file header data; f is the segment file data output by the slice; GOP is the video encoding group.
[0076] The segmentation module 101 is also used to describe each segment file, output an index file, use one or more index files to describe the information of all the segment files that are sliced, and set an identification ID for each program, the index file Use ID to name: ID.idx;
[0077] Wherein, the description information of each fragment file in the segmentation module 101 includes, but is not limited to: 1) file size in bytes; 2) broadcast time in seconds or milliseconds; 3) The start and end positions of the segment file in the complete broadcast program in seconds or milliseconds.
[0078] The storage module 102 specifically stores the segmented file on the storage of the playout server, and the playout server sends corresponding play data to the client according to the request of the play client. The communication protocol between the broadcast client and the broadcast server can be http, rtmp, rtsp, udp, etc.
[0079] The broadcast module 103 is specifically used to analyze the request parameters and retrieve the segment files that need to be broadcast. If the broadcast program format needs to send the file header, first send the file header data to the playback client, and broadcast according to the segment file The output sequence is sent to the playback client one by one.
[0080] In summary, the present invention divides the large file of the broadcast program into a large number of fragment files, each fragment file contains several seconds of broadcast content, and each fragment file can be played independently or with adjacent fragment files. Spliced together to play. The broadcast server sends one or more clip files to the client according to the client's playback request.
[0081] The benefits of this method are: 1) Dividing a large file into multiple small fragment files can be more convenient and fast to transmit on the Internet, and minimize the impact of network bandwidth instability on the transmission effect; 2) Fragment files can be Convenient movement between various acceleration nodes is very beneficial to CDN acceleration; 3) Fragment files can be conveniently distributed on various load balancing nodes, which is beneficial to load balancing.
[0082] The above description is only illustrative rather than restrictive for the present invention. Those skilled in the art understand that many modifications, changes or equivalents can be made without departing from the spirit and scope defined by the claims, but All will fall within the protection scope of the present invention.