Live transcoding method and system for dynamically switching video streams

文档序号:1548184 发布日期:2020-01-17 浏览:19次 中文

阅读说明:本技术 一种动态切换视频流的直播转码方法及系统 (Live transcoding method and system for dynamically switching video streams ) 是由 唐杰 刘冰 王喆 于 2019-10-21 设计创作,主要内容包括:本发明公开了一种动态切换视频流的直播转码方法及系统,该方法包括以下步骤:接收切流请求,根据切流请求接收目标输入信号;保持对原始输入信号进行转码的转码进程输出的同时,在转码进程中,创建目标线程对目标输入信号进行解封装与解码,其中,对原始输入信号进行转码的转码进程中包括对原始输入信号进行解封与解码的原始线程、对原始线程输出的原始数据流进行编码与封装的输出线程;待得到目标线程输出的目标数据流时,销毁原始线程,并切断原始输入信号;通过输出线程对目标数据流进行编码与封装,输出得到目标输入信号转码后的目标输出流。本发明具有播放切换无缓冲、不卡顿、不闪屏、不黑屏、声音连续、播放数据不丢失的技术特点。(The invention discloses a live transcoding method and a live transcoding system for dynamically switching video streams, wherein the method comprises the following steps: receiving a current switching request, and receiving a target input signal according to the current switching request; the method comprises the steps that when the output of a transcoding process for transcoding an original input signal is kept, a target thread is created to decapsulate and decode the target input signal in the transcoding process, wherein the transcoding process for transcoding the original input signal comprises an original thread for decapsulating and decoding the original input signal and an output thread for encoding and encapsulating an original data stream output by the original thread; when a target data stream output by the target thread is obtained, destroying the original thread and cutting off an original input signal; and encoding and packaging the target data stream through the output thread, and outputting to obtain a target output stream after transcoding the target input signal. The invention has the technical characteristics of no buffer, no blockage, no screen flashing, no screen blacking, continuous sound and no loss of playing data during playing switching.)

1. A live transcoding method for dynamically switching video streams is characterized by comprising the following steps:

receiving a current switching request, and receiving a target input signal according to the current switching request;

the method comprises the steps that a transcoding process for transcoding an original input signal is kept outputting, and meanwhile, a target thread is created in the transcoding process for decapsulating and decoding the target input signal, wherein the transcoding process for transcoding the original input signal comprises an original thread for decapsulating and decoding the original input signal and an output thread for encoding and encapsulating an original data stream output by the original thread;

when a target data stream output by the target thread is obtained, destroying the original thread and cutting off the original input signal;

and encoding and packaging the target data stream through the output thread, and outputting to obtain a target output stream after transcoding the target input signal.

2. The live transcoding method of claim 1, wherein the stream switching request includes a live stream switching request, a main signal switching request, a standby signal switching request, and a shim switching request, and receiving the target input signal according to the stream switching request specifically includes:

if the live broadcast stream switching request is received, the received target input signal is a live broadcast input signal required in the live broadcast stream switching request;

if the main signal switching request is received, the received target input signal is a main signal of the original input signal;

if the standby signal switching request is received, the received target input signal is a standby signal of the original input signal;

and if the gasket switching request is received, the received target input signal is a gasket signal.

3. The live transcoding method of dynamically switching video streams of claim 2, wherein the step of receiving the request for switching streams further comprises:

establishing a live broadcast task, and configuring the main signal, the standby signal and the gasket signal;

starting a live broadcast task, establishing a transcoding process to transcode and output the main signal, and in the transcoding output process:

if the main signal is cut off, automatically sending the standby signal switching request; if the main signal and the standby signal are both cut off, automatically sending the gasket switching request; if the main signal cutoff is recovered, automatically sending the main signal switching request; if the standby signal cutoff is recovered and the main signal cutoff is performed, automatically sending the standby signal switching request; and if the specified live broadcast content is required to be switched, sending the live broadcast stream switching request.

4. The live transcoding method of dynamically switching video streams of claim 1, wherein obtaining the target output stream comprises: and sending the target output stream for playing.

5. A live transcoding system that dynamically switches video streams, comprising:

the receiving module is used for receiving a flow cutting request and receiving a target input signal according to the flow cutting request;

the transcoding module is used for maintaining the output of a transcoding process for transcoding an original input signal, and simultaneously creating a target thread for decapsulating and decoding the target input signal in the transcoding process, wherein the transcoding process for transcoding the original input signal comprises an original thread for decapsulating and decoding the original input signal and an output thread for encoding and encapsulating an original data stream output by the original thread;

the flow switching module is used for destroying the original thread and cutting off the original input signal when the target data flow output by the target thread is obtained;

and the transcoding module is also used for encoding and packaging the target data stream through the output thread and outputting an output stream obtained by transcoding the target input signal.

6. The live transcoding system of claim 5, wherein the stream switching request comprises a live stream switching request, a main signal switching request, a standby signal switching request, and a shim switching request, and the receiving module is configured to receive the target input signal according to the stream switching request:

if the live broadcast stream switching request is received, the received target input signal is a live broadcast input signal required in the live broadcast stream switching request;

if the main signal switching request is received, the received target input signal is a main signal of the original input signal;

if the standby signal switching request is received, the received target input signal is a standby signal of the original input signal;

and if the gasket switching request is received, the received target input signal is a gasket signal.

7. The live transcoding system of dynamically switching video streams of claim 6, further comprising:

the configuration module is used for establishing a live broadcast task and configuring the main signal, the standby signal and the gasket signal;

the transcoding module is also used for starting a live broadcast task and establishing the transcoding process to transcode and output the main signal;

a request generation module, configured to, during a transcoding output process: if the main signal is cut off, automatically sending the standby signal switching request; if the main signal and the standby signal are both cut off, automatically sending the gasket switching request; if the main signal cutoff is recovered, automatically sending the main signal switching request; if the standby signal cutoff is recovered and the main signal cutoff is performed, automatically sending the standby signal switching request; and if the specified live broadcast content is required to be switched, sending the live broadcast stream switching request.

8. The live transcoding system of claim 5, further comprising a playing module, configured to send the target output stream for playing after obtaining the target output stream.

9. A computer-readable storage medium, having stored thereon a computer program which, when executed by a processor, implements a method of live transcoding for dynamically switching video streams as claimed in any of claims 1 to 4.

10. A computer device comprising a memory and a processor and a computer program stored on the memory and being callable by the processor, when executing the computer program, implementing a live transcoding method for dynamically switching video streams as claimed in any one of claims 1 to 4.

Technical Field

The invention belongs to the technical field of audio and video live broadcasting, and particularly relates to a live broadcasting transcoding method and system for dynamically switching video streams.

Background

With the rapid increase of the demand of live broadcast forms such as television live broadcast, live broadcast and the like, the application of the streaming media in the aspect of live broadcast transcoding is rapidly developed. With the development of streaming media technology, the performances of the live programs in the technical aspects of real-time performance, picture definition and the like are greatly improved. However, human factors existing in the live broadcasting process are difficult to avoid the occurrence of the human factors through technical improvement, so that the live broadcasting dynamic stream switching technology is gradually emphasized.

Through the dynamic cut-stream cutting, the content which does not conform to legal regulations or moral specifications in the live broadcasting process can be solved for technical personnel, the adverse influence of the live broadcasting content on the society is prevented, and therefore the normal live broadcasting is ensured. Referring to fig. 1, the method for live streaming cut-off at present mainly stops the whole transcoding process of the current stream, and then performs decapsulation, decoding, encoding and outputting on a new live stream or file, and then starts new video stream transmission, that is, after an input signal a is switched to an input signal B, a transcoder needs to quit the process a, and then restarts the process B, and after the process B obtains an output stream, the content can be viewed at a client. This method not only wastes resources in operation, but also requires a long time for exiting and starting, directly, i.e. buffering is required during the viewing process, which also results in loss of input signals and occurrence of stutter, black screen and the like at the playing end.

Disclosure of Invention

The invention aims to provide a live broadcast transcoding method and a live broadcast transcoding system for dynamically switching video streams, which have the technical characteristics of no buffer, no pause, no screen flashing, no screen blacking, continuous sound and no loss of played data during play switching.

In order to solve the problems, the technical scheme provided by the invention is as follows:

a live transcoding method for dynamically switching video streams comprises the following steps:

receiving a current switching request, and receiving a target input signal according to the current switching request;

the method comprises the steps that when the output of a transcoding process for transcoding an original input signal is kept, a target thread is created to decapsulate and decode the target input signal in the transcoding process, wherein the transcoding process for transcoding the original input signal comprises an original thread for decapsulating and decoding the original input signal and an output thread for encoding and encapsulating an original data stream output by the original thread;

when a target data stream output by the target thread is obtained, destroying the original thread and cutting off an original input signal;

and encoding and packaging the target data stream through the output thread, and outputting to obtain a target output stream after transcoding the target input signal.

Further preferably, the stream switching request includes a live stream switching request, a main signal switching request, a standby signal switching request, and a shim switching request, and receiving the target input signal according to the stream switching request specifically includes: if a live broadcast stream switching request is received, the received target input signal is a live broadcast input signal required in the live broadcast stream switching request; if a main signal switching request is received, the received target input signal is a main signal of an original input signal; if receiving a standby signal switching request, the received target input signal is a standby signal of the original input signal; if a gasket switching request is received, the received target input signal is a gasket signal.

Further preferably, before receiving the request for switching, the method further comprises the following steps: establishing a live broadcast task, and configuring a main signal, a standby signal and a gasket signal; starting a live broadcast task, establishing a transcoding process to transcode and output a main signal, and in the transcoding output process: if the main signal is cut off, automatically sending a standby signal switching request; if the main signal and the standby signal are cut off, automatically sending a gasket switching request; if the main signal cutoff is recovered, automatically sending a main signal switching request; if the standby signal is recovered and the main signal is cut off, automatically sending a standby signal switching request; and if the specified live broadcast content is required to be switched, sending a live broadcast stream switching request.

Further preferably, obtaining the target output stream comprises: and sending the target output stream for playing.

The invention also provides a live transcoding system for dynamically switching video streams, which comprises:

the receiving module is used for receiving the flow cutting request and receiving a target input signal according to the flow cutting request;

the transcoding module is used for maintaining the output of a transcoding process for transcoding the original input signal, and simultaneously establishing a target thread for decapsulating and decoding the target input signal in the transcoding process, wherein the transcoding process for transcoding the original input signal comprises an original thread for decapsulating and decoding the original input signal and an output thread for encoding and encapsulating an original data stream output by the original thread;

the flow switching module is used for destroying the original thread and cutting off the original input signal when the target data flow output by the target thread is to be obtained;

the transcoding module is further used for encoding and packaging the target data stream through the output thread, and outputting an output stream obtained after transcoding the target input signal.

Further preferably, the stream switching request includes a live stream switching request, a main signal switching request, a standby signal switching request, and a shim switching request, and the receiving module is configured to receive a target input signal according to the stream switching request: if a live broadcast stream switching request is received, the received target input signal is a live broadcast input signal required in the live broadcast stream switching request; if a main signal switching request is received, the received target input signal is a main signal of an original input signal; if receiving a standby signal switching request, the received target input signal is a standby signal of the original input signal; if a gasket switching request is received, the received target input signal is a gasket signal.

Further preferably, the method further comprises the following steps: the configuration module is used for establishing a live broadcast task and configuring a main signal, a standby signal and a gasket signal; the transcoding module is also used for starting a live broadcast task and establishing a transcoding process to transcode and output the main signal; a request generation module, configured to, during a transcoding output process: if the main signal is cut off, automatically sending a standby signal switching request; if the main signal and the standby signal are cut off, automatically sending a gasket switching request; if the main signal cutoff is recovered, automatically sending a main signal switching request; if the standby signal is recovered and the main signal is cut off, automatically sending a standby signal switching request; if the specified live broadcast content is required to be switched, sending a live broadcast stream switching request;

further preferably, the system further comprises a playing module, configured to send the target output stream for playing after obtaining the target output stream.

The present invention also provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements a live transcoding method for dynamically switching video streams as described above.

The invention also provides a computer device, which comprises a memory, a processor and a computer program stored on the memory and capable of being called by the processor, wherein when the processor executes the computer program, the live transcoding method for dynamically switching the video stream is realized.

Compared with the prior art, the invention has the following advantages and positive effects:

according to the invention, under the condition of not introducing an external component, a plurality of threads are started in the same transcoding process for processing, wherein after a stream switching request is received, one thread is restarted to decapsulate and decode a target input signal, and after a target data stream is output, the original thread which decapsulates and decodes an original input signal is destroyed, so that dynamic switching of video streams is realized, and transcoding is ensured to be output and uninterrupted all the time, so that no data is lost at a playing end after stream switching, and the whole transcoding process is not reestablished and destroyed, therefore, the switching time interval is greatly reduced, frame-level low-delay switching is realized, and the technical effects of no buffer, no blockage, no screen flicker, no black screen, continuous sound and no data loss during playing switching are achieved.

Drawings

Fig. 1 is a schematic diagram of a conventional framework for switching video streams;

fig. 2 is a schematic flow chart of a live transcoding method for dynamically switching video streams according to the present invention;

fig. 3 is a schematic diagram of a framework of a live transcoding system for dynamically switching video streams according to the present invention.

Detailed Description

In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following description will be made with reference to the accompanying drawings. It is obvious that the drawings in the following description are only some examples of the invention, and that for a person skilled in the art, other drawings and embodiments can be derived from them without inventive effort.

For the sake of simplicity, the drawings only schematically show the parts relevant to the present invention, and they do not represent the actual structure as a product. In addition, in order to make the drawings concise and understandable, components having the same structure or function in some of the drawings are only schematically illustrated or only labeled. In this document, "one" means not only "only one" but also a case of "more than one".

The following describes a live transcoding method and system for dynamically switching video streams in detail with reference to the accompanying drawings and specific embodiments.

13页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:直播互动方法、装置、服务器及机器可读存储介质

网友询问留言

已有0条留言

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

精彩留言,会给你点赞!

技术分类