Lossless high-precision stream acquisition method

文档序号:956381 发布日期:2020-10-30 浏览:8次 中文

阅读说明:本技术 一种无损高精度的流采集方法 (Lossless high-precision stream acquisition method ) 是由 马萧萧 李秀科 赵思阳 王智胜 马韬 于 2020-06-19 设计创作,主要内容包括:本发明涉及一种无损高精度的流采集方法,所述流采集方法包括:打开实时消息传输协议流或超文本传输协议流;创建读数据线程;获取流信息;创建封装线程。本发明的一种无损高精度的流采集方法,通过只精确编辑一个组包,节省了编码时间,同时降低了机器的负荷,CPU占用低,并能精确到帧地无损地采集音视频数据。(The invention relates to a lossless high-precision flow acquisition method, which comprises the following steps: opening a real-time message transmission protocol stream or a hypertext transmission protocol stream; creating a read data thread; acquiring flow information; an encapsulation thread is created. The lossless high-precision stream acquisition method saves the encoding time by accurately editing only one packet, reduces the load of a machine, has low CPU occupation, and can accurately acquire audio and video data in a frame-to-frame lossless manner.)

1. A lossless high-precision flow acquisition method is characterized by comprising the following steps:

s1: opening a real-time message transmission protocol stream or a hypertext transmission protocol stream;

s2: creating a read data thread;

s3: acquiring flow information;

s4: an encapsulation thread is created.

2. The method for lossless high-precision stream capture according to claim 1, wherein the creating a read data thread includes the sub-steps of:

s21: reading the stream data;

s22: analyzing data, and if the streaming data is a video packet, adding the streaming data into a video packet linked list; and if the streaming data is an audio packet, adding the streaming data into an audio packet linked list.

3. The method for collecting streams with high accuracy and no loss as claimed in claim 1, wherein said stream information obtained in step S3 includes video stream information and audio stream information.

4. The method according to claim 3, wherein the video stream information includes width, height, frame rate, code rate, coding format, pixel format, group of pictures, profile and level of the video; wherein, profile is the compression rate of H.264 video coding, including three types of baseline, main and high; level is the video coding performance, and the higher the resolution, frame rate and code rate, the higher the level.

5. A lossless high-precision stream collection method according to claim 3, wherein said audio stream information includes the number of channels, sampling rate, number of sampling bits, and format of audio.

6. The method for lossless high-precision stream acquisition as claimed in claim 1, wherein the step of creating the encapsulation thread includes the sub-steps of:

s41: turning on an encoder according to information of an audio source or a video source;

s42: preparing first picture group video data;

s43: clearing all video packets before a specified time code in a video data packet chain table to be output, and adding first video frame group data to a video data packet chain table head to be output;

S44: clearing all audio data packets before a timestamp timecode in the audio packet linked list;

s45: and circularly executing the encapsulated data.

7. The method for lossless high-precision flow collection according to claim 6, wherein said step S45 includes the following sub-steps:

s451: if the time stamp of the video packet chain table head data is smaller than the time stamp of the audio packet chain table head data, packaging the video data; otherwise, the audio data is encapsulated.

Technical Field

The invention relates to the field of data stream information processing, in particular to a lossless high-precision stream acquisition method.

Background

In the internet era of rapid development, television stations need to receive high-index real-time streaming media with high performance and frame accuracy. This requires that recording be started from a specified video screen (time stamp) and stopped until the specified video screen (time stamp) is reached, and that recording be performed without loss of audio and video.

The existing implementation processes are generally as follows:

the first method comprises the following steps: all audio-video packets are decoded upon reception of the network stream, encoding is started when a specified start picture (time stamp) is decoded, and encoding is stopped when a specified end picture (time stamp) is encoded. This approach can indeed ensure accurate frame inclusion. However, all audio and video packets are decoded and encoded, and all videos are encoded, so that the video quality is reduced, the CPU occupancy rate is high, and the requirement of high-performance and high-index recording cannot be met.

The second method comprises the following steps: when the time stamp of the video packet is larger than or equal to the specified starting time stamp when the network stream is received, the video packet is directly encapsulated into the local file, and the recording is stopped until the time stamp of the video packet is equal to the specified ending time stamp. The method has no video decoding and encoding process, so that the index CPU occupies extremely low space. When the video of the specified start time stamp is not an I frame (key frame) at the start of recording, the first GOP (picture) group of the stored local file is incomplete, and the decoder cannot decode the first GOP group video, but can start decoding only from the second GOP group, and therefore the recorded file cannot be accurate to a frame. This method cannot satisfy frame-accurate listing.

Disclosure of Invention

The invention aims to provide a lossless high-precision flow acquisition method aiming at the problems.

A lossless high-precision flow acquisition method comprises the following steps:

s1: opening a real-time message transmission protocol stream or a hypertext transmission protocol stream;

s2: creating a read data thread;

s3: acquiring flow information;

s4: an encapsulation thread is created.

Further, the method for collecting the flow without loss and high precision comprises the following sub-steps:

S21: reading the stream data;

s22: analyzing data, and if the streaming data is a video packet, adding the streaming data into a video packet linked list; and if the streaming data is an audio packet, adding the streaming data into an audio packet linked list.

Further, a lossless high-precision stream acquisition method, wherein the stream information comprises video stream information and audio stream information; the video stream information comprises the width, height, frame rate, code rate, coding format, pixel format, picture group, profile and level of the video; the audio stream information includes the number of channels, sampling rate, number of sampling bits, and format of the audio.

Further, the method for collecting the flow without loss and high precision comprises the following sub-steps:

s41: turning on an encoder according to information of an audio source or a video source;

s42: preparing first picture group video data;

s43: clearing all video packets before a specified time code in a video data packet chain table to be output, and adding first video frame group data to a video data packet chain table head to be output;

s44: clearing all audio data packets before a timestamp timecode in the audio packet linked list;

s45: and circularly executing the encapsulated data.

Further, the step S45 includes the following sub-steps:

S451: if the time stamp of the video packet chain table head data is smaller than the time stamp of the audio packet chain table head data, packaging the video data; otherwise, the audio data is encapsulated.

The invention achieves the following beneficial effects: the lossless high-precision stream acquisition method saves the encoding time by accurately editing only one packet, reduces the load of a machine, has low CPU occupation, and can accurately acquire audio and video data in a frame-to-frame lossless manner.

Drawings

Fig. 1 is a flow chart of a stream acquisition method of the present invention.

FIG. 2 is a flow diagram of the create package thread of the present invention.

Detailed Description

In order to make the objects, technical solutions and advantages of the present invention more apparent, the technical solutions in the examples of the present invention will be described clearly and completely with reference to the accompanying drawings in the examples of the present invention. It is to be understood that the described embodiments are merely exemplary of some, and not necessarily all, embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

7页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种基于SRS的视频文件生产方法、后台服务器和系统

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类