[go: up one dir, main page]

CN115209230A - Method for realizing real-time video transmission based on RTMP protocol - Google Patents

Method for realizing real-time video transmission based on RTMP protocol Download PDF

Info

Publication number
CN115209230A
CN115209230A CN202110391578.4A CN202110391578A CN115209230A CN 115209230 A CN115209230 A CN 115209230A CN 202110391578 A CN202110391578 A CN 202110391578A CN 115209230 A CN115209230 A CN 115209230A
Authority
CN
China
Prior art keywords
video
rtmp
video data
data
transmission
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.)
Pending
Application number
CN202110391578.4A
Other languages
Chinese (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.)
Individual
Original Assignee
Individual
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 Individual filed Critical Individual
Priority to CN202110391578.4A priority Critical patent/CN115209230A/en
Publication of CN115209230A publication Critical patent/CN115209230A/en
Pending legal-status Critical Current

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/60Network structure or processes for video distribution between server and client or between remote clients; Control signalling between clients, server and network components; Transmission of management data between server and client, e.g. sending from server to client commands for recording incoming content stream; Communication details between server and client 
    • H04N21/63Control signaling related to video distribution between client, server and network components; Network processes for video distribution between server and clients or between remote clients, e.g. transmitting basic layer and enhancement layers over different transmission paths, setting up a peer-to-peer communication via Internet between remote STB's; Communication protocols; Addressing
    • H04N21/643Communication protocols
    • 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/25Management operations performed by the server for facilitating the content distribution or administrating data related to end-users or client devices, e.g. end-user or client device authentication, learning user preferences for recommending movies
    • H04N21/262Content or additional data distribution scheduling, e.g. sending additional data at off-peak times, updating software modules, calculating the carousel transmission frequency, delaying a video stream transmission, generating play-lists
    • H04N21/26208Content or additional data distribution scheduling, e.g. sending additional data at off-peak times, updating software modules, calculating the carousel transmission frequency, delaying a video stream transmission, generating play-lists the scheduling operation being performed under constraints
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/80Generation or processing of content or additional data by content creator independently of the distribution process; Content per se
    • H04N21/85Assembly of content; Generation of multimedia applications
    • H04N21/858Linking data to content, e.g. by linking an URL to a video object, by creating a hotspot
    • H04N21/8586Linking data to content, e.g. by linking an URL to a video object, by creating a hotspot by using a URL
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N7/00Television systems
    • H04N7/18Closed-circuit television [CCTV] systems, i.e. systems in which the video signal is not broadcast

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Databases & Information Systems (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention relates to a method for realizing real-time video transmission based on an RTMP protocol, which transmits video data to a streaming media server in a local area network environment for scheduling and using by a client. The method for realizing real-time video transmission comprises three stages of video frame data uploading, streaming media server storage and client streaming. In the video frame data uploading stage, the video data acquired by the network camera is uploaded to the streaming media server in the form of RTMP packets, so that the reliability of the transmission process is ensured; the streaming media server ensures the real-time property of transmission through an RTMP real-time module of Nginx; the client pull stream adopts the video stream transmitted by the FFmpeg decoding server to ensure the video accuracy. The method uses the local area network to maintain the overall operation Of the system, and improves the real-time performance Of the video transmission system by adjusting the interval Of GOPs (Group Of Pictures) in the video uploading and receiving.

Description

一种基于RTMP协议的实时视频传输的实现方法A realization method of real-time video transmission based on RTMP protocol

技术领域technical field

本发明涉及一种基于RTMP协议的实时视频传输的实现方法。实时视频传输是视频监控系统的核心组成部分,属于通信领域。它广泛应用于直播,交通,医疗以及军事等各个领域。The invention relates to a realization method of real-time video transmission based on RTMP protocol. Real-time video transmission is the core component of video surveillance system and belongs to the field of communication. It is widely used in various fields such as live broadcast, transportation, medical treatment and military.

背景技术Background technique

在传输协议领域中,业界一直使用RTP作为传输视频流的网络协议,这种协议是依靠UDP网络协议进行传输,由于UDP是无连接且不可靠的,因此在网络传输时容易导致丢包、时延、抖动,当网络状况不佳时,会严重影响用户的体验。而RTMP协议使用TCP作为传输层的协议,可以有效保证视频流的传输质量,且支持声音以及视频从服务器到客户端的动态传输。此外RTMP协议支持的FLV封装格式能够在低码率的状况下显示清晰的画面,非常适用于带宽不足的情况下观看视频。采用RTMP协议传输视频数据具有可靠性,稳定性的作用。In the field of transmission protocols, the industry has always used RTP as the network protocol for transmitting video streams. This protocol relies on the UDP network protocol for transmission. Since UDP is connectionless and unreliable, it is easy to cause packet loss and time loss during network transmission. Delay and jitter, when the network condition is poor, it will seriously affect the user experience. The RTMP protocol uses TCP as the transport layer protocol, which can effectively ensure the transmission quality of the video stream, and supports the dynamic transmission of sound and video from the server to the client. In addition, the FLV encapsulation format supported by the RTMP protocol can display a clear picture under low bit rate conditions, which is very suitable for watching videos when the bandwidth is insufficient. The use of RTMP protocol to transmit video data has the effect of reliability and stability.

本发明提出的基于RTMP协议的实时视频传输的实现方法,通过网络摄像头采集视频数据,并基于RTMP协议将视频数据传送到Nginx流媒体服务器中,通过Nginx的epoll并发技术提供3000条左右的请求连接数,提高了视频传输的可靠性和实时性。The realization method of real-time video transmission based on RTMP protocol proposed by the present invention collects video data through a network camera, transmits the video data to Nginx streaming media server based on RTMP protocol, and provides about 3000 request connections through Nginx's epoll concurrency technology It improves the reliability and real-time performance of video transmission.

发明内容SUMMARY OF THE INVENTION

本发明的目的在于,提供一种基于RTMP协议的实时视频传输的实现方法,能够有效解决视频数据传输过程的丢包问题以及视频播放过程中产生的画面卡顿问题,具有视频数据传输高效以及低延迟等特点。The purpose of the present invention is to provide a realization method of real-time video transmission based on RTMP protocol, which can effectively solve the problem of packet loss in the process of video data transmission and the problem of picture jamming in the process of video playback, and has the advantages of high efficiency and low cost of video data transmission. delay, etc.

本发明是采用以下技术手段实现的:The present invention adopts the following technical means to realize:

1.一种基于RTMP协议的实时视频传输的实现方法,其视频传输过程分为视频帧数据上传、流媒体服务器存储和客户端拉流三个阶段:1. A realization method of real-time video transmission based on RTMP protocol, its video transmission process is divided into three stages of video frame data upload, streaming media server storage and client pull stream:

1.1通过远程网络摄像头采集高清视频数据,然后将该视频数据格式转换为YUV420格式,再按照H264标准进行编码,最后通过FFmpeg软件封装上下文转换为符合RTMP协议传输要求的FLV格式文件;1.1 Collect high-definition video data through a remote network camera, then convert the video data format to YUV420 format, encode it according to the H264 standard, and finally convert the context into an FLV format file that meets the RTMP protocol transmission requirements through FFmpeg software;

1.2流媒体服务器采用Nginx轻量级服务器,能够为上传的视频数据提供对应的网址进行存储或广播,在接收或者广播的过程中,建立RTMP连接通道进行传输,视频数据到达流媒体服务器后,通过其自身的epoll技术实现对多个客户端的并发连接;1.2 The streaming media server adopts the Nginx lightweight server, which can provide the corresponding URL for the uploaded video data for storage or broadcasting. During the process of receiving or broadcasting, an RTMP connection channel is established for transmission. After the video data reaches the streaming media server, it is Its own epoll technology realizes concurrent connections to multiple clients;

1.3视频监控系统客户端通过Qt框架搭建,采用循环开启线程的方式接收流媒体服务器广播的视频数据,每次线程的开启都会打开一条通道进行传输,并对每条线程进行监测,当线程停止进行解码视频时立即释放资源;1.3 The video surveillance system client is built through the Qt framework, and the video data broadcast by the streaming media server is received by the method of cyclically opening the thread. Every time the thread is opened, a channel is opened for transmission, and each thread is monitored. Release resources immediately when decoding video;

1.4通过创建FIFO缓冲队列以解决画面失真问题,首先客户端接收流媒体服务器传输的视频数据,将数据存储到FIFO缓存队列,解码器从FIFO缓存队列中读取视频数据进行解码,空闲的空间继续缓存视频数据。1.4 To solve the problem of picture distortion by creating a FIFO buffer queue, first the client receives the video data transmitted by the streaming media server, stores the data in the FIFO buffer queue, the decoder reads the video data from the FIFO buffer queue for decoding, and the free space continues Cache video data.

2.根据权利要求1所述的一种基于RTMP协议的实时视频传输的实现方法,其特征在于:视频输入源将数据传递给FFmpeg,经过编码、封装后以RTMP数据格式上传给Nginx服务器,然后服务器将数据转发给客户端。其中在上传数据建立网络连接前,服务器内部通过调用ngx_rtmp_handshake函数和ngx_rtmp_handshake_recv函数使视频推送端和服务器进行握手操作,选用Nginx的nginx-rtmp模块搭建流媒体服务器,然后通过对配置文件中rtmp模块的修改,实现视频数据流的转发。2. the realization method of a kind of real-time video transmission based on RTMP protocol according to claim 1, is characterized in that: video input source transmits data to FFmpeg, is uploaded to Nginx server with RTMP data format after encoding, encapsulation, then The server forwards the data to the client. Before uploading data to establish a network connection, the server internally calls the ngx_rtmp_handshake function and the ngx_rtmp_handshake_recv function to make the video pusher and the server perform handshake operations, select the nginx-rtmp module of Nginx to build the streaming media server, and then modify the rtmp module in the configuration file. , to realize the forwarding of the video data stream.

3.根据权利要求1所述的一种基于RTMP协议的实时视频传输的实现方法,其特征在于:前述1.2中Nginx服务器建立多个RTMP连接进行传输数据,这其中包括一个客户端中多个通道的连接以及多个客户端中多个通道的连接。3. the realization method of a kind of real-time video transmission based on RTMP protocol according to claim 1 is characterized in that: among the aforementioned 1.2, Nginx server establishes multiple RTMP connections to carry out data transmission, and this comprises multiple channels in a client connections and connections to multiple channels across multiple clients.

4.根据权利要求1所述的一种基于RTMP协议的实时视频传输的实现方法,其特征在于:前述1.4中FIFO缓冲队列在队列入口处缓存视频数据,在队列出口处解码视频。4. the realization method of a kind of real-time video transmission based on RTMP protocol according to claim 1, is characterized in that: in the aforementioned 1.4, FIFO buffer queue buffers video data at queue entry, and decodes video at queue exit.

5.根据权利要求1所述的一种基于RTMP协议的实时视频传输的实现方法,其特征在于:前述1.4中FIFO缓冲队列缓存双关键帧,并在推送视频数据和获取视频数据双方设置合理的gop_size大小来调整关键帧的体积和GOP帧之间的间隙。5. a kind of realization method based on the real-time video transmission of RTMP protocol according to claim 1, is characterized in that: in the aforementioned 1.4, FIFO buffer queue buffer double key frame, and in pushing video data and obtaining video data both sides are set reasonable. gop_size size to adjust the volume of keyframes and the gap between GOP frames.

本发明一种基于RTMP协议的实时视频传输的实现方法,具有以下优势:A method for realizing real-time video transmission based on RTMP protocol of the present invention has the following advantages:

1.即使在多条线程通道开启时,系统也能够在视频传输过程中实现零丢包,在客户端能够连续稳定地高清显示且不失真。1. Even when multiple thread channels are enabled, the system can achieve zero packet loss during video transmission, and can display continuously and stably in high-definition without distortion on the client side.

2.通过局域网以及对于GOP关键帧的设置,能够使视频监控系统从上传开始到接受的过程中始终保持着较低的视频延迟。2. Through the local area network and the setting of the GOP key frame, the video surveillance system can always maintain a low video delay from the beginning of uploading to the process of receiving.

3.服务器使用Nginx轻量级服务器具有良好调度资源的特性,并且能够为客户端提供良好稳定的连接。3. The server uses Nginx lightweight server has the characteristics of good scheduling resources, and can provide a good and stable connection for the client.

附图说明Description of drawings

图1是本发明的实时视频传输流程图Fig. 1 is the real-time video transmission flow chart of the present invention

图2是本发明的实时视频传输架构图Fig. 2 is the real-time video transmission architecture diagram of the present invention

图3是本发明的流媒体转发流程图Fig. 3 is the flow media forwarding flow chart of the present invention

图4是本发明的FIFO结构图Fig. 4 is the FIFO structure diagram of the present invention

图5是本发明的GOP帧结构图Fig. 5 is the GOP frame structure diagram of the present invention

图6是本发明视频流推送模块流程图Fig. 6 is the flow chart of the video stream push module of the present invention

图7是本发明视频数据获取模块流程图Fig. 7 is the flow chart of the video data acquisition module of the present invention

具体实施方式Detailed ways

以下结合说明书附图对本发明的实施做进一步的说明:The implementation of the present invention will be further described below in conjunction with the accompanying drawings:

图1是实时视频传输的流程图,分别为设备端,流媒体服务端以及客户端三个部分。首先设置网络摄像头开始视频数据采集,按照H.264标准格式进行编码,并按照FFmpeg提供的FLV封装策略进行封装;然后通过局域网将数据包传输至Nginx配置的流媒体服务器进行广播,并进入等待请求状态;客户端通过向流媒体服务器发出请求来获取视频,当视频到达客户端后,首先进入缓存区待解码线程开启,最后通过播放模块播放获取到的实时视频。在视频数据上传和视频数据获取的过程中均采用RTMP/TCP协议。Figure 1 is a flow chart of real-time video transmission, which includes three parts: the device side, the streaming media server side, and the client side. First set up the webcam to start video data collection, encode it according to the H.264 standard format, and encapsulate it according to the FLV encapsulation strategy provided by FFmpeg; then transmit the data packet to the streaming media server configured by Nginx through the LAN for broadcasting, and enter the waiting request Status; the client obtains the video by sending a request to the streaming media server. When the video reaches the client, it first enters the buffer area to be decoded and the thread is started, and finally plays the obtained real-time video through the playback module. RTMP/TCP protocol is adopted in the process of video data upload and video data acquisition.

图2是实时视频传输的架构图,主要分为四个部分:摄像头视频采集,流媒体服务器,网络传输,客户端。四个部分通过交换机路由器相连构成局域网,视频数据传输首先由摄像头采集获得,通过局域网建立RTMP连接传输至流媒体服务器;在服务端主要包含两个服务器:一是流媒体服务器,负责对视频数据的转发功能,二是数据库服务器负责用户信息以及设备信息的存储和查询功能。如果在用户数量以及设备数量不是很多的情况下,数据库服务器可以和流媒体服务器搭建在同一服务器中;视频监控客户端负责管理用户设备信息,多个客户端连入局域网中,向流媒体服务器发出请求获取实时视频数据,并将视频数据显示到客户端供用户观看。由于采用Nginx作为流媒体服务器,所以可支持3000个RTMP连接数供不同的客户端使用。Figure 2 is an architecture diagram of real-time video transmission, which is mainly divided into four parts: camera video capture, streaming media server, network transmission, and client. The four parts are connected by a switch router to form a local area network. The video data transmission is first collected by the camera, and then the RTMP connection is established through the local area network and transmitted to the streaming media server; the server mainly includes two servers: one is the streaming media server, responsible for video data. The forwarding function, the second is that the database server is responsible for the storage and query functions of user information and device information. If the number of users and devices is not large, the database server and the streaming media server can be built in the same server; the video surveillance client is responsible for managing user device information, and multiple clients are connected to the local area network and send messages to the streaming media server. Request to obtain real-time video data, and display the video data to the client for users to watch. Because Nginx is used as the streaming media server, it can support 3000 RTMP connections for different clients.

图3是流媒体转发流程图,流媒体在上传的过程中需要经历三个过程:建立网络连接、建立网络流、传输视频数据。在上传数据建立网络连接前,服务器内部通过调用ngx_rtmp_handshake函数和ngx_rtmp_handshake_recv函数使视频推送端和服务器进行握手操作,握手完成之后即建立了rtmp网络连接,Nginx调用内部函数ngx_rtmp_recv解析消息块,并利用ngx_event_t结构获取视频推送端发来的视频数据,将数据存储到ngx_rtmp_stream_t的in链表结构中。在连接持续的过程中,服务器利用ngx_rtmp_cmd_connect_init函数初始化网络连接,通过ngx_rtmp_receive_amf获取amf信息,其中amf信息是远程服务器与flash交换数据的格式信息。最后通过ngx_rtmp_cmd_args设置连接过程中必要的参数,并利用ngx_rtmp_notify_connect通知视频数据发送端所配置的参数,以此完成连接过程中的信息建立。Fig. 3 is a flow chart of streaming media forwarding. The streaming media needs to go through three processes during the uploading process: establishing a network connection, establishing a network stream, and transmitting video data. Before uploading data to establish a network connection, the server internally calls the ngx_rtmp_handshake function and the ngx_rtmp_handshake_recv function to make the video pusher and the server perform a handshake operation. After the handshake is completed, the rtmp network connection is established. Nginx calls the internal function ngx_rtmp_recv to parse the message block, and uses the ngx_event_t structure Get the video data sent by the video pusher, and store the data in the in linked list structure of ngx_rtmp_stream_t. During the continuous connection process, the server uses the ngx_rtmp_cmd_connect_init function to initialize the network connection, and obtains the amf information through ngx_rtmp_receive_amf, where the amf information is the format information of the data exchanged between the remote server and the flash. Finally, set the necessary parameters in the connection process through ngx_rtmp_cmd_args, and use ngx_rtmp_notify_connect to notify the video data sender of the configured parameters, so as to complete the information establishment in the connection process.

网络流表示音视频数据发送的通道,且在一个网络连接中可以包含多个通道。在ngx_rtmp_recv函数将接收到的数据解析完成后,将解析后的数据传递给ngx_rtmp_receive_message函数建立网络流。接收到信息后Nginx调用处理函数ngx_rtmp_protocol_message_handler以及ngx_rtmp_amf_message_handler,前者可以根据消息的类型对消息进行二次处理,后者会处理相应的amf控制消息。最后通过ngx_rtmp_cmd_create_stream_init函数初始化网络流,并调用ngx_rtmp_cmd_create_stream函数创建网络流,完成创建后,客户端和服务端即可以进行信息的传输,实现流转发功能。A network stream represents a channel for sending audio and video data, and a network connection can contain multiple channels. After the ngx_rtmp_recv function parses the received data, the parsed data is passed to the ngx_rtmp_receive_message function to establish a network flow. After receiving the information, Nginx calls the processing functions ngx_rtmp_protocol_message_handler and ngx_rtmp_amf_message_handler. The former can process the message twice according to the type of the message, and the latter will process the corresponding amf control message. Finally, the network stream is initialized by the ngx_rtmp_cmd_create_stream_init function, and the ngx_rtmp_cmd_create_stream function is called to create the network stream. After the creation, the client and the server can transmit information to realize the stream forwarding function.

图4是FIFO缓存队列的结构,它具有先进先出的特性,通过创建FIFO缓冲队列解决画面失真问题,当视频数据开始传输后,视频数据持续进入到FIFO缓存队列直至满一帧数据大小,然后解码线程进行解码,视频数据仍缓存至FIFO中,形成同时缓存解码的状态;解码器从FIFO中读取视频数据,而FIFO从流媒体服务器中连续下载数据,这样,当网络不可靠时,客户端创建的FIFO缓冲队列可以使用户在视觉上没有察觉,在播放过程中无失真且流畅。Figure 4 is the structure of the FIFO buffer queue. It has the characteristics of first-in, first-out. The problem of picture distortion is solved by creating a FIFO buffer queue. When the video data starts to transmit, the video data continues to enter the FIFO buffer queue until it is full of one frame of data size, and then The decoding thread performs decoding, and the video data is still buffered in the FIFO, forming a state of buffering and decoding at the same time; the decoder reads the video data from the FIFO, and the FIFO continuously downloads data from the streaming media server, so that when the network is unreliable, the client The FIFO buffer queue created by the terminal can make the user invisible visually, and the playback process is distortion-free and smooth.

图5是GOP帧的结构图,它表示I帧和P帧之间B帧的数量。在视频流中GOP(GroupofPicture)帧是一组连续的画面,由一张I帧和数张B/P帧组成,是视频图像编解码器存取的基本单位,具有一定的体积。GOP帧是视频的关键帧,每一秒视频至少需要使用一个关键帧,视频上传时会将每一帧数据打上时序标签后再在网络上进行传输,由于GOP帧的数据体积较大,当网络环境不佳时,GOP帧有可能不能够在秒级以内完成下载,从而影响延迟。本发明在推送视频数据和获取视频数据双方通过缩小GOP中I帧与P帧之间B帧的间距来调整关键帧的体积,并通过缓存双关键帧,使加载过程能够在短时间内完成,以降低视频传输过程中所产生的延迟。FIG. 5 is a structural diagram of a GOP frame, which indicates the number of B frames between I frames and P frames. In the video stream, GOP (Group of Picture) frame is a group of continuous pictures, which is composed of one I frame and several B/P frames. It is the basic unit of video image codec access and has a certain volume. The GOP frame is the key frame of the video. At least one key frame is required for each second of video. When the video is uploaded, the data of each frame will be marked with a timing label before being transmitted on the network. Due to the large data volume of the GOP frame, when the network is uploaded When the environment is not good, the GOP frame may not be able to be downloaded within seconds, thus affecting the latency. The present invention adjusts the volume of the key frame by reducing the spacing between the I frame and the B frame in the GOP in both pushing the video data and acquiring the video data, and by caching the double key frames, the loading process can be completed in a short time, In order to reduce the delay generated in the video transmission process.

图6是视频流推送模块流程图,视频数据采集和推送等同于系统的数据输入源,影响着监控系统的视频质量与整体性能,本发明通过OpenCV三方库获取远程网络摄像头采集的视频数据,利用FFmpeg对数据进行编码、封装和打包。在上述两个过程完成之后,推送端会根据封装头中指定的服务器地址发起连接请求,经过握手,创建网络连接,推送端和服务端的连接建立完成后,推送端可以通过网络流向服务器传输视频数据。Fig. 6 is the flow chart of the video stream push module, the video data collection and push are equivalent to the data input source of the system, which affects the video quality and overall performance of the monitoring system. FFmpeg encodes, encapsulates and packs data. After the above two processes are completed, the pusher will initiate a connection request according to the server address specified in the encapsulation header. After handshake, a network connection will be created. After the connection between the pusher and the server is established, the pusher can transmit video data to the server through the network stream. .

图7是视频数据获取模块流程图。视频帧数据接收模块是视频监控客户端中最重要的模块,也是视频传输过程中将服务器与客户端连接起来的桥梁。本发明采用多线程的方式将视频数据获取流程封装在线程的run()函数中,这样当n个窗口同时播放时即开启了n个线程从流媒体服务器中获取视频流,并显示到客户端对应的界面中。在视频帧数据接收的过程中,由客户端的设备列表模块向数据库服务器请求设备的URL(Uniform ResourceLocator,统一资源定位符),然后通过设备的URL向流媒体服务器请求视频数据。为防止监控视频马赛克现象,视频数据到达客户端时需要进入缓存,客户端从缓存区中读取视频数据,对数据进行解封装、解码、转码操作,以获得RGB格式的图像数据。FIG. 7 is a flowchart of a video data acquisition module. The video frame data receiving module is the most important module in the video surveillance client, and it is also the bridge connecting the server and the client during the video transmission process. The present invention encapsulates the video data acquisition process in the run() function of the thread in a multi-threaded manner, so that when n windows are played at the same time, n threads are opened to acquire the video stream from the streaming media server and display it to the client in the corresponding interface. In the process of receiving video frame data, the device list module of the client requests a URL (Uniform ResourceLocator, Uniform Resource Locator) of the device from the database server, and then requests video data from the streaming media server through the URL of the device. In order to prevent the phenomenon of monitoring video mosaic, the video data needs to enter the cache when it reaches the client. The client reads the video data from the cache, decapsulates, decodes, and transcodes the data to obtain image data in RGB format.

最后应当说明的是:以上实施例仅用以说明本发明的技术方案而非对其限制;尽管参照较佳实施例对本发明进行了详细的说明,所属领域的普通技术人员应当理解:依然可以对本发明的具体实施方式进行修改或者对部分技术特征进行等同替换;而不脱离本发明技术方案的精神,其均应涵盖在本发明请求保护的技术方案范围当中。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them; although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand: The specific embodiment of the invention is modified or some technical features are equivalently replaced; without departing from the spirit of the technical solution of the present invention, all of them should be included in the scope of the technical solution claimed in the present invention.

Claims (5)

1. A method for realizing real-time video transmission based on RTMP protocol, the video transmission process is divided into three stages of video frame data uploading, streaming media server storage and client terminal stream pulling:
1.1, acquiring high-definition video data through a remote network camera, converting the video data format into a YUV420 format, coding according to an H.264 standard, and finally converting the video data format into an FLV format file meeting the transmission requirement of an RTMP protocol through FFmpeg software encapsulation context;
1.2 the streaming media server adopts a Nginx lightweight server, can provide a corresponding website for the uploaded video data to be stored or broadcasted, establishes an RTMP connection channel for transmission in the process of receiving or broadcasting, and realizes concurrent connection of a plurality of clients through the epoll technology of the streaming media server after the video data reaches the streaming media server;
1.3 the client of the video monitoring system is built through a Qt framework, the video data broadcasted by the streaming media server is received by adopting a mode of circularly starting threads, one channel is opened for transmission each time the threads are started, each thread is monitored, and resources are released immediately when the threads stop decoding videos;
1.4, the problem of picture distortion is solved by creating a FIFO buffer queue, firstly, a client receives video data transmitted by a streaming media server, stores the data into the FIFO buffer queue, a decoder reads the video data from the FIFO buffer queue for decoding, and the video data is continuously buffered in an idle space.
2. The method of claim 1, wherein the RTMP protocol is applied to a real-time video transmission system, and the method comprises: the video input source transmits data to the FFmpeg, the data is uploaded to the Nginx server in an RTMP data format after being encoded and packaged, and then the server forwards the data to the client. Before network connection is established for uplink data, a video pushing end and a server are subjected to handshake operation by calling ngx _ rtm _ handshake function and ngx _ rtm _ handshake _ recv function in the server, a Nginx-rtmp module of Nginx is selected to build a streaming media server, and then forwarding of video data streams is achieved by modifying the rtmp module in a configuration file.
3. The method according to claim 1, wherein the RTMP protocol is used for real-time video transmission, and the method comprises: the aforementioned Nginx server in 1.2 establishes a plurality of RTMP connections for data transmission, which include connections of a plurality of channels in one client and connections of a plurality of channels in a plurality of clients.
4. The method according to claim 1, wherein the RTMP protocol is used for real-time video transmission, and the method comprises: the FIFO buffer queue in 1.4 above buffers video data at the entry of the queue and decodes video at the exit of the queue.
5. The method according to claim 1, wherein the RTMP protocol is used for real-time video transmission, and the method comprises: the FIFO buffer queue in 1.4 above buffers the double key frames and sets reasonable GOP _ size for both pushing video data and fetching video data to adjust the key frame volume and the gap between GOP frames.
CN202110391578.4A 2021-04-14 2021-04-14 Method for realizing real-time video transmission based on RTMP protocol Pending CN115209230A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110391578.4A CN115209230A (en) 2021-04-14 2021-04-14 Method for realizing real-time video transmission based on RTMP protocol

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110391578.4A CN115209230A (en) 2021-04-14 2021-04-14 Method for realizing real-time video transmission based on RTMP protocol

Publications (1)

Publication Number Publication Date
CN115209230A true CN115209230A (en) 2022-10-18

Family

ID=83570284

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110391578.4A Pending CN115209230A (en) 2021-04-14 2021-04-14 Method for realizing real-time video transmission based on RTMP protocol

Country Status (1)

Country Link
CN (1) CN115209230A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116260993A (en) * 2022-12-19 2023-06-13 珠海格力智能装备有限公司 video surveillance system

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102090061A (en) * 2008-07-09 2011-06-08 苹果公司 Video streaming using multiple channels
CN102131084A (en) * 2010-01-19 2011-07-20 深圳市在线通网络科技开发有限公司 RTMP (Real Time Messaging Protocol) pushing device and method for audio/video streaming media
CN102231863A (en) * 2011-06-02 2011-11-02 南京中兴力维软件有限公司 Transmission method of multichannel video streams and system thereof
CN102724561A (en) * 2012-05-16 2012-10-10 昆山日通电脑科技办公设备有限公司 Embedded real time streaming media network transmission method and implementation system thereof
CN102811368A (en) * 2012-07-16 2012-12-05 北京邮电大学 A mobile video live broadcast system
CN103369299A (en) * 2012-04-09 2013-10-23 维图通讯有限公司 Video monitoring method based on H.264 coding technology
CN104602044A (en) * 2015-02-05 2015-05-06 秦永红 RTMP stream media public network live broadcast system and design method thereof
CN105025327A (en) * 2015-07-14 2015-11-04 福建富士通信息软件有限公司 Method and system for live broadcast of mobile terminal
CN106412517A (en) * 2016-10-20 2017-02-15 浙江工业大学 Remote high-definition video monitoring and unlocking system
CN107743252A (en) * 2017-11-01 2018-02-27 创盛视联数码科技(北京)有限公司 A kind of method for reducing live delay
CN108667849A (en) * 2018-05-21 2018-10-16 武汉山骁科技有限公司 One kind being based on single connection multichannel streaming media and control method
WO2020086452A1 (en) * 2018-10-22 2020-04-30 Radiant Communications Corporation Low-latency video internet streaming for management and transmission of multiple data streams

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102090061A (en) * 2008-07-09 2011-06-08 苹果公司 Video streaming using multiple channels
CN102131084A (en) * 2010-01-19 2011-07-20 深圳市在线通网络科技开发有限公司 RTMP (Real Time Messaging Protocol) pushing device and method for audio/video streaming media
CN102231863A (en) * 2011-06-02 2011-11-02 南京中兴力维软件有限公司 Transmission method of multichannel video streams and system thereof
CN103369299A (en) * 2012-04-09 2013-10-23 维图通讯有限公司 Video monitoring method based on H.264 coding technology
CN102724561A (en) * 2012-05-16 2012-10-10 昆山日通电脑科技办公设备有限公司 Embedded real time streaming media network transmission method and implementation system thereof
CN102811368A (en) * 2012-07-16 2012-12-05 北京邮电大学 A mobile video live broadcast system
CN104602044A (en) * 2015-02-05 2015-05-06 秦永红 RTMP stream media public network live broadcast system and design method thereof
CN105025327A (en) * 2015-07-14 2015-11-04 福建富士通信息软件有限公司 Method and system for live broadcast of mobile terminal
CN106412517A (en) * 2016-10-20 2017-02-15 浙江工业大学 Remote high-definition video monitoring and unlocking system
CN107743252A (en) * 2017-11-01 2018-02-27 创盛视联数码科技(北京)有限公司 A kind of method for reducing live delay
CN108667849A (en) * 2018-05-21 2018-10-16 武汉山骁科技有限公司 One kind being based on single connection multichannel streaming media and control method
WO2020086452A1 (en) * 2018-10-22 2020-04-30 Radiant Communications Corporation Low-latency video internet streaming for management and transmission of multiple data streams

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116260993A (en) * 2022-12-19 2023-06-13 珠海格力智能装备有限公司 video surveillance system

Similar Documents

Publication Publication Date Title
US12096046B2 (en) Live streaming method and system, server, and storage medium
US8356324B2 (en) Implementing network personal video recorder for digital video settop boxes
CN101753973B (en) Channel switching method, device and system
US20160337424A1 (en) Transferring media data using a websocket subprotocol
US10862940B1 (en) Low latency live video on a communication session
US20170093939A1 (en) Real-time video streaming to client video element
JP6377784B2 (en) A method for one-to-many audio-video streaming with audio-video synchronization capture
CN101742269A (en) Channel switching over method, device and system
CN112752115A (en) Live broadcast data transmission method, device, equipment and medium
CN100550999C (en) A digital channel fast switching method and system and auxiliary channel generating equipment
CN105610824B (en) A kind of screen sharing method based on screen mirror image and RTSP Streaming Media frame
US20180176278A1 (en) Detecting and signaling new initialization segments during manifest-file-free media streaming
CN101938456A (en) A method, device and system for reducing media delay
CN110602522B (en) A multi-channel real-time live WebRTC stream synthesis method
CN114339146A (en) Audio and video monitoring method and device, electronic equipment and computer readable storage medium
CN115209230A (en) Method for realizing real-time video transmission based on RTMP protocol
CN104639979A (en) Video sharing method and system
US12395538B2 (en) Signaling media timing information from a media application to a network element
CN108124183B (en) Method for synchronously acquiring video and audio to perform one-to-many video and audio streaming
CN110602065A (en) Live broadcast stream pushing method and device
CN116170612B (en) A method for implementing live broadcast, edge node, electronic device and storage medium
TWI600319B (en) A method for capturing video and audio simultaneous for one-to-many video streaming
CN101193105A (en) A method for transmitting/switching media streams
CN120676208A (en) Pulling flow pushing method and device for localized deployment
CN117939199A (en) Live broadcast method and device, electronic equipment and readable storage medium

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20221018