CN116506412A - Video real-time encrypted transmission method and system compatible with H.264 and H.265 encoding standards - Google Patents

Video real-time encrypted transmission method and system compatible with H.264 and H.265 encoding standards Download PDF

Info

Publication number
CN116506412A
CN116506412A CN202310348907.6A CN202310348907A CN116506412A CN 116506412 A CN116506412 A CN 116506412A CN 202310348907 A CN202310348907 A CN 202310348907A CN 116506412 A CN116506412 A CN 116506412A
Authority
CN
China
Prior art keywords
parameter set
video
abstraction layer
network abstraction
nalu
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
CN202310348907.6A
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.)
Second Research Institute of CAAC
Original Assignee
Second Research Institute of CAAC
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 Second Research Institute of CAAC filed Critical Second Research Institute of CAAC
Priority to CN202310348907.6A priority Critical patent/CN116506412A/en
Publication of CN116506412A publication Critical patent/CN116506412A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/60Network streaming of media packets
    • H04L65/65Network streaming protocols, e.g. real-time transport protocol [RTP] or real-time control protocol [RTCP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/04Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks
    • H04L63/0428Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload
    • H04L63/0435Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload wherein the sending and receiving network entities apply symmetric encryption, i.e. same key used for encryption and decryption
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/60Network streaming of media packets
    • H04L65/70Media network packetisation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/40Network security protocols

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)

Abstract

The application belongs to the technical field of information encryption, and particularly relates to a video real-time transmission method and system compatible with H.264 and H.265 coding standards, wherein the video real-time encryption transmission method comprises the following steps: a streaming request; RTSP verification, wherein the verification process also comprises the steps of analyzing and encrypting the video stream and transmitting the coding parameter set to a video playing server; after passing the RTSP verification, the relevant video parameters in each frame of the video stream are removed, and only the reserved video data part is transmitted; the video playing server identifies and decrypts the encrypted encoding parameter set and restores the encoding parameter set plaintext. The video real-time encryption transmission method and system can protect the safety of video content on the premise of not changing the overall structure and transmission protocol of the video stream, are compatible with H.264 and H.265 coding standards, and in addition, because the parameter sets VPS, SPS and PPS are encrypted only once in the RTSP verification process, the ciphertext expansion rate is not more than 1%, the real-time transmission delay is lower, and the practicability is stronger.

Description

兼容H.264和H.265编码标准的视频实时加密传输方法及系统Video real-time encrypted transmission method and system compatible with H.264 and H.265 encoding standards

技术领域technical field

本申请属于信息加密技术领域,具体涉及一种兼容H.264和H.265编码标准的视频实时加密传输方法及系统。The application belongs to the technical field of information encryption, and specifically relates to a video real-time encrypted transmission method and system compatible with H.264 and H.265 encoding standards.

背景技术Background technique

随着互联网与通信技术的不断发展,多媒体信息的共享也变得更加便捷。视频会议、视频监控、围界安防等视频应用已经逐渐成为日常生活中的一部分。互联网的开放性也让视频信息暴露在公共的环境中,容易受到恶意组织或黑客的拦截、窃取或篡改等攻击,给行业和组织造成了极大的负面影响和经济损失。因此,如何在开放的互联网环境下保证视频数据的安全性显得尤为重要。With the continuous development of the Internet and communication technology, the sharing of multimedia information has become more convenient. Video applications such as video conferencing, video surveillance, and perimeter security have gradually become part of daily life. The openness of the Internet also exposes video information to the public environment, making it vulnerable to interception, theft, or tampering attacks by malicious organizations or hackers, which has caused great negative impacts and economic losses on industries and organizations. Therefore, how to ensure the security of video data in an open Internet environment is particularly important.

另外,随着视频不断的高清化,视频拼接和全景视频技术的不断发展,多路化、海量化的视频数据也为数据的传输和存储也带来了新的挑战。为了应对这一问题,视频编码标准从最早的H.261、MPEG系列编码标准,到划时代的H.264,而随着IC芯片技术的进一步发展,H.265也将会逐渐取代H.264成为未来的主流标准。H.265编码标准与H.264相比,不仅沿用了原有的技术,同时还对部分技术进行了完善和优化,将视频压缩率提高至H.264的约2倍,即传输相同质量的视频只需之前的一半带宽。虽然H.265是未来的应用主流,但现运行的系统还有很大一部分使用的是H.264编码标准。因此,研究在保证视频数据安全的前提下如何兼容H.264和H.265编码标准具有重要意义。In addition, with the continuous development of high-definition video, video stitching and panoramic video technology, multiplexed and massive video data also brings new challenges to data transmission and storage. In order to deal with this problem, video coding standards have changed from the earliest H.261 and MPEG series coding standards to the epoch-making H.264. With the further development of IC chip technology, H.265 will gradually replace H.264 as the The mainstream standard of the future. Compared with H.264, the H.265 coding standard not only continues to use the original technology, but also improves and optimizes some technologies, increasing the video compression rate to about twice that of H.264, that is, transmitting the same quality video. Video requires half the bandwidth of before. Although H.265 will be the mainstream of future applications, a large part of the currently running systems still use the H.264 encoding standard. Therefore, it is of great significance to study how to be compatible with H.264 and H.265 coding standards under the premise of ensuring video data security.

解决上述问题的一种方法是对视频内容本身进行加密。由于视频信息具有数据量大、相关性高等特性,因此在实时视频通信领域,视频在传输前往往需要通过压缩处理来降低视频信息冗余度,从而减少数据量来保证视频传输的实时性。One way to solve the above problem is to encrypt the video content itself. Because video information has the characteristics of large data volume and high correlation, in the field of real-time video communication, video often needs to be compressed before transmission to reduce the redundancy of video information, thereby reducing the amount of data to ensure real-time video transmission.

视频加密方案主要分为:编码前加密、编码时加密与编码后加密三种类型;其中,编码后加密是直接对编码后的视频码流执行加密操作,因为该加密方案是视频编码格式弱相关的,所以目前被各大安全厂商和视频厂商普遍采用。Video encryption schemes are mainly divided into three types: encryption before encoding, encryption during encoding, and encryption after encoding; among them, encryption after encoding is to directly perform encryption operations on the encoded video stream, because the encryption scheme is weakly related to the video encoding format. Therefore, it is currently widely used by major security vendors and video vendors.

但是,目前的编码后加密大多属于全加密,即所有编码后的视频流都加密,这样的方式仍然需要加密处理较大的视频数据量,从而导致时延开销和带宽开销较大。However, most of the current encryption after encoding is full encryption, that is, all encoded video streams are encrypted. This method still needs to encrypt and process a large amount of video data, resulting in large delay overhead and bandwidth overhead.

发明内容Contents of the invention

为了解决现有技术中存在的至少一个技术问题,本申请提供了一种兼容H.264和H.265编码标准的视频实时加密传输方法及系统。In order to solve at least one technical problem in the prior art, the present application provides a video real-time encrypted transmission method and system compatible with H.264 and H.265 encoding standards.

第一方面,本申请公开了一种兼容H.264和H.265编码标准的视频实时加密传输方法,包括如下步骤:In the first aspect, the present application discloses a video real-time encrypted transmission method compatible with H.264 and H.265 encoding standards, comprising the following steps:

步骤一、视频播放服务端与视频拍摄端之间进行拉流请求;Step 1: Make a streaming request between the video playback server and the video capture end;

步骤二、拉流请求成功后所述视频播放服务端与所述视频拍摄端之间进行RTSP验证,在验证过程中还包括对视频流进行解析和加密处理,以及将解析和加密处理后得到的编码参数集传输至所述视频播放服务端;其中,所述对视频流进行解析包括:Step 2, after the stream pull request is successful, RTSP verification is performed between the video playback server and the video capture end, and the verification process also includes parsing and encrypting the video stream, and analyzing and encrypting the obtained The encoding parameter set is transmitted to the video playback server; wherein, parsing the video stream includes:

步骤2.1、对所述视频流进行解析,以判断其编码标准,其中,所述编码标准包括H.264和/或H.265;Step 2.1, analyzing the video stream to determine its encoding standard, wherein the encoding standard includes H.264 and/or H.265;

步骤2.2、对所述视频流中每一个网络抽象层单元NALU中的预定参数集进行定位,其中:Step 2.2, locating the predetermined parameter set in each network abstraction layer unit NALU in the video stream, wherein:

当所述编码标准为H.264时,所述预定参数集包括序列参数集SPS和图像参数集PPS;When the encoding standard is H.264, the predetermined parameter set includes a sequence parameter set SPS and a picture parameter set PPS;

当所述编码标准为H.265或同时包括H.264和H.265时,所述预定参数集包括视频参数集VPS、序列参数集SPS和图像参数集PPS;When the coding standard is H.265 or includes both H.264 and H.265, the predetermined parameter set includes a video parameter set VPS, a sequence parameter set SPS and a picture parameter set PPS;

步骤2.3、将定位出的所述预定参数集标识为关键内容;Step 2.3, identifying the located predetermined parameter set as key content;

所述对视频流进行加密处理包括:The encryption processing of the video stream includes:

步骤2.4、将步骤2.3中标识的所述关键内容进行加密处理,得到编码参数集;Step 2.4, encrypting the key content identified in step 2.3 to obtain an encoding parameter set;

步骤三、RTSP验证通过后,在所述视频拍摄端向所述视频播放服务端传输的视频流中,将每帧中的相关视频参数进行剔除,仅保留视频数据部分传输到所述视频播放服务器;Step 3, after the RTSP verification is passed, in the video stream transmitted from the video shooting end to the video playback server, the relevant video parameters in each frame are removed, and only the video data part is reserved for transmission to the video playback server ;

步骤四、所述视频播放服务器识别和解密加密后的所述编码参数集,并恢复编码参数集明文。Step 4: The video playing server identifies and decrypts the encrypted encoding parameter set, and recovers the plaintext of the encoding parameter set.

根据本申请的至少一个实施方式,所述步骤2.2中,对每一个所述网络抽象层单元NALU中的预定参数集进行定位包括:According to at least one embodiment of the present application, in the step 2.2, locating the predetermined parameter set in each of the network abstraction layer units NALU includes:

对每一个所述网络抽象层单元NALU中各参数集的确定以及对各参数集的开始及结束位置的定位。The determination of each parameter set in each network abstraction layer unit NALU and the positioning of the start and end positions of each parameter set.

根据本申请的至少一个实施方式,对每一个所述网络抽象层单元NALU中的视频参数集VPS、序列参数集SPS和图像参数集PPS的确定包括如下步骤:According to at least one embodiment of the present application, the determination of the video parameter set VPS, the sequence parameter set SPS and the image parameter set PPS in each of the network abstraction layer units NALU includes the following steps:

步骤2.2.1、在所述视频流中通过搜索起始码来对所述网络抽象层单元NALU进行定位;Step 2.2.1, locate the network abstraction layer unit NALU by searching the start code in the video stream;

步骤2.2.2、再按位读取所述网络抽象层单元NALU头部的数据类型位nal_unit_type,随后将其值转化为整形后判断所述网络抽象层单元NALU内是否包含对应的参数集,其中:Step 2.2.2, then read the data type bit nal_unit_type of the network abstraction layer unit NALU header bit by bit, then convert its value into plastic and determine whether the corresponding parameter set is contained in the network abstraction layer unit NALU, wherein :

对于H.264编码标准:For the H.264 encoding standard:

当整形后的数值为7时,确定网络抽象层单元NALU内包含序列参数集SPS;When the reshaped value is 7, it is determined that the network abstraction layer unit NALU contains the sequence parameter set SPS;

当整形后的数值为8时,确定网络抽象层单元NALU内包含图像参数集PPS;When the reshaped value is 8, it is determined that the network abstraction layer unit NALU contains the image parameter set PPS;

对于H.265编码标准:For the H.265 encoding standard:

当整形后的数值为32时,确定所述网络抽象层单元NALU内包含视频参数集VPS;When the shaped value is 32, it is determined that the network abstraction layer unit NALU includes a video parameter set VPS;

当整形后的数值为33时,确定所述网络抽象层单元NALU内包含序列参数集SPS;When the shaped value is 33, it is determined that the network abstraction layer unit NALU contains a sequence parameter set SPS;

当整形后的数值为34时,确定所述网络抽象层单元NALU内包含图像参数集PPS。When the reshaped value is 34, it is determined that the network abstraction layer unit NALU includes a picture parameter set PPS.

根据本申请的至少一个实施方式,对每一个所述网络抽象层单元NALU中各参数集的开始及结束位置的定位包括:According to at least one embodiment of the present application, the positioning of the start and end positions of each parameter set in each network abstraction layer unit NALU includes:

步骤2.2.3、在当前网络抽象层单元NALU头部跳过一个或两个字节,以定位其中对应参数集的开始位置;Step 2.2.3, skipping one or two bytes at the head of the current network abstraction layer unit NALU to locate the start position of the corresponding parameter set;

步骤2.2.4、通过搜索起始码来定位下一个网络抽象层单元NALU,从而确定当前网络抽象层单元NALU的结束位置,即对应参数集的结束位置。Step 2.2.4. Locate the next network abstraction layer unit NALU by searching the start code, so as to determine the end position of the current network abstraction layer unit NALU, that is, the end position of the corresponding parameter set.

根据本申请的至少一个实施方式,所述步骤2.4中,将标识的所述关键内容进行加密处理包括如下步骤:According to at least one embodiment of the present application, in the step 2.4, encrypting the identified key content includes the following steps:

步骤2.4.1、使用对称分组加密算法对所述关键内容进行保密性加密,得到保密性加密后的密文数据;Step 2.4.1, using a symmetric block encryption algorithm to perform confidentiality encryption on the key content to obtain confidentiality-encrypted ciphertext data;

步骤2.4.2、使用基于密钥的哈希运算消息认证码算法对关键内容进行完整性加密,得到完整性加密后的密文数据;Step 2.4.2, use the key-based hash operation message authentication code algorithm to perform integrity encryption on the key content, and obtain the ciphertext data after integrity encryption;

步骤2.4.3、将保密性加密后的密文数据和完整性加密后的密文数据进行直接拼接,并使用拼接后的密文替换所述关键内容的明文。Step 2.4.3, directly splicing the confidentiality-encrypted ciphertext data and the integrity-encrypted ciphertext data, and using the spliced ciphertext to replace the plaintext of the key content.

根据本申请的至少一个实施方式,在所述步骤2.4中,在对所述关键内容进行加密处理后,得到所述编码参数集之前,还包括对加密处理后得到的密文进行加壳处理,具体包括如下步骤:According to at least one embodiment of the present application, in the step 2.4, after encrypting the key content and before obtaining the encoding parameter set, it also includes performing packing processing on the ciphertext obtained after the encryption processing, Specifically include the following steps:

步骤2.4.4、对拼接后的密文进行加壳操作;Step 2.4.4, packing the spliced ciphertext;

步骤2.4.5、在拼接后的密文末尾添加0xffffffff校验码,用以标识该密文的结束。Step 2.4.5. Add a 0xffffffff check code at the end of the spliced ciphertext to mark the end of the ciphertext.

第二方面,本申请还公开了一种兼容H.264和H.265编码标准的视频实时加密传输系统,包括视频播放服务端、视频拍摄端以及视频加密客户端,其中:In the second aspect, the present application also discloses a video real-time encrypted transmission system compatible with H.264 and H.265 encoding standards, including a video playback server, a video capture terminal, and a video encryption client, wherein:

所述视频播放服务端用于与视频拍摄端之间进行拉流请求,并在拉流请求成功后与所述视频拍摄端之间进行RTSP验证;The video playback server is used to perform a streaming request with the video capture terminal, and performs RTSP verification with the video capture terminal after the stream pull request succeeds;

所述视频加密客户端用于在RTSP验证过程对视频流进行解析和加密处理,以及将解析和加密处理后得到的编码参数集传输至所述视频播放服务端;其中,所述对视频流进行解析包括如下步骤:The video encryption client is used to analyze and encrypt the video stream in the RTSP verification process, and transmit the encoding parameter set obtained after the analysis and encryption to the video playback server; wherein, the video stream is performed Parsing includes the following steps:

步骤2.1、对所述视频流进行解析,以判断其编码标准,其中,所述编码标准包括H.264和/或H.265;Step 2.1, analyzing the video stream to determine its encoding standard, wherein the encoding standard includes H.264 and/or H.265;

步骤2.2、对所述视频流中每一个网络抽象层单元NALU中的预定参数集进行定位,其中:Step 2.2, locating the predetermined parameter set in each network abstraction layer unit NALU in the video stream, wherein:

当所述编码标准为H.264时,所述预定参数集包括序列参数集SPS和图像参数集PPS;When the encoding standard is H.264, the predetermined parameter set includes a sequence parameter set SPS and a picture parameter set PPS;

当所述编码标准为H.265或同时包括H.264和H.265时,所述预定参数集包括视频参数集VPS、序列参数集SPS和图像参数集PPS;When the coding standard is H.265 or includes both H.264 and H.265, the predetermined parameter set includes a video parameter set VPS, a sequence parameter set SPS and a picture parameter set PPS;

步骤2.3、将定位出的所述预定参数集标识为关键内容;Step 2.3, identifying the located predetermined parameter set as key content;

所述对视频流进行加密处理包括如下步骤:Described video flow is carried out encrypting and processing comprises the steps:

步骤2.4、将步骤2.3中标识的所述关键内容进行加密处理,得到编码参数集;Step 2.4, encrypting the key content identified in step 2.3 to obtain an encoding parameter set;

进一步,所述视频加密客户端还用于在RTSP验证通过后,在所述视频拍摄端向所述视频播放服务端传输的视频流中,将每帧中的相关视频参数进行剔除,仅保留视频数据部分传输到所述视频播放服务器;Further, the video encryption client is also used to remove relevant video parameters in each frame from the video stream transmitted from the video shooting end to the video playback server after the RTSP verification is passed, and only keep the video The data part is transmitted to the video playing server;

进一步,所述视频播放服务端还用于识别和解密加密后的所述编码参数集,并恢复编码参数集明文。Further, the video playing server is also used for identifying and decrypting the encrypted encoding parameter set, and recovering the plaintext of the encoding parameter set.

根据本申请的至少一个实施方式,所述视频加密客户端包括:According to at least one embodiment of the present application, the video encryption client includes:

第一定位模块,用于对每一个所述网络抽象层单元NALU中各参数集进行确定;A first positioning module, configured to determine each parameter set in each of the network abstraction layer units NALU;

第二定位模块,用于对每一个所述网络抽象层单元NALU中各参数集的开始及结束位置进行定位。The second positioning module is configured to locate the start and end positions of each parameter set in each of the network abstraction layer units NALU.

根据本申请的至少一个实施方式,所述第一定位模块对各参数集进行确定包括:According to at least one embodiment of the present application, the determination of each parameter set by the first positioning module includes:

在所述待加密视频流中通过搜索起始码来对所述网络抽象层单元NALU进行定位,再按位读取所述网络抽象层单元NALU头部的数据类型位nal_unit_type,随后将其值转化为整形,其中:Locate the network abstraction layer unit NALU by searching the start code in the video stream to be encrypted, then read the data type bit nal_unit_type of the network abstraction layer unit NALU header bit by bit, and then convert its value is shaping, where:

对于H.264编码标准:For the H.264 encoding standard:

当整形后的数值为7时,确定参数集包含序列参数集SPS;当整形后的数值为8时,确定参数集包含图像参数集PPS;When the value after shaping is 7, it is determined that the parameter set includes the sequence parameter set SPS; when the value after shaping is 8, it is determined that the parameter set includes the image parameter set PPS;

对于H.265编码标准:For the H.265 encoding standard:

当整形后的数值为32时,确定参数集包含视频参数集VPS;当整形后的数值为33时,确定参数集包含序列参数集SPS;当整形后的数值为34时,确定参数集包含图像参数集PPS;When the value after shaping is 32, it is determined that the parameter set contains video parameter set VPS; when the value after shaping is 33, it is determined that the parameter set contains sequence parameter set SPS; when the value after shaping is 34, it is determined that the parameter set contains image parameter set PPS;

进一步,所述第二定位模块对各参数集的开始及结束位置进行定位包括:Further, the positioning of the start and end positions of each parameter set by the second positioning module includes:

在当前网络抽象层单元NALU头部跳过一个或两个字节,以定位其中对应参数集的开始位置,再通过搜索起始码来定位下一个网络抽象层单元NALU,从而确定当前网络抽象层单元NALU的结束位置,即对应参数集的结束位置。Skip one or two bytes at the head of the current network abstraction layer unit NALU to locate the start position of the corresponding parameter set, and then locate the next network abstraction layer unit NALU by searching the start code to determine the current network abstraction layer The end position of the unit NALU, that is, the end position of the corresponding parameter set.

根据本申请的至少一个实施方式,所述视频加密客户端还包括:According to at least one embodiment of the present application, the video encryption client also includes:

第一加密模块,用于通过对称分组加密算法对所述关键内容进行保密性加密,得到保密性加密后的密文数据;The first encryption module is configured to perform confidentiality encryption on the key content through a symmetric block encryption algorithm to obtain confidentiality-encrypted ciphertext data;

第二加密模块,用于基于密钥的哈希运算消息认证码算法对关键内容进行完整性加密,得到完整性加密后的密文数据;The second encryption module is used to perform integrity encryption on the key content based on the hash operation message authentication code algorithm based on the key, and obtain the ciphertext data after the integrity encryption;

拼接模块,用于将保密性加密后的密文数据和完整性加密后的密文数据进行直接拼接,并使用拼接后的密文替换所述关键内容的明文;A splicing module, configured to directly splice the confidentiality-encrypted ciphertext data and the integrity-encrypted ciphertext data, and use the spliced ciphertext to replace the plaintext of the key content;

加壳模块,用于对拼接后的密文进行加壳操作,再在拼接后的密文末尾添加0xffffffff校验码,用以标识该密文的结束。The packing module is used for packing the spliced ciphertext, and then adding a 0xffffffff check code at the end of the spliced ciphertext to mark the end of the ciphertext.

本申请至少存在以下有益技术效果:The present application at least has the following beneficial technical effects:

1)本申请的兼容H.264和H.265编码标准的视频实时加密传输方法及系统,能够在不改变视频流整体结构和传输协议的前提下保护视频内容的安全,同时兼容主流的H.264和H.265编码标准;1) The video real-time encrypted transmission method and system compatible with the H.264 and H.265 coding standards of this application can protect the security of the video content without changing the overall structure of the video stream and the transmission protocol, and is compatible with the mainstream H. 264 and H.265 encoding standards;

另外,本申请仅在RTSP验证的返回RTSP 200OK步骤中保留编码参数集,后续在视频流传输过程中会将每帧中的视频参数剔除,仅保留视频数据部分传输到视频播放服务器,最后在视频播放服务器使用解密的编码参数集进行解码播放,从而能够进一步节约宽带资源消耗,更好的适用于高清视频、全景视频等对带宽资源要求较高的视频实时传输加密场景;In addition, this application only retains the encoding parameter set in the return RTSP 200OK step of RTSP verification, and then removes the video parameters in each frame during the video stream transmission process, and only retains the video data part to be transmitted to the video playback server, and finally in the video The playback server uses the decrypted encoding parameter set for decoding and playback, which can further save bandwidth resource consumption, and is better suitable for high-definition video, panoramic video and other video real-time transmission encryption scenarios that require high bandwidth resources;

2)本申请的兼容H.264和H.265编码标准的视频实时加密传输方法及系统中,由于仅在RTSP验证过程中加密一次参数集VPS、SPS和PPS,因此使得密文膨胀率不超过1%,且使得实时传输时延较低,实用性更强。2) In the video real-time encrypted transmission method and system compatible with H.264 and H.265 coding standards of the present application, because only once in the RTSP authentication process, encrypt the parameter set VPS, SPS and PPS, therefore make the ciphertext expansion rate not exceed 1%, which makes the real-time transmission delay lower and more practical.

附图说明Description of drawings

图1是本申请兼容H.264和H.265编码标准的视频实时加密传输方法的流程框图;Fig. 1 is the block flow diagram of the video real-time encryption transmission method compatible with H.264 and H.265 encoding standards of the present application;

图2是本申请兼容H.264和H.265编码标准的视频实时加密传输方法中RTSP验证流程框图;Fig. 2 is that the application is compatible with H.264 and H.265 encoding standard in the video real-time encrypted transmission method RTSP verification flow block diagram;

图3是本申请兼容H.264和H.265编码标准的视频实时加密传输方法中解析和加密处理步骤的流程框图;Fig. 3 is the flow diagram of analysis and encryption processing steps in the video real-time encrypted transmission method compatible with H.264 and H.265 encoding standards of the present application;

图4是本申请兼容H.264和H.265编码标准的视频实时加密传输系统的结构框图;Fig. 4 is the structural block diagram of the video real-time encrypted transmission system compatible with H.264 and H.265 coding standards of the present application;

图5是本申请兼容H.264和H.265编码标准的视频实时加密传输系统中定位模块构成图;Fig. 5 is a composition diagram of positioning modules in the video real-time encryption transmission system compatible with H.264 and H.265 coding standards of the present application;

图6是本申请兼容H.264和H.265编码标准的视频实时加密传输系统中加密模块构成图;Fig. 6 is a composition diagram of an encryption module in the video real-time encrypted transmission system compatible with the H.264 and H.265 coding standards of the present application;

图7是H.264的NALU头部格式(帧格式)解析图;Fig. 7 is the NALU header format (frame format) parsing diagram of H.264;

图8是H.265的NALU头部格式(帧格式)解析图;Fig. 8 is the NALU header format (frame format) parsing diagram of H.265;

图9是一实施例中一段H.265码流图(表)。Fig. 9 is a diagram (table) of an H.265 code stream in an embodiment.

具体实施方式Detailed ways

为了使本领域技术人员更好地理解本申请,首先对本申请中提及的技术用语进行说明:In order to enable those skilled in the art to better understand the application, the technical terms mentioned in the application are first described:

1)视频编码,是将视频原始数据压缩成码流的方式,本申请中,采用H.264和/或H.265(即可以为H.264或H.265,或者同时包含H.264和H.265)技术进行编码;1) Video coding is a method of compressing raw video data into code streams. In this application, H.264 and/or H.265 are used (that is, H.264 or H.265, or both H.264 and H.264 H.265) technology for encoding;

2)码流,是由多个网络抽象层单元组成(Network Abstract Layer Unit,NALU),例如H.264原始码流(又称为“裸流”)是由一个一个的NALU组成,其中每个NALU之间通过startcode(起始码)进行分隔,起始码分成两种:0x000001(3Byte)或者0x00000001(4Byte);2) The code stream is composed of multiple network abstract layer units (Network Abstract Layer Unit, NALU). For example, the H.264 original code stream (also known as "naked stream") is composed of NALUs one by one, and each The NALUs are separated by startcode (start code), which is divided into two types: 0x000001 (3Byte) or 0x00000001 (4Byte);

3)网络抽象层单元NALU,包括头部(Header)和有效负载数据(Payload Data)两部分,根据承载的数据类型不同,NALU包括:用于视频编码层网络抽象层单元(Video CodeLayer NALU,VCLU)和非视频编码层网络抽象层单元(non-Video Code Layer NALU,non-VCLU)两种类型;3) The network abstraction layer unit NALU includes two parts: the header (Header) and the payload data (Payload Data). According to the different types of data carried, the NALU includes: a video coding layer network abstraction layer unit (Video CodeLayer NALU, VCLU ) and non-video coding layer network abstraction layer unit (non-Video Code Layer NALU, non-VCLU) two types;

其中,non-VCLU为用于承载参数集的NALU,本申请中,参数集包括:视频参数集(Video Parament Set,VPS)、序列参数集(Sequence Paramenter Set,SPS)、图像参数集(Picture Paramenter Set,PPS)三种类型;Wherein, the non-VCLU is the NALU used to carry the parameter set. In this application, the parameter set includes: Video Parament Set (Video Paramenter Set, VPS), Sequence Parameter Set (Sequence Paramenter Set, SPS), Image Parameter Set (Picture Paramenter Set, Set, PPS) three types;

另外,视频参数集VPS是H.265编码标准特有的参数集,序列参数集SPS和图像参数集PPS是H.264和H.265共有的参数集;In addition, the video parameter set VPS is a parameter set unique to the H.265 coding standard, and the sequence parameter set SPS and the image parameter set PPS are common parameter sets of H.264 and H.265;

5)视频流,是指视频数据的传输,例如,它能够被作为一个稳定的和连续的流通过网络处理,即可以使音频、视频和其它多媒体能在Internet及Intranet上以实时的、无需下载等待的方式进行播放的技术;5) Video stream refers to the transmission of video data, for example, it can be processed as a stable and continuous stream through the network, that is, audio, video and other multimedia can be transmitted in real time on the Internet and Intranet without downloading The technology of playing in a waiting manner;

6)视频流解析,是指从对应码流中分析得到它的基本单元NALU,并且可以解析NALU首部的字段,例如H.264码流的解析首先是从码流中搜索0x000001和0x00000001,分离出NALU,然后再分析NALU的各个字段。6) Video stream analysis refers to analyzing its basic unit NALU from the corresponding code stream, and can analyze the fields of the NALU header. For example, the analysis of the H.264 code stream first searches for 0x000001 and 0x00000001 from the code stream, and separates NALU, and then analyze the various fields of the NALU.

7)明文,是指没有加密的文字(或者字符串),在通信系统中它可能是比特流,如文本、位图、数字化的语音或者数字化的视频图像等,一般可以简单地认为明文是有意义的字符或比特集,或通过某种公开的编码标准就能获得的消息。7) Plaintext refers to unencrypted text (or character strings). In a communication system, it may be a bit stream, such as text, bitmap, digitized voice, or digitized video image. A meaningful set of characters or bits, or a message that can be obtained through some public encoding standard.

为使本申请实施的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行更加详细的描述。所描述的实施例是本申请一部分实施例,而不是全部的实施例。下面通过参考附图描述的实施例是示例性的,旨在用于解释本申请,而不能理解为对本申请的限制。In order to make the purpose, technical solution and advantages of the application more clear, the technical solution in the embodiment of the application will be described in more detail below in conjunction with the drawings in the embodiment of the application. The described embodiments are some, but not all, embodiments of the application. The embodiments described below by referring to the figures are exemplary, and are intended to explain the present application, and should not be construed as limiting the present application.

第一方面,如图1-3所示,本申请公开了一种兼容H.264和H.265编码标准的视频实时加密传输方法,包括如下步骤:In the first aspect, as shown in Figure 1-3, the present application discloses a video real-time encrypted transmission method compatible with H.264 and H.265 encoding standards, including the following steps:

步骤一、视频播放服务端与视频拍摄端(即图1中的摄像头)之间进行拉流请求。Step 1: A streaming request is made between the video playing server and the video shooting end (that is, the camera in FIG. 1 ).

需要说明的是,在明文视频传输领域,视频播放服务端与摄像头之间依次进行的拉流请求、RTSP验证以及视频流传输,属于比较成熟的技术,因此此处不再对各个步骤进行具体描述。It should be noted that in the field of plaintext video transmission, the streaming request, RTSP verification, and video streaming between the video playback server and the camera are relatively mature technologies, so no specific description of each step will be given here. .

步骤二、拉流请求成功后视频播放服务端与视频拍摄端之间进行RTSP验证(参见图2所示流程),在验证过程中还包括对视频流进行解析和加密处理(参见图3所示流程),以及将解析和加密处理后得到的编码参数集传输至视频播放服务端。Step 2: After the streaming request is successful, RTSP verification is performed between the video playback server and the video shooting end (see the process shown in Figure 2), and the verification process also includes parsing and encrypting the video stream (see Figure 3 process), and transmit the encoding parameter set obtained after parsing and encryption to the video playback server.

其中,对视频流进行解析包括:Among them, parsing the video stream includes:

步骤2.1、对频流进行解析,以判断其编码标准,其中,编码标准包括H.264和/或H.265(图1中默认除了H.265之外的编码标准是目前较为普遍使用的H.264)。Step 2.1, analyze the frequency stream to determine its encoding standard, wherein the encoding standard includes H.264 and/or H.265 (the default encoding standard other than H.265 in Figure 1 is currently more commonly used H .264).

步骤2.2、对视频流中每一个(前面提到,原始码流是由多个的NALU组成)网络抽象层单元NALU中的预定参数集进行定位,其中:Step 2.2, locate the predetermined parameter set in the network abstraction layer unit NALU of each (mentioned above, the original code stream is made up of a plurality of NALUs) in the video stream, wherein:

当编码标准为H.264时,预定参数集包括序列参数集SPS和图像参数集PPS;When the encoding standard is H.264, the predetermined parameter set includes a sequence parameter set SPS and a picture parameter set PPS;

当编码标准为H.265或同时包括H.264和H.265时,预定参数集包括视频参数集VPS、序列参数集SPS和图像参数集PPS。When the encoding standard is H.265 or includes both H.264 and H.265, the predetermined parameter set includes video parameter set VPS, sequence parameter set SPS and picture parameter set PPS.

进一步,此步骤所说的定位包括对每一个网络抽象层单元NALU中各参数集(即视频参数集VPS、序列参数集SPS和图像参数集PPS)的确定以及对各参数集的开始及结束位置的定位。Further, the positioning mentioned in this step includes the determination of each parameter set (i.e. video parameter set VPS, sequence parameter set SPS and image parameter set PPS) in each network abstraction layer unit NALU and the start and end positions of each parameter set positioning.

具体的,针对每一个网络抽象层单元NALU中的视频参数集VPS、序列参数集SPS和图像参数集PPS的确定包括如下步骤:Specifically, the determination of the video parameter set VPS, the sequence parameter set SPS and the image parameter set PPS in each network abstraction layer unit NALU includes the following steps:

步骤2.2.1、在视频流中通过搜索起始码(0x000001)来对网络抽象层单元NALU进行定位。Step 2.2.1, locate the network abstraction layer unit NALU by searching the start code (0x000001) in the video stream.

步骤2.2.2、再分别按照编码标准按位读取网络抽象层单元NALU头部的数据类型位nal_unit_type,随后将其值转化为整形后判断网络抽象层单元NALU内是否包含对应的参数集,其中:Step 2.2.2, then read the data type bit nal_unit_type of the network abstraction layer unit NALU header bit by bit according to the coding standard, and then convert its value into shaping and then determine whether the network abstraction layer unit NALU contains the corresponding parameter set, wherein :

对于H.264编码标准:For the H.264 encoding standard:

当整形后的数值为7时,确定网络抽象层单元NALU内包含序列参数集SPS;When the reshaped value is 7, it is determined that the network abstraction layer unit NALU contains the sequence parameter set SPS;

当整形后的数值为8时,确定网络抽象层单元NALU内包含图像参数集PPS。When the reshaped value is 8, it is determined that the network abstraction layer unit NALU contains the image parameter set PPS.

对于H.265编码标准:For the H.265 encoding standard:

当整形后的数值为32时,确定网络抽象层单元NALU内包含视频参数集VPS;When the reshaped value is 32, it is determined that the network abstraction layer unit NALU contains the video parameter set VPS;

当整形后的数值为33时,确定网络抽象层单元NALU内包含序列参数集SPS;When the reshaped value is 33, it is determined that the sequence parameter set SPS is included in the network abstraction layer unit NALU;

当整形后的数值为34时,确定网络抽象层单元NALU内包含图像参数集PPS。When the reshaped value is 34, it is determined that the network abstraction layer unit NALU contains the image parameter set PPS.

进一步的,参照图7所示,H.264的NALU头(Header)只占一个字节(即1byte,其等于8bit),其中:Further, as shown in FIG. 7, the NALU header (Header) of H.264 only occupies one byte (that is, 1 byte, which is equal to 8 bits), wherein:

F:forbidden_zero_bit,为禁止位,占1bit,禁止位应该为0,当禁止位为1时说明NALU中存在错误,需要进行舍弃或纠错;F: forbidden_zero_bit, which is the forbidden bit, occupying 1 bit, the forbidden bit should be 0, when the forbidden bit is 1, it means that there is an error in the NALU, and it needs to be discarded or corrected;

NRI:nal_ref_idc,为重要指示位,占2bit,取00~11,指示这个NALU的重要性;取值越大,表示当前NAL越重要,需要优先受到保护;如果当前NALU是序列参数集或是图像参数集这些重要的单位时,本句法元素必需大于0;NRI: nal_ref_idc, which is an important indicator bit, occupies 2 bits, takes 00~11, and indicates the importance of this NALU; the larger the value, the more important the current NAL is, and it needs to be protected first; if the current NALU is a sequence parameter set or an image When parameter sets these important units, this syntax element must be greater than 0;

Type:nal_unit_type,标识NALU中负荷的数据类型,占5bit,常见的nal_unit_type具体含义如下表1所示:Type: nal_unit_type, which identifies the data type of the load in the NALU, accounting for 5 bits. The specific meanings of common nal_unit_type are shown in Table 1 below:

表1-H.264的NALU头中常见的nal_unit_type含义表Table 1 - Common nal_unit_type meaning table in the NALU header of H.264

nal_unit_typenal_unit_type 表示的内容Expressed content 00 没有定义Not defined 77 序列参数集SPSSequence parameter set SPS 88 图像参数集PPSImage parameter set PPS 24twenty four 事件组合包Event Package 25-2725-27 时间组合包Time Pack 28-2928-29 分片单元Fragmentation unit 30-3130-31 保留位reserved bit

进一步的,参照图8所示,H.265的NALU头占两个字节,其中:Further, as shown in Figure 8, the NALU header of H.265 occupies two bytes, where:

F:forbidden_zero_bit,为禁止位,占1bit,禁止位应该为0,当禁止位为1时说明NALU中存在错误,需要进行舍弃或纠错;F: forbidden_zero_bit, which is the forbidden bit, occupying 1 bit, the forbidden bit should be 0, when the forbidden bit is 1, it means that there is an error in the NALU, which needs to be discarded or corrected;

Type:nal_unit_type,占6bit,标识NALU中负荷的数据类型;常见的nal_unit_type具体含义见下表2所示;Type: nal_unit_type, occupying 6 bits, identifies the data type of the load in the NALU; the specific meaning of the common nal_unit_type is shown in Table 2 below;

LayerId:nuh_layer_id,占6bit,表示NALU所属层的标识符或non-VCLU所应用的层的标识符;LayerId: nuh_layer_id, occupying 6 bits, indicating the identifier of the layer to which the NALU belongs or the identifier of the layer to which the non-VCLU is applied;

TID:nuh_temporal_id_plus1,占3bit,指定了NALU的时间标识符;TID: nuh_temporal_id_plus1, accounting for 3 bits, specifies the time identifier of the NALU;

表2-H.265的NALU头中常见的nal_unit_type含义表Table 2 - Common nal_unit_type meaning table in the NALU header of H.265

进一步的,参见图9所示,是以一段H.265的码流来实例分析,其中,矩形框a1里的为起始码,矩形框a2里的为NALU头,“40 01”对应的nal_unit_type为32(VPS),“42 01”对应的nal_unit_type为33(SPS),“44 01”对应的nal_unit_type为34(PPS)。Further, as shown in Figure 9, it is an example analysis of a H.265 code stream, where the start code in the rectangle a1 is the start code, the NALU header in the rectangle a2, and the nal_unit_type corresponding to "40 01" is 32 (VPS), the nal_unit_type corresponding to "42 01" is 33 (SPS), and the nal_unit_type corresponding to "44 01" is 34 (PPS).

进一步,此步骤三中对每一个网络抽象层单元NALU中各参数集的开始及结束位置的定位具体包括:Further, the positioning of the start and end positions of each parameter set in each network abstraction layer unit NALU in step 3 specifically includes:

步骤2.2.3、根据识别的编码标准,在当前网络抽象层单元NALU头部跳过一个或两个字节,以定位其中对应参数集的开始位置。Step 2.2.3. According to the recognized encoding standard, one or two bytes are skipped at the head of the current network abstraction layer unit NALU to locate the start position of the corresponding parameter set.

步骤2.2.4、通过搜索起始码(0x000001)来定位下一个网络抽象层单元NALU,从而确定当前网络抽象层单元NALU的结束位置,即对应参数集的结束位置。Step 2.2.4. Locate the next network abstraction layer unit NALU by searching the start code (0x000001), so as to determine the end position of the current network abstraction layer unit NALU, that is, the end position of the corresponding parameter set.

步骤2.3、将定位出的预定参数集标识为关键内容。Step 2.3, identifying the located predetermined parameter set as key content.

具体的,此步骤是将步骤2.2中定位到的参数集VPS、SPS和PPS标识为关键内容。Specifically, this step is to identify the parameter sets VPS, SPS and PPS located in step 2.2 as key content.

需要说明的是,通过对H.264和H.265编码的分析可以得知在视频流中信息并不是均匀分布的,存在部分关键内容相较于其他内容包含有更多的信息,在视频编解码(即解析)过程中具有更重要的作用,下面将简析重要内容的划分理由:It should be noted that through the analysis of H.264 and H.265 encoding, it can be known that the information in the video stream is not evenly distributed, and some key content contains more information than other content. It plays a more important role in the decoding (that is, parsing) process. The reason for the division of important content will be briefly analyzed below:

视频参数集VPS包含视频编码序列的多个语法元素,根据视频参数集的内容可以将其分为三个部分:第一部分由子层或操作点共用的语法元素构成,主要包括视频参数集标识符、视频编码序列的最大层数、视频编码序列的最大时域子层数等;第二部分由与档次、层以及级别相关的信息构成,主要包括语法元素profile_tier_level();profile_tier_level()会依据参数的值来确定档次、层和级别的相关内容;第三部分由视频参数集特有的操作点信息构成。The video parameter set VPS contains multiple syntax elements of the video coding sequence, which can be divided into three parts according to the content of the video parameter set: the first part is composed of syntax elements shared by sub-layers or operation points, mainly including the video parameter set identifier, The maximum number of layers of the video coding sequence, the maximum number of time-domain sub-layers of the video coding sequence, etc.; the second part is composed of information related to grades, layers and levels, mainly including the syntax element profile_tier_level(); profile_tier_level() will be based on the parameters The value is used to determine the relevant content of the grade, layer and level; the third part is composed of the specific operation point information of the video parameter set.

序列参数集SPS的内容主要由编码视频序列中图像所共用的信息构成,根据序列参数集的内容可以将其分为四个部分:第一部分由操作点共用的语法元素构成,主要包括视频参数集参考标识符、序列参数集标识符、视频编码序列包含的最大时域子层数以及视频编码序列帧间预测的限制信息,其中SPS会通过vps_id字段指明所参考的视频参数集,通过sps_id字段作为唯一标识使其能够被图像参数集引用;第二部分由与档次、层以及级别相关的信息构成;第三部分由图像格式相关信息构成,主要包括色度采样格式、图像的分辨率、量化深度、时域子层顺序标志;第四部分由编码参数相关信息构成,主要包括最小亮度编码块的大小及其与最大亮度编码块的差值、最小变换块大小及其与最大变换块的差值、帧间预测编码块与帧内预测编码块的最大变换层次深度、是否使用量化表等。The content of the sequence parameter set SPS is mainly composed of the information shared by the images in the coded video sequence. According to the content of the sequence parameter set, it can be divided into four parts: the first part is composed of the syntax elements shared by the operation point, mainly including the video parameter set Reference identifier, sequence parameter set identifier, the maximum number of time-domain sub-layers contained in the video coding sequence, and restriction information for inter-frame prediction of the video coding sequence, where SPS will indicate the referenced video parameter set through the vps_id field, and use the sps_id field as The unique identifier enables it to be referenced by the image parameter set; the second part is composed of information related to grade, layer and level; the third part is composed of image format-related information, mainly including chroma sampling format, image resolution, and quantization depth , Time-domain sub-layer order mark; the fourth part is composed of coding parameter-related information, mainly including the size of the minimum brightness coding block and its difference with the maximum brightness coding block, the minimum transformation block size and its difference with the maximum transformation block , the maximum transformation level depth of the inter-frame prediction coding block and the intra-frame prediction coding block, whether to use a quantization table, etc.

图像参数集PPS主要由编解码图像过程中所用到的各类公共参数构成,根据图像参数集的内容可以将其分为五个部分:第一部分由编码图像的共用语法元素构成,主要包括pps_id字段、引用的sps_id字段;第二部分由分片头部相关信息构成,主要包括分片是否为依赖片、分片头部是否存在额外比特数据、二进制熵编码算法初始化方法等信息;第三部分由与量化相关的语法元素构成,主要包括量化参数初始值、亮度与色度量化参数的偏移等语法元素;第四部分由编码工具可用性相关信息构成,主要包括P帧加权预测B帧加权预测、TILE模式、熵编码同步模式等;第五部分由扩展信息相关标志信息构成,包括指示条带头扩展信息的标志以及指示图像参数集扩展信息的标志。The image parameter set PPS is mainly composed of various public parameters used in the process of encoding and decoding images. According to the content of the image parameter set, it can be divided into five parts: the first part is composed of the common syntax elements of the encoded image, mainly including the pps_id field , the referenced sps_id field; the second part consists of information about the slice header, mainly including whether the slice is a dependent slice, whether there is extra bit data in the slice header, the initialization method of the binary entropy coding algorithm, etc.; the third part consists of Composition of syntax elements related to quantization, mainly including syntax elements such as the initial value of quantization parameters, the offset of brightness and color quantization parameters; the fourth part is composed of information related to the availability of coding tools, mainly including P frame weighted prediction B frame weighted prediction, TILE mode, entropy coding synchronization mode, etc.; the fifth part is composed of extension information-related flag information, including a flag indicating the extension information of the slice header and a flag indicating the extension information of the image parameter set.

通过上述分析可以看到,参数集VPS、SPS和PPS包含了在视频编解码过程中需要的大量关键信息,如标识符字段、图像尺寸、视频格式、差值、编码的档级等,没有参数集将导致所有使用该参数集进行编码的视频流都无法被正常解码,也不能被通用解码器解析与播放,因此本申请中将参数集VPS、SPS和PPS标识为关键内容。并且由于参数集中的参数字段众多,取值范围更广,因此其明文空间足以抵抗暴力穷举攻击,即使加密后的视频流被截取或泄露,没有特定的解码器和密钥依旧无法恢复出视频内容。另外,由于加密部分不含实际编码后的视频内容,所以加解密处理时延和传输时延较低,从而可以适用于例如视频监控、围界安防等对实时性要求较高的视频监控系统。From the above analysis, we can see that the parameter sets VPS, SPS and PPS contain a large amount of key information needed in the video encoding and decoding process, such as identifier field, image size, video format, difference value, encoding level, etc., without parameter set will cause all video streams encoded using this parameter set to be unable to be decoded normally, nor can it be parsed and played by a general-purpose decoder. Therefore, the parameter sets VPS, SPS and PPS are identified as key content in this application. And because there are many parameter fields in the parameter set and the value range is wider, the plaintext space is sufficient to resist brute force attacks. Even if the encrypted video stream is intercepted or leaked, the video cannot be recovered without a specific decoder and key. content. In addition, since the encrypted part does not contain the actual encoded video content, the encryption and decryption processing delay and transmission delay are low, so it can be applied to video surveillance systems with high real-time requirements such as video surveillance and perimeter security.

步骤2.4、将步骤2.3中标识的关键内容进行加密处理。Step 2.4, encrypting the key content identified in step 2.3.

具体的,此步骤中是标识的关键内容参数集VPS、SPS和PPS进行加密,具体包括以下步骤:Specifically, in this step, the identified key content parameter sets VPS, SPS and PPS are encrypted, specifically including the following steps:

步骤2.4.1、使用对称分组加密算法对所述关键内容进行保密性加密,得到保密性加密后的密文数据;其中的对称分组加密算法包括AES、SM1、SM4等。Step 2.4.1. Use a symmetric block encryption algorithm to perform confidentiality encryption on the key content to obtain confidentially encrypted ciphertext data; wherein the symmetric block encryption algorithm includes AES, SM1, SM4, etc.

步骤2.4.2、使用基于密钥的哈希运算消息认证码算法(HMAC)对关键内容进行完整性加密,得到完整性加密后的密文数据;其中的基于密钥的哈希运算消息认证码算法包括SHA-256、SHA-512、SM3等。Step 2.4.2, use the key-based hash operation message authentication code algorithm (HMAC) to carry out integrity encryption on the key content, and obtain the ciphertext data after integrity encryption; wherein the key-based hash operation message authentication code Algorithms include SHA-256, SHA-512, SM3, etc.

步骤2.4.3、将保密性加密后的密文数据和完整性加密后的密文数据进行直接拼接,中间不加任何分隔符,并使用拼接后的密文替换所述关键内容的明文。需要说明的是,因为完整性加密输出的密文具有固定长度,所以特定解码器解码时需要首先定位和截取完整性加密的密文,剩余的即为保密性加密的密文。Step 2.4.3. Directly concatenate the confidentiality-encrypted ciphertext data and the integrity-encrypted ciphertext data without adding any separator, and use the concatenated ciphertext to replace the plaintext of the key content. It should be noted that since the ciphertext output by integrity encryption has a fixed length, a specific decoder needs to first locate and intercept the integrity-encrypted ciphertext when decoding, and the rest is the confidentiality-encrypted ciphertext.

在进一步的实施例中,在步骤2.4中对关键内容进行加密处理后,且得到编码参数集之前,还包括对加密处理后得到的密文进行加壳处理,具体包括如下步骤:In a further embodiment, after encrypting the key content in step 2.4 and before obtaining the coding parameter set, it also includes packing the ciphertext obtained after the encryption, specifically including the following steps:

步骤2.4.4、对上述步骤2.4.3中拼接后的密文进行加壳操作。Step 2.4.4, performing a packing operation on the ciphertext spliced in the above step 2.4.3.

步骤2.4.5、在拼接后的密文末尾添加0xffffffff校验码,用以标识该密文的结束。Step 2.4.5. Add a 0xffffffff check code at the end of the spliced ciphertext to mark the end of the ciphertext.

需要说明的是,H.264规定每个NALU前有一个起始码0x000001,解码器检测每个起始码,作为一个NALU的起始标识,当检测到下一个起始码时,当前NALU结束。同时,H.264规定当检测到0x000000时,也可以表征当前NALU的结束。所以当加密后的密文末尾出现0时,会导致H.264不能被解码器正确解码。It should be noted that H.264 stipulates that there is a start code 0x000001 before each NALU. The decoder detects each start code as the start identifier of a NALU. When the next start code is detected, the current NALU ends . At the same time, H.264 stipulates that when 0x000000 is detected, it can also represent the end of the current NALU. Therefore, when 0 appears at the end of the encrypted ciphertext, H.264 cannot be decoded correctly by the decoder.

为此,本申请在拼接后的密文末尾添加0xffffffff校验码,用以标识密文的结束,从而能够兼容H.264和H.265编码标准。另外,通过解码器针对本申请的信息进行解码时,当检测到0xffffffff序列时,即为密文的结束位置,之后逐字节读取加密数据,再进行密文解密和完整性校验。For this reason, the present application adds a 0xffffffff check code at the end of the spliced ciphertext to mark the end of the ciphertext, so as to be compatible with H.264 and H.265 encoding standards. In addition, when the information of this application is decoded by the decoder, when the 0xffffffff sequence is detected, it is the end position of the ciphertext, and then the encrypted data is read byte by byte, and then the ciphertext decryption and integrity verification are performed.

步骤三、RTSP验证通过后,在视频拍摄端向所述视频播放服务端传输的视频流中,将每帧中的相关视频参数进行剔除,仅保留视频数据部分传输到所述视频播放服务器。Step 3: After the RTSP verification is passed, in the video stream transmitted from the video shooting end to the video playback server, the relevant video parameters in each frame are removed, and only the video data part is reserved for transmission to the video playback server.

步骤四、视频播放服务器识别和解密加密后的所述编码参数集,并恢复编码参数集明文。Step 4: The video playing server identifies and decrypts the encrypted encoding parameter set, and recovers the plaintext of the encoding parameter set.

需要说明的是,参见图2所示,通常视频拍摄端(即摄像头)针对PLAY请求返回的RTSP 200OK中会包含全部的编码参数集,在明文视频传输的RTSP验证过程中,返回到视频播放服务端的RTSP 200OK中的编码参数集是明文状态的;但是在本申请中,视频加密客户端会针对摄像头返回的RTSP 200OK中的编码参数集进行加密,之后将加密后的RTSP 200OK返回到视频播放服务端。视频播放服务端接收到加密后的RTSP 200OK,利用嵌入的解密模块识别和解密加密后的编码参数集,恢复编码参数集明文。It should be noted that, as shown in Figure 2, usually the RTSP 200OK returned by the video shooting end (that is, the camera) for the PLAY request will contain all the encoding parameter sets. During the RTSP verification process of plaintext video transmission, the video playback service The encoding parameter set in the RTSP 200OK at the end is in plain text; however, in this application, the video encryption client will encrypt the encoding parameter set in the RTSP 200OK returned by the camera, and then return the encrypted RTSP 200OK to the video playback service end. The video playback server receives the encrypted RTSP 200OK, uses the embedded decryption module to identify and decrypt the encrypted encoding parameter set, and restores the plaintext of the encoding parameter set.

另外,在明文视频的视频流传输过程中,一般摄像头内置编码器编码出的每帧都会加上SPS、PPS或VPS等编码参数集,所以在视频流传输过程中有一部分数据包会包含编码参数集;通常情况下,同一编码器编出的编码参数是一样的,有一定的宽带资源耗费,不能很好的适用于宽带资源紧张的场景,因此,本申请仅在返回RTSP 200OK中保留了编码参数集,后续在视频流传输过程中,视频加密客户端会将每帧中的视频参数剔除,仅保留视频数据部分传输到视频播放服务器,在视频播放服务器使用解密的编码参数集进行解码播放。In addition, in the process of video streaming of plaintext video, each frame encoded by the built-in encoder of the camera will add encoding parameter sets such as SPS, PPS or VPS, so some data packets will contain encoding parameters during video streaming. set; usually, the encoding parameters compiled by the same encoder are the same, which consumes a certain amount of broadband resources and cannot be well applied to scenarios where broadband resources are tight. Therefore, this application only retains the encoding in the returned RTSP 200OK Parameter set, during the subsequent video streaming process, the video encryption client will remove the video parameters in each frame, and only retain the video data part to transmit to the video playback server, where the decrypted encoding parameter set is used for decoding and playback.

综上,本申请的兼容H.264和H.265编码标准的视频实时传输方法,能够在不改变视频流整体结构和传输协议的前提下保护视频内容的安全,同时兼容主流的H.264和H.265编码标准;并且,本申请的加密传输方法能够进一步节约宽带资源消耗,以更好的适用于高清视频、全景视频等对带宽资源要求较高的视频实时传输加密场景;另外,本申请的加密传输方法中由于仅在RTSP验证过程中加密一次参数集VPS、SPS和PPS,因此使得密文膨胀率不超过1%,且使得实时传输时延较低,实用性更强。To sum up, the real-time video transmission method compatible with the H.264 and H.265 encoding standards of this application can protect the security of the video content without changing the overall structure of the video stream and the transmission protocol, and is compatible with the mainstream H.264 and H.265 encoding standards. H.265 encoding standard; and, the encrypted transmission method of the present application can further save the consumption of broadband resources, so as to be better applicable to high-definition video, panoramic video and other video real-time transmission encryption scenarios that require higher bandwidth resources; in addition, the present application In the encrypted transmission method, because the parameter sets VPS, SPS and PPS are only encrypted once during the RTSP verification process, the ciphertext expansion rate does not exceed 1%, and the real-time transmission delay is low, and the practicability is stronger.

第二方面,如图1、4所示,本申请还公开了一种兼容H.264和H.265编码标准的视频实时加密传输系统,可以包括视频播放服务端100、视频拍摄端200以及视频加密客户端300。In the second aspect, as shown in Figures 1 and 4, this application also discloses a video real-time encrypted transmission system compatible with H.264 and H.265 encoding standards, which may include a video playback server 100, a video capture terminal 200, and a video Encrypt client 300.

其中,视频播放服务端100用于与视频拍摄端200之间进行拉流请求,并在拉流请求成功后与视频拍摄端之间进行RTSP验证。Wherein, the video playing server 100 is used to perform a streaming request with the video shooting end 200, and perform RTSP verification with the video shooting end after the streaming request is successful.

视频加密客户端300用于在RTSP验证过程对视频流进行解析和加密处理,以及将解析和加密处理后得到的编码参数集传输至视频播放服务端100。The video encryption client 300 is used to analyze and encrypt the video stream during the RTSP verification process, and transmit the encoding parameter set obtained after the analysis and encryption to the video playback server 100 .

其中,对视频流进行解析包括如下步骤:Wherein, parsing the video stream includes the following steps:

步骤2.1、对视频流进行解析,以判断其编码标准,其中,编码标准包括H.264和/或H.265;Step 2.1, analyzing the video stream to determine its encoding standard, wherein the encoding standard includes H.264 and/or H.265;

步骤2.2、对视频流中每一个网络抽象层单元NALU中的预定参数集进行定位,其中:Step 2.2, locate the predetermined parameter set in each network abstraction layer unit NALU in the video stream, wherein:

当编码标准为H.264时,预定参数集包括序列参数集SPS和图像参数集PPS;When the encoding standard is H.264, the predetermined parameter set includes a sequence parameter set SPS and a picture parameter set PPS;

当编码标准为H.265或同时包括H.264和H.265时,预定参数集包括视频参数集VPS、序列参数集SPS和图像参数集PPS。When the encoding standard is H.265 or includes both H.264 and H.265, the predetermined parameter set includes video parameter set VPS, sequence parameter set SPS and picture parameter set PPS.

具体的,如图5所示,视频加密客户端300又可以包括第一定位模块301和第二定位模块302。Specifically, as shown in FIG. 5 , the video encryption client 300 may further include a first positioning module 301 and a second positioning module 302 .

其中,第一定位模块301用于对每一个网络抽象层单元NALU中各参数集进行确定,具体包括:Wherein, the first positioning module 301 is used to determine each parameter set in each network abstraction layer unit NALU, specifically including:

在待加密视频流中通过搜索起始码来对网络抽象层单元NALU进行定位,再按位读取所述网络抽象层单元NALU头部的数据类型位nal_unit_type,随后将其值转化为整形;In the video stream to be encrypted, the network abstraction layer unit NALU is positioned by searching the start code, and then the data type bit nal_unit_type of the network abstraction layer unit NALU header is read bit by bit, and then its value is converted into shaping;

其中:in:

对于H.264编码标准:For the H.264 encoding standard:

当整形后的数值为7时,确定参数集包含序列参数集SPS;当整形后的数值为8时,确定参数集包含图像参数集PPS。When the reshaped value is 7, it is determined that the parameter set includes the sequence parameter set SPS; when the reshaped value is 8, it is determined that the parameter set includes the image parameter set PPS.

对于H.265编码标准:For the H.265 encoding standard:

当整形后的数值为32时,确定参数集包含视频参数集VPS,当整形后的数值为33时,确定参数集包含序列参数集SPS,当整形后的数值为34时,确定参数集包含图像参数集PPS。When the value after shaping is 32, it is determined that the parameter set contains video parameter set VPS; when the value after shaping is 33, it is determined that the parameter set contains sequence parameter set SPS; when the value after shaping is 34, it is determined that the parameter set contains image Parameter set PPS.

第二定位模块302用于对每一个网络抽象层单元NALU中各参数集的开始及结束位置进行定位,具体包括:The second positioning module 302 is used to locate the start and end positions of each parameter set in each network abstraction layer unit NALU, specifically including:

在当前网络抽象层单元NALU头部跳过一个或两个字节,以定位其中对应参数集的开始位置,再通过搜索起始码来定位下一个网络抽象层单元NALU,从而确定当前网络抽象层单元NALU的结束位置,即对应参数集的结束位置。Skip one or two bytes at the head of the current network abstraction layer unit NALU to locate the start position of the corresponding parameter set, and then locate the next network abstraction layer unit NALU by searching the start code to determine the current network abstraction layer The end position of the unit NALU, that is, the end position of the corresponding parameter set.

进一步的,如图6所示,视频加密客户端300还包括第一加密模块303、第二加密模块304拼接模块305以及加壳模块306。Further, as shown in FIG. 6 , the video encryption client 300 also includes a first encryption module 303 , a second encryption module 304 , a splicing module 305 and a packing module 306 .

其中,第一加密模块303用于通过对称分组加密算法对所述关键内容进行保密性加密,得到保密性加密后的密文数据;Wherein, the first encryption module 303 is configured to perform confidentiality encryption on the key content through a symmetric block encryption algorithm to obtain confidentiality-encrypted ciphertext data;

第二加密模块304用于基于密钥的哈希运算消息认证码算法对关键内容进行完整性加密,得到完整性加密后的密文数据;The second encryption module 304 is used to perform integrity encryption on the key content based on the hash operation message authentication code algorithm of the key, and obtain the ciphertext data after the integrity encryption;

拼接模块305用于将保密性加密后的密文数据和完整性加密后的密文数据进行直接拼接,并使用拼接后的密文替换所述关键内容的明文。The splicing module 305 is used to directly splice the confidentiality-encrypted ciphertext data and the integrity-encrypted ciphertext data, and use the spliced ciphertext to replace the plaintext of the key content.

加壳模块306用于对拼接后的密文进行加壳操作,再在拼接后的密文末尾添加0xffffffff校验码,用以标识该密文的结束,最后处理后的加壳的密文与剩余的视频流进行组合,从而得到加密待传输视频流。Packing module 306 is used for carrying out packing operation to the ciphertext after splicing, then adds 0xffffffff check code at the end of ciphertext after splicing, in order to mark the end of this ciphertext, the ciphertext of packing after the final processing and The remaining video streams are combined to obtain encrypted video streams to be transmitted.

同样,本申请的兼容H.264和H.265编码标准的视频实时加密传输系统,能够在不改变视频流整体结构和传输协议的前提下保护视频内容的安全,同时兼容主流的H.264和H.265编码标准;并且,本申请的加密传输系统能够进一步节约宽带资源消耗,以更好的适用于高清视频、全景视频等对带宽资源要求较高的视频实时传输加密场景;另外,本申请的加密传输系统中由于仅在RTSP验证过程中加密一次参数集VPS、SPS和PPS,因此使得密文膨胀率不超过1%,且使得实时传输时延较低,实用性更强。Similarly, the video real-time encrypted transmission system compatible with the H.264 and H.265 encoding standards of this application can protect the security of the video content without changing the overall structure of the video stream and the transmission protocol, and is compatible with the mainstream H.264 and H.265 encoding standards. H.265 encoding standard; and, the encrypted transmission system of the present application can further save the consumption of broadband resources, so as to be better applicable to high-definition video, panoramic video and other video real-time transmission encryption scenarios that require higher bandwidth resources; in addition, the present application In the encrypted transmission system, the parameter sets VPS, SPS and PPS are only encrypted once during the RTSP verification process, so the ciphertext expansion rate does not exceed 1%, and the real-time transmission delay is low, and the practicability is stronger.

本申请的另一方面,提供了一种计算机设备,包括处理器、存储器以及存储在存储器上并可在处理器上运行的计算机程序,处理器执行计算机程序用于实现上述兼容H.264和H.265编码标准的视频实时传输方法。Another aspect of the present application provides a computer device, including a processor, a memory, and a computer program stored on the memory and operable on the processor. The processor executes the computer program to implement the above-mentioned compatible H.264 and H. .265 encoding standard video real-time transmission method.

计算机设备可以包括中央处理单元(CPU),其可以根据存储在只读存储器(ROM)中的程序或者从存储部分加载到随机访问存储器(RAM)中的程序而执行各种适当的动作和处理。在RAM中,还存储有计算机设备操作所需的各种程序和数据。CPU、ROM以及RAM通过总线彼此相连。输入/输出(I/O)接口也连接至总线。The computer device may include a central processing unit (CPU) that can perform various appropriate actions and processes according to programs stored in a read only memory (ROM) or loaded from a storage section into a random access memory (RAM). In RAM, various programs and data necessary for the operation of the computer device are also stored. The CPU, ROM, and RAM are connected to each other through a bus. Input/output (I/O) interfaces are also connected to the bus.

以下部件连接至I/O接口:包括键盘、鼠标等的输入部分;包括诸如阴极射线管(CRT)、液晶显示器(LCD)等以及扬声器等的输出部分;包括硬盘等的存储部分;以及包括诸如LAN卡、调制解调器等的网络接口卡的通信部分。通信部分经由诸如因特网的网络执行通信处理。驱动器也根据需要连接至I/O接口。可拆卸介质,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据需要安装在驱动器上,以便于从其上读出的计算机程序根据需要被安装入存储部分。The following parts are connected to the I/O interface: an input section including a keyboard, a mouse, etc.; an output section including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage section including a hard disk, etc.; The communication part of the network interface card of LAN card, modem, etc. The communication section performs communication processing via a network such as the Internet. Drives are also connected to the I/O interface as needed. A removable medium, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is mounted on the drive as necessary so that a computer program read therefrom is installed into the storage section as necessary.

特别地,根据本申请的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本申请的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分从网络上被下载和安装,和/或从可拆卸介质被安装。在该计算机程序被中央处理单元(CPU)执行时,执行本申请的方法中限定的上述功能。需要说明的是,本申请的计算机存储介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本申请中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本申请中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、电线、光缆、RF等等,或者上述的任意合适的组合。In particular, according to the embodiments of the present application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments of the present application include a computer program product, which includes a computer program carried on a computer-readable medium, where the computer program includes program codes for executing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from a network via the communication part, and/or installed from a removable medium. When the computer program is executed by a central processing unit (CPU), the above-mentioned functions defined in the method of the present application are performed. It should be noted that the computer storage medium in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. A computer readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, electrical connections with one or more wires, portable computer diskettes, hard disks, random access memory (RAM), read-only memory (ROM), erasable Programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above. In this application, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, however, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, in which computer-readable program codes are carried. Such propagated data signals may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. . Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

描述于本申请实施例中所涉及到的模块或单元可以通过软件的方式实现,也可以通过硬件的方式来实现。所描述的模块或单元也可以设置在处理器中,这些模块或单元的名称在某种情况下并不构成对该模块或单元本身的限定。The modules or units involved in the embodiments described in the present application may be implemented by means of software or by means of hardware. The described modules or units may also be set in the processor, and the names of these modules or units do not constitute limitations on the modules or units themselves in some cases.

作为另一方面,本申请还提供了一种计算机可读存储介质,该计算机可读存储介质可以是上述实施例中描述的装置中所包含的;也可以是单独存在,而未装配入该装置中。上述计算机可读存储介质承载有一个或者多个程序,当上述一个或者多个程序被该装置执行时按上述方法对数据进行处理。As another aspect, the present application also provides a computer-readable storage medium, which may be included in the device described in the above-mentioned embodiments; or exist independently without being assembled into the device middle. The computer-readable storage medium carries one or more programs, and when the one or more programs are executed by the device, the data is processed according to the above method.

以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。The above is only a specific embodiment of the application, but the scope of protection of the application is not limited thereto. Any person familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the application. All should be covered within the scope of protection of this application. Therefore, the protection scope of the present application should be determined by the protection scope of the claims.

Claims (10)

1. A video real-time encryption transmission method compatible with H.264 and H.265 coding standards is characterized by comprising the following steps:
step one, a streaming request is carried out between a video playing server and a video shooting end;
step two, after the streaming request is successful, RTSP verification is carried out between the video playing server and the video shooting end, and the verification process also comprises the steps of analyzing and encrypting the video stream and transmitting the coding parameter set obtained after the analysis and the encryption to the video playing server; wherein, the parsing the video stream includes:
step 2.1, analyzing the video stream to judge the coding standard, wherein the coding standard comprises H.264 and/or H.265;
step 2.2, locating a predetermined parameter set in each network abstraction layer unit NALU in the video stream, wherein:
when the coding standard is h.264, the predetermined parameter set includes a sequence parameter set SPS and a picture parameter set PPS;
when the encoding standard is h.265 or includes both h.264 and h.265, the predetermined parameter set includes a video parameter set VPS, a sequence parameter set SPS, and a picture parameter set PPS;
step 2.3, marking the positioned preset parameter set as key content;
The encrypting the video stream comprises:
step 2.4, encrypting the key content identified in the step 2.3 to obtain a coding parameter set;
step three, after passing the RTSP verification, rejecting relevant video parameters in each frame in a video stream transmitted from the video shooting end to the video playing server, and only reserving a video data part for transmission to the video playing server;
and step four, the video playing server identifies and decrypts the encrypted coding parameter set and restores the plaintext of the coding parameter set.
2. The method according to claim 1, wherein in step 2.2, locating the predetermined parameter set in each network abstraction layer unit NALU comprises:
the determination of the parameter sets in each of said network abstraction layer units NALU and the positioning of the start and end positions of the parameter sets.
3. The method for video real-time encrypted transmission according to claim 2, wherein the determination of the video parameter set VPS, the sequence parameter set SPS and the picture parameter set PPS in each of the network abstraction layer units NALU comprises the steps of:
Step 2.2.1, locating the network abstraction layer unit NALU in the video stream by searching a start code;
step 2.2.2, reading the data type bit nal_unit_type of the network abstraction layer unit NALU header according to the bit, converting the value into a shaped value, and judging whether the network abstraction layer unit NALU contains a corresponding parameter set, wherein:
for the h.264 coding standard:
when the shaped value is 7, determining that a sequence parameter set SPS is contained in a network abstraction layer unit NALU;
when the shaped value is 8, determining that the network abstraction layer unit NALU contains an image parameter set PPS;
for the h.265 coding standard:
when the shaped value is 32, determining that the network abstraction layer unit NALU contains a video parameter set VPS;
when the shaped value is 33, determining that the network abstraction layer unit NALU contains a sequence parameter set SPS;
when the shaped value is 34, it is determined that the network abstraction layer unit NALU contains the picture parameter set PPS.
4. A method of video real-time encrypted transmission according to claim 3, wherein locating the start and end positions of the parameter sets in each network abstraction layer unit NALU comprises:
Step 2.2.3, skipping one or two bytes in the head of the current network abstraction layer unit NALU to locate the start position of the corresponding parameter set therein;
and 2.2.4, locating the next network abstraction layer unit NALU by searching the start code, thereby determining the end position of the current network abstraction layer unit NALU, namely the end position of the corresponding parameter set.
5. The method for real-time encrypted transmission of video according to claim 1, wherein in step 2.4, the step of encrypting the identified key content comprises the steps of:
2.4.1, carrying out confidentiality encryption on the key content by using a symmetric block encryption algorithm to obtain confidentiality encrypted ciphertext data;
step 2.4.2, carrying out integrity encryption on the key content by using a hash operation message authentication code algorithm based on a secret key to obtain encrypted ciphertext data;
and 2.4.3, directly splicing the encrypted ciphertext data with confidentiality and the encrypted ciphertext data with integrity, and replacing the plaintext of the key content by using the spliced ciphertext.
6. The method for real-time encrypted transmission of video according to claim 5, wherein after said encrypting said key content in step 2.4 and before said obtaining said encoding parameter set, further comprising the step of shell-adding ciphertext obtained after said encrypting, comprising the steps of:
Step 2.4.4, performing shell adding operation on the spliced ciphertext;
and 2.4.5, adding a 0xffffffff check code at the end of the spliced ciphertext to identify the end of the ciphertext.
7. The video real-time encryption transmission system compatible with the H.264 and H.265 coding standards is characterized by comprising a video playing service end (100), a video shooting end (200) and a video encryption client end (300), wherein:
the video playing server (100) is used for carrying out a streaming request with the video shooting end (200) and carrying out RTSP verification with the video shooting end after the streaming request is successful;
the video encryption client (300) is used for analyzing and encrypting the video stream in the RTSP verification process and transmitting the coding parameter set obtained after the analysis and encryption to the video playing server (100); the parsing the video stream includes the following steps:
step 2.1, analyzing the video stream to judge the coding standard, wherein the coding standard comprises H.264 and/or H.265;
step 2.2, locating a predetermined parameter set in each network abstraction layer unit NALU in the video stream, wherein:
when the coding standard is h.264, the predetermined parameter set includes a sequence parameter set SPS and a picture parameter set PPS;
When the encoding standard is h.265 or includes both h.264 and h.265, the predetermined parameter set includes a video parameter set VPS, a sequence parameter set SPS, and a picture parameter set PPS;
step 2.3, marking the positioned preset parameter set as key content;
the encryption processing of the video stream comprises the following steps:
step 2.4, encrypting the key content identified in the step 2.3 to obtain a coding parameter set;
further, the video encryption client (300) is further configured to reject relevant video parameters in each frame from a video stream transmitted from the video capturing end (200) to the video playing server (100) after the RTSP verification is passed, and only a video data portion is reserved and transmitted to the video playing server (100);
further, the video playing server (100) is further configured to identify and decrypt the encrypted encoding parameter set, and restore the encoding parameter set plaintext.
8. The video real-time encrypted transmission system according to claim 7, wherein the video encryption client (300) comprises:
a first positioning module (301) configured to determine parameter sets in each network abstraction layer unit NALU;
And a second positioning module (302) configured to position a start and end position of each parameter set in each network abstraction layer unit NALU.
9. The video real-time encrypted transmission system according to claim 8, wherein said first positioning module (301) determining each parameter set comprises:
the network abstraction layer unit NALU is positioned in the video stream to be encrypted by searching a start code, then a data type bit nal_unit_type of the head of the network abstraction layer unit NALU is read according to the bit, and then the value is converted into a shaping, wherein:
for the h.264 coding standard:
when the shaped value is 7, determining that the parameter set comprises a sequence parameter set SPS; when the shaped value is 8, determining that the parameter set comprises an image parameter set PPS;
for the h.265 coding standard:
when the shaped value is 32, determining that the parameter set comprises a video parameter set VPS; when the shaped value is 33, determining that the parameter set comprises a sequence parameter set SPS; when the shaped value is 34, determining that the parameter set comprises the picture parameter set PPS;
further, the second positioning module (302) positioning the start and end positions of each parameter set includes:
One or two bytes are skipped over from the head of the NALU of the current network abstraction layer unit to locate the start position of the corresponding parameter set, and then the NALU of the next network abstraction layer unit is located by searching the start code, so that the end position of the NALU of the current network abstraction layer unit, namely the end position of the corresponding parameter set, is determined.
10. The video real-time encrypted transmission system according to claim 7, wherein said video encryption client (300) further comprises:
the first encryption module (303) is used for carrying out confidentiality encryption on the key content through a symmetric block encryption algorithm to obtain confidentiality encrypted ciphertext data;
the second encryption module (304) is used for carrying out integrity encryption on the key content based on a hash operation message authentication code algorithm of the key to obtain encrypted ciphertext data;
the splicing module (305) is used for directly splicing the secret encrypted ciphertext data and the integrity encrypted ciphertext data and replacing the plaintext of the key content by using the spliced ciphertext;
and the shell adding module (306) is used for carrying out shell adding operation on the spliced ciphertext, and then adding a 0 xffffffffff check code at the tail end of the spliced ciphertext to mark the end of the ciphertext.
CN202310348907.6A 2023-04-03 2023-04-03 Video real-time encrypted transmission method and system compatible with H.264 and H.265 encoding standards Pending CN116506412A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310348907.6A CN116506412A (en) 2023-04-03 2023-04-03 Video real-time encrypted transmission method and system compatible with H.264 and H.265 encoding standards

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310348907.6A CN116506412A (en) 2023-04-03 2023-04-03 Video real-time encrypted transmission method and system compatible with H.264 and H.265 encoding standards

Publications (1)

Publication Number Publication Date
CN116506412A true CN116506412A (en) 2023-07-28

Family

ID=87317537

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310348907.6A Pending CN116506412A (en) 2023-04-03 2023-04-03 Video real-time encrypted transmission method and system compatible with H.264 and H.265 encoding standards

Country Status (1)

Country Link
CN (1) CN116506412A (en)

Similar Documents

Publication Publication Date Title
US9641322B2 (en) Container agnostic decryption device and methods for use therewith
US7558954B2 (en) Method and apparatus for ensuring the integrity of data
US7680269B2 (en) Method for ciphering a compressed audio or video stream with error tolerance
US7581094B1 (en) Cryptographic checksums enabling data manipulation and transcoding
CN101867750B (en) OSD information processing method and device for video monitoring system
WO2021072878A1 (en) Audio/video data encryption and decryption method and apparatus employing rtmp, and readable storage medium
CN110012260B (en) Video conference content protection method, device, equipment and system
CN100505866C (en) A method for encryption and decryption of video information
KR20050009227A (en) Individual video encryption system and method
KR100840200B1 (en) Packaging / unpackaging device and method thereof for protecting H.264 format video files
KR20210143553A (en) Video encryption and decryption method and apparatus
CN116506412A (en) Video real-time encrypted transmission method and system compatible with H.264 and H.265 encoding standards
CN111064717B (en) Data encoding method, data decoding method, related terminal and device
CN109743627B (en) Playing method of digital movie package based on AVS + video coding
JP2013150147A (en) Encryption device, decryption device, encryption program, and decryption program
CN109561345B (en) Digital movie packaging method based on AVS + coding format
WO2009117924A1 (en) Method and device for processing transcoding of streaming media
CN117640958A (en) Video code stream authentication method, computer device and storage medium
Ling et al. The Video Encryption is Selectively Conducted Utilizing the SM2 Algorithm
CN117651146A (en) Video code stream authentication method, computer device and storage medium
Li et al. Research on Real-Time Video Stream Authentication Based on SM2 in H. 264
CN118138769A (en) Video encoding method, video decoding method, encoder, decoder, and medium
CN118042144A (en) Security processing method, related device, equipment and medium
CN118296178A (en) File generation method, device, equipment and readable storage medium
CN118449703A (en) Signature and authentication method of code stream

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