CN104639943B - A kind of generic video encryption method and system based on H.264 coding standard - Google Patents

A kind of generic video encryption method and system based on H.264 coding standard Download PDF

Info

Publication number
CN104639943B
CN104639943B CN201510050727.5A CN201510050727A CN104639943B CN 104639943 B CN104639943 B CN 104639943B CN 201510050727 A CN201510050727 A CN 201510050727A CN 104639943 B CN104639943 B CN 104639943B
Authority
CN
China
Prior art keywords
video
piece
encryption
information
pieces
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.)
Expired - Fee Related
Application number
CN201510050727.5A
Other languages
Chinese (zh)
Other versions
CN104639943A (en
Inventor
刘庆超
芦翔
潘磊
汪明伟
吕世超
周新运
孙利民
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Institute of Information Engineering of CAS
Jiangsu IoT Research and Development Center
Original Assignee
Institute of Information Engineering of CAS
Jiangsu IoT Research and Development Center
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 Institute of Information Engineering of CAS, Jiangsu IoT Research and Development Center filed Critical Institute of Information Engineering of CAS
Priority to CN201510050727.5A priority Critical patent/CN104639943B/en
Publication of CN104639943A publication Critical patent/CN104639943A/en
Application granted granted Critical
Publication of CN104639943B publication Critical patent/CN104639943B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/434Disassembling of a multiplex stream, e.g. demultiplexing audio and video streams, extraction of additional data from a video stream; Remultiplexing of multiplex streams; Extraction or processing of SI; Disassembling of packetised elementary stream
    • H04N21/4345Extraction or processing of SI, e.g. extracting service information from an MPEG stream
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream, rendering scenes according to MPEG-4 scene graphs
    • H04N21/4408Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream, rendering scenes according to MPEG-4 scene graphs involving video stream encryption, e.g. re-encrypting a decrypted video stream for redistribution in a home network

Abstract

The present invention relates to a kind of generic video encryption method and system based on H.264 coding standard, comprise the following steps:Video is parsed, identifies the NAL unit in video;It will identify that the parameter set in NAL unit and Supplemental Enhancement Information directly carry out plaintext transmission in a network;Parse piece of video, identify the position of first macro block in stem, data division and the piece of video of piece of video, using the information before first macro block in the stem and piece of video of piece of video as information is retained, not encrypt, the information in piece of video in addition to information is retained is encrypted;Shell adding is carried out to the ciphertext obtained by encryption in piece of video, information before first macro block in ciphertext Jing Guo shell adding, the stem of piece of video and piece of video is combined, the piece of video by encryption is obtained, the piece of video by encryption is transmitted in a network.The present invention can protect the safety of video content in the case where not changing video overall structure, and versatility is good, robustness is high, cost is low.

Description

A kind of generic video encryption method and system based on H.264 coding standard
Technical field
The present invention relates to video encryption method, is encrypted more particularly, to a kind of generic video based on H.264 coding standard Method and system.
Background technology
It is video conference, DTV, Video chat, online with the fast development of video coding technique and network technology Video display etc. have been increasingly becoming the part in people's daily life.Video conference with its it is quick in real time the characteristics of obtain extensively should With, however, these Video services are easily subject to artificial attack in open network environment, as data interception, information stealth, Data tampering and data, which add, deletes.At present, prevented more using authentication techniques, delineation of power or establish by the way of escape way non- Method user accesses the video in memory.All there is the defects of certain in these modes, safe procedures, which excessively can strictly reduce, to be used for Experience, and if it is difficult to safeguard, excessively succinct, security breaches easily occur.
A kind of method to solve the above problems is that video content is encrypted in itself.Currently, the safe of video content obtains To the extensive attention of educational circles, many encryption methods are constantly proposed, but are studied and be directed to algorithm in itself more, application-oriented demand Seldom.According to the data type of encryption and shared ratio, AES can be roughly divided into complete encryption, Partial encryption, Scrambling encryption, selective encryption and based on Entropy Encoding and Encryption etc..Full cipher mode is to be not added with distinguishing by content in each frame, will be joined Number and data subject are all encrypted, and other manner can select a part of parameter or video block to be encrypted.But these modes Problems with all be present using upper:
1), imperfection is gone back in the research with encoding the encryption being combined.Some encryption methods can significantly change information source structure And syntax, very big on next code influence, this can reduce network resource utilization and network service quality.Other methods are being pacified Quan Xing, compression ratio and encryption complexity etc. contradiction each other, it is difficult to realize business application.
2) it is, bad with encoding the versatility for the encryption being combined.The more coding standard of current application is all for different Application scenarios provide the kinds of schemes such as basic shelves, main shelves and extension shelves.The coding strategy taken between different shelves levels exists certain Difference, parameter such as sampling frequency, picture size, coding bit rate etc. of setting also all have differences.This needs picture pick-up device The producer first must modify and optimize according to the characteristics of coding and hardware device, therefore the encryption based on coding needs basis Different equipment designs different schemes, and versatility is inadequate.
3) it is, higher with encoding the cost for the encryption being combined.In order to improve coding rate, most of picture pick-up device all uses Hardware mode is to Video coding, namely integrated DSP processor etc. is responsible for Video coding specially on video processor.If using With encoding the mode that is combined to video-encryption, the structure of the hardware module related to Video coding, this meeting must be just adjusted Greatly improve the cost of coding.
The content of the invention
The technical problems to be solved by the invention are to provide one kind and protect video content in the case where not changing video overall structure Safety, versatility is good, robustness is high, cost low generic video encryption method and system based on H.264 coding standard.
The technical scheme that the present invention solves above-mentioned technical problem is as follows:A kind of generic video based on H.264 coding standard Encryption method, comprise the following steps:
Step 1:The video based on H.264 coding standard is parsed, identifies the NAL unit in video, the NAL unit bag Include parameter set, Supplemental Enhancement Information and piece of video;It will identify that the parameter set in NAL unit and Supplemental Enhancement Information directly exist Plaintext transmission is carried out in network;
Step 2:Piece of video is parsed, identifies in stem, data division and the piece of video of piece of video first macro block Position, using the information before first macro block in the stem and piece of video of piece of video as information is retained, not encrypt, by piece of video In information in addition to information is retained be encrypted;
Step 3:Shell adding is carried out to the ciphertext obtained by encryption in piece of video, by the ciphertext Jing Guo shell adding, piece of video Stem and piece of video in information before first macro block be combined, obtain the piece of video by encryption, encryption will be passed through Piece of video be transmitted in a network.
The beneficial effects of the invention are as follows:After the present invention encodes according to H.264 video encoding standard, retain the parameter of video With other important informations, only data subject is encrypted.Specifically, parameter set SPS (the sequence ginsengs in video are exactly retained Manifold), PPS (picture parameter set), SEI (Supplemental Enhancement Information) etc., only the part such as I frames, P frames and B frames is encrypted.And For the frame of encryption, still retain several important fields in head, other parts are all encrypted.Video after encryption can It to obtain the safeguard protection of high intensity, but still can in a network transmit, can be preserved by commonsense method as ordinary video With management ciphertext data, therefore this is that a kind of versatility is more preferable, the encryption method of video stream that robustness is higher, cost is lower.
On the basis of above-mentioned technical proposal, the present invention can also do following improvement.
Further, the parameter set in the step 1 in NAL unit includes sequence parameter set SPS and picture parameter set PPS; Piece of video includes I pieces, B pieces, P pieces, SI pieces and SP pieces.
Further, the reservation information in the step 2 in piece of video before first macro block includes first_mb_in_ Slice fields, slice_type fields, pic_parameter_set_id fields and rame_num fields.
Further, stream cipher encrypting or block encryption are encrypted as in the step 2, the stream cipher encrypting includes using RC4 AESs, grouping encryption method include des encryption algorithm, 3DES encryption algorithm, AES encryption algorithm, SM1 AESs With SM4 AESs.
Further, in the step 3, when occurring start-stop code in the ciphertext for detecting encryption, before last byte Start-stop code labeling is inserted, in decoding, when detecting start-stop code labeling, start-stop code labeling is abandoned.
Further, a kind of generic video encryption system based on H.264 coding standard, including parsing module, encrypting module And composite module;
The parsing module, for parsing the video based on H.264 coding standard, identify the NAL unit in video, institute Stating NAL unit includes parameter set, Supplemental Enhancement Information and piece of video;It will identify that the parameter set in NAL unit and auxiliary increase Strong information directly carries out plaintext transmission in a network;
The encrypting module, for parsing piece of video, identify in stem, data division and the piece of video of piece of video The position of one macro block, using the information before first macro block in the stem and piece of video of piece of video as information is retained, not add It is close, the information in piece of video in addition to information is retained is encrypted;
The composite module, for carrying out shell adding to the ciphertext obtained by encryption in piece of video, by by shell adding Information in ciphertext, the stem of piece of video and piece of video before first macro block is combined, and obtains the piece of video by encryption, Piece of video by encryption is transmitted in a network.
Further, the parameter set in the parsing module in NAL unit includes sequence parameter set SPS and picture parameter set PPS;Piece of video includes I pieces, B pieces, P pieces, SI pieces and SP pieces.
Further, the reservation information in the encrypting module in piece of video before first macro block includes first_mb_in_ Slice fields, slice_type fields, pic_parameter_set_id fields and rame_num fields.
Further, stream cipher encrypting or block encryption are encrypted as in the encrypting module, the stream cipher encrypting includes adopting With RC4 AESs, grouping encryption method includes des encryption algorithm, 3DES encryption algorithm, AES encryption algorithm, SM1 encryption calculations Method and SM4 AESs.
Further, in the composite module, when occurring start-stop code in the ciphertext for detecting encryption, by last byte Preceding insertion start-stop code labeling, in decoding, when detecting start-stop code labeling, start-stop code labeling is abandoned.
Brief description of the drawings
Fig. 1 is the structure of existing H.264 encoded video;
Fig. 2 is the display order of existing I pieces, P pieces and B pieces;
Fig. 3 is the schematic diagram of existing video transmission sequence;
Fig. 4 is the inventive method flow chart of steps;
Fig. 5 is present system structure chart.
In accompanying drawing, the list of parts representated by each label is as follows:
1st, parsing module, 2, encrypting module, 3, composite module.
Embodiment
The principle and feature of the present invention are described below in conjunction with accompanying drawing, the given examples are served only to explain the present invention, and It is non-to be used to limit the scope of the present invention.
Embodiment 1
As shown in figure 4, a kind of generic video encryption method based on H.264 coding standard, comprises the following steps:
Step 1:The video based on H.264 coding standard is parsed, identifies the NAL unit in video, the NAL unit bag Include parameter set, Supplemental Enhancement Information and piece of video;It will identify that the parameter set in NAL unit and Supplemental Enhancement Information directly exist Plaintext transmission is carried out in network;
Step 2:Piece of video is parsed, identifies in stem, data division and the piece of video of piece of video first macro block Position, using the information before first macro block in the stem and piece of video of piece of video as information is retained, not encrypt, by piece of video In information in addition to information is retained be encrypted;
Step 3:Shell adding is carried out to the ciphertext obtained by encryption in piece of video, by the ciphertext Jing Guo shell adding, piece of video Stem and piece of video in information before first macro block be combined, obtain the piece of video by encryption, encryption will be passed through Piece of video be transmitted in a network.
Parameter set in the step 1 in NAL unit includes sequence parameter set SPS and picture parameter set PPS;Piece of video bag Include I pieces, B pieces, P pieces, SI pieces and SP pieces.
Reservation information in the step 2 in piece of video before first macro block include first_mb_in_slice fields, Slice_type fields, pic_parameter_set_id fields and rame_num fields.
Stream cipher encrypting or block encryption are encrypted as in the step 2, the stream cipher encrypting includes calculating using RC4 encryptions Method, grouping encryption method include des encryption algorithm, 3DES encryption algorithm, AES encryption algorithm, SM1 AESs and SM4 encryptions Algorithm.
In the step 3, when occurring start-stop code in the ciphertext for detecting encryption, start-stop will be inserted before last byte Code labeling, in decoding, when detecting start-stop code labeling, start-stop code labeling is abandoned.
As shown in figure 5, a kind of generic video encryption system based on H.264 coding standard, including parsing module 1, encryption Module 2 and composite module 3;
The parsing module 1, for parsing the video based on H.264 coding standard, the NAL unit in video is identified, The NAL unit includes parameter set, Supplemental Enhancement Information and piece of video;It will identify that the parameter set and auxiliary in NAL unit Enhancement information directly carries out plaintext transmission in a network;
The encrypting module 2, for parsing piece of video, in the stem, data division and the piece of video that identify piece of video The position of first macro block, using the information before first macro block in the stem and piece of video of piece of video as information is retained, not Encryption, the information in piece of video in addition to information is retained is encrypted;
The composite module 3, for carrying out shell adding to the ciphertext obtained by encryption in piece of video, by by shell adding Information in ciphertext, the stem of piece of video and piece of video before first macro block is combined, and obtains the piece of video by encryption, Piece of video by encryption is transmitted in a network.
Parameter set in the parsing module 1 in NAL unit includes sequence parameter set SPS and picture parameter set PPS;Video Piece includes I pieces, B pieces, P pieces, SI pieces and SP pieces.
Reservation information in the encrypting module 2 in piece of video before first macro block includes first_mb_in_slice Field, slice_type fields, pic_parameter_set_id fields and rame_num fields.
Stream cipher encrypting or block encryption are encrypted as in the encrypting module 2, the stream cipher encrypting includes adding using RC4 Close algorithm, grouping encryption method include des encryption algorithm, 3DES encryption algorithm, AES encryption algorithm, SM1 AESs and SM4 AES.
In the composite module 3, when occurring start-stop code in the ciphertext for detecting encryption, it will be inserted before last byte Start-stop code labeling, in decoding, when detecting start-stop code labeling, start-stop code labeling is abandoned.
H.264 the video compression coding standard that the joint video team that coding is made up of ISO/IEC and ITU-T is formulated, Formal announcement in 2003, obtains very extensive application at present.
H.264 the structure of encoded video:Video is made up of the time series of image, also commonly referred to as video image, Image sequence, video sequence etc., image as each width are referred to as a frame.Frame per second is exactly the broadcasting speed of time series, is led to Normal frame per second is 25~30 frame per second.
Video is a kind of structure of classification, and in the video encoding standard of early stage, video is a kind of to be similar to ICP/IP protocol Hierarchy, each layer has a head (also comprising necessary afterbody), and every layer of data division includes the data of this layer. And the data division of this layer is several high-rise data cells, these units have head and the data division of oneself again. This structure is applied widely in various procotols, but each layer of head and its data division form management and quilt The strong dependence of management, once head is lost, the information of data division is hardly possible to be correctly decoded out again.In network In would generally take re-transmission policy and abandon vicious packet.Because frame of video is general all than the MTU of network Greatly, it is impossible to the syntax elements of whole layer are all put into same packet, if the packet loss where head, the layer its He, which is grouped i.e. enabled be correctly received, can not also be combined into a complete frame, thus can not decode, and cause the wasting of resources.
H.264 coding standard devises the knot of five levels on the basis of the advantages of absorbing all kinds of coding standards extensively Five structure, respectively sequence, image, piece, macro block, sub-macroblock basic levels.Correlation at all levels, as shown in Figure 1.
In H.264 coding standard, two kinds of parameter sets are the introduction of first --- sequence parameter set (SPS) and image parameter Collect (PPS), both parameters are out to form the section syntax element sepatation for originally belonging to sequence and picture headers, other Part be then put into lamella.Parameter set is an independent data unit, independent of other syntax elements outside parameter set.Sequence What row parameter set SPS was included is the parameter for a continuous programming code video sequence, as number-mark, frame number, reference frame number, Decode picture size and frame field coding mode selection mark etc..It is a certain image in a sequence corresponding to picture parameter set PPS Or parameter identification, entropy code model selection mark, piece group number, initial quantization parameters and the deblocking filtering system of a few width images Number adjustment mark etc..
Generally, a sequence parameter set SPS may map to multiple images parameter set.Fig. 1 describes sequence ginseng The relation of various syntax elements outside manifold SPS and picture parameter set PPS.Line in figure represents next layer to be needed in encoding and decoding With reference to the information of last layer.Parameter set is simply cited when lamella syntax elements need, and it is not corresponding one it is specific Image or sequence, same picture parameter set can also be quoted by multiple images, only encoder is thought to need undated parameter During the content of collection, new parameter can be just sent out.In the h .264 standard, the mapping relations between all kinds of parameter sets and piece, image Compare flexibly, a complete frame can be made up of a piece or multiple, and each piece can be selected flexibly as needed Need the parameter quoted.
Under the mechanism of this parameter set independence, parameter set can be retransmitted repeatedly, and H.264 coding or decoding process When middle some syntax elements for needing to ensure in lamella will quote some parameter set, that parameter set has arrived at decoder, Be exactly that parameter set must be transmitted first in time, if the parameter that cannot be needed, the parsing of syntax will complete mistake, In general decoder can be discarded, just normal after receiving next sequence parameter set SPS and picture parameter set PPS Decoding.Therefore H.264 the syntax elements outside parameter set and parameter set are in different channels by standard suggestion.Set of transmission parameters When, when being come using safer but more expensive cost passage, and transmitting general data, the low but less reliable letter of use cost Road.
As shown in figure 1, be a kind of basic model of simplification for code flow structure, all pieces only have a type here, one Individual or multiple one sub-picture of composition, the model can normal work, it is but not perfect enough.Generally, the type of piece may Only two kinds, it is also possible to which a variety of, this depends on the shelves level that coding uses.In order to adapt to the occasion of complexity, except piece and parameter Collection is outer to also need to other data units to provide extra information, therefore also further to be extended.
H.264 encode to improve the reliability of the efficiency of compression and transmission, video is divided into three kinds of different class.Base This class, it is mainly used in the related application of video session, such as Remote Video Conference, videophone, tele-medicine, long-range religion In the scenes higher to requirement of real-time such as, real-time monitoring.Main class, is mainly used in consumption electronic product, in full In the scenes such as word TV, video storage.And the video flowing that class is mainly used in network is extended, such as video request program.
For above-mentioned three kinds of class, each must all is fulfilled for one group of specific encoding function, and supports a kind of specific Using.During using basic class, only I pieces and two kinds of of P pieces, it would be preferable to support in frame and interframe encode, support to be based on The entropy code of the adaptive variable length coding (CAVLC) of context.During using main class, the requirement except meeting basic class, Interlaced video is also supported, the interframe encode using B pieces and the intraframe coding using weight estimation, is supported using based on context Adaptive arithmetic coding (CABAC), therefore, there are three kinds of sheet types of I pieces, P pieces and B pieces.And class is extended except I pieces, P pieces Outside B pieces, in order to support effective switching between code stream, also two kinds of pieces of SP pieces and SI pieces.
A kind of as shown in Fig. 2 video structure for including I frames, P frames and B frame three types.One video image can be encoded into One or more, coded slice typically has three kinds of different types, I pieces, P pieces, B pieces.The afterbody of arrow is the ginseng of stem in figure Examine image, I pieces, i.e., (Intra) piece in frame, using from current slice decoded pixel be used as with reference to carrying out infra-frame prediction, and The decoded pixel in other is not taken to be used as with reference to progress infra-frame prediction.P pieces are used as reference chart by the use of above encoded I pieces As carrying out infra-frame prediction.B pieces are then that reference is predicted using former and later two P pieces.Because I pieces are not using other images as reference, General data amount is bigger, and P pieces are much smaller, and B pieces are smaller, so can further compress video size.
In order to comply with the requirement of the bandwidth self-adaption of video flowing and error-resilient performance, in the extension of H.264 coding standard Two kinds of new frame types are defined in shelves again:SP pieces and SI pieces.The general principle of SP frames coding is similar with P pieces, is still based on frame Between the motion compensated predictive coding predicted, difference between the two is that SP pieces can reconstruct identical with reference to different reference frames Picture frame.This characteristic is made full use of, SP pieces may replace I pieces, be widely used in switching (bitstream between stream Switching (splicing), Stochastic accessing (random access), fast forwarding and fast rewinding (fast forward, fast), are spliced Backward) and in the application such as Fault recovery (error recovery), while the expense of code check is greatly reduced.With SP pieces Corresponding, SI pieces are then to be based on intraframe predictive coding technology, and its reconstructed image is identical with the reconstructed image to SP pieces.SP pieces Although code efficiency slightly below P pieces, significantly larger than I pieces substantially improve the network compatibility of H.264 encoded video, branch Flexible streaming media service application is held, there is very strong error-resilient performance, adapt in the wireless communication that noise jamming is big, packet loss is high Transmitted in road.
The internal structure of piece is divided into piece first (slice_header) and two main parts of sheet data (slice_data). The address of first macro block in piece owner record piece, the type of piece, the order of the call number of picture parameter set and decoding etc.. Need to be retained during encryption.
The data division of piece is mainly made up of several macro blocks, and a macro block is by 16 × 16 luminance pixels and additional One 8 × 8Cb and 8 × 8Cr colour elements block composition.In each image, some macro blocks are arranged sheet of form.Macro block Also there are I, P and B three types, wherein I pieces only include I macro blocks, and P pieces can include P macro blocks and I macro blocks, and B pieces can include B macro blocks With I macro blocks.
I macro blocks using from current slice decoded pixel be used as with reference to infra-frame prediction is carried out, and can not take in other Decoded pixel be used as with reference to carry out infra-frame prediction.P macro blocks are carried out in frame using above encoded image as reference picture Prediction, the macro block of an intraframe coding can further make the segmentation of macro block, such as 16 × 16,16 × 8,8 × 16 or 8 × 8 brightness pictures Plain block (and subsidiary colour element) etc..
Compared with former standard, such as H.263 coding is compared with MPEG-4 codings, the function of codec H.264 Module does not have too big change, primary difference is that each functional module realizes details, these details are mainly reflected in grand In block.Meet various multimedia application in addition, being H.264 encoded to, there is provided the mechanism of many optimization coding and decoding videos, therefore not Same macroblock structure difference is larger.But macro block does not bring to transmission of video and management and directly affected, and can all encrypt.
Pass through analysis above, it can be seen that sequence parameter set SPS and picture parameter set PPS essential records video sequence The global parameter of row, such as picture size, video format, and shelves level of coding etc., major function is in order to which peripheral operation can It correctly to identify a complete video sequence, therefore cannot encrypt, network transmission, storage otherwise will be caused to conciliate Analysis etc. can not be carried out.Due to without reality video content, not encryption parameter will not bring safety problem.
And for data units such as Supplemental Enhancement Informations (SEI), extra data or synchronizing information are mainly provided, Ke Yishi When the complex characteristic of raising net synchronization capability or definition image, but, it is not required in decoding process not comprising video content in itself , therefore need not encrypt.
Therefore, video encryption method of the present invention comprises the following steps:
The first step, parsing are described to identify the NAL unit H.264 in encoded video based on the video H.264 encoded Identifying the NAL unit of encoded video includes parameter set, Supplemental Enhancement Information SEI and piece of video;It will identify that in NAL unit Parameter set and the direct plaintext transmissions of Supplemental Enhancement Information SEI;
Parameter set in identification NAL unit includes sequence parameter set SPS, picture parameter set PPS;Piece of video includes I pieces, B Piece, P pieces, SI pieces and SP pieces.
Second step, parsing piece of video, identify the position of first macro block in stem, data division and the piece of video of piece of video Put, the information before first macro block in the stem and sheet data of piece of video is retained, remaining information in piece is added It is close;
Reservation information in sheet data before first macro block includes first_mb_in_slice fields, slice_type Field, pic_parameter_set_id fields and frame_num fields.
The method encrypted to information in piece can use conventional data ciphering method, stream cipher encrypting or block encryption Method, the stream cipher encrypting method include RC4, and grouping encryption method includes DES, 3DES, AES, SM1 or SM4.Divide when using During group encryption, if being encrypted again when end video is less than a packet, it is necessary to be filled.The method of block encryption filling can In the method commonly used using the art, here is omitted.
It is the main body of video content, it is necessary to it due to the SI pieces and SP pieces in I pieces, P pieces and B pieces, and extension shelves level Encryption.But still the stem (slice_head) of piece is all retained.Due to the field before first macro block in piece still Video coding decoding is played an important role, if encryption can cause occur mistake during decryption of video, therefore for sheet data part, The information before first macro block is wanted all to retain, particularly following four fields:First_mb_in_slice, slice_ Type, pic_parameter_set_id, frame_num.First_mb_in_slice, two bytes, represent macro block in piece Address, piece demarcate the address of its own by the syntax elements.Slice_type, two bytes, the type of piece is indicated, is decoded Device judges the type of current slice by the byte.Pic_parameter_set_id, two bytes, the index of picture parameter set Number.Frame_num, two bytes, specify the decoding order of each image.
3rd step, shell adding is carried out to the ciphertext in NAL unit, to occur without start-stop code in the ciphertext after encryption.
H.264 encoded video adds start-stop codes of the 0x000001 as new NAL unit before each NAL unit.At this Under the mechanism of sample, decoder will detect that 0x000001 has begun to as new NAL unit, and to the video in NAL unit After sheet data is encrypted, it is likely that occur start-stop code in ciphertext.In the embodiment of the present invention, the start-stop in ciphertext is detected During code, 0x03 will be inserted before last byte, in decoding, when detecting 0x000003 sequences, 0x03 is abandoned.In addition, Also need to carry out shell adding protection, detailed process and 0x000001 to 0x000000,0x000002 and 0x000003 for occurring in coding Situation it is similar, here is omitted.
It is preferable that the present invention is mainly characterized by versatility to the encryption method of H.264 encoded video, goes for all kinds of fields The encryption of scape, is mainly reflected in the following aspects:Go for the encryption after all kinds of shelves level codings, go for all kinds of Need to carry out the encryption after code optimization according to equipment, ciphertext can be transmitted by the RTP/RTSP agreements of routine, can be according to The method of management Clear video is stored and forwarded, and common decoder can also be used to decode, but will not reveal video Content.Specifically:
1), in order to adapt to different purposes, H.264 coding standard devises basic class, main class and extension class three The coding of kind class, one shares the piece of 5 types, and coded system, the prediction mode of different pieces are all very different, typically Encryption method be directed to different the characteristics of separately design encryption method.These differences are mainly reflected in the internal structure of piece In, in the embodiment of the present invention, the interior details of piece are not considered, and it is all encrypted, therefore various piece of video can be encrypted.
In order to improve the efficiency of compressed encoding, the quality of video image is improved, Fault recovery function is improved and improves net Network friendly etc., H.264 encoded video employ many advanced technologies, but the raising of performance be using increase computation complexity as Cost, particularly STAD calculating, interframe SAD calculating etc. are related to largely in quantization, motion estimation motion compensation, frame Data-moving and calculating, therefore, handle video in real time under the limited embedded environment of hardware resource, typically first to optimize volume Code.Common encipherment scheme must do optimization situation for specific equipment and adjust.Because these differences are also embodied in piece In internal structure, due in the embodiment of the present invention, not considering the interior details of piece, various equipment can be produced with a kind of mode Video be encrypted.
2), video-encryption strategy of the invention is a kind of preferable method of versatility, be mainly reflected in can use it is general Transmission of video agreement, as RTP/RTSP agreements come transmit encryption after video.Reason is as follows:H.264 encoded video sequence bag A series of NAL unit is included, because the length of NAL unit is not fixed, such as picture parameter set PPS only has 8 bytes, and NAL unit size comprising I pieces is then up to thousands of individual bytes, and RTP, can be according to NAL size, by frame of video when transmitting video A bag is combined into, or splits into multiple bags.
After being encoded according to H.264 video encoding standard, the stem of the NAL unit of video has an important attribute field Nal_unit_type, span 0-31.Wherein 1-23 is mainly used in the type that decoder distinguishes NAL, and 24-31 etc. is counted Value is not used in coding.Such as 7 represent sequence parameter set SPS, 8 represent picture parameter set PPS etc..But remain some marks Will position, such as flag bit between 0 and 24-31, RTP to frame of video when packaging or splitting into multiple bags, it is necessary to make The type of processing is indicated with nal_unit_type several untapped numerical value, such as 24 combinations for representing single incidents Bag, 26 represent the combination bag of multiple times, and 28 represent burst etc..Due in the embodiment of the present invention, nal_unit_type being protected Stay, and the data division inside piece is encrypted, therefore RTP transmission belts will not be influenceed using the encryption of the present invention.By In nal_unit_type in NAL header field, in the present invention, by NAL stem and the first_ of NAL data divisions Tetra- fields of mb_in_slice, slice_type, pic_parameter_set_id, frame_num retain, therefore, after encryption Video do not influence the transmission of video.
Specifically, H.264 encoded video is using NAL as unit, unit close-packed arrays, processor by identifier come Different units is identified, common video sequence includes polytype data, such as parameter set PS, image delimiter PD, coding Piece, data segmentation, the sequence ends symbol and filling data etc..Typical video transmission sequence is as shown in Figure 3.Each unit is by only Vertical NAL unit transmission.
H.264 the transmission means of coding standard and undefined NAL unit, determines it according to different transmission environments in practice Transmission means.Such as in packet network, each NAL unit is transmitted with independent bag, is resequenced before decoding.
In order to distinguish the data type in bag, RTP carrys out table using the reserved bit of the nal_unit_type in H.264 encoding Show NAL state.The concrete meaning of nal_unit_type flag bits is as shown in the table.
When Real-time Transport Protocol is resolved to NAL unit (nal_unit), nal_unit_type is first parsed, then divides three kinds of feelings Condition processing:
I), single NAL unit pattern
That is a RTP bag is only made up of a complete NAL unit, in this case RTP NAL heads type field and original The NAL unit head type field of the H.264 encoded video to begin is the same.
Ii package pattern), is combined
It is probably to form a RTP bag by multiple NAL units, there are 4 kinds of combinations respectively:STAP-A, STAP-B, MTAP16, MTAP24.So here types value is 24,25,26 and 27 respectively.
Iii), burst package pattern
For a NALU unit to be packaged into multiple RTP bags, two types FU-A and FU-B types value be present is respectively 28 and 29
As can be seen here, the type of each such sheets is mainly distinguished during transmission of video using the nal_unit_type of chip level, and it is right Data division in piece does not distinguish, therefore can use common transmission of video agreement such as using the video after this programme encryption RTP is transmitted.
3), to being stored in local video file, it is necessary to do basic parsing to video, in order to manage.H.264 solution Code is carried out in units of NAL unit, before NAL unit parsing is carried out, is parsed first by Real-time Transport Protocol, or pass through starting Code detection, obtains NAL unit data from transmission code stream.If to be decoded to NAL unit, its input is NAL unit, defeated Go out the sample value that result is the present image (CurrPic) by decoding, because now video content is encryption, will will only see Muddy picture, and valuable content can not be seen.
After the present invention encodes according to H.264 video encoding standard, retain the parameter of video and other important informations, it is only right Data subject is encrypted.Specifically, parameter set SPS (sequence parameter set) in video, PPS (image parameters are exactly retained Collection), SEI (Supplemental Enhancement Information) etc., only the part such as I frames, P frames and B frames is encrypted.And for the frame of encryption, still Retain several important fields in head, other parts are all encrypted.Video after encryption can obtain the peace of high intensity Full guard, but still can be transmitted in a network as ordinary video, ciphertext data can be preserved and managed by commonsense method, because This this be that a kind of versatility is more preferable, the encryption method of video stream that robustness is higher, cost is lower.
The foregoing is only presently preferred embodiments of the present invention, be not intended to limit the invention, it is all the present invention spirit and Within principle, any modification, equivalent substitution and improvements made etc., it should be included in the scope of the protection.

Claims (10)

1. a kind of generic video encryption method based on H.264 coding standard, it is characterised in that comprise the following steps:
Step 1:The video based on H.264 coding standard is parsed, identifies the NAL unit in video, the NAL unit includes ginseng Manifold, Supplemental Enhancement Information and piece of video;It will identify that parameter set in NAL unit and Supplemental Enhancement Information directly in network Middle carry out plaintext transmission;
Step 2:Piece of video is parsed, identifies the position of first macro block in stem, data division and the piece of video of piece of video, Using the information before first macro block in the stem and piece of video of piece of video as information is retained, not encrypt, will be removed in piece of video Retain the information outside information to be encrypted;
Step 3:Shell adding is carried out to the ciphertext obtained by encryption in piece of video, by the ciphertext Jing Guo shell adding, the head of piece of video Information in portion and piece of video before first macro block is combined, and obtains the piece of video by encryption, by regarding by encryption Frequency piece is transmitted in a network.
2. the generic video encryption method according to claim 1 based on H.264 coding standard, it is characterised in that described Parameter set in step 1 in NAL unit includes sequence parameter set SPS and picture parameter set PPS;Piece of video includes I pieces, B pieces, P Piece, SI pieces and SP pieces.
3. the generic video encryption method according to claim 1 based on H.264 coding standard, it is characterised in that described Reservation information in step 2 in piece of video before first macro block includes first_mb_in_slice fields, slice_type words Section, pic_parameter_set_id fields and rame_num fields.
4. the generic video encryption method according to claim 1 based on H.264 coding standard, it is characterised in that described Stream cipher encrypting or block encryption are encrypted as in step 2, the stream cipher encrypting includes using RC4 AESs, block encryption Method includes des encryption algorithm, 3DES encryption algorithm, AES encryption algorithm, SM1 AESs and SM4 AESs.
5. the generic video encryption method according to claim 1 based on H.264 coding standard, it is characterised in that described In step 3, when occurring start-stop code in the ciphertext for detecting encryption, start-stop code labeling will be inserted before last byte, solved During code, when detecting start-stop code labeling, start-stop code labeling is abandoned.
6. a kind of generic video encryption system based on H.264 coding standard, it is characterised in that including parsing module (1), encryption Module (2) and composite module (3);
The parsing module (1), for parsing the video based on H.264 coding standard, identify the NAL unit in video, institute Stating NAL unit includes parameter set, Supplemental Enhancement Information and piece of video;It will identify that the parameter set in NAL unit and auxiliary increase Strong information directly carries out plaintext transmission in a network;
The encrypting module (2), for parsing piece of video, identify in stem, data division and the piece of video of piece of video The position of one macro block, using the information before first macro block in the stem and piece of video of piece of video as information is retained, not add It is close, the information in piece of video in addition to information is retained is encrypted;
The composite module (3), for carrying out shell adding to the ciphertext obtained by encryption in piece of video, by by the close of shell adding Information in literary, piece of video stem and piece of video before first macro block is combined, and obtains the piece of video by encryption, will Piece of video by encryption is transmitted in a network.
7. the generic video encryption system according to claim 6 based on H.264 coding standard, it is characterised in that described Parameter set in parsing module (1) in NAL unit includes sequence parameter set SPS and picture parameter set PPS;Piece of video include I pieces, B pieces, P pieces, SI pieces and SP pieces.
8. the generic video encryption system according to claim 6 based on H.264 coding standard, it is characterised in that described Reservation information in encrypting module (2) in piece of video before first macro block includes first_mb_in_slice fields, slice_ Type fields, pic_parameter_set_id fields and rame_num fields.
9. the generic video encryption system according to claim 6 based on H.264 coding standard, it is characterised in that described Stream cipher encrypting or block encryption are encrypted as in encrypting module (2), the stream cipher encrypting includes using RC4 AESs, point Group encryption method includes des encryption algorithm, 3DES encryption algorithm, AES encryption algorithm, SM1 AESs and SM4 AESs.
10. the generic video encryption system according to claim 6 based on H.264 coding standard, it is characterised in that described In composite module (3), when occurring start-stop code in the ciphertext for detecting encryption, start-stop code mark will be inserted before last byte Note, in decoding, when detecting start-stop code labeling, start-stop code labeling is abandoned.
CN201510050727.5A 2015-01-30 2015-01-30 A kind of generic video encryption method and system based on H.264 coding standard Expired - Fee Related CN104639943B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510050727.5A CN104639943B (en) 2015-01-30 2015-01-30 A kind of generic video encryption method and system based on H.264 coding standard

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510050727.5A CN104639943B (en) 2015-01-30 2015-01-30 A kind of generic video encryption method and system based on H.264 coding standard

Publications (2)

Publication Number Publication Date
CN104639943A CN104639943A (en) 2015-05-20
CN104639943B true CN104639943B (en) 2018-02-13

Family

ID=53218182

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510050727.5A Expired - Fee Related CN104639943B (en) 2015-01-30 2015-01-30 A kind of generic video encryption method and system based on H.264 coding standard

Country Status (1)

Country Link
CN (1) CN104639943B (en)

Families Citing this family (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105471860A (en) * 2015-11-19 2016-04-06 浙江宇视科技有限公司 Video data transmission method and apparatus
CN105635149A (en) * 2015-12-30 2016-06-01 深圳Tcl数字技术有限公司 Streaming media encryption method, device and system
CN105704545B (en) * 2016-01-20 2018-06-15 中国科学院信息工程研究所 A kind of crypto-synchronization information transmission method based on H.264 video flowing
CN107172431B (en) * 2017-06-27 2019-12-27 西南科技大学 Scalable authentication method based on H264/SVC video stream
CN108235152B (en) * 2018-03-07 2020-10-27 北京视博数字电视科技有限公司 DRM application system and method for transferring DRM private data
CN108235060B (en) * 2018-03-12 2020-06-26 上海哔哩哔哩科技有限公司 Video encryption playing method, system and storage medium based on parameter set confusion
CN108600196A (en) * 2018-04-04 2018-09-28 广东中星电子有限公司 The encryption method and device and decryption method and device of image
CN108769740A (en) * 2018-06-05 2018-11-06 苏州科达科技股份有限公司 Video data encrypted transmission method, system, equipment and storage medium
CN109388618B (en) * 2018-10-15 2021-02-12 密卡思(深圳)电讯有限公司 Method and device for compressing, decompressing, encrypting and decrypting file of embedded system
CN110611830A (en) * 2019-09-29 2019-12-24 腾讯科技(深圳)有限公司 Video processing method, device, equipment and medium
CN111405233B (en) * 2020-03-25 2021-08-20 苏州科达科技股份有限公司 Encrypted graph transmission method, device, storage medium and system in video conference
CN114189713A (en) * 2021-12-21 2022-03-15 杭州当虹科技股份有限公司 Content encryption method
CN116095331B (en) * 2023-03-03 2023-07-07 浙江大华技术股份有限公司 Encoding method and decoding method

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1333973A (en) * 1998-11-20 2002-01-30 艾利森电话股份有限公司 Method and device for encryption of images
CN1452840A (en) * 2000-05-02 2003-10-29 通用仪器公司 Method and apparatus for enabling random access to individual pictures in encrypted video stream
CN1726713A (en) * 2002-12-16 2006-01-25 皇家飞利浦电子股份有限公司 Method and apparatus to encrypt video data streams

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100724825B1 (en) * 2005-11-17 2007-06-04 삼성전자주식회사 A Methodology and System for Scalable Video Bitstream Encryption and Decryption to Scalable Conditional Access Control according to Multi-dimensionalScalability in Scalable Video Coding

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1333973A (en) * 1998-11-20 2002-01-30 艾利森电话股份有限公司 Method and device for encryption of images
CN1452840A (en) * 2000-05-02 2003-10-29 通用仪器公司 Method and apparatus for enabling random access to individual pictures in encrypted video stream
CN1726713A (en) * 2002-12-16 2006-01-25 皇家飞利浦电子股份有限公司 Method and apparatus to encrypt video data streams

Also Published As

Publication number Publication date
CN104639943A (en) 2015-05-20

Similar Documents

Publication Publication Date Title
CN104639943B (en) A kind of generic video encryption method and system based on H.264 coding standard
CN101505316B (en) Method and device for reordering and multiplexing multimedia packets from multimedia streams pertaining to interrelated sessions
KR101478280B1 (en) Packet format of Network Abstraction Layer Unit(NALU), and algorithm and apparatus for video encoding and decoding using the format, QoS control algorithm and apparatus for IPv6 Label Switching using the format
CN101390399B (en) Backward-compatible aggregation of pictures in scalable video coding
CN102177718B (en) Method and device for generating multi-view media data
CN102804773B (en) In 2 systems of MPEG, combination multi-angle video decodes sub- bit stream
CN1934865B (en) Method and device for resizing of buffer in encoder and decoder
AU2010279256B2 (en) Signaling characteristics of an MVC operation point
CN103404140B (en) The method and apparatus of indication bit stream subset
CN101867750B (en) OSD information processing method and device for video monitoring system
KR101345544B1 (en) Multi-view video coding system, decoding system, bitstream extracting system for decoding base view and supporting view random access
KR101819524B1 (en) Signal transmission and reception apparatus and signal transmission and reception method for providing trick play service
US20060215711A1 (en) Apparatus for receiving packet stream
CN109963176A (en) Video code flow processing method, device, the network equipment and readable storage medium storing program for executing
KR101396948B1 (en) Method and Equipment for hybrid multiview and scalable video coding
CN103339930A (en) Method and apparatus for managing content distribution over multiple terminal devices in collaborative media system
KR101340203B1 (en) Encryption procedure and device for an audiovisual data stream
CN106303537B (en) A kind of more code stream transmission methods of openh264
RU2671992C2 (en) Transmission device, transmission method, reception device and reception method
CN110636387A (en) H.264 network-based video transmission system
JP5976189B2 (en) Transmitting apparatus, transmitting method, receiving apparatus, and receiving method
CN109561345B (en) Digital movie packaging method based on AVS + coding format
JP6614281B2 (en) Receiving apparatus and receiving method
JP6350638B2 (en) Transmitting apparatus, transmitting method, receiving apparatus, and receiving method
JP6052354B2 (en) Transmitting apparatus, transmitting method, receiving apparatus, and receiving method

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20180213

Termination date: 20200130