CN114666624A - Video file encryption and decryption method - Google Patents
Video file encryption and decryption method Download PDFInfo
- Publication number
- CN114666624A CN114666624A CN202210370826.1A CN202210370826A CN114666624A CN 114666624 A CN114666624 A CN 114666624A CN 202210370826 A CN202210370826 A CN 202210370826A CN 114666624 A CN114666624 A CN 114666624A
- Authority
- CN
- China
- Prior art keywords
- data
- frame
- video
- encrypted
- audio
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 78
- 238000012545 processing Methods 0.000 claims description 32
- 230000015654 memory Effects 0.000 description 19
- 238000010586 diagram Methods 0.000 description 5
- 229910002056 binary alloy Inorganic materials 0.000 description 3
- 230000000694 effects Effects 0.000 description 3
- 230000006870 function Effects 0.000 description 3
- 239000007787 solid Substances 0.000 description 3
- 238000004590 computer program Methods 0.000 description 2
- 230000010354 integration Effects 0.000 description 2
- 230000002452 interceptive effect Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 238000011084 recovery Methods 0.000 description 2
- PCTMTFRHKVHKIS-BMFZQQSSSA-N (1s,3r,4e,6e,8e,10e,12e,14e,16e,18s,19r,20r,21s,25r,27r,30r,31r,33s,35r,37s,38r)-3-[(2r,3s,4s,5s,6r)-4-amino-3,5-dihydroxy-6-methyloxan-2-yl]oxy-19,25,27,30,31,33,35,37-octahydroxy-18,20,21-trimethyl-23-oxo-22,39-dioxabicyclo[33.3.1]nonatriaconta-4,6,8,10 Chemical compound C1C=C2C[C@@H](OS(O)(=O)=O)CC[C@]2(C)[C@@H]2[C@@H]1[C@@H]1CC[C@H]([C@H](C)CCCC(C)C)[C@@]1(C)CC2.O[C@H]1[C@@H](N)[C@H](O)[C@@H](C)O[C@H]1O[C@H]1/C=C/C=C/C=C/C=C/C=C/C=C/C=C/[C@H](C)[C@@H](O)[C@@H](C)[C@H](C)OC(=O)C[C@H](O)C[C@H](O)CC[C@@H](O)[C@H](O)C[C@H](O)C[C@](O)(C[C@H](O)[C@H]2C(O)=O)O[C@H]2C1 PCTMTFRHKVHKIS-BMFZQQSSSA-N 0.000 description 1
- OTZZZISTDGMMMX-UHFFFAOYSA-N 2-(3,5-dimethylpyrazol-1-yl)-n,n-bis[2-(3,5-dimethylpyrazol-1-yl)ethyl]ethanamine Chemical compound N1=C(C)C=C(C)N1CCN(CCN1C(=CC(C)=N1)C)CCN1C(C)=CC(C)=N1 OTZZZISTDGMMMX-UHFFFAOYSA-N 0.000 description 1
- 206010039203 Road traffic accident Diseases 0.000 description 1
- 241001441724 Tetraodontidae Species 0.000 description 1
- 238000004458 analytical method Methods 0.000 description 1
- 238000003491 array Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 230000011664 signaling Effects 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/20—Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
- H04N21/23—Processing of content or additional data; Elementary server operations; Server middleware
- H04N21/234—Processing of video elementary streams, e.g. splicing of video streams, manipulating MPEG-4 scene graphs
- H04N21/2347—Processing of video elementary streams, e.g. splicing of video streams, manipulating MPEG-4 scene graphs involving video stream encryption
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/40—Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
- H04N21/43—Processing 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/44—Processing 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/4405—Processing 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 decryption
Abstract
The invention discloses a video file encryption and decryption method, which comprises the steps of obtaining video file data, wherein the video file data comprises a plurality of video frame data; encrypting each video frame data, and adding a preset video separator and video frame length data to the frame header position of each encrypted video frame data to obtain each video frame encrypted data; integrating all video frame encrypted data to obtain corresponding first video encrypted data; and adding corresponding frame header information to the first video encryption data and writing the first video encryption data into an encryption file. The method encrypts the video file by using the algorithm (namely, the condition of not increasing a fixed encryption chip or a special video storage chip) so as to reduce the encryption cost, and the algorithm can be updated in real time, thereby solving the problem that the encrypted file cannot be recovered once being cracked.
Description
Technical Field
The invention relates to the technical field of data processing, in particular to a video file encryption and decryption method.
Background
With the further development of the 5G and Internet of things technologies, audio and video information systems are more and more common in daily life and more widely applied, for example, audio and video files recorded by a vehicle-mounted driving recorder are used as important evidences for handling traffic accidents and driver and crew disputes. However, the data can be often tampered and stolen, which affects the proof process and reveals the personal privacy of the driver and passenger, so that the recorded audio and video needs to be encrypted. The encryption mode that present common on-vehicle driving recorder adopted is for adopting fixed encryption chip or special video memory chip to encrypt. There are many problems with this encryption method: the hardware encryption cost is high, the encryption algorithm cannot be updated, and once the encryption algorithm is cracked, the recovery cannot be realized. Therefore, a new encryption method is needed.
Disclosure of Invention
In view of this, embodiments of the present invention provide methods for encrypting and decrypting a video file, so as to solve technical problems in the prior art that hardware encryption cost is high, an encryption algorithm cannot be updated, and once cracked, recovery cannot be performed.
The technical scheme provided by the invention is as follows:
a first aspect of an embodiment of the present invention provides a video file encryption method, where the video file encryption method includes: acquiring video file data, wherein the video file data comprises a plurality of video frame data; encrypting each video frame data, and adding a preset video separator and video frame length data to the frame header position of each encrypted video frame data to obtain each video frame encrypted data; integrating all video frame encrypted data to obtain corresponding first video encrypted data; and adding corresponding frame header information to the first video encryption data and writing the first video encryption data into an encryption file.
Optionally, the video file data further comprises a plurality of audio frame data; the method further comprises the following steps: encrypting each audio frame data, and adding a preset audio separator and audio frame length data to the frame header position of each encrypted audio frame data to obtain each audio frame encrypted data; integrating all the audio frame encrypted data to obtain corresponding first audio encrypted data; and adding corresponding frame header information to the first audio encryption data and writing the first audio encryption data into an encryption file.
Optionally, the encrypting process is performed on each video frame data, and includes: encrypting each video frame data by using a stream encryption algorithm to generate a corresponding encrypted video frame data pseudorandom key string; and performing exclusive-or operation processing on the encrypted video frame data pseudo-random key string and each video frame data according to each byte.
Optionally, the encrypting process is performed on each audio frame data, and includes: carrying out encryption processing on each audio frame data by using a stream encryption algorithm to generate a corresponding encrypted audio frame data pseudorandom key string; and performing exclusive-OR operation processing on the encrypted audio frame data pseudo-random key string and each audio frame data according to each byte.
Optionally, the encrypting each video frame data and adding a preset video separator and video frame length data to the frame header position of each encrypted video frame data to obtain each video frame encrypted data includes: and encrypting any video frame data, adding a preset video separator and video frame length data at the frame head position of each encrypted video frame data to obtain each video frame encrypted data, and adding interference video frame data at the frame tail position corresponding to each video frame encrypted data.
Optionally, the encrypting each audio frame data and adding a preset audio separator and audio frame length data to the frame header position of each encrypted audio frame data to obtain each audio frame encrypted data includes: and encrypting any audio frame data, adding a preset audio separator and audio frame length data at the frame head position of each encrypted audio frame data to obtain each audio frame encrypted data, and adding interference audio frame data at the frame tail position corresponding to each audio frame encrypted data.
A second aspect of the embodiments of the present invention provides a video file decryption method, where the video file decryption method includes: acquiring an encrypted file, wherein the encrypted file comprises a video frame encrypted file, the video frame encrypted file consists of frame header information and a plurality of video information data, each video information data comprises a video separator, video frame length data and encrypted original video data, and the video separator and the video frame length data are arranged at the position of a frame header of the encrypted original video data; traversing the encrypted file, and reading the length data of the video frame after traversing the video separator; determining the original video data encrypted by each frame according to the video frame length data; and decrypting the encrypted original video data of each frame to obtain the original video data of each frame, adding corresponding frame header information to the frame header position of the original video data of each frame, and writing the frame header information into a decrypted video file.
Optionally, the encrypted file further includes an audio frame encrypted file, where the audio frame encrypted file is composed of frame header information and multiple audio information data, each audio information data includes a preset audio delimiter, audio frame length data, and encrypted original audio data, and the audio delimiter and the audio frame length data are set at a frame header position of the encrypted original audio data; the method further comprises the following steps: traversing the encrypted file, and reading the length data of the audio frame after traversing the audio separator; determining the original audio data encrypted by each frame according to the length data of the audio frames; and decrypting the encrypted original audio data of each frame to obtain the original audio data of each frame, adding corresponding frame header information to the frame header position of the original audio data of each frame, and writing the frame header information into a decrypted audio file.
Optionally, decrypting the encrypted original video data of each frame to obtain the original video data of each frame includes: decrypting the original video data encrypted by each frame by using a stream encryption algorithm corresponding to the video frame encryption file to obtain a corresponding decrypted video frame data pseudorandom key string; and carrying out XOR operation processing on the decrypted video frame data pseudo-random key string and the encrypted original video data of each frame according to each byte to obtain the original video data of each frame.
Optionally, decrypting the encrypted original audio data of each frame to obtain the original audio data of each frame includes: decrypting the original audio data encrypted by each frame by using a stream encryption algorithm corresponding to the audio frame encryption file to obtain a corresponding pseudo-random key string of decrypted audio frame data; and carrying out exclusive OR operation processing on the decrypted audio frame data pseudorandom key string and the encrypted original audio data of each frame according to each byte to obtain the original audio data of each frame.
Optionally, the method further comprises: and inputting the decrypted video file and the decrypted audio file into a preset mixer to obtain a corresponding decrypted file.
The technical scheme provided by the invention has the following effects:
the video file encryption method provided by the embodiment of the invention obtains video file data, wherein the video file data comprises a plurality of video frame data; encrypting each video frame data, and adding a preset video separator and video frame length data to the frame header position of each encrypted video frame data to obtain each video frame encrypted data; integrating all video frame encrypted data to obtain corresponding first video encrypted data; and adding corresponding frame header information to the first video encryption data and writing the first video encryption data into an encryption file. The method encrypts the video file by using the algorithm (namely, the condition of not increasing a fixed encryption chip or a special video storage chip) so as to reduce the encryption cost, and the algorithm can be updated in real time so as to solve the problem that the encrypted file cannot be recovered once being cracked.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a flow diagram of a video file encryption method according to an embodiment of the present invention;
fig. 2 is a flowchart of a video file decryption method according to an embodiment of the present invention;
fig. 3 is a block diagram of a structure of a video file encryption apparatus according to an embodiment of the present invention;
fig. 4 is a block diagram of the structure of a video file decrypting apparatus according to an embodiment of the present invention;
FIG. 5 is a schematic structural diagram of a computer-readable storage medium provided according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
An embodiment of the present invention provides a video file encryption method, as shown in fig. 1, the method includes the following steps:
step S101: video file data is obtained, wherein the video file data comprises a plurality of video frame data. Specifically, a sensor such as a video processor may be used to acquire a video file that needs to be processed. For example, a video file recorded by the vehicle-mounted tachograph is acquired, and the video file includes a plurality of H264 data (video data). The video processor can be internally integrated with a plurality of processors such as a video encoder, an audio encoder and the like; the video encoder is used for encoding the video data to obtain video frame data; the audio encoder is used for encoding the audio data to obtain audio frame data.
Step S102: and encrypting each video frame data, and adding a preset video separator and video frame length data at the frame header position of each encrypted video frame data to obtain each video frame encrypted data. Specifically, firstly, the encryption algorithm is used for encrypting each acquired video frame data, and then a preset video separator and video frame length data are added at the position of a frame header corresponding to each frame of video frame data obtained after encryption. The encryption algorithm can comprise an MD5 algorithm, a DES algorithm, an IDEA algorithm and other encryption algorithms as long as encryption requirements are met; the preset video delimiter represents a character string of a specific length, such as ABCD; the video frame length data is used to indicate the length of one frame of video data acquired.
Each frame of video data can be conveniently analyzed and divided by adding separators; meanwhile, the length data of the video frames are added, so that the corresponding video frame data can be conveniently determined during analysis.
Step S103: and integrating all the video frame encrypted data to obtain corresponding first video encrypted data. Specifically, the corresponding complete encrypted video data stream, i.e., the first video encrypted data, can be determined according to the obtained encrypted data of each frame of video frame.
Step S104: and adding corresponding frame header information to the first video encryption data and writing the first video encryption data into an encryption file. The frame header information is used for representing the expression of the related attribute information of the video data stream, including but not limited to synchronization information, address information, error control information and the like; the encrypted file is used to mean a file storing encrypted video file data.
After the first video encrypted data is obtained, frame header information is added to the first video encrypted data to obtain final video encrypted data, namely, the final video encrypted data is expressed as "frame header information + first video encrypted data". The final video encrypted data is then stored, i.e., written to an encrypted file.
According to the video file encryption method provided by the embodiment of the invention, the video file is encrypted by utilizing the algorithm (namely, the condition that a fixed encryption chip or a special video storage chip is not added), so that the encryption cost is reduced, the algorithm can be updated in real time, and the problem that the encrypted file cannot be recovered once being cracked is solved.
As an optional implementation manner of the embodiment of the present invention, the video file data further includes a plurality of audio frame data; the method further comprises the following steps: encrypting each audio frame data, and adding a preset audio separator and audio frame length data to the frame header position of each encrypted audio frame data to obtain each audio frame encrypted data; integrating all the audio frame encrypted data to obtain corresponding first audio encrypted data; and adding corresponding frame header information to the first audio encryption data and writing the first audio encryption data into an encryption file. For a specific encryption process, refer to the encryption processes from step S102 to step S104, which are not described herein again.
As an optional implementation manner of the embodiment of the present invention, the encrypting each video frame data includes: encrypting each video frame data by using a stream encryption algorithm to generate a corresponding encrypted video frame data pseudorandom key string; and performing exclusive-or operation processing on the encrypted video frame data pseudo-random key string and each video frame data according to each byte.
The stream encryption algorithm is one of symmetric encryption algorithms, the same pseudorandom encryption data stream is used as a key during encryption and decryption, then plaintext data and the key data stream are sequentially and correspondingly encrypted each time to obtain a ciphertext data stream, namely the data is encrypted by using an exclusive OR operation according to bits.
Typically, a corresponding pseudo-random encrypted data stream is generated using an encryption algorithm and a predetermined key. For example, 011000110111010001100110 is obtained after the character string "ctf" is converted into binary, and 4-bit binary 0110 (preset) is used as a key for encryption. Directly using the binary system with 4 bits as a period, expanding the binary system into a binary string 01100110011001100110011001100110 (pseudo-random encrypted data stream) with the same length as the binary system of the original data, and performing bitwise exclusive or with the original binary data to obtain the binary data 00000101000100100000000001101100, which is the data after stream encryption.
In the embodiment of the invention, the corresponding pseudo-random encryption data stream is generated by utilizing the linear feedback shift register, so that the security of the key can be improved.
Specifically, when each piece of video frame data is encrypted, first, a stream encryption algorithm is used to encrypt each piece of acquired video frame data to generate a corresponding encrypted video frame data pseudo-random key string (i.e., a pseudo-random encrypted data stream), and then, the encrypted video frame data pseudo-random key string and each piece of video frame data are subjected to an exclusive-or operation per byte (i.e., subjected to exclusive-or processing per bit). The stream encryption algorithm may include any one of a stream encryption algorithm, a DES algorithm, a 3DES algorithm, a TDEA algorithm, a Blowfish algorithm, an RC5 algorithm, and an IDEA algorithm, which is not specifically limited in the present invention, as long as the requirements are met.
Similarly, the encrypting process is performed on each audio frame data, and includes: carrying out encryption processing on each audio frame data by using a stream encryption algorithm to generate a corresponding encrypted audio frame data pseudorandom key string; and performing exclusive-OR operation processing on the encrypted audio frame data pseudo-random key string and each audio frame data according to each byte. The specific processing procedure refers to a processing procedure for performing encryption processing on each video frame data, and details are not repeated here.
As an optional implementation manner of the embodiment of the present invention, step S102 includes: and encrypting any video frame data, adding a preset video separator and video frame length data at the frame head position of each encrypted video frame data to obtain each video frame encrypted data, and adding interference video frame data at the frame tail position corresponding to each video frame encrypted data.
Specifically, each video frame data is encrypted, and while the encrypted data of each video frame is obtained by adding a preset video separator and video frame length data to the position of the frame header of each encrypted video frame data, the interfering video frame data is added to the position of the frame tail corresponding to any one of the obtained encrypted data of the video frame, so that the complexity of the encrypted data of the video frame is increased, that is, the complexity and the difficulty of decryption of the first video encrypted data are further increased.
Similarly, encrypting each audio frame data and adding a preset audio separator and audio frame length data at the frame header position of each encrypted audio frame data to obtain each audio frame encrypted data includes: and encrypting any audio frame data, adding a preset audio separator and audio frame length data at the frame head position of each encrypted audio frame data to obtain each audio frame encrypted data, and adding interference audio frame data at the frame tail position corresponding to each audio frame encrypted data. The specific process and effect refer to the above-mentioned process of encrypting each video frame data and adding a preset video delimiter and video frame length data at the frame header position of each encrypted video frame data to obtain the encrypted data of each video frame, and are not described herein again.
An embodiment of the present invention further provides a video file decryption method, as shown in fig. 2, the method includes the following steps:
step S201: the method comprises the steps of obtaining an encrypted file, wherein the encrypted file comprises a video frame encrypted file, the video frame encrypted file is composed of frame header information and a plurality of video information data, each video information data comprises a video separator, video frame length data and encrypted original video data, and the video separator and the video frame length data are arranged at the position of a frame header of the encrypted original video data.
And acquiring the encrypted file generated through encryption processing. Specifically, video file data including a plurality of video frame data is encrypted to obtain a video frame encrypted file (that is, video encrypted data obtained by adding corresponding frame header information to the first video encrypted data). For example, a video file recorded by the vehicle-mounted tachograph is encrypted, and the video file includes a plurality of H264 data (video data), that is, the video file includes an encrypted H264 video frame.
Step S202: and traversing the encrypted file, and reading the length data of the video frames after traversing the video separators. Specifically, the obtained encrypted file includes a video frame encrypted file expressed in the form of "one frame header information + a plurality of video information data". Each piece of video information data is expressed as 'video separator + video frame length data + encrypted original video data', and the video separator is used for dividing the video data, so that the encrypted file is traversed, and after the corresponding video separator is traversed, the corresponding video frame length data can be read.
Step S203: and determining the original video data encrypted by each frame according to the video frame length data. Specifically, the video frame length data is used to indicate the length of one frame of video data, and the encrypted original video data is located behind the video frame length data, so that each frame of encrypted original video data can be determined according to the read video frame length data.
Step S204: and decrypting the encrypted original video data of each frame to obtain the original video data of each frame, adding corresponding frame header information to the frame header position of the original video data of each frame, and writing the frame header information into a decrypted video file. Specifically, first, the original video data of each frame encrypted in the video frame encryption file is decrypted by using the encryption algorithm (the encryption algorithm used in step S102) for encrypting the original video data of each frame, so that the original video data of each frame can be obtained, and then, the corresponding frame header information is added to the frame header position of the original video data of each frame and written into the decrypted video file.
Specifically, since the original video data does not include the frame header information data, the video information of the original video data obtained after decryption cannot be normally played, and therefore, the complete original video can be obtained by adding the corresponding frame header information to the frame header position of each frame of the original video data and written into the decrypted video file.
According to the video file decryption method provided by the embodiment of the invention, the video separator and the video frame length data are read by traversing the encrypted file, the corresponding encrypted video data are determined according to the video separator and the video frame length data and are decrypted, and the single video data can be obtained after decryption.
As an optional implementation manner of the embodiment of the present invention, the encrypted file further includes an audio frame encrypted file, where the audio frame encrypted file is composed of frame header information and multiple audio information data, each audio information data includes a preset audio delimiter, audio frame length data, and encrypted original audio data, and the audio delimiter and the audio frame length data are set at a frame header position of the encrypted original audio data; the method further comprises the following steps: traversing the encrypted file, and reading the length data of the audio frame after traversing the audio separator; determining the original audio data encrypted by each frame according to the length data of the audio frames; and decrypting the encrypted original audio data of each frame to obtain the original audio data of each frame, adding corresponding frame header information to the frame header position of the original audio data of each frame, and writing the frame header information into a decrypted audio file. For the specific decryption process, refer to the decryption processes of steps S202 to S204, which are not described herein again.
As an optional implementation manner of the embodiment of the present invention, decrypting the encrypted original video data of each frame to obtain the original video data of each frame includes: decrypting the original video data encrypted by each frame by using a stream encryption algorithm corresponding to the video frame encryption file to obtain a corresponding decrypted video frame data pseudorandom key string; and carrying out XOR operation processing on the decrypted video frame data pseudo-random key string and the encrypted original video data of each frame according to each byte to obtain the original video data of each frame. Specifically, the stream encryption algorithm uses the same pseudo-random encrypted data stream as a key during encryption and decryption, so that the stream encryption algorithm corresponding to the video frame encryption file is used to decrypt each frame of encrypted original video data to obtain a corresponding decrypted video frame data pseudo-random key string, and then the decrypted video frame data pseudo-random key string and each frame of encrypted original video data are subjected to bitwise xor processing again to obtain each corresponding frame of original video data (i.e., each video frame data in step S101).
Similarly, decrypting the encrypted original audio data of each frame to obtain the original audio data of each frame includes: decrypting the original audio data encrypted by each frame by using a stream encryption algorithm corresponding to the audio frame encryption file to obtain a corresponding pseudo-random key string of decrypted audio frame data; and performing exclusive-or operation processing on the decrypted audio frame data pseudorandom key string and the encrypted original audio data of each frame according to each byte to obtain the original audio data of each frame. The specific decryption process refers to the decryption process for decrypting the encrypted original video data of each frame to obtain the original video data of each frame, which is not described herein again.
As an optional implementation manner of the embodiment of the present invention, the method further includes: and inputting the decrypted video file and the decrypted audio file into a preset mixer to obtain corresponding decrypted video file data. Specifically, when a complete video file needs to be acquired, the decrypted video file and the decrypted audio file obtained through decryption are input into a preset mixer to be mixed, and complete decrypted video file data can be acquired.
Alternatively, the decrypted video file and the decrypted audio file may be mixed using ffmepg commands. The specific mixing method is not particularly limited, and the requirements can be met.
An embodiment of the present invention further provides a video file encryption apparatus, as shown in fig. 3, the apparatus includes:
a first obtaining module 301, configured to obtain video file data, where the video file data includes a plurality of video frame data; for details, refer to the related description of step S101 in the above method embodiment.
The first encryption module 302 is configured to encrypt each piece of video frame data and add a preset video delimiter and video frame length data to a frame header position of each piece of encrypted video frame data to obtain encrypted data of each video frame; for details, refer to the related description of step S102 in the above method embodiment.
A first integration module 303, configured to integrate all video frame encryption data to obtain corresponding first video encryption data; for details, refer to the related description of step S103 in the above method embodiment.
A first adding module 304, configured to add corresponding frame header information to the first video encrypted data and write the first video encrypted data into an encrypted file; for details, refer to the related description of step S104 in the above method embodiment.
The video file encryption device provided by the embodiment of the invention encrypts the video file by using the algorithm (namely, the condition of not increasing a fixed encryption chip or a special video storage chip) so as to reduce the encryption cost, and the algorithm can be updated in real time, thereby solving the problem that the encrypted file cannot be recovered once being cracked.
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes: the second encryption module is used for encrypting each audio frame data and adding a preset audio separator and audio frame length data to the frame header position of each encrypted audio frame data to obtain each audio frame encrypted data; the second integration module is used for integrating all the audio frame encrypted data to obtain corresponding first audio encrypted data; and the second adding module is used for adding corresponding frame header information to the first audio encrypted data and then writing the frame header information into an encrypted file.
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes: the third encryption module is used for encrypting each video frame data by using a stream encryption algorithm to generate a corresponding encrypted video frame data pseudorandom key string; and the first processing module is used for carrying out exclusive-or operation processing on the encrypted video frame data pseudo-random key string and each video frame data according to each byte.
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes: the fourth encryption code module is used for encrypting each audio frame data by using a stream encryption algorithm to generate a corresponding encrypted audio frame data pseudorandom key string; and the second processing module is used for carrying out exclusive OR operation processing on the encrypted audio frame data pseudo-random key string and each audio frame data according to each byte.
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes: and the third adding module is used for encrypting any video frame data, adding a preset video separator and video frame length data at the frame head position of each encrypted video frame data to obtain each video frame encrypted data, and adding interference video frame data at the frame tail position corresponding to each video frame encrypted data.
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes: and the fourth adding module is used for encrypting any audio frame data, adding a preset audio separator and audio frame length data to the frame header position of each encrypted audio frame data to obtain each audio frame encrypted data, and adding interference audio frame data to the position of the frame tail corresponding to each audio frame encrypted data.
For a detailed description of the functions of the video file encryption apparatus provided in the embodiments of the present invention, reference is made to the description of the video file encryption method in the above embodiments.
An embodiment of the present invention further provides a video file decryption apparatus, and as shown in fig. 4, the apparatus includes:
a second obtaining module 401, configured to obtain an encrypted file, where the encrypted file includes a video frame encrypted file, where the video frame encrypted file is composed of frame header information and multiple pieces of video information data, each piece of video information data includes a video delimiter and video frame length data, and encrypted original video data, and the video delimiter and the video frame length data are set at a frame header position of the encrypted original video data; for details, refer to the related description of step S201 in the above method embodiment.
A first traversal module 402, configured to traverse an encrypted file, and read length data of the video frame after traversing the video delimiter; for details, refer to the related description of step S202 in the above method embodiment.
A first determining module 403, configured to determine, according to the video frame length data, original video data encrypted for each frame; for details, refer to the related description of step S203 in the above method embodiment.
A first decryption module 404, configured to decrypt the encrypted original video data of each frame to obtain original video data of each frame, add corresponding frame header information to a frame header position of the original video data of each frame, and write the frame header information into a decrypted video file; for details, refer to the related description of step S204 in the above method embodiment.
The video file decryption device provided by the embodiment of the invention reads the video separator and the video frame length data by traversing the encrypted file, determines and decrypts the corresponding encrypted video data according to the video separator and the video frame length data, and can obtain the single video data after decryption.
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes: the second traversal module is used for traversing the encrypted file and reading the length data of the audio frame after traversing the audio separator; the second determining module is used for determining the original audio data encrypted by each frame according to the length data of the audio frames; and the second decryption module is used for decrypting the encrypted original audio data of each frame to obtain the original audio data of each frame, adding corresponding frame header information to the frame header position of the original audio data of each frame, and writing the frame header information into a decrypted audio file.
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes: the third decryption module is used for decrypting the original video data encrypted by each frame by using the stream encryption algorithm corresponding to the video frame encryption file to obtain a corresponding decrypted video frame data pseudorandom key string; and the third processing module is used for carrying out exclusive-or operation processing on the decrypted video frame data pseudo-random key string and the encrypted original video data of each frame according to each byte to obtain the original video data of each frame.
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes: the fourth decryption module is used for decrypting the original audio data encrypted by each frame by using the stream encryption algorithm corresponding to the audio frame encryption file to obtain a corresponding decrypted audio frame data pseudorandom key string; and the fourth processing module is used for carrying out exclusive OR operation processing on the decrypted audio frame data pseudo-random key string and the encrypted original audio data of each frame according to each byte to obtain the original audio data of each frame.
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes: and the input module is used for inputting the decrypted video file and the decrypted audio file into a preset mixer to obtain corresponding decrypted video file data.
For a detailed description of the functions of the video file decryption apparatus according to the embodiment of the present invention, reference is made to the description of the video file decryption method in the above embodiment.
An embodiment of the present invention further provides a storage medium, as shown in fig. 5, on which a computer program 501 is stored, and when the instructions are executed by a processor, the steps of the video file encryption method or the video file decryption method in the foregoing embodiments are implemented. The storage medium is also stored with audio and video stream data, characteristic frame data, an interactive request signaling, encrypted data, preset data size and the like. The storage medium may be a magnetic Disk, an optical Disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a Flash Memory (Flash Memory), a Hard Disk (Hard Disk Drive, abbreviated as HDD) or a Solid State Drive (SSD), etc.; the storage medium may also comprise a combination of memories of the kind described above.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic Disk, an optical Disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a Flash Memory (Flash Memory), a Hard Disk (Hard Disk Drive, abbreviated as HDD), a Solid State Drive (SSD), or the like; the storage medium may also comprise a combination of memories of the kind described above.
An embodiment of the present invention further provides an electronic device, as shown in fig. 6, the electronic device may include a processor 61 and a memory 62, where the processor 61 and the memory 62 may be connected by a bus or in another manner, and fig. 6 illustrates the connection by the bus as an example.
The processor 61 may be a Central Processing Unit (CPU). The Processor 61 may also be other general purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, or combinations thereof.
The memory 62, which is a non-transitory computer readable storage medium, may be used to store non-transitory software programs, non-transitory computer executable programs, and modules, such as the corresponding program instructions/modules in embodiments of the present invention. The processor 61 executes various functional applications and data processing of the processor, i.e., implements the video file encryption method or the video file decryption method in the above-described method embodiments, by executing the non-transitory software programs, instructions, and modules stored in the memory 62.
The memory 62 may include a storage program area and a storage data area, wherein the storage program area may store an operating device, an application program required for at least one function; the storage data area may store data created by the processor 61, and the like. Further, the memory 62 may include high speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, the memory 62 may optionally include memory located remotely from the processor 61, and these remote memories may be connected to the processor 61 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The one or more modules are stored in the memory 62 and, when executed by the processor 61, perform a video file encryption method or a video file decryption method as in the embodiment shown in fig. 1-2.
The details of the electronic device may be understood by referring to the corresponding descriptions and effects in the embodiments shown in fig. 1 to fig. 2, and are not described herein again.
Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations fall within the scope defined by the appended claims.
Claims (11)
1. A video file encryption method is characterized by comprising the following steps:
acquiring video file data, wherein the video file data comprises a plurality of video frame data;
encrypting each video frame data, and adding a preset video separator and video frame length data to the frame header position of each encrypted video frame data to obtain each video frame encrypted data;
integrating all video frame encrypted data to obtain corresponding first video encrypted data;
and writing the first video encrypted data into an encrypted file after adding corresponding frame header information to the first video encrypted data.
2. The method of claim 1, wherein the video file data further comprises a plurality of audio frame data; the method further comprises the following steps:
encrypting each audio frame data, and adding a preset audio separator and audio frame length data to the frame header position of each encrypted audio frame data to obtain each audio frame encrypted data;
integrating all the audio frame encrypted data to obtain corresponding first audio encrypted data;
and adding corresponding frame header information to the first audio encryption data and writing the first audio encryption data into an encryption file.
3. The method of claim 1, wherein the encrypting each video frame data comprises:
encrypting each video frame data by using a stream encryption algorithm to generate a corresponding encrypted video frame data pseudorandom key string;
and performing exclusive-or operation processing on the encrypted video frame data pseudo-random key string and each video frame data according to each byte.
4. The method of claim 2, wherein the encrypting each audio frame data comprises:
carrying out encryption processing on each audio frame data by using a stream encryption algorithm to generate a corresponding encrypted audio frame data pseudorandom key string;
and performing exclusive-OR operation processing on the encrypted audio frame data pseudo-random key string and each audio frame data according to each byte.
5. The method of claim 1, wherein encrypting each video frame data and adding a predetermined video separator and video frame length data to the header of each encrypted video frame data to obtain the encrypted data of each video frame comprises:
and encrypting any video frame data, adding a preset video separator and video frame length data at the frame head position of each encrypted video frame data to obtain each video frame encrypted data, and adding interference video frame data at the frame tail position corresponding to each video frame encrypted data.
6. The method of claim 2, wherein encrypting each audio frame data and adding a predetermined audio separator and audio frame length data to the header of each audio frame data after encryption to obtain each audio frame encrypted data comprises:
and encrypting any audio frame data, adding a preset audio separator and audio frame length data at the frame head position of each encrypted audio frame data to obtain each audio frame encrypted data, and adding interference audio frame data at the frame tail position corresponding to each audio frame encrypted data.
7. A method for decrypting a video file, comprising the steps of:
acquiring an encrypted file, wherein the encrypted file comprises a video frame encrypted file, the video frame encrypted file consists of frame header information and a plurality of video information data, each video information data comprises a video separator, video frame length data and encrypted original video data, and the video separator and the video frame length data are arranged at the position of a frame header of the encrypted original video data;
traversing the encrypted file, and reading the length data of the video frame after traversing the video separator;
determining the original video data encrypted by each frame according to the video frame length data;
and decrypting the encrypted original video data of each frame to obtain the original video data of each frame, adding corresponding frame header information to the frame header position of the original video data of each frame, and writing the frame header information into a decrypted video file.
8. The method according to claim 7, wherein the encrypted file further comprises an audio frame encrypted file composed of a header information and a plurality of audio information data, each audio information data containing a predetermined audio delimiter and audio frame length data and the encrypted original audio data, the audio delimiter and audio frame length data being set at a position of the header of the encrypted original audio data; the method further comprises the following steps:
traversing the encrypted file, and reading the length data of the audio frame after traversing the audio separator;
determining the original audio data encrypted by each frame according to the length data of the audio frames;
and decrypting the encrypted original audio data of each frame to obtain the original audio data of each frame, adding corresponding frame header information to the frame header position of the original audio data of each frame, and writing the frame header information into a decrypted audio file.
9. The method of claim 7, wherein decrypting the encrypted original video data for each frame to obtain original video data for each frame comprises:
decrypting the original video data encrypted by each frame by using a stream encryption algorithm corresponding to the video frame encryption file to obtain a corresponding decrypted video frame data pseudorandom key string;
and performing exclusive-or operation processing on the decrypted video frame data pseudorandom key string and the encrypted original video data of each frame according to each byte to obtain the original video data of each frame.
10. The method of claim 8, wherein decrypting the encrypted original audio data for each frame to obtain the original audio data for each frame comprises:
decrypting the original audio data encrypted by each frame by using a stream encryption algorithm corresponding to the audio frame encryption file to obtain a corresponding pseudo-random key string of decrypted audio frame data;
and carrying out exclusive OR operation processing on the decrypted audio frame data pseudorandom key string and the encrypted original audio data of each frame according to each byte to obtain the original audio data of each frame.
11. The method of claim 8, further comprising:
and inputting the decrypted video file and the decrypted audio file into a preset mixer to obtain a corresponding decrypted file.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210370826.1A CN114666624A (en) | 2022-04-07 | 2022-04-07 | Video file encryption and decryption method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210370826.1A CN114666624A (en) | 2022-04-07 | 2022-04-07 | Video file encryption and decryption method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114666624A true CN114666624A (en) | 2022-06-24 |
Family
ID=82036117
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210370826.1A Pending CN114666624A (en) | 2022-04-07 | 2022-04-07 | Video file encryption and decryption method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114666624A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115426507A (en) * | 2022-07-29 | 2022-12-02 | 宁波星巡智能科技有限公司 | Method, device and equipment for transmitting and playing private video based on target detection |
Citations (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1385032A (en) * | 1999-08-29 | 2002-12-11 | 英特尔公司 | Digital video content transmisson ciphering and deciphering method and apparatus |
CN101047501A (en) * | 2006-04-14 | 2007-10-03 | 华为技术有限公司 | Method and equipment for raising safety of data flow transmission in mobile TV. system |
US20080101478A1 (en) * | 2006-10-31 | 2008-05-01 | Kabushiki Kaisha Toshiba | Decoding device and decoding method |
CN101442676A (en) * | 2008-12-26 | 2009-05-27 | 北京工业大学 | Method for enciphering H.264 video based on CAVLC encode |
CN102255886A (en) * | 2011-04-02 | 2011-11-23 | 南京邮电大学 | Encryption and decryption methods of streaming media on-demand system |
CN106096334A (en) * | 2016-06-02 | 2016-11-09 | 中国传媒大学 | The encryption method of hypermedia data and encryption device, decryption method and deciphering device |
CN106254895A (en) * | 2016-07-21 | 2016-12-21 | 重庆科技学院 | A kind of for audio frequency and video Mp4 file encryption decryption system |
CN107911210A (en) * | 2017-10-20 | 2018-04-13 | 广东省南方数字电视无线传播有限公司 | Video segment encryption and decryption method and related device |
CN111093098A (en) * | 2019-12-30 | 2020-05-01 | 北京电子科技学院 | Logistic mapping-based chaotic encryption method |
CN113098938A (en) * | 2021-03-25 | 2021-07-09 | 卓尔智联(武汉)研究院有限公司 | Video sharing method and device and electronic equipment |
CN113453026A (en) * | 2020-03-26 | 2021-09-28 | 阿里巴巴集团控股有限公司 | Video data processing method and device, electronic equipment and computer storage medium |
-
2022
- 2022-04-07 CN CN202210370826.1A patent/CN114666624A/en active Pending
Patent Citations (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1385032A (en) * | 1999-08-29 | 2002-12-11 | 英特尔公司 | Digital video content transmisson ciphering and deciphering method and apparatus |
CN101047501A (en) * | 2006-04-14 | 2007-10-03 | 华为技术有限公司 | Method and equipment for raising safety of data flow transmission in mobile TV. system |
US20080101478A1 (en) * | 2006-10-31 | 2008-05-01 | Kabushiki Kaisha Toshiba | Decoding device and decoding method |
CN101442676A (en) * | 2008-12-26 | 2009-05-27 | 北京工业大学 | Method for enciphering H.264 video based on CAVLC encode |
CN102255886A (en) * | 2011-04-02 | 2011-11-23 | 南京邮电大学 | Encryption and decryption methods of streaming media on-demand system |
CN106096334A (en) * | 2016-06-02 | 2016-11-09 | 中国传媒大学 | The encryption method of hypermedia data and encryption device, decryption method and deciphering device |
CN106254895A (en) * | 2016-07-21 | 2016-12-21 | 重庆科技学院 | A kind of for audio frequency and video Mp4 file encryption decryption system |
CN107911210A (en) * | 2017-10-20 | 2018-04-13 | 广东省南方数字电视无线传播有限公司 | Video segment encryption and decryption method and related device |
CN111093098A (en) * | 2019-12-30 | 2020-05-01 | 北京电子科技学院 | Logistic mapping-based chaotic encryption method |
CN113453026A (en) * | 2020-03-26 | 2021-09-28 | 阿里巴巴集团控股有限公司 | Video data processing method and device, electronic equipment and computer storage medium |
CN113098938A (en) * | 2021-03-25 | 2021-07-09 | 卓尔智联(武汉)研究院有限公司 | Video sharing method and device and electronic equipment |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115426507A (en) * | 2022-07-29 | 2022-12-02 | 宁波星巡智能科技有限公司 | Method, device and equipment for transmitting and playing private video based on target detection |
CN115426507B (en) * | 2022-07-29 | 2023-12-05 | 宁波星巡智能科技有限公司 | Privacy video transmission and playing method, device and equipment based on target detection |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10721057B2 (en) | Dynamic channels in secure queries and analytics | |
US9240883B2 (en) | Multi-key cryptography for encrypting file system acceleration | |
KR101405720B1 (en) | Accelerated cryptography with an encryption attribute | |
CN100592787C (en) | Method and condition access system for contents protection | |
CN110753226B (en) | High-capacity ciphertext domain image reversible data hiding method | |
EP2352251A1 (en) | Content decoding apparatus, content decoding method and integrated circuit | |
CN111031353B (en) | Video encryption method and device | |
US9268918B2 (en) | Encryption and decryption of a dataset in at least two dimensions | |
KR101117588B1 (en) | Record carrier comprising encryption indication information | |
CN114666624A (en) | Video file encryption and decryption method | |
CN110688667A (en) | Picture file processing method and device, terminal equipment and medium | |
CN113098938B (en) | Video sharing method and device and electronic equipment | |
WO2016202089A1 (en) | Method, apparatus, and system for encrypting data of remote storage device | |
US9031239B2 (en) | Information processing apparatus, information processing method, and computer readable storage medium | |
KR101953908B1 (en) | Security System and Method of Embeded software in Vehicle electric device | |
WO2019184741A1 (en) | Application program information storing method and apparatus, and application program information processing method and apparatus | |
CN114390317B (en) | Encryption method and system for streaming video | |
CN113542224B (en) | Training data processing method, device, server and medium | |
CN107861892B (en) | Method and terminal for realizing data processing | |
US20220345292A1 (en) | Method and device for encryption of video stream, communication equipment, and storage medium | |
JP4299801B2 (en) | Data transmission method and electronic device | |
US11886624B2 (en) | Crypto device, integrated circuit and computing device having the same, and writing method thereof | |
Kim et al. | Data forgery detection for vehicle black box | |
US10764285B2 (en) | Method and system for encryption using a radio frequency fingerprint | |
CN113032345A (en) | File processing method, device, terminal and non-transitory storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20220624 |