CN112565808B - 一种在直播流中插播垫片的方法 - Google Patents

一种在直播流中插播垫片的方法 Download PDF

Info

Publication number
CN112565808B
CN112565808B CN202011454277.3A CN202011454277A CN112565808B CN 112565808 B CN112565808 B CN 112565808B CN 202011454277 A CN202011454277 A CN 202011454277A CN 112565808 B CN112565808 B CN 112565808B
Authority
CN
China
Prior art keywords
stream
live
switching
timestamp
gasket
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011454277.3A
Other languages
English (en)
Other versions
CN112565808A (zh
Inventor
苏许臣
朱立松
黄建杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Cntv Wuxi Co ltd
Original Assignee
Cntv Wuxi Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Cntv Wuxi Co ltd filed Critical Cntv Wuxi Co ltd
Priority to CN202011454277.3A priority Critical patent/CN112565808B/zh
Publication of CN112565808A publication Critical patent/CN112565808A/zh
Application granted granted Critical
Publication of CN112565808B publication Critical patent/CN112565808B/zh
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/21Server components or server architectures
    • H04N21/218Source of audio or video content, e.g. local disk arrays
    • H04N21/2187Live feed
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/234Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs
    • H04N21/23424Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving splicing one content stream with another content stream, e.g. for inserting or substituting an advertisement
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/234Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs
    • H04N21/2343Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements
    • H04N21/234309Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements by transcoding between formats or standards, e.g. from MPEG-2 to MPEG-4 or from Quicktime to Realvideo
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/234Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs
    • H04N21/2343Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements
    • H04N21/234327Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements by decomposing into layers, e.g. base layer and one or more enhancement layers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs
    • H04N21/44016Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving splicing one content stream with another content stream, e.g. for substituting a video clip
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs
    • H04N21/4402Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display
    • H04N21/440218Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display by transcoding between formats or standards, e.g. from MPEG-2 to MPEG-4
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs
    • H04N21/4402Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display
    • H04N21/440227Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display by decomposing into layers, e.g. base layer and one or more enhancement layers

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Databases & Information Systems (AREA)
  • Business, Economics & Management (AREA)
  • Marketing (AREA)
  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)

Abstract

本发明涉及计算机多媒体信息处理技术领域,具体涉及一种在直播流中插播垫片的方法,旨在解决现有技术中在直播中插入垫片耗费资源同时降低直播流的画面质量形成的问题,其技术要点在于:包含用户交互模块、流切换模块及拼接模块,其中用户交互模块用于接收用户的切换指令并发送到流切换模块,流切换模块负责解析直播流编码参数并且根据切换指令控制直播流和垫片的切换,它的输入是直播源和待插播的垫片文件,输出是udp+ts封装的直播流,所述流拼接模块中将流切换模块输出的udp+ts流进行拼接、修正时间戳不连续并且重新封装成下游需要的媒体流格式。不需要对直播源进行转码,只需要对垫片文件进行转码,不会降低直播流的画面质量,并且降低了资源使用率。

Description

一种在直播流中插播垫片的方法
技术领域
本发明涉及计算机多媒体信息处理技术领域,具体涉及一种在直播流中插播垫片的方法。
背景技术
在直播中插播垫片通常分为两个场景,一种是在播放器端插播,这种一般需要在播放器端做定制开发,需要控制实现什么时候停止播放直播流,什么时候开始获取点播流,什么时候切换回直播流。如果播放器属于第三方则该方案并不适合,这种情况需要在服务端将垫片文件插播到直播流中去,拼接成一个直播流给到播放器端,播放器端把它当做一个直播流来处理。在服务端拼接垫片流通常的做法是将直播流和垫片统一编码成一种格式然后拼接再输出,这种做法不好的地方在于需要对直播流进行转码,这样一方面比较消耗资源,另一方面转码也会降低直播流的画面质量。
发明内容
因此,本发明要解决的技术问题在于克服现有技术中在直播中插入垫片耗费资源同时降低直播流的画面质量形成的缺陷,从而提供一种在直播流中插播垫片的方法。
本发明的上述技术目的是通过以下技术方案得以实现的:
一种在直播流中插播垫片的方法,包含用户交互模块、流切换模块及拼接模块,其中用户交互模块用于接收用户的切换指令并发送到流切换模块,流切换模块负责解析直播流编码参数并且根据切换指令控制直播流和垫片的切换,它的输入是直播源和待插播的垫片文件,输出是udp+ts封装的直播流,所述流拼接模块中将流切换模块输出的udp+ts流进行拼接、修正时间戳不连续并且重新封装成下游需要的媒体流格式。
优选的,所述流切换模块包含以下步骤:
S1:打开直播源并解析直播源的编码参数;
S2:调用ffmpeg API对直播源进行解封装然后重新封装成udp+ts流输出,流地址可以为本地回环网卡地址,将该地址记为D1;
S3:如果接收到切换垫片的指令,停止当前直播源输出,关闭并释放相关资源;然后打开垫片文件,并调用ffmpeg API对垫片文件进行转码,编码参数设置为跟直播源编码参数保持一致转码输出到同一个流地址D1;
S4:如果接收到切换直播的指令,那么首先停止当前垫片流输出,关闭并释放相关资源,跳转到S2。
优选的,所述解封装只解码网络协议层和文件封装层,不解码编码层。
优选的,所述流拼接模块的处理流程包括:
S1:调用ffmpeg API打开流切换模块中的流地址D1,初始化时间戳偏移ts_offset值为0,初始化下一帧的时间戳next_ts为0;
S2:读取一帧的数据;
S3:提取当前帧的时间戳cur_ts,并调整当前时间戳cur_ts=cur_ts+ts_offset;
S4:计算当前时间戳与下一个时间戳的差值delta=cur_ts-next_ts,如果delta的绝对值大于某个阈值,那么调整当前帧的时间戳为cur_ts=cur_ts-delta,同时调整时间戳偏移为ts_offset=ts_offset-delta;
S5:保存下一帧的时间戳为next_ts=cur_ts。
S6:调用ffmpeg API将当前帧重新封装成下游要求的流媒体格式输出。
上述所述的一种在直播流中插播垫片的方法,使用过程中,不需要对直播源进行转码,只需要对垫片文件进行转码,不会降低直播流的画面质量,并且降低了资源使用率。
附图说明
为了更清楚地说明本发明具体实施方式或现有技术中的技术方案,下面将对具体实施方式或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施方式,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本发明的一种实施方式的一种在直播流中插播垫片的方法的结构示意图;
图2为本发明的一种实施方式的一种在直播流中插播垫片的方法中流切换模块的流程示意图;
图3为本发明的一种实施方式的一种在直播流中插播垫片的方法中流拼接模块的流程示意图。
具体实施方式
为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。
文中部分释义:
UDP(英文:User Datagram Protocol):UDP协议全称是用户数据报协议,在网络中它与TCP协议一样用于处理数据包,是一种无连接的协议。
TS:日本高清摄像机拍摄下进行的封装格式,全称为MPEG2-TS。
Ffmpeg:一套可以用来记录、转换数字音频、视频,并能将其转化为流的开源计算机程序。
API:(Application Programming Interface,应用程序接口)是一些预先定义的函数,或指软件系统不同组成部分衔接的约定。
以下结合附图与具体实施方式对本申请进行阐述。
请参阅图1,一种在直播流中插播垫片的方法,包含以下三个模块:用户交互模块、流切换模块及拼接模块。其中用户交互模块用于接收用户的切换指令并发送到流切换模块,流切换模块负责解析直播流编码参数并且根据切换指令控制直播流和垫片的切换,它的输入是直播源和待插播的垫片文件,输出是udp+ts封装的直播流,因为切换过程udp+ts直播流会有短暂的时间戳不连续情况,在流拼接模块中将流切换模块输出的udp+ts流进行拼接、修正时间戳不连续并且重新封装成下游需要的媒体流格式然后分发。
在一实施方式中,请参阅图1,所述流切换模块包含以下步骤::
S1:打开直播源并解析直播源的编码参数。
具体的,在一实施方式中,所述编码参数包括分辨率、视频编码器类型(h264/mpeg4等)、视频码率、帧率、关键帧间隔、颜色空间(yuv420p、yuv422p等等)、音频编码器类型(aac/mp2等)、音频采样率、声道数、音频码率等信息。上述编码参数的集合记为CEST。
S2:调用ffmpegAPI对直播源进行解封装然后重新封装成udp+ts流输出,流地址可以为本地回环网卡地址,如:udp://127.0.0.1:8008,将该地址记为D1。
在一实施方式中,所述解封装只解码网络协议层和文件封装层,不解码编码层。
S3:如果接收到切换垫片的指令,停止当前直播源输出,关闭并释放相关资源;然后打开垫片文件,并调用ffmpeg API对垫片文件进行转码,编码参数设置为跟直播源编码参数保持一致,即CSET。转码输出到同一个流地址D1。
S4:如果接收到切换直播的指令,那么首先停止当前垫片流输出,关闭并释放相关资源,跳转到S2。
请参阅图3,在一实施方式中,所述流拼接模块的处理流程包括:
S1:调用ffmpeg API打开流切换模块中的流地址D1,初始化时间戳偏移ts_offset值为0,初始化下一帧的时间戳next_ts为0;
S2:读取一帧的数据。
所述S2是对收到的流进行解封装,在一实施方式中,所述解封装只解码网络协议层和文件封装层,不解码编码层。
S3:提取当前帧的时间戳cur_ts,并调整当前时间戳cur_ts=cur_ts+ts_offset。
S4:计算当前时间戳与下一个时间戳的差值delta=cur_ts-next_ts,如果delta的绝对值大于某个阈值,那么调整当前帧的时间戳为cur_ts=cur_ts-delta,同时调整时间戳偏移为ts_offset=ts_offset-delta。
在一实施方式中,所述阀值设置为2秒。
S5:保存下一帧的时间戳为next_ts=cur_ts。
S6:调用ffmpeg API将当前帧重新封装成下游要求的流媒体格式输出。
在一实施方式中,所述流媒体格式包括udp+ts、http+flv、rtmp+flv等。
经过流拼接模块后,可以确保输出的帧时间戳都是连续递增的,这样可以保证下游客户端播放就不会有问题。
本申请所提供的一种在直播流中插播垫片的方法,使用过程中,不需要对直播源进行转码,只需要对垫片文件进行转码,不会降低直播流的画面质量,并且降低了资源使用率。
显然,上述实施例仅仅是为清楚地说明所作的举例,而并非对实施方式的限定。对于所属领域的普通技术人员来说,在上述说明的基础上还可以做出其它不同形式的变化或变动。这里无需也无法对所有的实施方式予以穷举。而由此所引伸出的显而易见的变化或变动仍处于本发明创造的保护范围之中。

Claims (2)

1.一种在直播流中插播垫片的方法,其特征在于:包含用户交互模块、流切换模块及拼接模块,其中用户交互模块用于接收用户的切换指令并发送到流切换模块,流切换模块负责解析直播流编码参数并且根据切换指令控制直播流和垫片的切换,它的输入是直播源和待插播的垫片文件,输出是udp+ts封装的直播流,流拼接模块中将流切换模块输出的udp+ts流进行拼接、修正时间戳不连续并且重新封装成下游需要的媒体流格式;
所述流切换模块包含以下步骤:
S1:打开直播源并解析直播源的编码参数;
S2:调用ffmpeg API对直播源进行解封装然后重新封装成udp+ts流输出,流地址可以为本地回环网卡地址,将该地址记为D1;
S3:如果接收到切换垫片的指令,停止当前直播源输出,关闭并释放相关资源;然后打开垫片文件,并调用ffmpeg API对垫片文件进行转码,编码参数设置为跟直播源编码参数保持一致转码输出到同一个流地址D1;
S4:如果接收到切换直播的指令,那么首先停止当前垫片流输出,关闭并释放相关资源,跳转到S2;
所述流拼接模块的处理流程包括:
S1:调用ffmpeg API打开流切换模块中的流地址D1,初始化时间戳偏移ts_offset值为0,初始化下一帧的时间戳next_ts为0;
S2:读取一帧的数据;
S3:提取当前帧的时间戳cur_ts,并调整当前时间戳cur_ts=cur_ts+ts_offset;
S4:计算当前时间戳与下一个时间戳的差值delta=cur_ts-next_ts,如果delta的绝对值大于某个阈值,那么调整当前帧的时间戳为cur_ts=cur_ts-delta,同时调整时间戳偏移为ts_offset=ts_offset-delta;
S5:保存下一帧的时间戳为next_ts=cur_ts;
S6:调用ffmpeg API将当前帧重新封装成下游要求的流媒体格式输出。
2.根据权利要求1所述的在直播流中插播垫片的方法,其特征在于:所述解封装只解码网络协议层和文件封装层,不解码编码层。
CN202011454277.3A 2020-12-10 2020-12-10 一种在直播流中插播垫片的方法 Active CN112565808B (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011454277.3A CN112565808B (zh) 2020-12-10 2020-12-10 一种在直播流中插播垫片的方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011454277.3A CN112565808B (zh) 2020-12-10 2020-12-10 一种在直播流中插播垫片的方法

Publications (2)

Publication Number Publication Date
CN112565808A CN112565808A (zh) 2021-03-26
CN112565808B true CN112565808B (zh) 2022-07-15

Family

ID=75061594

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011454277.3A Active CN112565808B (zh) 2020-12-10 2020-12-10 一种在直播流中插播垫片的方法

Country Status (1)

Country Link
CN (1) CN112565808B (zh)

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107197360B (zh) * 2017-06-14 2019-11-29 杭州当虹科技股份有限公司 一种直播信号安全播出的方法及系统
CN111083559B (zh) * 2018-10-22 2020-12-22 深圳Tcl数字技术有限公司 一种数字电视的频道跳转方法、存储设备及数字电视
CN109660838A (zh) * 2018-12-19 2019-04-19 上海众源网络有限公司 一种视频直播流生成方法、装置及电子设备
CN110708564B (zh) * 2019-10-21 2021-12-07 上海网达软件股份有限公司 一种动态切换视频流的直播转码方法及系统

Also Published As

Publication number Publication date
CN112565808A (zh) 2021-03-26

Similar Documents

Publication Publication Date Title
US8743906B2 (en) Scalable seamless digital video stream splicing
US11770582B2 (en) Frame conversion for adaptive streaming alignment
US10177958B2 (en) Method for synchronously taking audio and video in order to proceed one-to-multi multimedia stream
US20120159530A1 (en) Micro-Filtering of Streaming Entertainment Content Based on Parental Control Setting
CN112752115B (zh) 直播数据传输方法、装置、设备及介质
US10862940B1 (en) Low latency live video on a communication session
US11039200B2 (en) System and method for operating a transmission network
CN112740325B (zh) 即时播放帧(ipf)的生成、传输及处理的方法、设备及系统
US10536665B2 (en) Device for transmitting broadcast signal, device for receiving broadcast signal, method for transmitting broadcast signal, and method for receiving broadcast signal
AU2018300191A1 (en) Processing media data using file tracks for web content
CN109640162B (zh) 码流转换方法及系统
CN113938470A (zh) 一种浏览器播放rtsp数据源的方法、装置以及流媒体服务器
CN111711870B (zh) 一种跨网络边界的实时流传输方法
CN112565808B (zh) 一种在直播流中插播垫片的方法
CN109600651B (zh) 文档类直播交互数据和音视频数据同步方法和系统
CN113645485A (zh) 一种实现任意流媒体协议到ndi的转换方法及装置
CN107248991B (zh) 基于视频关键帧的ip流调度系统及方法
CN113055706A (zh) 视频合成方法、装置、电子设备和存储介质
EP3668101A1 (en) Transmission device, transmission method, reception device, and reception method
CN117956224A (zh) 音视频处理方法、音视频处理装置、服务器和浏览器
CN117241050A (zh) 在轮播节目中无缝插入直播流的方法、系统、设备及介质
CN117376593A (zh) 直播流的字幕处理方法、装置、存储介质及计算机设备
CN118200618A (zh) 一种直播视频的处理方法和系统
Räsänen Implementation of recording and playback in video call
CN117981328A (zh) 音视频的多路同步播放方法、装置、电子设备及存储介质

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant