[go: up one dir, main page]

CN104038844B - A mobile live broadcast system based on MPEG‑2 standard - Google Patents

A mobile live broadcast system based on MPEG‑2 standard Download PDF

Info

Publication number
CN104038844B
CN104038844B CN201410293451.9A CN201410293451A CN104038844B CN 104038844 B CN104038844 B CN 104038844B CN 201410293451 A CN201410293451 A CN 201410293451A CN 104038844 B CN104038844 B CN 104038844B
Authority
CN
China
Prior art keywords
module
video
rtsp
rtp
signaling
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
CN201410293451.9A
Other languages
Chinese (zh)
Other versions
CN104038844A (en
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.)
Zhejiang University of Technology ZJUT
Original Assignee
Zhejiang University of Technology ZJUT
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 Zhejiang University of Technology ZJUT filed Critical Zhejiang University of Technology ZJUT
Priority to CN201410293451.9A priority Critical patent/CN104038844B/en
Publication of CN104038844A publication Critical patent/CN104038844A/en
Application granted granted Critical
Publication of CN104038844B publication Critical patent/CN104038844B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

A kind of mobile live broadcast system based on the standards of MPEG 2, including mobile device end, streaming media server and player end, the mobile device end includes video data acquiring subsystem, and the video data acquiring subsystem includes H264 video compression codings module, the standard package modules of MPEG 2 and thread pool module;Described thread pool module is connected with RTSP signalling modules, RTP transport modules;The streaming media server includes live data forwarding module, RTCP rate control modules, video request program module and RTSP signalling modules, the mobile live broadcast system also includes RTSP signal servers, and for sending, signaling is opened in RTSP requests or RTSP requests stop signaling.The present invention improves video flowing package mode and transmission mode, and is applied to mobile phone terminal, sets up a new signaling system and carries out unified management, it is ensured that the various pieces communication stability of system is good.

Description

一种基于MPEG-2标准的移动直播系统A Mobile Live Broadcasting System Based on MPEG-2 Standard

技术领域technical field

本发明涉及网络直播领域的视频直播技术领域,尤其是一种移动直播系统。The invention relates to the technical field of video live broadcast in the field of network live broadcast, in particular to a mobile live broadcast system.

背景技术Background technique

随着有线数字电视的普及,MPEG-2系统复用技术的地位日益凸显,根据传输媒介的质量不同,MPEG-2标准中定义了两种复用信息流:传输流(TS:Transport Stream)和节目流(PS:Program Stream)。TS流与PS流的区别在于TS流的包结构是固定长度的,而PS流的包结构是可变长度的。PS包由于长度是变化的,一旦丢失某一PS包的同步信息,接收机就会进入失步状态,从而导致严重的信息丢失事件。而TS码流由于采用了固定长度的包结构,当传输误码破坏了某一TS包的同步信息时,接收机可在固定的位置检测它后面包中的同步信息,从而恢复同步,避免了信息丢失。因此在信道环境较为恶劣、传输误码较高时一般采用TS码流,而在信道环境较好、传输误码较低时一般采用PS码流,此外采用固定长度包格式的TS码流在多路数据复用提供充分的灵活性的同时也表现出诸多的优点,譬如动态带宽分配、可分级性、可扩展性、抗干扰性、接收机成本低廉。With the popularization of cable digital TV, the status of MPEG-2 system multiplexing technology has become increasingly prominent. According to the quality of the transmission medium, the MPEG-2 standard defines two multiplexed information streams: transport stream (TS: Transport Stream) and Program stream (PS: Program Stream). The difference between the TS stream and the PS stream is that the packet structure of the TS stream is of fixed length, while the packet structure of the PS stream is of variable length. Since the length of the PS packet changes, once the synchronization information of a certain PS packet is lost, the receiver will enter an out-of-synchronization state, resulting in serious information loss events. Since the TS code stream adopts a fixed-length packet structure, when a transmission error destroys the synchronization information of a certain TS packet, the receiver can detect the synchronization information in the packet behind it at a fixed position, thereby restoring synchronization, avoiding Information is lost. Therefore, when the channel environment is relatively bad and the transmission error is high, the TS code stream is generally used, and when the channel environment is good and the transmission error is low, the PS code stream is generally used. While providing sufficient flexibility for data multiplexing, it also exhibits many advantages, such as dynamic bandwidth allocation, scalability, scalability, anti-interference, and low cost of the receiver.

发明内容Contents of the invention

为了克服现有流媒体直播系统的网络丢包严重、播放速度不准确、在音频和视频时分两路发送和接收、音视频同时录像音频和视频必须分开保存成两个文件,播放时同步及速率不准确、对主流播放器不能完美支持等不足,本发明提供一种改进视频流封包方式和传输模式,并将其应用于手机终端,建立一个新的信令系统进行统一的管理,保证了系统的各个部分通信稳定性良好的基于MPEG-2标准的移动直播系统。In order to overcome the serious network packet loss and inaccurate playback speed of the existing streaming media live broadcast system, the audio and video are sent and received in two channels, and the audio and video are recorded at the same time. Inaccurate, unable to perfectly support mainstream players and other deficiencies, the present invention provides an improved video stream packetization method and transmission mode, and applies it to mobile terminals, establishes a new signaling system for unified management, and ensures system A mobile live broadcast system based on the MPEG-2 standard with good communication stability in each part.

本发明解决其技术问题所采用的技术方案是:The technical solution adopted by the present invention to solve its technical problems is:

一种基于MPEG-2标准的移动直播系统,包括移动设备端、流媒体服务器和播放器端,所述移动设备端包括视频数据采集子系统,所述视频数据采集子系统包括H264视频压缩编码模块、MPEG-2标准封包模块和线程池模块;所述H264视频压缩编码模块中,调用IOS系统层的API接口,开启摄像功能,采集到原始的视频数据,对采集过来的每一帧进行H264编码,得到ES基本码流;所述的MPEG-2标准封包模块中,基于MPEG-2标准的视频压缩编码,将H.264编码出的ES流打包成PES流,PES流再按188B的固定长度加上辅助数据组成TS码流,然后将TS码流放到RTP缓存池中;所述的线程池模块与RTSP信令模块、RTP传输模块连接;所述RTSP信令模块中,启动一个监听RTSP信令的服务,所述RTP传输模块中,当检测到RTP缓存池里的数据不为空时,就从缓存池中读取TS码流数据,向流媒体服务器发送RTP包,直到RTP缓存池里数据为空;A mobile live broadcast system based on the MPEG-2 standard, comprising a mobile device end, a streaming media server and a player end, the mobile device end comprising a video data acquisition subsystem, the video data acquisition subsystem comprising an H264 video compression encoding module , MPEG-2 standard packet module and thread pool module; In the H264 video compression encoding module, call the API interface of the IOS system layer, open the camera function, collect the original video data, and carry out H264 encoding to each frame collected , obtain the ES basic code stream; In the described MPEG-2 standard packet module, based on the video compression coding of the MPEG-2 standard, the ES stream encoded by H.264 is packaged into a PES stream, and the PES stream is then pressed to a fixed length of 188B Add auxiliary data to form the TS code stream, then put the TS code stream in the RTP buffer pool; the thread pool module is connected with the RTSP signaling module and the RTP transmission module; in the RTSP signaling module, start a monitoring RTSP signal In the service of order, in the described RTP transmission module, when detecting that the data in the RTP buffer pool is not empty, just read the TS stream data from the buffer pool, send the RTP packet to the streaming media server, until in the RTP buffer pool data is empty;

所述流媒体服务器包括直播数据转发模块、RTCP码率控制模块、视频点播模块及RTSP信令模块,所述的直播数据转发模块中,将所有的视频数据转发;所述RTCP码率控制模块中,采用RTCP网际协议,对IOS设备直播软件采集发送的数据包和流媒体服务器端接受到的数据包进行统计和反馈,在发生网络拥塞时,以控制和调节IOS直播软件端采集发送的码率;所述视频点播模块中,对IOS直播软件上传的视频文件进行保存并满足IOS直播软件随时随地的回放。Described streaming media server comprises live data forwarding module, RTCP bit rate control module, video on demand module and RTSP signaling module, in described live data forwarding module, all video data is forwarded; In described RTCP bit rate control module , using the RTCP Internet protocol to count and feed back the data packets collected and sent by the IOS device live broadcast software and the data packets received by the streaming media server, and to control and adjust the code rate collected and sent by the IOS live broadcast software when network congestion occurs ; In the video-on-demand module, the video file uploaded by the IOS live broadcast software is saved and meets the playback of the IOS live broadcast software anytime and anywhere.

所述移动直播系统还包括RTSP信令服务器,用于发出RTSP请求开启信令或RTSP请求停止信令。The mobile live broadcast system also includes an RTSP signaling server, which is used for sending RTSP request start signaling or RTSP request stop signaling.

进一步,所述线程池模块中,在IOS设备上线时,会和RTSP信令模块通信,启动一个监听RTSP信令的服务,当收到来自远程RTSP信令服务器的RTSP请求开启信令时,向H264视频压缩编码模块发送开启摄像采集消息,进行视频采集,同时激活RTP传输模块,开辟一个RTP缓存池,用于存放MPEG-2标准封包模块所产生的TS码流数据;当收到来自远程RTSP信令服务器的RTSP请求停止信令时,向H264视频压缩编码模块发送关闭摄像采集消息,停止视频采集。Further, in the thread pool module, when the IOS device goes online, it will communicate with the RTSP signaling module, start a service to monitor the RTSP signaling, and when receiving the RTSP request from the remote RTSP signaling server to open the signaling, send The H264 video compression coding module sends a camera capture message to start video capture, and at the same time activates the RTP transmission module to open up an RTP buffer pool for storing the TS stream data generated by the MPEG-2 standard packet module; When the RTSP request of the signaling server stops the signaling, it sends a closing camera collection message to the H264 video compression coding module to stop the video collection.

更进一步,所述视频数据采集子系统还包括RTCP控制模块:和RTCP码率控制模块建立另一条链接,配合监控网络状况,根据不同的网络状况进行实时的调整摄像头采集视频的帧率以调整发送出去的码率来适应网络的变化。Furthermore, the video data acquisition subsystem also includes an RTCP control module: establish another link with the RTCP code rate control module, cooperate with monitoring network conditions, and adjust the frame rate of the video captured by the camera in real time according to different network conditions to adjust the sending The outbound bit rate adapts to changes in the network.

所述视频数据采集子系统还包括REGISTER模块,在软件开启时向服务器注册设备,成为一个上线的设备。The video data acquisition subsystem also includes a REGISTER module, which registers the device with the server when the software is started, and becomes an online device.

所述视频数据采集子系统还包括本地保存模块,在直播的同时,对摄像头采集编码出的TS流数据进行保存,用户能对历史录像进行观看。The video data collection subsystem also includes a local storage module, which saves the TS stream data collected and coded by the camera during the live broadcast, and the user can watch the historical video.

本发明的技术构思为:采用RTP/UDP传输技术、线程池管理技术、流媒体分发技术、RTSP协议、TCP协议及MPEG-2视频编码标准技术,实现IOS手机视频采集软件、流媒体服务器与PC端视频播放器的三者间的通信和数据传输。The technical idea of the present invention is: adopt RTP/UDP transmission technology, thread pool management technology, streaming media distribution technology, RTSP protocol, TCP protocol and MPEG-2 video coding standard technology, realize IOS mobile phone video collection software, streaming media server and PC The communication and data transmission between the three end video players.

TS码流传输在有线数字电视中得到了很好的应用,同时也证明了TS码流用来传输视频数据的优越性,本发明将把MPEG-2技术应用到移动互联的网络环境中进行传输视频数据,在移动设备端用软编码的方法产生TS码流,经流媒体服务器转发进行网络直播,同样也保证TS码流与有线数字电视中一样的优越性。TS code stream transmission has been well applied in cable digital TV, and it has also proved the superiority of TS code stream for transmitting video data. This invention will apply MPEG-2 technology to the network environment of mobile Internet to transmit video For the data, the TS code stream is generated by soft coding on the mobile device side, and forwarded by the streaming media server for network live broadcast, which also ensures the same superiority of the TS code stream as in cable digital TV.

本发明的有益效果主要表现在:有效减少网络丢包,播放速度更准确,播放时同步及速率良好,对主流播放器实现完美支持。The beneficial effects of the present invention are mainly manifested in: effectively reducing network packet loss, more accurate playback speed, good synchronization and rate during playback, and perfect support for mainstream players.

附图说明Description of drawings

图1是基于MPEG-2标准的移动直播系统的总体架构框架。Figure 1 is the overall framework of the mobile live broadcast system based on the MPEG-2 standard.

图2是IOS设备数据采集端模块设计图。Figure 2 is a design diagram of the IOS device data acquisition terminal module.

图3是PES包结构图,其中,ES(Elementary Streams):原始码流;PES(PacketizedElementary Streams):分组的原始码流;Packet Start Code Prefix:包起始码前缀;Stream ID:流ID;PES Packet Length:分组码流包长度;Optional PES Header:分组码流可选头部;PES Packet Data Bytes:分组码流负载数据字节;PES Scrambling Control:分组码流干扰控制符;PES Priority:分组码流优先级;Data Alignment Indicator:数据校验标识;Copyright:版本;Original Or Copy:是否为副本;7Flags:7个标识;PES HeaderData Length:分组码流头部数据长度;Optional Fields:可选域;0xFF:0xFF填充字节;PTS(Presentation Time Stamp):显示时间标记;DTS(Decoding Time Stamp):解码时间标记;ESCR(Elementary Stream Clock Reference):原始码流参考时钟;ES Rate:原始码流速率;DSM Trick Mode:DSM特技模式;Additional Copy Information:附加版本信息;PESCRC(Packetized Elementary Stream Cyclic Redundancy Check):分组码流循环冗余校验;PES Extension:分组码流扩展;Optional Fields:可选域;5Flags:5个标识;PESPrivate Data:分组码流私有数据;Packet Header Field:分组头域;Program PacketSequence Counter:节目包序列计数器;P-STD Buffer:P-STD缓存;PES Extension FieldLength:分组码流扩展域长度;PES Extension Field Data:分组码流扩展域数据。Figure 3 is a PES packet structure diagram, wherein, ES (Elementary Streams): original stream; PES (PacketizedElementary Streams): original stream of packets; Packet Start Code Prefix: packet start code prefix; Stream ID: stream ID; PES Packet Length: packet length of packet code stream; Optional PES Header: optional header of packet code stream; PES Packet Data Bytes: payload data bytes of packet code stream; PES Scrambling Control: packet code stream interference control symbol; PES Priority: packet code Stream priority; Data Alignment Indicator: data verification identifier; Copyright: version; Original Or Copy: whether it is a copy; 7Flags: 7 flags; PES HeaderData Length: packet stream header data length; Optional Fields: optional field; 0xFF: 0xFF filling byte; PTS (Presentation Time Stamp): display time stamp; DTS (Decoding Time Stamp): decoding time stamp; ESCR (Elementary Stream Clock Reference): original stream reference clock; ES Rate: original stream rate ;DSM Trick Mode: DSM trick mode; Additional Copy Information: additional version information; PESCRC (Packetized Elementary Stream Cyclic Redundancy Check): packet stream cyclic redundancy check; PES Extension: packet stream extension; Optional Fields: optional fields ;5Flags: 5 flags; PESPrivate Data: packet stream private data; Packet Header Field: packet header field; Program PacketSequence Counter: program packet sequence counter; P-STD Buffer: P-STD cache; PES Extension FieldLength: packet stream Extended field length; PES Extension Field Data: Packet code stream extended field data.

图4是TS包结构图,其中,Header:头部;Payload:负载;Sync Byte:同步码;Transport Error Indicator:传输错误标识;Payload Uint Start Indicator:负载单元起始标识;Transport Priority:传输优先级;PID(Packet ID):打包ID;TransportScrambling Control:传输干扰控制;Adaptation Field Control:自适应域控制;Continuity Counter:连续计数器;Adaptation Field:自适应域;Adaptation FieldLength:自适应域长度;Discontinuity Indicator:非连续标识;Random AccessIndicator:随机存取标识;Elementary Stream Priority Indicator:原始码流优先级标识;5Flags:5个标识;Optional Fields:可选域;Stuffing Bytes:填充字节;PCR(ProgramClock Reference):节目参考时钟;OPCR(Original Program Clock Reference):原始节目参考时钟;Splice Countdown:拼接倒计时;Transport Private Data Length:传输私有数据长度;Transport Private Data:传输私有数据;Adaptation Field ExtenstionLength:自适应域扩展长度;3Flags:3个标识;Optional Fields:可选域;LTW_valid flag(legal time window):合法时间窗标识;LTW offset(legal time window):合法时间窗口偏移;Piecewise Rate:分段率;Splice Type:接头类型;DTS_next_au(decoding timestamp next access unit):解码时间标记下一个存取单元。Figure 4 is a TS packet structure diagram, where Header: header; Payload: load; Sync Byte: synchronization code; Transport Error Indicator: transmission error indicator; Payload Uint Start Indicator: load unit start indicator; Transport Priority: transmission priority ;PID (Packet ID): Packet ID; TransportScrambling Control: Transmission interference control; Adaptation Field Control: Adaptive field control; Continuity Counter: Continuous counter; Adaptation Field: Adaptive field; Adaptation FieldLength: Adaptive field length; Discontinuity Indicator: Non-continuous identifier; Random AccessIndicator: random access identifier; Elementary Stream Priority Indicator: original code stream priority identifier; 5Flags: 5 identifiers; Optional Fields: optional field; Stuffing Bytes: filling bytes; PCR (ProgramClock Reference): Program reference clock; OPCR (Original Program Clock Reference): original program reference clock; Splice Countdown: splicing countdown; Transport Private Data Length: transmission private data length; Transport Private Data: transmission private data; Adaptation Field ExtensionLength: adaptive field extension length ;3Flags: 3 flags; Optional Fields: optional field; LTW_valid flag(legal time window): legal time window flag; LTW offset(legal time window): legal time window offset; Piecewise Rate: segmentation rate; Splice Type : connector type; DTS_next_au (decoding timestamp next access unit): decoding timestamp next access unit.

图5是RTSP信令交互图,其中,REGISTER+MD5:摘要加密的注册信令;200OK:接收验证成功;OPTION:可选信令;DESCRIBE:描述信令;401Unauthorized+nonce:携带一个随机数的授权验证失败信令,代号401;DESCRIBE+username+response:携带用户名和经过随机数加密的响应描述信令;200OK+sdp:会话描述成功信令;SETUP+Transport:携带端口号的建立会话信令;100Try:正在尝试;200OK+session+transport:会话ID和端口信息;PLAY+session:会话ID上播放的信令;200OK+RTP Info:RTP传输信息;TS/RTP/UDP:用RTP包来传输TS视频流;TEARDOWN+session:会话ID上关闭的信令。Figure 5 is an interaction diagram of RTSP signaling, where, REGISTER+MD5: Digest-encrypted registration signaling; 200OK: Received and verified successfully; OPTION: Optional signaling; DESCRIBE: Description signaling; 401Unauthorized+nonce: Carrying a random number Authorization verification failure signaling, code 401; DESCRIBE+username+response: carrying username and random number encrypted response description signaling; 200OK+sdp: session description success signaling; SETUP+Transport: session establishment signaling carrying port number ;100Try: trying; 200OK+session+transport: session ID and port information; PLAY+session: signaling played on the session ID; 200OK+RTP Info: RTP transmission information; TS/RTP/UDP: use RTP packets to transmit TS video stream; TEARDOWN+session: Signaling of closing on session ID.

图6是IOS设备线程池管理图Figure 6 is the IOS device thread pool management diagram

具体实施方式detailed description

下面结合附图对本发明作进一步描述。The present invention will be further described below in conjunction with the accompanying drawings.

参照图1~图6,一种基于MPEG-2标准的移动直播系统,包括移动设备端、流媒体服务器和播放器端,所述移动设备端包括视频数据采集子系统,所述视频数据采集子系统包括H264视频压缩编码模块、MPEG-2标准封包模块和线程池模块;所述H264视频压缩编码模块中,调用IOS系统层的API接口,开启摄像功能,采集到原始的视频数据,对采集过来的每一帧进行H264编码,得到ES基本码流;所述的MPEG-2标准封包模块中,基于MPEG-2标准的视频压缩编码,将H.264编码出的ES流打包成PES流,PES流再按188B的固定长度加上辅助数据组成TS码流,然后将TS码流放到RTP缓存池中;所述的线程池模块与RTSP信令模块、RTP传输模块连接;所述RTSP信令模块中,启动一个监听RTSP信令的服务,所述RTP传输模块中,当检测到RTP缓存池里的数据不为空时,就从缓存池中读取TS码流数据,向流媒体服务器发送RTP包,直到RTP缓存池里数据为空;With reference to Fig. 1~Fig. 6, a kind of mobile live broadcasting system based on MPEG-2 standard comprises mobile device end, streaming media server and player end, and described mobile device end comprises video data collecting subsystem, and described video data collecting sub-system System comprises H264 video compression coding module, MPEG-2 standard encapsulation module and thread pool module; In described H264 video compression coding module, call the API interface of IOS system layer, open camera function, collect original video data, come to collection Each frame of H264 is encoded to obtain the ES basic code stream; in the described MPEG-2 standard packet module, based on the video compression encoding of the MPEG-2 standard, the ES stream encoded by H.264 is packaged into a PES stream, and the PES The fixed length of 188B adds the auxiliary data to form the TS code stream, and then puts the TS code stream in the RTP buffer pool; the thread pool module is connected with the RTSP signaling module and the RTP transmission module; the RTSP signaling module , start a service to monitor RTSP signaling, in the RTP transmission module, when it is detected that the data in the RTP buffer pool is not empty, it will read the TS stream data from the buffer pool, and send RTP to the streaming media server packet until the data in the RTP buffer pool is empty;

所述流媒体服务器包括直播数据转发模块、RTCP码率控制模块、视频点播模块及RTSP信令模块,所述的直播数据转发模块中,将所有的视频数据转发;所述RTCP码率控制模块中,采用RTCP网际协议,对IOS设备直播软件采集发送的数据包和流媒体服务器端接受到的数据包进行统计和反馈,在发生网络拥塞时,以控制和调节IOS直播软件端采集发送的码率;所述视频点播模块中,对IOS直播软件上传的视频文件进行保存并满足IOS直播软件随时随地的回放。Described streaming media server comprises live data forwarding module, RTCP bit rate control module, video on demand module and RTSP signaling module, in described live data forwarding module, all video data is forwarded; In described RTCP bit rate control module , using the RTCP Internet Protocol to make statistics and feedback on the data packets collected and sent by the IOS device live broadcast software and the data packets received by the streaming media server, in order to control and adjust the code rate collected and sent by the IOS live broadcast software when network congestion occurs ; In the video-on-demand module, the video file uploaded by the IOS live broadcast software is saved and meets the playback of the IOS live broadcast software anytime and anywhere.

所述移动直播系统还包括RTSP信令服务器,用于发出RTSP请求开启信令或RTSP请求停止信令。The mobile live broadcast system also includes an RTSP signaling server, which is used for sending RTSP request start signaling or RTSP request stop signaling.

进一步,所述线程池模块中,在IOS设备上线时,会和RTSP信令模块通信,启动一个监听RTSP信令的服务,当收到来自远程RTSP信令服务器的RTSP请求开启信令时,向H264视频压缩编码模块发送开启摄像采集消息,进行视频采集,同时激活RTP传输模块,开辟一个RTP缓存池,用于存放MPEG-2标准封包模块所产生的TS码流数据;当收到来自远程RTSP信令服务器的RTSP请求停止信令时,向H264视频压缩编码模块发送关闭摄像采集消息,停止视频采集。Further, in the thread pool module, when the IOS device goes online, it will communicate with the RTSP signaling module, start a service to monitor the RTSP signaling, and when receiving the RTSP request from the remote RTSP signaling server to open the signaling, send The H264 video compression coding module sends a camera capture message to start video capture, and at the same time activates the RTP transmission module to open up an RTP buffer pool for storing the TS stream data generated by the MPEG-2 standard packet module; When the RTSP request of the signaling server stops the signaling, it sends a closing camera collection message to the H264 video compression coding module to stop the video collection.

更进一步,所述视频数据采集子系统还包括RTCP控制模块:和RTCP码率控制模块建立另一条链接,配合监控网络状况,根据不同的网络状况进行实时的调整摄像头采集视频的帧率以调整发送出去的码率来适应网络的变化。Furthermore, the video data acquisition subsystem also includes an RTCP control module: establish another link with the RTCP code rate control module, cooperate with monitoring network conditions, and adjust the frame rate of the video captured by the camera in real time according to different network conditions to adjust the sending The outbound bit rate adapts to changes in the network.

所述视频数据采集子系统还包括REGISTER模块,在软件开启时向服务器注册设备,成为一个上线的设备。The video data acquisition subsystem also includes a REGISTER module, which registers the device with the server when the software is started, and becomes an online device.

所述视频数据采集子系统还包括本地保存模块,在直播的同时,对摄像头采集编码出的TS流数据进行保存,用户能对历史录像进行观看。The video data collection subsystem also includes a local storage module, which saves the TS stream data collected and coded by the camera during the live broadcast, and the user can watch the historical video.

本实施例中,移动直播系统基本流程包括移动设备端现场视频的拍摄、压缩编码、视频数据格式封装、RTP封装和数据发送,及本地录像数据的保存;接收端接收数据、解封装、数据储存、视频信号发生,主要采用市场已有的支持RTSP协议的主流播放器,可进行二次开发扩展;流媒体服务器实现根据播放器的请求对移动设备端的视频数据进行转发,以及采用RTCP控制协议优化移动设备端的码率,自适应网络带宽,以求最佳的用户体验;RTSP信令服务器负责系统中信令控制消息的传输、转发,是系统通信协议实现的关键部分,同时又要负责对系统中各个终端的管理,完成发送端、接收端和RTSP信令服务器的交互会话。这种平台化的设计既方便了对移动设备端和播放器端的统一管理,又能增强系统整体的负载能力。移动直播系统的设计框架如图1所示。In this embodiment, the basic process of the mobile live broadcast system includes the shooting of live video on the mobile device, compression encoding, video data format encapsulation, RTP encapsulation and data transmission, and preservation of local video data; the receiving end receives data, decapsulates, and stores data , The video signal is generated, mainly using the mainstream player that supports the RTSP protocol already in the market, which can be used for secondary development and expansion; the streaming media server realizes the forwarding of the video data of the mobile device according to the request of the player, and adopts the RTCP control protocol to optimize The code rate on the mobile device side adapts to the network bandwidth for the best user experience; the RTSP signaling server is responsible for the transmission and forwarding of signaling control messages in the system, which is a key part of the system communication protocol. The management of each terminal in the network completes the interactive session between the sending end, the receiving end and the RTSP signaling server. This platform-based design not only facilitates the unified management of mobile devices and players, but also enhances the overall load capacity of the system. The design framework of the mobile live broadcast system is shown in Figure 1.

针对移动设备端以IOS手机为例,视频采集软件需要利用ffmpeg编码库将原始图像数据编码成H264视频帧并转换成TS流数据包,采用的线程池技术降低各个模块之间的耦合度,让各个模块可以独立编程,功能模块设计框图如图2所示。模块设计为:For mobile devices, taking IOS mobile phones as an example, the video capture software needs to use the ffmpeg encoding library to encode the original image data into H264 video frames and convert them into TS stream data packets. The thread pool technology used reduces the coupling between modules, allowing Each module can be programmed independently, and the functional module design block diagram is shown in Figure 2. The module is designed to:

摄像头:主要负责实时采集原始数据;预览:主要给用户观看当前采集的实时画面;H.264编码模块:将摄像头采集到的原始图像数据进行H.264压缩编码,便于在网络中传输,减少发送到网络中的码率;TS码流封装模块:基于MPEG-2标准的视频压缩编码,将H.264编码出的ES流打包成PES流,PES流再按188B的固定长度加上辅助数据组成TS码流;RTP打包:将已封装好的TS码流打包成RTP包,然后将打包好的RTP包发送给流媒体服务器,并且对已发送成功的RTP包进行统计,反馈给RTCP控制模块;3G/4G/WIFI模块:选择最好的网络条件发送RTP包。RTCP控制模块:这个模块会和流媒体的RTCP码率控制模块建立另一条链接,配合监控网络状况,根据不同的网络状况进行实时的调整摄像头采集视频的帧率以调整发送出去的码率来适应网络的变化,避免网络拥塞而导致更严重的丢包现象,提高用户的观看体验;REGISTER模块:在软件开启时向服务器注册设备,成为一个上线的设备;本地保存模块:设备在直播的同时,对摄像头采集编码出的TS流数据进行保存,为了用户能进行对历史录像进行观看,主要包含两个文件,一个是.M3U8文件,用于单码率适配流的HLS技术,项目中只用到了一种CIF码率,一个是.ts文件,存储视频数据的切片媒体文件;WIFI上传:当用户处于网络状况不良好的情况下,用户也可以先进行视频录像的录制,并且保存至本地待WiFi网络下上传至远程的HLS视频点播服务器,实现其他用户随时随地的点播录像视频;本地HLS和本地播放:建立本地HLS服务,本地回看录像文件。Camera: mainly responsible for real-time collection of raw data; preview: mainly for users to watch the real-time images currently collected; H.264 encoding module: compress and encode the original image data collected by the camera in H.264, which is convenient for transmission in the network and reduces transmission Bit rate to the network; TS stream encapsulation module: based on MPEG-2 standard video compression encoding, the ES stream encoded by H.264 is packaged into a PES stream, and the PES stream is composed of a fixed length of 188B plus auxiliary data TS code stream; RTP packaging: pack the packaged TS code stream into RTP packets, then send the packaged RTP packets to the streaming media server, and count the successfully sent RTP packets, and feed them back to the RTCP control module; 3G/4G/WIFI module: choose the best network conditions to send RTP packets. RTCP control module: This module will establish another link with the RTCP bit rate control module of streaming media, cooperate with monitoring network conditions, and adjust the frame rate of video captured by the camera in real time according to different network conditions to adjust the bit rate sent out to adapt Changes in the network can avoid more serious packet loss caused by network congestion and improve the viewing experience of users; REGISTER module: register the device with the server when the software is started, and become an online device; local save module: when the device is live, Save the TS stream data collected and encoded by the camera. In order for the user to watch the historical video, it mainly includes two files, one is the .M3U8 file, which is used for the HLS technology of the single bit rate adaptive stream. There is a CIF bit rate, one is a .ts file, which stores sliced media files of video data; WIFI upload: when the user is in a bad network condition, the user can also record the video first, and save it locally for later Upload to the remote HLS video-on-demand server under the WiFi network to realize video-on-demand video for other users anytime and anywhere; local HLS and local playback: establish a local HLS service, and watch the video files locally.

从H264视频帧数据封装成TS码流需要将H264视频帧数据包裹一层PES的头,就形成了PES包,通常PES包的长度并不固定,一般情况下一个视频帧生成一个PES包。在PES包中会加入PTS(Presentation Time Stamp)和DTS(Decoding Time Stamp)数据,PES包按照MPEG-2标准附上系统信息而成为TS包,进而组成完整的TS码流。PES包的起始码由包的起始码前缀和流标识构成包起始码前缀是一个固定的码字结构,它的值为0x000001,用于收发两端对PES包进行同步。流标识设定了基本码流类型,编码器所生成的每一个ES码流均被分配了唯一的识别标志ID号,依据这个ID号,可对多达几十路的视频ES流进行识别和复用。如图3所示,其中PTS和DTS为两个主要的功能域参数,其他标识位可根据不同的应用场合而有所不同,PTS用于通知解码器何时显示一个已解码的图像帧,而DTS指示何时对接受到的一帧图像的编码码流进行解码。如图4所示,PES封装成TS包时,PCR(Program ClockReference)作为一个非常主要的指标,指示着系统时钟本身的瞬时值得时间标签,用于解码端恢复出于编码端一致的系统时序时钟STC(System Time Clock)。PTS和DTS正是依赖STC才能在解码端以正常的速率进行解码和显示。PCR在TS包头中共占用6Bytes,其中预留6bits,其他42bits有效位又分为两部分:33bits的PCR-Base和9bits的PCR-Ext。PCR-Ease是由27MHz脉冲经300分频后的90kHz脉冲触发计数器,再对计数器状态进行取样得到的;PCR-Ext是由27MHz脉冲直接触发计数器,再对计数器状态进行取样得到的。Encapsulating H264 video frame data into TS code stream requires wrapping H264 video frame data with a PES header to form a PES packet. Usually, the length of a PES packet is not fixed. Generally, one video frame generates a PES packet. PTS (Presentation Time Stamp) and DTS (Decoding Time Stamp) data are added to the PES packet, and the PES packet is attached with system information according to the MPEG-2 standard to become a TS packet, thereby forming a complete TS stream. The start code of the PES packet is composed of the start code prefix of the packet and the flow identifier. The start code prefix of the packet is a fixed code word structure, and its value is 0x000001, which is used to synchronize the PES packet at both the sending and receiving ends. The stream identifier sets the basic stream type, and each ES stream generated by the encoder is assigned a unique identification ID number. According to this ID number, up to dozens of video ES streams can be identified and reuse. As shown in Figure 3, PTS and DTS are two main functional domain parameters, and other identification bits can vary according to different applications. PTS is used to inform the decoder when to display a decoded image frame, and The DTS indicates when to decode the received coded stream of a frame of image. As shown in Figure 4, when PES is encapsulated into TS packets, PCR (Program ClockReference) is a very important indicator, indicating the instantaneous value time tag of the system clock itself, which is used by the decoding end to restore the system timing clock consistent with the encoding end STC (System Time Clock). PTS and DTS rely on STC to decode and display at a normal rate at the decoder. PCR occupies a total of 6Bytes in the TS header, of which 6bits are reserved, and the other 42bits are divided into two parts: 33bits of PCR-Base and 9bits of PCR-Ext. PCR-Ease is obtained by triggering the counter with a 90kHz pulse after 27MHz pulse divided by 300, and then sampling the state of the counter; PCR-Ext is obtained by directly triggering the counter with a 27MHz pulse, and then sampling the state of the counter.

设备在开启时调用REGISTER模块,向RTSP信令服务器注册设备,注册成功则成为在线设备,供RTSP信令服务器调度。利用开源的VLC播放器作为PC端的支持RTSP协议的测试播放器,打开网络串流rtsp://192.168.1.167:8554/test,会向RTSP信令服务器发送RTSP请求串流信令,当RTSP信令服务器接到信令时进行验证,成功则去请求设备开启视频直播功能,如果设备接受请求,则告诉设备需要发送RTP包的目的IP和端口,也就是流媒体服务器的IP和接收端口,并返回请求成功和RTP信息给VLC播放器,这样通过中间的流媒体服务器,建立了一条从设备端到PC播放器的视频流传输链路。基本的RTSP信令交互过程如图5所示。When the device is turned on, it calls the REGISTER module to register the device with the RTSP signaling server. If the registration is successful, it becomes an online device for scheduling by the RTSP signaling server. Use the open source VLC player as a test player supporting the RTSP protocol on the PC side, open the network stream rtsp://192.168.1.167:8554/test, and send the RTSP request stream signaling to the RTSP signaling server. When the RTSP signal Make the server verify when it receives the signaling. If it succeeds, it will request the device to enable the live video function. If the device accepts the request, it will tell the device the destination IP and port of the RTP packet that needs to be sent, that is, the IP and receiving port of the streaming media server, and Return the request success and RTP information to the VLC player, so that a video stream transmission link from the device to the PC player is established through the intermediate streaming server. The basic RTSP signaling interaction process is shown in Figure 5.

参照图6,采用线程池进行统一管理RTSP信令模块、H264视频的编码、TS包的封装、RTP传输模块及分配RTP缓存空间降低了各个模块的耦合度,实现更灵活,扩展性更好。在IOS设备REGISTER上线时,线程池模块会和RTSP模块通信,启动一个监听RTSP信令的服务,当收到来自远程RTSP服务器的RTSP请求开启信令时,线程池进行资源分配,并向H264视频压缩编码模块发送开启摄像采集消息,进行视频采集,同时激活RTP传输模块,开辟一个RTP缓存池,用于存放MPEG-2标准封包模块所产生的TS码流数据;当收到来自远程RTSP服务器的RTSP请求停止信令时,向H264视频压缩编码模块发送关闭摄像采集消息,停止视频采集,进行线程回收;当RTP传输模块检测到RTP缓存池里的数据不为空时,就从缓存池中读取TS码流数据,向流媒体服务器发送RTP包,直到RTP缓存池里数据为空,如果收到RTSP的停止信令,则把RTP线程回收,同时回收RTP缓存区。Referring to Figure 6, the use of thread pools for unified management of RTSP signaling modules, H264 video encoding, TS packet encapsulation, RTP transmission modules, and allocation of RTP buffer space reduces the coupling of each module, making it more flexible and scalable. When the IOS device REGISTER goes online, the thread pool module will communicate with the RTSP module and start a service that monitors RTSP signaling. When receiving an RTSP request from a remote RTSP server to enable signaling, the thread pool will allocate resources and send H264 video The compression encoding module sends the camera acquisition message to start video acquisition, and at the same time activates the RTP transmission module to open up an RTP buffer pool for storing the TS code stream data generated by the MPEG-2 standard packet module; When the RTSP requests to stop signaling, send the closing camera acquisition message to the H264 video compression encoding module, stop the video acquisition, and perform thread recovery; when the RTP transmission module detects that the data in the RTP buffer pool is not empty, it reads from the buffer pool Fetch TS code stream data, send RTP packets to the streaming media server until the data in the RTP buffer pool is empty, if the RTSP stop signal is received, the RTP thread is recycled, and the RTP buffer area is recycled at the same time.

Claims (1)

1. a kind of mobile live broadcast system based on Moving Picture Experts Group-2, including mobile device end, streaming media server and player end, It is characterized in that:The mobile device end includes video data acquiring subsystem, and the video data acquiring subsystem includes H264 video compression codings module, Moving Picture Experts Group-2 package module and thread pool module;The H264 video compression codings module In, the api interface of IOS system layers is called, camera function is opened, collects original video data, what collection was come is each Frame carries out H264 codings, obtains ES elementary streams;In described Moving Picture Experts Group-2 package module, the video based on Moving Picture Experts Group-2 Compressed encoding, PES streams are packaged into by the ES streams H.264 encoded out, and PES streams add helper data set by 188B regular length again Into TS code streams, then TS code streams are put into RTP cache pools;Described thread pool module and RTSP signalling modules, RTP transmission moulds Block is connected;In the RTSP signalling modules, start in the service of a monitoring RTSP signaling, the RTP transport modules, work as detection Data in RTP cache pools are not space-time, and TS bit stream datas are just read from cache pool, RTP is sent to streaming media server Bag, until RTP cache pools mileage evidence is sky;
The streaming media server includes live data forwarding module, RTCP rate control modules, video request program module and RTSP In signalling module, described live data forwarding module, all video datas are forwarded;The RTCP rate control modules In, using RTCP Internet protocols, what packet and the streaming media server termination that software collection live to ios device is sent were subject to Packet is counted and fed back, when occurring network congestion, and the code sent is gathered to control and adjust the live software ends of IOS Rate;In the video request program module, the video file of the live software uploads of IOS is preserved and meet the live softwares of IOS with When playback everywhere;
The mobile live broadcast system also includes RTSP signal servers, and for sending, signaling is opened in RTSP requests or RTSP requests stop Only signaling;
In the thread pool module, when ios device is reached the standard grade, it can start one with the communication of RTSP signalling modules and monitor RTSP letters The service of order, when receiving the request unlatching signalings of the RTSP from long-range RTSP signal servers, to H264 video compression codings Module, which is sent, opens shooting collection message, carries out video acquisition, while activating RTP transport modules, opens up a RTP cache pool, For depositing the TS bit stream datas produced by Moving Picture Experts Group-2 package module;When receiving from long-range RTSP signal servers When RTSP requests stop signaling, sent to H264 video compression codings module and close shooting collection message, stop video acquisition;
The video data acquiring subsystem also includes RTCP control modules:Another chain is set up with RTCP rate control modules Connect, coordinate monitoring network condition, carry out the frame per second of adjustment camera collection video in real time to adjust according to different network conditions The code check seen off is haircuted to adapt to the change of network;
The video data acquiring subsystem also includes REGISTER modules, when software is opened to server registration equipment, into For the equipment reached the standard grade;
The video data acquiring subsystem also includes local preservation module, live while, and camera capturing and coding is gone out TS flow datas preserved, user can to history video recording watch.
CN201410293451.9A 2014-06-25 2014-06-25 A mobile live broadcast system based on MPEG‑2 standard Active CN104038844B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410293451.9A CN104038844B (en) 2014-06-25 2014-06-25 A mobile live broadcast system based on MPEG‑2 standard

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410293451.9A CN104038844B (en) 2014-06-25 2014-06-25 A mobile live broadcast system based on MPEG‑2 standard

Publications (2)

Publication Number Publication Date
CN104038844A CN104038844A (en) 2014-09-10
CN104038844B true CN104038844B (en) 2017-07-25

Family

ID=51469410

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410293451.9A Active CN104038844B (en) 2014-06-25 2014-06-25 A mobile live broadcast system based on MPEG‑2 standard

Country Status (1)

Country Link
CN (1) CN104038844B (en)

Families Citing this family (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104506883A (en) * 2014-12-11 2015-04-08 成都德芯数字科技有限公司 Audio and video encoder based on wide area network live broadcast and working method thereof
CN105992013A (en) * 2015-02-05 2016-10-05 天脉聚源(北京)科技有限公司 RTSP live broadcast video recording method and system
CN106210925A (en) * 2015-05-05 2016-12-07 阿里巴巴集团控股有限公司 The decoding method of a kind of real-time media stream and device
CN105049918A (en) * 2015-07-08 2015-11-11 成都西可科技有限公司 Method for separating local recorded video and network live video
CN105430430B (en) * 2015-11-24 2019-07-23 上海梯方教育科技有限公司 Intelligent terminal network communication means
CN105430530B (en) * 2015-11-24 2019-05-03 上海熙菱信息技术有限公司 A kind of video stream forwarding method and system avoiding network congestion and frame losing
CN105491397B (en) * 2015-12-01 2019-02-22 深圳市福云明网络科技有限公司 The method pushed in real time based on the video that UDT agreement and TS slice combine
CN105812895A (en) * 2016-03-17 2016-07-27 张俊莲 Video on-demand data processing method and system
CN106534804B (en) * 2016-12-14 2019-07-05 成都中科大旗软件有限公司 A kind of scenic spot flow medium live system
CN107204093A (en) * 2017-05-22 2017-09-26 上海热像机电科技股份有限公司 A kind of method and system for determining triggering alert position
CN107864125A (en) * 2017-10-26 2018-03-30 苏州市伏泰信息科技股份有限公司 Environmental sanitation unified monitoring management platform
CN108415855A (en) * 2018-03-06 2018-08-17 珠海全志科技股份有限公司 It makes video recording file memory method and device, computer installation and storage medium
CN110049346A (en) * 2019-04-10 2019-07-23 视联动力信息技术股份有限公司 A kind of method and system of net cast
CN114173144A (en) * 2021-12-02 2022-03-11 北京优祥智恒科技有限公司 Live broadcast equipment, control method thereof and live broadcast backpack

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101902524A (en) * 2010-07-13 2010-12-01 上海未来宽带技术及应用工程研究中心有限公司 Mobile phone capable of being taken as video source of live video system and audio-video transmission method
CN101945096A (en) * 2010-07-13 2011-01-12 上海未来宽带技术及应用工程研究中心有限公司 Video live broadcast system facing to set-top box and PC of mobile phone and working method thereof
CN102137098A (en) * 2011-01-25 2011-07-27 北京天纵网联科技有限公司 Method for on-line real-time recording and forwarding of audio/ video streams by mobile internet terminal
CN103501392A (en) * 2013-10-16 2014-01-08 江西省文明手机台传播有限责任公司 Method for performing real-time audio and video shooting and live broadcast by using mobile phone

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101902524A (en) * 2010-07-13 2010-12-01 上海未来宽带技术及应用工程研究中心有限公司 Mobile phone capable of being taken as video source of live video system and audio-video transmission method
CN101945096A (en) * 2010-07-13 2011-01-12 上海未来宽带技术及应用工程研究中心有限公司 Video live broadcast system facing to set-top box and PC of mobile phone and working method thereof
CN102137098A (en) * 2011-01-25 2011-07-27 北京天纵网联科技有限公司 Method for on-line real-time recording and forwarding of audio/ video streams by mobile internet terminal
CN103501392A (en) * 2013-10-16 2014-01-08 江西省文明手机台传播有限责任公司 Method for performing real-time audio and video shooting and live broadcast by using mobile phone

Also Published As

Publication number Publication date
CN104038844A (en) 2014-09-10

Similar Documents

Publication Publication Date Title
CN104038844B (en) A mobile live broadcast system based on MPEG‑2 standard
US10826958B2 (en) Content server media stream management
US8819714B2 (en) Ratings and quality measurements for digital broadcast viewers
US9031078B2 (en) Modification of live streams
CN112752115B (en) Live broadcast data transmission method, device, equipment and medium
US20160337424A1 (en) Transferring media data using a websocket subprotocol
US20150181003A1 (en) Method and apparatus for transmitting and receiving packets in hybrid transmission service of mmt
US9577682B2 (en) Adaptive forward error correction (FEC) system and method
CN107409234A (en) File format based streaming utilizing DASH format based on LCT
KR102076064B1 (en) Robust live operation of dash
US20180176278A1 (en) Detecting and signaling new initialization segments during manifest-file-free media streaming
JP6903172B2 (en) Equipment and methods for live uplink adaptive streaming
KR20190029551A (en) Media data transmission apparatus and method, and media data reception apparatus and method in mmt system
CN107147916B (en) Method for transmitting H.265 coding video data on transmission layer
KR102098723B1 (en) Method configuring and transmitting mmt transport packet
TW202448163A (en) Signaling media timing information from a media application to a network element
KR20140104975A (en) System and method for multiplexed streaming of multimedia content
Paulsen et al. MPEG-4/AVC versus MPEG-2 in IPTV.
US20250119372A1 (en) Real-time transport (rtp) header extension binding and rtp header extension for in-band delay measurement on either end device
WO2025076172A1 (en) Real-time transport (rtp) header extension binding and rtp header extension for in-band delay measurement on either end device
KR20150047958A (en) Method For Producing RTP Timestamp In Mobile Communication Terminal

Legal Events

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