CN114301602A - Video protection method and device based on block chain - Google Patents

Video protection method and device based on block chain Download PDF

Info

Publication number
CN114301602A
CN114301602A CN202111631141.XA CN202111631141A CN114301602A CN 114301602 A CN114301602 A CN 114301602A CN 202111631141 A CN202111631141 A CN 202111631141A CN 114301602 A CN114301602 A CN 114301602A
Authority
CN
China
Prior art keywords
index file
hash value
block
level
media
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.)
Granted
Application number
CN202111631141.XA
Other languages
Chinese (zh)
Other versions
CN114301602B (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.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent Technology Co Ltd
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 Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN202111631141.XA priority Critical patent/CN114301602B/en
Publication of CN114301602A publication Critical patent/CN114301602A/en
Application granted granted Critical
Publication of CN114301602B publication Critical patent/CN114301602B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The invention provides a video protection method and a device based on a block chain, belonging to the technical field of video protection, wherein the method comprises the following steps: the video is segmented to generate media segments and index files; recording the address of the first block of the block chain in a primary index file, calculating a hash value of the primary index file, and storing the hash value of the primary index file on the first block of the block chain; recording the hash value of each media fragment and the address of a second block of the block chain in a secondary index file, and storing the hash value of the secondary index file on the second block of the block chain; and the user sends a video request to the server through the client, verifies the hash values of the first-level index file and the second-level index file after the hash values of the first-level index file and the second-level index file pass, verifies the hash values of the media fragments, and sequentially plays the media fragments of which the hash values pass the verification. The invention saves the video index file through the block chain, realizes the lightweight protection of the video, and simultaneously verifies the media fragment hash value to ensure the safety of playing the video.

Description

Video protection method and device based on block chain
Technical Field
The invention belongs to the technical field of video protection, and particularly relates to a video protection method and device based on a block chain.
Background
Because of the vigorous development of network related applications in recent years, various image-text images can be rapidly acquired and transmitted through the network, and the purpose of preventing information from being falsified can be achieved by combining a block chain technology, but the data carried by each block in the block chain is very limited, and the complexity of the block per se causes that continuous images are not easy to be rapidly updated and transmitted on the basis of the block chain.
The block chain decentralized operation mode is characterized in that after an only hash value is calculated from important information, multi-party authentication and storage are achieved through a distributed book accounting mechanism, and the important information is public, traceable and not capable of being tampered.
In a video protection system and a computer storage medium based on the blockchain technology, the patent document CN113411614A describes the following technologies: the video encryption module packs each frame data of the video into a block, each block forms a block chain according to the sequence of the frames, and the original frame data are stored in the block; the monitoring module calls a hash function to calculate a certain block, if a difference exists, frame data in the block is tampered, and in addition, the difference is compared with data of the next block, and if the difference exists, the second block is tampered or the data of the block between the two blocks is lost. In the method for preventing video content from being tampered, lost and recovered based on the block chain technology in the patent document CN110650321B, the following technologies are described: establishing a video block chain, wherein the chain is formed by a plurality of camera IP video chains and is expanded by a founding block; the IP of the camera is used as a basis for judging the legality of the video and verifying whether the data on the chain is falsified; the video node obtains the accounting right through a PoW mechanism. In CN110366049a, a streaming video integrity protection method, techniques are described for generating integrity description data, defining an extra real-time integrity ES stream in a TS stream, where the ES stream performs integrity protection on a data ES stream in the TS stream; the receiving end analyzes the corresponding real-time integrity ES flow in the TS flow, if the Hash values are consistent, the data is considered to be complete, otherwise, the video is considered to be tampered; the method does not increase the play delay, provides frame-level audio and video protection, and is suitable for TCP and UDP transmission.
The patent technology of CN113411614A transfers all data frames to a block chain for protection, and since each block body on the block chain can carry very little data, hundreds of MB or GB of videos are placed on the main chain and occupy a large number of blocks; and because the hash value of each frame and the next frame needs to be calculated when the video is played, if data is lost due to a network environment, the hash value is compared wrongly, the video is easily judged to be falsified by mistake, and when the network data is lost, the client cannot obtain the next block of data, and the next block of data needs to be retransmitted, so that the experience is influenced by delay. Patent document CN110650321B also protects the full data frame by uploading it to the block chain, and aims to prevent falsification, but has the same problem of efficiency in acquiring video as patent document CN 113411614A. The patent document CN110366049A uses a lightweight method to verify the integrity of a video, and uses a TS stream to match with an ES stream to achieve a fast and real-time verification method, but due to the lack of other verification mechanisms, when a client acquires a segment of video, it cannot confirm whether the video is original or has been altered.
This is a disadvantage of the prior art, and therefore, it is very necessary to provide a video protection method and apparatus based on a block chain to address the above-mentioned disadvantages of the prior art.
Disclosure of Invention
The invention provides a video protection method and device based on a block chain, aiming at the defects that in the prior art, by means of a block chain to protect videos, all videos are placed on a main chain of a block, the data volume is large, the videos are easy to lose, transmission of a next block is influenced when the videos are lost, retransmission is needed, a light transmission mode is adopted, and a verification mechanism is still lacked.
In a first aspect, the present invention provides a video protection method based on a block chain, including the following steps:
s1, fragmenting a video to generate media fragments and an index file; the index files comprise a first-level index file and a second-level index file;
s2, recording the address of the first block of the block chain in a primary index file, calculating a hash value of the primary index file, and storing the hash value of the primary index file in the first block of the block chain;
s3, calculating the hash value of each media fragment, recording the hash value of each media fragment and the address of a second block of the block chain in a secondary index file, calculating the hash value of the secondary index file, and storing the hash value of the secondary index file in the second block of the block chain;
s4, the user sends a video request to the server through the client, receives a first-level index file returned by the server, requests a second-level index file to the server after verifying that the hash value of the first-level index file passes, downloads each media fragment according to the second-level index file after verifying that the hash value of the second-level index file passes, verifies the hash value of each media fragment, and plays the media fragments of which the hash value passes verification in sequence.
Further, the step S1 specifically includes the following steps:
s11, HLS fragmentation is carried out on the video to generate media fragments;
and S12, creating a primary index file and a secondary index file for the media fragments. The media fragment is a segmented video file, the index file stores the information of the video, the first-level index file stores the address of the first block in the block chain, and also stores important information related to the video, such as copyright information; the secondary index file stores addresses of the second block and subsequent blocks, and also stores corresponding media fragment hash values.
Further, the step S2 specifically includes the following steps:
s21, recording the address of the first block of the block chain in a first-level index file;
and S22, calculating the hash value of the primary index file, and storing the hash value of the primary index file on the first block. The first block of the block chain stores the hash value of the first-level index file and the important information of the video file, and the content of the first block is obtained and used for verifying the video file for the first time and verifying the hash value of the first-level index file.
Further, the step S3 specifically includes the following steps:
s31, determining the number of second index files and the number of blocks in the block chain according to the number of the media fragments;
s32, calculating hash values of all media fragments;
s33, recording the media fragment hash value to be stored in the second block and the address of the second block in a first-level index file;
s34, calculating a first secondary index file hash value, and storing the first secondary index file hash value on a second block;
s35, judging whether all media fragment hash values are stored completely;
if yes, go to step S4;
if not, go to step S36;
s36, recording the media fragment hash value to be stored in the third block and the address of the third block in a second-level index file;
and S37, calculating the hash value of the second-level index file, storing the hash value of the second-level index file on a third block, and repeating the step S35 until all the media fragment hash values are stored. The second block is a block which is immediately followed by a first block in the block chain, the third block is a block which is immediately followed by the second block, the subsequent blocks which start from the second block store the hash values of the secondary index file, the number of the subsequent blocks which start from the second block is set according to the number of the media fragments, and the hash values of the secondary index file and the media fragment hash values are stored in the second block and the subsequent blocks and used for verifying the subsequent video to be played.
Further, the step S4 specifically includes the following steps:
s41, a user sends a video request to a server through a client;
s42, the server returns a primary index file to the client;
s43, after calculating the hash value of the first-level index file, the client judges whether the hash value is consistent with the hash value of the first-level index file stored in the first block;
if not, returning an error, and ending;
if yes, go to step S44;
s44, the client requests a first-level second-level index file from the server;
s45, the server returns a first-level second-level index file to the client;
s46, the client calculates the hash value of the first-level second index file and judges whether the hash value of the first-level second index file is consistent with the hash value of the first-level second index file stored in the second block;
if not, discarding the media fragment corresponding to the index file on the block, and entering step S49;
if yes, go to step S47;
s47, the client downloads each media fragment corresponding to the first index file of the second block;
s48, the client calculates the hash value of each media fragment corresponding to the first second index file, and judges whether the hash value of each media fragment corresponding to the first second index file is consistent with the hash value of each media fragment corresponding to the first second index file;
if yes, playing each media fragment corresponding to the first index file of the second chunk, and entering step S49;
if not, processing the media fragments with inconsistent hash values, and entering step S49;
s49, judging whether the comparison of all media fragmentation hash values is finished;
if yes, ending;
if not, repeating the steps S44-S48 until the media fragment hash value comparison on the last block is completed. When the video request is to play the video on demand, the firmware of the index file is not changed, according to the steps of the invention, if the video request is to play the live video, the index file is continuously updated, the client needs to send the video request according to the video updating frequency, meanwhile, the hash value of the index file needs to be updated to the block of the corresponding block chain in advance, and the block chain with the processing speed greater than the threshold value needs to be selected.
Further, the step S43 specifically includes the following steps:
s431, the client searches a first block address from the primary index text and connects the first block;
s432, the client acquires a first-level index file hash value from the first block and sets the first-level index file hash value as a first hash value;
s433, the client calculates a hash value according to the first-level index file returned by the server, and sets the hash value as a second hash value;
s434, comparing whether the first hash value is consistent with the second hash value;
if not, returning an error, and ending;
if they match, the process proceeds to step S44. The first-level index file hash value verification is the first verification of video playing, and if the verification fails, important video information may be tampered, and video playing cannot be performed.
Further, the step S46 specifically includes the following steps:
s461, the client searches a second block address from the first-level secondary index file and connects the second block;
s462, the client acquires the first-level second index file hash value from the second block and sets a third hash value;
s463, the client calculates a hash value according to the first-level second-level index file returned by the server, and sets the hash value as a fourth hash value;
s464, comparing whether the third hash value is consistent with the fourth hash value;
if not, discarding the media fragment corresponding to the index file on the block, and entering step S49;
if they match, the process proceeds to step S47. The hash value of the secondary index file is the verification of the second block address, the verification fails, and the media fragment corresponding to the secondary index file can not be played in the whole.
Further, the step S48 specifically includes the following steps:
s481, the client searches a media fragment hash value from the first-level index file returned by the server and sets the hash value as a fifth hash value;
s482, the client calculates a hash value according to each media fragment corresponding to the first index file of the downloaded second block, and sets the hash value as a sixth hash value;
s483, comparing whether the fifth hash value is consistent with the sixth hash value;
if yes, go to step S484;
if not, the step S485 is carried out;
s484, playing each media fragment corresponding to the first index file of the second block, and entering step S49;
s485, acquiring media fragments with inconsistent hash values, and setting the media fragments as error media fragments;
and S486, discarding the error media fragment, requiring the error media fragment to be retransmitted, setting a comparison threshold value for the error media fragment, stopping playing the error media fragment when the comparison times exceed the comparison threshold value, and entering the step S49. The verification of the media fragment hash value is specific to the verification of a certain media fragment, and the verification is not passed, only the media fragment cannot be played.
In a second aspect, the present invention provides a video protection device based on a block chain, including:
the video slicing module is used for slicing the video to generate media slices and index files; the index files comprise a first-level index file and a second-level index file;
the first-level index file recording and first block storage module is used for recording the address of the first block of the block chain in the first-level index file, calculating the hash value of the first-level index file and storing the hash value of the first-level index file in the first block of the block chain;
the second-level index file recording and second block storage module is used for calculating each media fragment hash value, recording each media fragment hash value and the address of the second block of the block chain in the second-level index file, calculating the second-level index file hash value and storing the second-level index file hash value on the second block of the block chain;
the video verification module is used for sending a video request to the server through the client, receiving a first-level index file returned by the server, requesting a second-level index file to the server after verifying that the hash value of the first-level index file passes, downloading each media fragment according to the second-level index file after verifying that the hash value of the second-level index file passes, verifying the hash value of each media fragment, and sequentially playing the media fragments of which the hash values pass verification.
Further, the video slicing module includes:
the media fragment generating unit is used for HLS (HTTP live streaming) fragmentation of the video to generate media fragments;
the index file generation unit is used for creating a primary index file and a secondary index file for the media fragments;
the first-level index file recording and first block storage module comprises:
a first block address storage unit, configured to record an address of a first block of a block chain in a primary index file;
the first-level index file hash value storage unit is used for calculating the first-level index file hash value and storing the first-level index file hash value on the first block;
the second index file recording and second block storage module comprises:
a second index file and block number determining unit, configured to determine the number of second index files and the number of blocks in the block chain according to the number of media fragments;
the media slicing hash value calculating unit is used for calculating the hash value of each media slice;
the media fragment hash value and second block address recording unit is used for recording the media fragment hash value and the second block address which need to be stored in the second block into the first secondary index file;
the first-level second index file hash value recording unit is used for calculating the first-level second index file hash value and storing the first-level second index file hash value on the second block;
the media fragment hash value storage judging unit is used for judging whether all the media fragment hash values are stored completely;
the media fragment address and third block address recording unit is used for recording the media fragment hash value to be stored in the third block and the address of the third block in the second-level index file when the media fragment hash value is not completely stored;
the second-level index file hash value recording unit is used for calculating the second-level index file hash value, storing the second-level index file hash value on a third block, and repeating the work of the media fragmentation hash value storage judging unit until all the media fragmentation hash values are stored;
the video verification module includes:
the video request unit is used for sending a video request to the server side through the client side by a user;
the server side returns the first-level index file to the client side;
the first-level index file hash value judging unit is used for judging whether the hash value of the first-level index file is consistent with the hash value of the first-level index file stored in the first block or not after the client calculates the hash value of the first-level index file;
the first-level and second-level index file request unit is used for requesting the first-level and second-level index files from the server by the client when the hash values of the first-level index files are consistent;
the first-grade index file returning unit is used for returning the first-grade index file to the client by the server;
the first-level second index file hash value judgment unit is used for calculating the first-level second index file hash value by the client and judging whether the first-level second index file hash value is consistent with the first-level second index file hash value stored on the second block;
the media fragment discarding unit is used for discarding the media fragments corresponding to the index files on the block when the hash values of the first-level and second-level index files are inconsistent;
the media fragment downloading unit is used for downloading each media fragment corresponding to the first index file of the second block by the client when the hash values of the first-level second index file are consistent;
the media fragment hash value judgment unit is used for calculating the hash value of each media fragment corresponding to the first second index file by the client and judging whether the hash value of each media fragment corresponding to the first second index file is consistent with the hash value of each media fragment corresponding to the first second index file;
the media fragment playing unit is used for playing each media fragment corresponding to the first index file of the first block when the hash values of the media fragments are consistent;
the media fragmentation processing unit is used for processing the media fragments with inconsistent hash values when the hash values of the media fragments are inconsistent;
the media fragment hash value comparison completion judging unit is used for judging whether the comparison of all the media fragment hash values is completed;
and the media fragment hash value continuous comparison unit is used for repeatedly comparing the media fragments of the subsequent blocks when the media fragment hash values are not compared completely until the media fragment hash values on the last block are compared completely.
The beneficial effect of the invention is that,
according to the video protection method and device based on the block chain, the index file of the video is protected through the block chain, the video does not need to be stored, information stored on the block chain is less, light-weight video protection is achieved, meanwhile, the media fragment hash value is verified, the situation that the played video is changed is prevented, and the video safety is guaranteed.
In addition, the invention has reliable design principle, simple structure and very wide application prospect.
Therefore, compared with the prior art, the invention has prominent substantive features and remarkable progress, and the beneficial effects of the implementation are also obvious.
Drawings
In order to more clearly illustrate the embodiments or technical solutions in the prior art of the present invention, the drawings used in the description of the embodiments or prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained based on these drawings without creative efforts.
Fig. 1 is a schematic flow chart of an embodiment 1 of a video protection method based on a block chain according to the present invention.
Fig. 2 is a schematic flow chart of an embodiment 2 of the video protection method based on a block chain according to the present invention.
Fig. 3 is a flowchart illustrating the step S4 of the video protection method based on the blockchain according to the present invention.
Fig. 4 is a schematic diagram of a video protection apparatus based on a block chain according to the present invention.
In the figure, 1-video slicing module; 1.1-media fragment generating unit; 1.2-index file generating unit; 2-a first-level index file recording and first block storage module; 2.1 — first block address storage unit; 2.2-a first-level index file hash value storage unit; 3-a second-level index file recording and second block storage module; 3.1-second index file and block number determining unit; 3.2-media slicing hash value calculating unit; 3.3-media fragment hash value and second block address recording unit; 3.4-a second grade index file hash value recording unit; 3.5-media slicing hash value storage judging unit; 3.6-media slicing address and third area block address recording unit; 3.7-second level index file hash value recording unit; 4-a video verification module; 4.1-video request unit; 4.2-first level index file return unit; 4.3-a first-level index file hash value judgment unit; 4.4-number one secondary index file request unit; 4.5-number one secondary index file returning unit; 4.6-number one secondary index file hash value judging unit; 4.7-media fragment discarding unit; 4.8-media fragment download unit; 4.9-media slicing hash value judging unit; 4.10-media segment playing unit; 4.11-media fragment processing unit; 4.12-media fragment hash value comparison completion judgment unit; 4.13-media fragment hash value continue comparison unit.
Detailed Description
In order to make those skilled in the art better understand the technical solution of the present invention, the technical solution in the embodiment of the present invention will be clearly and completely described below with reference to the drawings in the embodiment of the present invention, and it is obvious that the described embodiment is only a part of the embodiment of the present invention, and not all embodiments. 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.
The following explains key terms appearing in the present invention.
ES, which is an abbreviation of Elementary Stream, is also called Elementary Stream, and includes continuous streams of video, audio, or data.
The TS is a short name for Transport Stream, and a TS Stream is also called Transport Stream, that is, in the MPEG-2 system, a standard information Stream for actual transmission generated by multiplexing an ES Stream of video and audio and auxiliary data is called MPEG-2 Transport Stream. A TS stream is an ES stream consisting of 188 byte fixed length packets, containing one or more programs with independent time bases, one program in turn containing multiple video, audio, and text messages.
HLS, abbreviated as HTTP Live Streaming, mainly defines the file format of data and the corresponding behavior that the server and the client should have, is the currently mainstream video playing format, and can push continuous or long-term movies.
Example 1:
as shown in fig. 1, the present invention provides a video protection method based on a block chain, which includes the following steps:
s1, fragmenting a video to generate media fragments and an index file; the index files comprise a first-level index file and a second-level index file;
s2, recording the address of the first block of the block chain in a primary index file, calculating a hash value of the primary index file, and storing the hash value of the primary index file in the first block of the block chain;
s3, calculating the hash value of each media fragment, recording the hash value of each media fragment and the address of a second block of the block chain in a secondary index file, calculating the hash value of the secondary index file, and storing the hash value of the secondary index file in the second block of the block chain;
s4, the user sends a video request to the server through the client, receives a first-level index file returned by the server, requests a second-level index file to the server after verifying that the hash value of the first-level index file passes, downloads each media fragment according to the second-level index file after verifying that the hash value of the second-level index file passes, verifies the hash value of each media fragment, and plays the media fragments of which the hash value passes verification in sequence.
Example 2:
as shown in fig. 2 and fig. 3, the present invention provides a video protection method based on a block chain, including the following steps:
s1, fragmenting a video to generate media fragments and an index file; the index files comprise a first-level index file and a second-level index file; the method comprises the following specific steps:
s11, HLS fragmentation is carried out on the video to generate media fragments;
s12, creating a primary index file and a secondary index file for the media fragments;
s2, recording the address of the first block of the block chain in a primary index file, calculating a hash value of the primary index file, and storing the hash value of the primary index file in the first block of the block chain; the method comprises the following specific steps:
s21, recording the address of the first block of the block chain in a first-level index file;
s22, calculating a first-level index file hash value, and storing the first-level index file hash value on a first block;
s3, calculating the hash value of each media fragment, recording the hash value of each media fragment and the address of a second block of the block chain in a secondary index file, calculating the hash value of the secondary index file, and storing the hash value of the secondary index file in the second block of the block chain; the method comprises the following specific steps:
s31, determining the number of second index files and the number of blocks in the block chain according to the number of the media fragments;
s32, calculating hash values of all media fragments;
s33, recording the media fragment hash value to be stored in the second block and the address of the second block in a first-level index file;
s34, calculating a first secondary index file hash value, and storing the first secondary index file hash value on a second block;
s35, judging whether all media fragment hash values are stored completely;
if yes, go to step S4;
if not, go to step S36;
s36, recording the media fragment hash value to be stored in the third block and the address of the third block in a second-level index file;
s37, calculating the hash value of the second-level index file, storing the hash value of the second-level index file on a third block, and repeating the step S35 until all the media fragment hash values are stored;
s4, a user sends a video request to a server through a client, receives a first-level index file returned by the server, requests a second-level index file to the server after verifying that the hash value of the first-level index file passes, downloads each media fragment according to the second-level index file after verifying that the hash value of the second-level index file passes, verifies the hash value of each media fragment, and plays the media fragments with the hash values passing verification in sequence; the method comprises the following specific steps:
s41, a user sends a video request to a server through a client;
s42, the server returns a primary index file to the client;
s43, after calculating the hash value of the primary index file, the client judges whether the hash value is stored in the first block or not
The hash values of the upper-level index files are consistent;
if not, returning an error, and ending;
if yes, go to step S44;
s44, the client requests a first-level second-level index file from the server;
s45, the server returns a first-level second-level index file to the client;
s46, the client calculates the hash value of the first-level second-level index file, judges and stores the hash value in the second block
Whether the hash values of the first-level index file are consistent or not is judged;
if not, discarding the media fragment corresponding to the index file on the block, and entering step S49;
if yes, go to step S47;
s47, the client downloads each media fragment corresponding to the first index file of the second block;
s48, the client calculates the hash value of each media fragment corresponding to the first index file and judges
Whether the hash values of the corresponding media fragments stored in the first-level index file are consistent or not;
if the first index file is consistent with the second index file, playing each media fragment corresponding to the first index file of the second block, and entering
Step S49;
if not, processing the media fragments with inconsistent hash values, and entering step S49;
s49, judging whether the comparison of all media fragmentation hash values is finished;
if yes, ending;
if not, repeating the steps S44-S48 until the media fragment hash value comparison on the last block is completed.
In the above embodiment 2, the step S43 includes the following steps:
s431, the client searches a first block address from the primary index text and connects the first block;
s432, the client acquires a first-level index file hash value from the first block and sets the first-level index file hash value as a first hash value;
s433, the client calculates a hash value according to the first-level index file returned by the server, and sets the hash value as a second hash value;
s434, comparing whether the first hash value is consistent with the second hash value;
if not, returning an error, and ending;
if yes, go to step S44;
the step S46 includes the following steps:
s461, the client searches a second block address from the first-level secondary index file and connects the second block;
s462, the client acquires the first-level second index file hash value from the second block and sets a third hash value;
s463, the client calculates a hash value according to the first-level second-level index file returned by the server, and sets the hash value as a fourth hash value;
s464, comparing whether the third hash value is consistent with the fourth hash value;
if not, discarding the media fragment corresponding to the index file on the block, and entering step S49;
if yes, go to step S47;
the step S48 includes the following steps:
s481, the client searches a media fragment hash value from the first-level index file returned by the server and sets the hash value as a fifth hash value;
s482, the client calculates a hash value according to each media fragment corresponding to the first index file of the downloaded second block, and sets the hash value as a sixth hash value;
s483, comparing whether the fifth hash value is consistent with the sixth hash value;
if yes, go to step S484;
if not, the step S485 is carried out;
s484, playing each media fragment corresponding to the first index file of the second block, and entering step S49;
s485, acquiring media fragments with inconsistent hash values, and setting the media fragments as error media fragments;
and S486, discarding the error media fragment, requiring the error media fragment to be retransmitted, setting a comparison threshold value for the error media fragment, stopping playing the error media fragment when the comparison times exceed the comparison threshold value, and entering the step S49.
In the above embodiment 2, the MD5 algorithm or SHA-1 algorithm may be used for the calculation and verification of the hash value, the MD5 algorithm may generate a 128-bit hash value, and the SHA-1 algorithm may generate a 160-bit hash value;
when the requested video is a point video, the index file cannot be changed, so that enough time can be provided for updating the block chain in advance, but when the requested video is a live video, the index file needs to be changed according to the video updating frequency, a newly generated index file hash value needs to be uploaded to the block chain in time and then provided to a client, and the block chain with the transaction speed greater than the threshold value needs to be processed; the hash value and the important information of the index file are transmitted to a block chain through a computer network, and the block chain synchronizes the information to other block nodes according to the specification and a formulated algorithm program of the block chain; each chunk calculates, via a complex algorithm, a hash value stored on the chunk, the hash value being unique across the chain of chunks.
Example 3:
as shown in fig. 4, the present invention provides a video protection apparatus based on a block chain, including:
the video slicing module 1 is used for slicing the video to generate media slices and index files; the index files comprise a first-level index file and a second-level index file; the video slicing module 1 includes:
the media fragment generating unit 1.1 is configured to perform HLS fragmentation on the video to generate media fragments;
the index file generation unit 1.2 is used for creating a primary index file and a secondary index file for the media fragments;
the first-level index file recording and first block storage module 2 is used for recording the address of the first block of the block chain in the first-level index file, calculating the hash value of the first-level index file and storing the hash value of the first-level index file in the first block of the block chain; the first-level index file recording and first block storage module 2 includes:
a first block address storage unit 2.1 for recording the address of the first block of the block chain in the first-level index file;
the first-level index file hash value storage unit 2.2 is used for calculating the first-level index file hash value and storing the first-level index file hash value on the first block;
the second-level index file recording and second block storage module 3 is used for calculating each media fragment hash value, recording each media fragment hash value and the address of the second block of the block chain in the second-level index file, calculating the second-level index file hash value, and storing the second-level index file hash value on the second block of the block chain; the second-level index file recording and second block storage module 3 includes:
a second index file and block number determining unit 3.1 for determining the first index file and block number according to the media fragment number
The number of index files and the number of blocks in a block chain;
the media slicing Hash value calculating unit 3.2 is used for calculating the Hash value of each media slicing;
a media fragment hash value and second block address recording unit 3.3, for recording the media fragment hash value and the second block address to be stored in the second block in the first secondary index file;
the first-level second index file hash value recording unit 3.4 is used for calculating the first-level second index file hash value and storing the first-level second index file hash value on the second block;
a media fragment hash value storage judging unit 3.5, for judging whether all media fragment hash values are stored completely;
the media slicing address and third block address recording unit 3.6 is used for recording the media slicing hash value and the address of the third block which need to be stored in the third block in the second-level index file when the media slicing hash value is not stored;
the second-level index file hash value recording unit 3.7 is used for calculating the second-level index file hash value, storing the second-level index file hash value on a third block, and repeating the work of the media fragment hash value storage judging unit 3.5 until all the media fragment hash values are stored;
the video verification module 4 is used for sending a video request to the server through the client, receiving a first-level index file returned by the server, requesting a second-level index file to the server after verifying that the hash value of the first-level index file passes, downloading each media fragment according to the second-level index file after verifying that the hash value of the second-level index file passes, verifying the hash value of each media fragment, and sequentially playing the media fragments of which the hash values pass verification; the video verification module 4 includes:
the video request unit 4.1 is used for sending a video request to the server side through the client side by the user;
the first-level index file returning unit 4.2 is used for returning the first-level index file to the client by the server;
the first-level index file hash value judgment unit 4.3 is used for judging whether the hash value of the first-level index file is consistent with the hash value of the first-level index file stored in the first block or not after the client calculates the hash value of the first-level index file;
the first-level second-level index file request unit 4.4 is used for requesting the first-level second-level index file from the server side when the hash values of the first-level index files are consistent;
the first-stage index file returning unit 4.5 is used for returning the first-stage index file to the client by the server;
the first-level second index file hash value judgment unit 4.6 is used for the client to calculate the first-level second index file hash value and judge whether the first-level second index file hash value is consistent with the first-level second index file hash value stored in the second block;
the media fragment discarding unit 4.7 is used for discarding the media fragment corresponding to the index file on the block when the hash values of the first-level and second-level index files are inconsistent;
the media fragment downloading unit 4.8 is used for downloading each media fragment corresponding to the first index file of the second block by the client when the hash values of the first secondary index file are consistent;
the media fragment hash value judgment unit 4.9 is used for the client to calculate the hash value of each media fragment corresponding to the first second index file and judge whether the hash value of each media fragment corresponding to the first second index file is consistent with the hash value of each media fragment stored in the first second index file;
the media fragment playing unit 4.10 is used for playing each media fragment corresponding to the first index file of the first block when the hash values of the media fragments are consistent;
the media fragmentation processing unit 4.11 is used for processing the media fragments with inconsistent hash values when the hash values of the media fragments are inconsistent;
the media fragmentation hash value comparison completion judging unit 4.12 is used for judging whether the comparison of all the media fragmentation hash values is completed;
and the media fragment hash value continuous comparison unit 4.13 is used for repeatedly comparing the media fragments of the subsequent blocks when the media fragment hash values are not compared completely until the media fragment hash values on the last block are compared completely.
Although the present invention has been described in detail by referring to the drawings in connection with the preferred embodiments, the present invention is not limited thereto. Various equivalent modifications or substitutions can be made on the embodiments of the present invention by those skilled in the art without departing from the spirit and scope of the present invention, and these modifications or substitutions are within the scope of the present invention/any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (10)

1. A video protection method based on a block chain is characterized by comprising the following steps:
s1, fragmenting a video to generate media fragments and an index file; the index files comprise a first-level index file and a second-level index file;
s2, recording the address of the first block of the block chain in a primary index file, calculating a hash value of the primary index file, and storing the hash value of the primary index file in the first block of the block chain;
s3, calculating the hash value of each media fragment, recording the hash value of each media fragment and the address of a second block of the block chain in a secondary index file, calculating the hash value of the secondary index file, and storing the hash value of the secondary index file in the second block of the block chain;
s4, the user sends a video request to the server through the client, receives a first-level index file returned by the server, requests a second-level index file to the server after verifying that the hash value of the first-level index file passes, downloads each media fragment according to the second-level index file after verifying that the hash value of the second-level index file passes, verifies the hash value of each media fragment, and plays the media fragments of which the hash value passes verification in sequence.
2. The video protection method based on the blockchain according to claim 1, wherein the step S1 specifically comprises the following steps:
s11, HLS fragmentation is carried out on the video to generate media fragments;
and S12, creating a primary index file and a secondary index file for the media fragments.
3. The video protection method based on the blockchain according to claim 1, wherein the step S2 specifically comprises the following steps:
s21, recording the address of the first block of the block chain in a first-level index file;
and S22, calculating the hash value of the primary index file, and storing the hash value of the primary index file on the first block.
4. The video protection method based on the blockchain according to claim 1, wherein the step S3 specifically comprises the following steps:
s31, determining the number of second index files and the number of blocks in the block chain according to the number of the media fragments;
s32, calculating hash values of all media fragments;
s33, recording the media fragment hash value to be stored in the second block and the address of the second block in a first-level index file;
s34, calculating a first secondary index file hash value, and storing the first secondary index file hash value on a second block;
s35, judging whether all media fragment hash values are stored completely;
if yes, go to step S4;
if not, go to step S36;
s36, recording the media fragment hash value to be stored in the third block and the address of the third block in a second-level index file;
and S37, calculating the hash value of the second-level index file, storing the hash value of the second-level index file on a third block, and repeating the step S35 until all the media fragment hash values are stored.
5. The video protection method based on the blockchain according to claim 4, wherein the step S4 includes the following steps:
s41, a user sends a video request to a server through a client;
s42, the server returns a primary index file to the client;
s43, after calculating the hash value of the first-level index file, the client judges whether the hash value is consistent with the hash value of the first-level index file stored in the first block;
if not, returning an error, and ending;
if yes, go to step S44;
s44, the client requests a first-level second-level index file from the server;
s45, the server returns a first-level second-level index file to the client;
s46, the client calculates the hash value of the first-level second index file and judges whether the hash value of the first-level second index file is consistent with the hash value of the first-level second index file stored in the second block;
if not, discarding the media fragment corresponding to the index file on the block, and entering step S49;
if yes, go to step S47;
s47, the client downloads each media fragment corresponding to the first index file of the second block;
s48, the client calculates the hash value of each media fragment corresponding to the first second index file, and judges whether the hash value of each media fragment corresponding to the first second index file is consistent with the hash value of each media fragment corresponding to the first second index file;
if yes, playing each media fragment corresponding to the first index file of the second chunk, and entering step S49;
if not, processing the media fragments with inconsistent hash values, and entering step S49;
s49, judging whether the comparison of all media fragmentation hash values is finished;
if yes, ending;
if not, repeating the steps S44-S48 until the media fragment hash value comparison on the last block is completed.
6. The video protection method based on the blockchain according to claim 5, wherein the step S43 includes the following steps:
s431, the client searches a first block address from the primary index text and connects the first block;
s432, the client acquires a first-level index file hash value from the first block and sets the first-level index file hash value as a first hash value;
s433, the client calculates a hash value according to the first-level index file returned by the server, and sets the hash value as a second hash value;
s434, comparing whether the first hash value is consistent with the second hash value;
if not, returning an error, and ending;
if they match, the process proceeds to step S44.
7. The video protection method based on the blockchain according to claim 5, wherein the step S46 includes the following steps:
s461, the client searches a second block address from the first-level secondary index file and connects the second block;
s462, the client acquires the first-level second index file hash value from the second block and sets a third hash value;
s463, the client calculates a hash value according to the first-level second-level index file returned by the server, and sets the hash value as a fourth hash value;
s464, comparing whether the third hash value is consistent with the fourth hash value;
if not, discarding the media fragment corresponding to the index file on the block, and entering step S49;
if they match, the process proceeds to step S47.
8. The video protection method based on the blockchain according to claim 7, wherein the step S48 includes the following steps:
s481, the client searches a media fragment hash value from the first-level index file returned by the server and sets the hash value as a fifth hash value;
s482, the client calculates a hash value according to each media fragment corresponding to the first index file of the downloaded second block, and sets the hash value as a sixth hash value;
s483, comparing whether the fifth hash value is consistent with the sixth hash value;
if yes, go to step S484;
if not, the step S485 is carried out;
s484, playing each media fragment corresponding to the first index file of the second block, and entering step S49;
s485, acquiring media fragments with inconsistent hash values, and setting the media fragments as error media fragments;
and S486, discarding the error media fragment, requiring the error media fragment to be retransmitted, setting a comparison threshold value for the error media fragment, stopping playing the error media fragment when the comparison times exceed the comparison threshold value, and entering the step S49.
9. A video protection device based on a blockchain, comprising:
the video slicing module (1) is used for slicing the video to generate media slices and index files; the index files comprise a first-level index file and a second-level index file;
the first-level index file recording and first block storage module (2) is used for recording the address of the first block of the block chain in the first-level index file, calculating the hash value of the first-level index file and storing the hash value of the first-level index file in the first block of the block chain;
the second-level index file recording and second block storage module (3) is used for calculating each media fragment hash value, recording each media fragment hash value and the address of the second block of the block chain in the second-level index file, calculating the second-level index file hash value, and storing the second-level index file hash value on the second block of the block chain;
and the video verification module (4) is used for sending a video request to the server side through the client side, receiving the first-level index file returned by the server side, requesting a second-level index file to the server side after verifying that the hash value of the first-level index file passes, downloading each media fragment according to the second-level index file after verifying that the hash value of the second-level index file passes, verifying the hash value of each media fragment, and sequentially playing the media fragments of which the hash value passes verification.
10. The blockchain-based video protection device according to claim 9, wherein the video slicing module (1) comprises:
the media fragment generating unit (1.1) is used for carrying out HLS (hyper text transfer protocol) fragmentation on the video to generate media fragments;
the index file generation unit (1.2) is used for creating a primary index file and a secondary index file for the media fragments;
the first-level index file recording and first block storage module (2) comprises:
a first block address storage unit (2.1) for recording the address of the first block of the block chain in a primary index file;
the first-level index file hash value storage unit (2.2) is used for calculating the first-level index file hash value and storing the first-level index file hash value on the first block;
the second index file recording and second block storage module (3) comprises:
a second index file and block number determining unit (3.1) for determining the number of second index files and the number of blocks in the block chain according to the number of media fragments;
the media slicing Hash value calculating unit (3.2) is used for calculating the Hash value of each media slicing;
the media slicing hash value and second block address recording unit (3.3) is used for recording the media slicing hash value and the second block address which need to be stored in the second block into the first-level index file;
the first-level second index file hash value recording unit (3.4) is used for calculating the first-level second index file hash value and storing the first-level second index file hash value on the second block;
a media fragment hash value storage judging unit (3.5) for judging whether all the media fragment hash values are stored completely;
a media fragment address and third block address recording unit (3.6) for recording the media fragment hash value and the address of the third block which need to be stored in the third block in the second-level index file when the media fragment hash value is not stored;
the second-level index file hash value recording unit (3.7) is used for calculating the second-level index file hash value, storing the second-level index file hash value on a third block, and repeating the work of the media fragmentation hash value storage judging unit (3.5) until all the media fragmentation hash values are stored;
the video verification module (4) comprises:
the video request unit (4.1) is used for sending a video request to the server side through the client side by the user;
the first-level index file returning unit (4.2) is used for returning the first-level index file to the client by the server;
the first-level index file hash value judgment unit (4.3) is used for judging whether the hash value of the first-level index file is consistent with the hash value of the first-level index file stored in the first block or not after the client calculates the hash value of the first-level index file;
the first-level second-level index file request unit (4.4) is used for requesting the first-level second-level index file from the server side when the hash values of the first-level index files are consistent;
the first-grade index file returning unit (4.5) is used for returning the first-grade index file to the client by the server;
the first-level second index file hash value judgment unit (4.6) is used for calculating the first-level second index file hash value by the client and judging whether the first-level second index file hash value is consistent with the first-level second index file hash value stored on the second block or not;
the media fragment discarding unit (4.7) is used for discarding the media fragment corresponding to the index file on the block when the hash values of the first-level and second-level index files are inconsistent;
the media fragment downloading unit (4.8) is used for downloading each media fragment corresponding to the first index file of the second block by the client when the hash values of the first secondary index file are consistent;
the media fragmentation hash value judgment unit (4.9) is used for calculating the hash value of each media fragmentation corresponding to the first second index file by the client and judging whether the hash value of each media fragmentation corresponding to the first second index file is consistent with the hash value of each media fragmentation corresponding to the first second index file;
the media fragment playing unit (4.10) is used for playing each media fragment corresponding to the first index file of the first block when the media fragment hash values are consistent;
the media fragmentation processing unit (4.11) is used for processing the media fragments with inconsistent hash values when the hash values of the media fragments are inconsistent;
a media fragment hash value comparison completion judging unit (4.12) for judging whether the comparison of all the media fragment hash values is completed;
and the media fragment hash value continuous comparison unit (4.13) is used for repeatedly comparing the media fragments of the subsequent blocks when the media fragment hash values are not compared completely until the media fragment hash values on the last block are compared completely.
CN202111631141.XA 2021-12-28 2021-12-28 Video protection method and device based on block chain Active CN114301602B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111631141.XA CN114301602B (en) 2021-12-28 2021-12-28 Video protection method and device based on block chain

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111631141.XA CN114301602B (en) 2021-12-28 2021-12-28 Video protection method and device based on block chain

Publications (2)

Publication Number Publication Date
CN114301602A true CN114301602A (en) 2022-04-08
CN114301602B CN114301602B (en) 2023-08-15

Family

ID=80972332

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111631141.XA Active CN114301602B (en) 2021-12-28 2021-12-28 Video protection method and device based on block chain

Country Status (1)

Country Link
CN (1) CN114301602B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115017103A (en) * 2022-08-08 2022-09-06 平安银行股份有限公司 Financial business image information acquisition method and device, electronic equipment and storage medium
CN115499138A (en) * 2022-11-16 2022-12-20 成都同步新创科技股份有限公司 High-performance storage tamper-proof verification method and storage system combined with block chain
CN116132199A (en) * 2023-04-17 2023-05-16 丹氏生物科技成都有限公司 Method for processing liquid nitrogen tank monitoring data based on blockchain

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111181989A (en) * 2020-01-02 2020-05-19 烽火通信科技股份有限公司 Method and system for realizing HLS distribution tamper resistance
CN111460526A (en) * 2020-04-17 2020-07-28 支付宝(杭州)信息技术有限公司 Image data recording, acquiring and verifying method and device based on block chain
CN113196702A (en) * 2018-11-16 2021-07-30 先进信息技术公司 System and method for distributed data storage and transfer using blockchains

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113196702A (en) * 2018-11-16 2021-07-30 先进信息技术公司 System and method for distributed data storage and transfer using blockchains
CN111181989A (en) * 2020-01-02 2020-05-19 烽火通信科技股份有限公司 Method and system for realizing HLS distribution tamper resistance
CN111460526A (en) * 2020-04-17 2020-07-28 支付宝(杭州)信息技术有限公司 Image data recording, acquiring and verifying method and device based on block chain

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115017103A (en) * 2022-08-08 2022-09-06 平安银行股份有限公司 Financial business image information acquisition method and device, electronic equipment and storage medium
CN115499138A (en) * 2022-11-16 2022-12-20 成都同步新创科技股份有限公司 High-performance storage tamper-proof verification method and storage system combined with block chain
CN116132199A (en) * 2023-04-17 2023-05-16 丹氏生物科技成都有限公司 Method for processing liquid nitrogen tank monitoring data based on blockchain

Also Published As

Publication number Publication date
CN114301602B (en) 2023-08-15

Similar Documents

Publication Publication Date Title
CN114301602B (en) Video protection method and device based on block chain
US10630463B2 (en) Meta block chain
US10764258B2 (en) Blockchain infrastructure for securing and/or managing electronic artifacts
WO2019218717A1 (en) Distributed storage method and apparatus, computer device, and storage medium
CN108648084B (en) Data processing method, device and equipment of block chain network and storage medium
US20210209373A1 (en) Media authentication using distributed ledger
CN108270874B (en) Application program updating method and device
TW202011329A (en) Blockchain-based transaction consensus processing method and apparatus, and electrical device
US9813248B2 (en) Content-based encryption keys
US20100008509A1 (en) Communication apparatus, key server, and management server
WO2017071512A1 (en) Cloud storage and cloud download methods for multimedia data and related devices
JP6495346B2 (en) Information processing system
Ali et al. Blockstack: A new decentralized internet
CN112235420B (en) Data synchronization method, system and related equipment based on block chain
CN111523150B (en) Document editing method, device and system based on block chain
CN111047324A (en) Method and apparatus for updating a set of public keys at a blockchain node
EP3659311B1 (en) Data stream integrity
WO2019061630A1 (en) Transaction accounting method, and client
CN109656882A (en) Data record method, extracting method and device, storage medium, terminal
WO2011150845A1 (en) Mehtod, device and system for verifying integrity of streaming media contents
JP5237661B2 (en) File synchronization apparatus, file synchronization method, and file synchronization program
WO2022068362A1 (en) Block chain-based information processing method and apparatus, device, and medium
CN112131041A (en) Method, apparatus and computer program product for managing data placement
WO2022068235A1 (en) Information processing method and apparatus for generating random number on the basis of attribute of information, and device
US11818246B2 (en) Blockchain data structures and systems and methods therefor for multipath transaction management

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
GR01 Patent grant
GR01 Patent grant