CN114040222A - Multimedia file tamper-proof playing method, processing method and device - Google Patents
Multimedia file tamper-proof playing method, processing method and device Download PDFInfo
- Publication number
- CN114040222A CN114040222A CN202111600373.9A CN202111600373A CN114040222A CN 114040222 A CN114040222 A CN 114040222A CN 202111600373 A CN202111600373 A CN 202111600373A CN 114040222 A CN114040222 A CN 114040222A
- Authority
- CN
- China
- Prior art keywords
- file
- target
- index
- slice
- hash value
- 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 56
- 238000003672 processing method Methods 0.000 title claims description 11
- 238000012545 processing Methods 0.000 claims description 17
- 238000010586 diagram Methods 0.000 description 8
- 238000004422 calculation algorithm Methods 0.000 description 7
- 230000005540 biological transmission Effects 0.000 description 4
- 238000012795 verification Methods 0.000 description 3
- 238000004364 calculation method Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 238000004590 computer program Methods 0.000 description 1
- 125000004122 cyclic group Chemical group 0.000 description 1
- 238000007405 data analysis Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 230000011218 segmentation 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/231—Content storage operation, e.g. caching movies for short term storage, replicating data over plural servers, prioritizing data for deletion
-
- 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 or manipulating encoded video stream scene graphs
- H04N21/2343—Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements
- H04N21/234309—Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements by transcoding between formats or standards, e.g. from MPEG-2 to MPEG-4 or from Quicktime to Realvideo
-
- 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/433—Content storage operation, e.g. storage operation in response to a pause request, caching operations
-
- 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 or rendering scenes according to encoded video stream scene graphs
- H04N21/4402—Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display
- H04N21/440218—Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display by transcoding between formats or standards, e.g. from MPEG-2 to MPEG-4
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Storage Device Security (AREA)
Abstract
The playing end responds to a playing instruction of a target multimedia file, acquires an m3u8 index file which is in an association relation with the target multimedia file, determines a target m3u8 slice file according to the m3u8 index file under the condition that the m3u8 index file is judged to correspond to the target multimedia file based on a preset index hash value of the m3u8 index file, further plays the target m3u8 slice file under the condition that the target m3u8 slice file is judged to correspond to the target multimedia file based on the preset file hash value of the target m3u8 slice file, and then carries out correspondence judgment on the next target m3u8 slice file until the playing is finished. The method can ensure the consistency of the played content and the target multimedia file, effectively prevent the file content from being replaced, and further ensure the correctness of the played content.
Description
Technical Field
The invention belongs to the technical field of internet, and particularly relates to a multimedia file tamper-proof playing method, a multimedia file tamper-proof processing method and a multimedia file tamper-proof playing device.
Background
The HLS (HTTP Live streaming) protocol is a streaming media network transmission protocol based on HTTP, and the protocol is mainly characterized in that continuous large-capacity multimedia files are segmented, and then a large number of m3u8 slice files are obtained for transmission, and in the process of playing videos, a client only needs to sequentially obtain small-capacity m3u8 slice files based on m3u8 index files synchronously obtained in the segmentation process, so that the requirement on network data transmission capacity can be reduced, and smooth playing is further realized.
As the HLS protocol becomes a mainstream playing protocol for realizing multimedia playing in the internet, how to ensure that a multimedia file is not tampered in the process of playing multimedia based on the HLS protocol becomes a technical key point in the field. However, the prior art mostly only focuses on how to avoid the data of the multimedia file from being damaged at the server, focuses on protection of the multimedia file data, and does not consider how to ensure the correctness of the media content, for example, a set of m3u8 slice files corresponding to video a is set a, a set of m3u8 slice files corresponding to video B is set B, and how to prevent the set corresponding to video a from being replaced by the set B, thereby ensuring the correctness of the played content, which is lacking in the prior art.
Disclosure of Invention
In view of the above, an object of the present invention is to provide a method, a device and a computer program product for playing a multimedia file in a tamper-proof manner, wherein the method comprises performing a correspondence check on an actually obtained m3u8 index file and an m3u8 slice file with a target multimedia file to ensure that the actually obtained m3u8 slice file corresponds to the target multimedia file, and further ensure the correctness of playing contents, and the specific scheme is as follows:
in a first aspect, the present invention provides a multimedia file tamper-resistant playing method, which is applied to a playing end, and the method includes:
responding to a playing instruction of a target multimedia file, and acquiring an m3u8 index file which is associated with the target multimedia file;
checking whether the m3u8 index file corresponds to the target multimedia file based on a preset index hash value included in the file name of the m3u8 index file;
the preset index hash value is obtained based on an m3u8 index file of the target multimedia file;
determining a target m3u8 slice file according to the m3u8 index file in case that the m3u8 index file corresponds to the target multimedia file;
wherein the target m3u8 slice file is one of a plurality of m3u8 slice files corresponding to the m3u8 index file;
checking whether the target m3u8 sliced file corresponds to the target multimedia file based on a preset file hash value included in the file name of the target m3u8 sliced file;
wherein the preset file hash value is obtained based on the m3u8 slice file of the target multimedia file.
And in the case that the target m3u8 slice file corresponds to the target multimedia file, playing the target m3u8 slice file, and returning to the step of determining the target m3u8 slice file according to the m3u8 index file until the playing is finished.
Optionally, the checking whether the m3u8 index file corresponds to the target multimedia file based on a preset index hash value included in the file name of the m3u8 index file includes:
calculating the hash value of the m3u8 index file to obtain the current index hash value of the m3u8 index file;
if the current index hash value is consistent with the preset index hash value, judging that the m3u8 index file corresponds to the target multimedia file;
and if the current index hash value is not consistent with the preset index hash value, judging that the m3u8 index file is not corresponding to the target multimedia file.
Optionally, the preset file hash values include a first preset file hash value obtained based on the first N file data packets of the m3u8 sliced file of the target multimedia file, and a second preset file hash value obtained based on the m3u8 sliced file of the target multimedia file;
the checking whether the target m3u8 sliced file corresponds to the target multimedia file based on a preset file hash value included in the file name of the target m3u8 sliced file includes:
acquiring the first N file data packets of the target m3u8 slice file;
wherein N is a natural number;
calculating the hash values of the first N file data packets to obtain a first current file hash value;
if the first current file hash value is consistent with the first preset file hash value, acquiring the remaining file data packets in the target m3u8 slice file to obtain a complete target m3u8 slice file;
calculating the hash value of the target m3u8 slice file to obtain a second current file hash value;
if the second current file hash value is consistent with the second preset file hash value, judging that the target m3u8 slice file corresponds to the target multimedia file;
and if the first current file hash value is inconsistent with the first preset file hash value, or the second actual file hash value is inconsistent with the second preset file hash value, judging that the target m3u8 slice file is not corresponding to the target multimedia file.
Optionally, before obtaining the remaining file data packages in the target m3u8 file, the method further includes:
playing the multimedia content corresponding to the first N file data packets;
the playing the target m3u8 slice file comprises:
and playing the multimedia content corresponding to the rest file data packets except the N file data packets in the target m3u8 slice file.
Optionally, the obtaining an m3u8 index file having an association relationship with the target multimedia file includes:
acquiring the storage address of the m3u8 index file of the target multimedia file and the identification code of the target multimedia file
And acquiring an m3u8 index file which is associated with the target multimedia file according to the m3u8 index file storage address and the identification code.
Optionally, the condition for determining the end of the playing includes: the target m3u8 slice file does not correspond to the target multimedia file or traverses the m3u8 index file.
In a second aspect, the present invention provides a multimedia file tamper-resistant processing method, which is applied to a server, and the method includes:
acquiring a multimedia file to be processed and an identification code of the multimedia file to be processed;
transcoding the multimedia file to be processed to obtain a corresponding m3u8 index file and a plurality of m3u8 slice files;
respectively calculating the hash value of the m3u8 index file, the hash value of each m3u8 slice file and the hash values of the first N data packets of each m3u8 slice file;
wherein N is a natural number, the hash value of the m3u8 index file is used as a preset index hash value of the m3u8 index file, the hash values of the first N data packets of each m3u8 slice file are used as first preset file hash values of the corresponding m3u8 slice file, and the hash value of each m3u8 slice file is used as second preset file hash values of the corresponding m3u8 slice file;
naming the m3u8 index file based on the preset index hash value and the identification code;
for any m3u8 slice file, naming the m3u8 slice file based on the first and second preset file hash values corresponding to the m3u8 slice file and the identification code.
Optionally, the method for processing a multimedia file in a tamper-proof manner according to a second aspect of the present invention further includes:
transmitting each m3u8 slice file to a content distribution network;
and sending the storage address of the m3u8 index file and the identification code to a database.
In a third aspect, the present invention provides a multimedia file tamper-resistant playing device, which is applied to a playing end, and the device includes:
the device comprises a first acquisition unit, a second acquisition unit and a third acquisition unit, wherein the first acquisition unit is used for responding to a playing instruction of a target multimedia file and acquiring an m3u8 index file which is associated with the target multimedia file;
a first checking unit, configured to check whether the m3u8 index file corresponds to the target multimedia file based on a preset index hash value included in a file name of the m3u8 index file;
a determining unit, configured to determine a target m3u8 slice file according to the m3u8 index file if the m3u8 index file corresponds to the target multimedia file;
wherein the target m3u8 slice file is one of a plurality of m3u8 slice files corresponding to the m3u8 index file;
a second checking unit, configured to check whether the target m3u8 sliced file corresponds to the target multimedia file based on a preset file hash value included in a filename of the target m3u8 sliced file;
and the first playing unit is used for playing the target m3u8 slice file if the target m3u8 slice file corresponds to the target multimedia file, and returning to the step of determining the target m3u8 slice file according to the m3u8 index file until the playing is finished.
In a fourth aspect, the present invention provides a multimedia file tamper-resistant processing apparatus, applied to a server, the apparatus including:
the second acquisition unit is used for acquiring a multimedia file to be processed and an identification code of the multimedia file to be processed;
the file processing unit is used for transcoding the multimedia file to be processed to obtain a corresponding m3u8 index file and a plurality of m3u8 slice files;
a calculating unit, configured to calculate a hash value of the m3u8 index file, a hash value of each of the m3u8 slice files, and a hash value of the first N data packets of each of the m3u8 slice files, respectively;
wherein the hash value of the m3u8 index file is used as a preset index hash value of the m3u8 index file, the hash values of the first N data packets of each m3u8 slice file are used as a first preset file hash value of the corresponding m3u8 slice file, and the hash value of each m3u8 slice file is used as a second preset file hash value of the corresponding m3u8 slice file;
the first naming unit is used for naming the m3u8 index file based on the preset index hash value and the identification code;
and the second naming unit is used for naming the m3u8 slice files based on the first preset file hash value and the second preset file hash value corresponding to the m3u8 slice files and the identification codes aiming at any one of the m3u8 slice files.
Based on the technical scheme, the playing method for preventing the tampering of the multimedia file, provided by the invention, includes that a playing end responds to a playing instruction of a target multimedia file to obtain an m3u8 index file which has an association relation with the target multimedia file, whether the m3u8 index file corresponds to the target multimedia file is verified based on a preset index hash value of the m3u8 index file, if the m3u8 index file corresponds to the target multimedia file, the target m3u8 slice file is determined according to the m3u8 index file, whether the target m3u8 slice file corresponds to the target multimedia file is further verified based on the preset file hash value of the target m3u8 slice file, the target m3u8 slice file is played when the target m3u8 slice file corresponds to the target multimedia file, and then the next target m3u8 slice file is subjected to correspondence judgment until the playing is finished. By the playing method provided by the invention, the m3u8 index file, each m3u8 slice file and the target multimedia file are correspondingly verified before playing, so that the consistency of the played content and the target multimedia file is ensured, the file content is effectively prevented from being replaced, and the correctness of the played content is further ensured.
Furthermore, the method is applied to the playing end, the playing process can be stopped in time in the playing process, and the playing accident is effectively avoided.
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 introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a flowchart of a method for tamper-proofing a multimedia file according to an embodiment of the present invention;
fig. 2 is a flowchart of a method for playing a multimedia file in a tamper-proof manner according to an embodiment of the present invention;
fig. 3 is a flowchart of a m3u8 slice file verification method according to an embodiment of the present invention;
fig. 4 is a block diagram of a multimedia file tamper-resistant processing apparatus according to an embodiment of the present invention;
FIG. 5 is a block diagram of another apparatus for processing multimedia files in a tamper-proof manner according to an embodiment of the present invention;
fig. 6 is a block diagram illustrating a structure of a multimedia file tamper-resistant playing apparatus according to an embodiment of the present invention;
fig. 7 is a block diagram of another multimedia file tamper-resistant playback apparatus 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.
To facilitate understanding of the multimedia file tamper-proofing processing method and the playing method provided by the invention, the following first introduces an implementation process of the multimedia file tamper-proofing processing method, clarifies a processing process of a multimedia file, further explains tamper-proofing processing of the multimedia file, and introduces the multimedia file tamper-proofing playing method provided by the embodiment of the invention, and clarifies an implementation process of tamper-proofing playing based on the processed multimedia file.
The multimedia file tamper-proofing processing method provided by the embodiment of the invention can be applied to electronic equipment which can be applied to a server side, wherein the electronic equipment can be terminal equipment with data analysis capability such as a notebook computer, a Personal Computer (PC) and the like, obviously, the electronic equipment can also be a server which is specially used for processing and storing multimedia files; referring to fig. 1, a process of the method for tamper-proofing a multimedia file according to an embodiment of the present invention may include:
s100, acquiring the multimedia file to be processed and the identification code of the multimedia file to be processed.
The multimedia file to be processed according to the present invention may be any multimedia file capable of performing file playing processing based on the HLS technology in practical applications, and in practical applications, the multimedia file may be an audio file, a video file, or other multimedia files, which are not listed here.
The identification code of the multimedia file to be processed is in one-to-one correspondence with the multimedia file to be processed, and the multimedia file corresponding to the identification code can be uniquely determined through the identification code. As an alternative implementation manner, the identification code may be implemented by using a UUID (universal Unique Identifier).
S110, transcoding the multimedia file to be processed to obtain a corresponding m3u8 index file and a plurality of m3u8 slice files.
According to the file transmission requirement of the HLS protocol, transcoding processing needs to be carried out on the multimedia file to be processed, and an m3u8 index file and a plurality of m3u8 slice files corresponding to the multimedia file to be processed are obtained. Based on the basic principle of the HLS protocol, the storage addresses of the m3u8 slice files are recorded in the m3u8 index file, and when downloading and playing the m3u8 slice files, the storage addresses and the storage sequence of the m3u8 index file need to be recorded.
As for the specific process of transcoding the multimedia file to be processed, the specific process can be implemented by referring to the prior art, which is not limited in the present invention.
And S120, respectively calculating the hash value of the m3u8 index file, the hash value of each m3u8 slice file and the hash values of the first N data packets of each m3u8 slice file.
It should be noted that N is a natural number, and considering that playing can be performed only by acquiring 3 video data packets and 3 audio data packets, N may be 6, and of course, other values may also be selected according to requirements, and details are not described here.
For the calculation of the hash value, in practical applications, a commonly used MD5(Message-Digest Algorithm), CRC (Cyclic Redundancy Check) Algorithm, and the like may be selected.
Further, for each m3u8 slice file, taking the hash value of the first N data packets of the m3u8 slice file as the first preset file hash value of the corresponding m3u8 slice file, and taking the hash value of the m3u8 slice file as the second preset file hash value of the corresponding m3u8 slice file; accordingly, the hash value of the m3u8 index file is taken as the preset index hash value of the m3u8 index file.
And S130, naming the m3u8 index file based on the preset index hash value and the identification code.
After the hash values of the files are obtained, naming the corresponding files based on the hash values. Specifically, the m3u8 index file is named based on the preset index hash value and the identification code of the aforementioned multimedia file to be processed.
For example, the m3u8 index file may be named md5(file _ index) _ uuid.m3u8, where md5(file _ index) represents a preset index hash value of the m3u8 index file, and uuid represents an identification code of the multimedia file to be processed.
And S140, for any m3u8 slice file, naming the m3u8 slice file based on the first preset file hash value and the second preset file hash value corresponding to the m3u8 slice file and the identification code.
Accordingly, for each m3u8 slice file, the m3u8 slice file is named based on the first and second preset file hash values of the m3u8 slice file and the identification code.
For example, any m3u8 slice file may be named: and md5(packet) _ md5(file) _ uuid.ts, wherein md5(packet) represents the hash values of the first N file data packets of the m3u8 sliced file, namely the first preset file hash value, md5(file) represents the hash value of the whole file of the m3u8 sliced file, namely the second preset file hash value, and uuid still represents the identification code of the multimedia file to be processed.
It should be noted that, for the execution of S130 and S140, there is no need to distinguish the order, the two may be executed simultaneously, or S140 may be executed first, and then S130 is executed.
Optionally, after the naming of each file is completed, each m3u8 sliced file may be sent to a content distribution network, and at the same time, the storage address of the m3u8 index file and the identification code of the multimedia file to be processed are sent to a database for use when the terminal side acquires the multimedia file to be processed.
In summary, in the multimedia file tamper-proofing processing method provided in the embodiment of the present invention, the m3u8 index file is named based on the hash value of the m3u8 index file, and a corresponding relationship between the m3u8 index file and the preset index hash value is established, so that when the target multimedia file is played at the terminal side, whether the obtained m3u8 index file corresponds to the multimedia file or not can be verified based on the preset index hash value; further, the first preset file hash value and the second preset file hash value are obtained by calculating multimedia files, hash values obtained by calculating different multimedia files are naturally different, the corresponding m3u8 slice files are named according to the first preset file hash value and the second preset file hash value, a corresponding relation between the preset file hash value and the m3u8 slice files is established, and then whether the obtained m3u8 slice files correspond to the multimedia files can be judged through the preset file hash values, so that the multimedia files can be effectively prevented from being tampered, the actually obtained m3u8 slice files are prevented from not corresponding to the multimedia files to be accessed, and the correctness of playing contents is further ensured.
The following describes a process of implementing tamper-resistant playing of a multimedia file processed based on the above tamper-resistant processing method. The tamper-proof playing method provided by the invention is applied to electronic equipment at a playing end, and the electronic equipment can be electronic equipment capable of playing multimedia files, such as a notebook computer, a PC (personal computer), a smart phone, a tablet personal computer and the like. Referring to fig. 2, fig. 2 is a flowchart of a method for playing a multimedia file in an anti-tampering manner according to an embodiment of the present invention, where the flow of the method may include:
s200, responding to the playing instruction of the target multimedia file, and acquiring an m3u8 index file which is associated with the target multimedia file.
In this embodiment, the target multimedia file refers to a multimedia file that a user needs to play, and in practical applications, the target multimedia file may be any multimedia file that can be selected by the user for playing. The playing instruction of the target multimedia file can be obtained through various ways, and can be a playing instruction input by a user through a command input device, such as a mouse or a keyboard, or a playing instruction input by the user through clicking a touch screen.
Optionally, in response to the play instruction, an m3u8 index file storage address of the target multimedia file and an identifier of the target multimedia file are obtained from an API (Application Programming Interface), and then an m3u8 index file having an association relationship with the target multimedia file is obtained according to the obtained m3u8 index file storage address and identifier.
It should be noted that, the specific implementation process of acquiring the m3u8 index file of the multimedia file and the identifier code of the multimedia file based on the distributed network or other media asset storage network established based on the HLS protocol may be implemented with reference to the prior art, which is not limited in this disclosure.
It should be noted that, considering that the target multimedia file may have been tampered with, the m3u8 index file acquired in this step is not necessarily the m3u8 index file obtained based on the target multimedia file, but may be an index file of another tampered multimedia file, and therefore, in the subsequent steps, it is first necessary to determine whether the obtained m3u8 index file corresponds to the target multimedia file. The phrase "having an association relationship with a target multimedia file" in this embodiment means that the m3u8 index file can be obtained by using the m3u8 index file storage address of the target multimedia file, and the obtained m3u8 index file is not considered to correspond to the target multimedia file.
S210, checking whether the m3u8 index file corresponds to the target multimedia file or not based on a preset index hash value included in the file name of the m3u8 index file.
As can be seen from the foregoing embodiment, the preset index hash value is obtained based on the m3u8 index file of the target multimedia file, and has a one-to-one correspondence relationship with the m3u8 index file of the target multimedia file, and after the m3u8 index file is obtained in S200, the content of the corresponding field of the file name in the index file is extracted, so that the preset index hash value can be obtained.
Further, calculating a hash value of the obtained m3u8 index file to obtain a current index hash value of the m3u8 index file, and if the obtained current index hash value is consistent with a preset index hash value in the file name, judging that the obtained m3u8 index file corresponds to the target multimedia file; on the contrary, if the current index hash value is not consistent with the preset index hash value, it is determined that the m3u8 index file does not correspond to the target multimedia file.
And under the condition that the obtained m3u8 index file does not correspond to the target multimedia file, exiting the current playing process and avoiding playing accidents.
And S220, determining a target m3u8 slice file according to the m3u8 index file when the m3u8 index file corresponds to the target multimedia file.
As described above, the HLS technology stores the multimedia file in the network system in the form of a plurality of m3u8 slice files, the m3u8 index file records the storage address of each m3u8 slice file, and all m3u8 slice files can be obtained by traversing the m3u8 index file, where the target m3u8 slice file mentioned in this step is one of a plurality of m3u8 slice files corresponding to the m3u8 index file.
It should be noted that although it has been determined through the foregoing steps that the m3u8 index file corresponds to the target multimedia file, in practical applications, it still cannot be guaranteed that the m3u8 slice file obtained according to the m3u8 index file necessarily corresponds to the target multimedia file, and further verification is required.
S230, checking whether the target m3u8 slice file corresponds to the target multimedia file or not based on the preset file hash value included in the file name of the target m3u8 slice file.
As described above, the file names of the m3u8 slice files are named based on the hash values of the slice files, and specifically, the preset file hash values in the file names of the target m3u8 slice files include a first preset file hash value obtained based on the first N file packets of the m3u8 slice file of the target multimedia file and a second preset file hash value obtained based on the m3u8 slice file of the target multimedia file.
Optionally, based on the above, for an optional implementation manner of this step, see fig. 3:
s2301, acquiring the first N file data packets of the target m3u8 slice file.
For the value of N, reference is made to the foregoing, and the description is not repeated here. The specific process of acquiring the first N file data packets may be implemented based on the HLS protocol, which is not specifically limited in the present invention.
S2302, calculating hash values of the previous N file data packets to obtain a first current file hash value.
Alternatively, the specific calculation process may be implemented by using the MD5 algorithm or the CRC algorithm, as long as the same calculation algorithm is used as in the embodiment shown in fig. 1.
S2303, judging whether the first current file hash value is consistent with the first preset file hash value, if so, executing S2304, and if not, executing S2308.
If the first current file hash value is identical to the first preset file hash value, S2304 is continuously performed, and conversely, if the first current file hash value is not identical to the first preset file hash value, S2308 is performed.
Optionally, if the first current file hash value is consistent with the first preset file hash value, it may be at least stated that the first N file data packets of the target m3u8 slice file correspond to the target multimedia file, and the multimedia content corresponding to the first N file data packets may be played first, so that not only the playing efficiency may be improved, but also the hardware performance requirement on the playing-end electronic device may be reduced. Of course, instead of playing the multimedia content corresponding to the first N file packets, the entire target m3u8 slice file may be played after being determined to correspond to the target multimedia file.
S2304, obtaining the remaining file data packets in the target m3u8 slice file to obtain a complete target m3u8 slice file.
And under the condition that the first N file data packages are determined to correspond to the target multimedia file, further acquiring the remaining file data packages in the target m3u8 slice file in an asynchronous downloading mode to obtain a complete target m3u8 slice file.
S2305, calculating the hash value of the target m3u8 slice file to obtain a second current file hash value.
After a complete target m3u8 slice file is obtained, the hash value of the target m3u8 slice file is calculated to obtain a second current file hash value.
And S2306, judging whether the second current file hash value is consistent with the second preset file hash value, if so, executing S2307, and if not, executing S2308.
S2307, it is determined that the target m3u8 slice file corresponds to the target multimedia file.
And under the condition that the second current file hash value is consistent with the second preset file hash value, judging that the target m3u8 slice file corresponds to the target multimedia file.
S2308, it is determined that the target m3u8 slice file does not correspond to the target multimedia file.
And under the condition that the first current file hash value is inconsistent with the first preset file hash value or the second actual file hash value is inconsistent with the second preset file hash value, judging that the target m3u8 slice file is not corresponding to the target multimedia file.
And S240, playing the target m3u8 slice file under the condition that the target m3u8 slice file corresponds to the target multimedia file, and returning to the S220 until the playing is finished.
In the case where it is determined that the target m3u8 slice file corresponds to the target multimedia file, the target m3u8 slice file may be played. Optionally, if the multimedia content corresponding to the first N file data packets has already been played in S2303, only the multimedia content after the first N file data packets needs to be played in this step.
And meanwhile, returning to S220, continuing to judge the next target m3u8 slice file according to the m3u8 index file until the m3u8 index file is traversed, finishing the playing of all m3u8 slice files, and finishing the playing of the target multimedia file.
Of course, if any target m3u8 slice file does not correspond to the target multimedia file in the loop process, the playing process can be directly ended to prevent playing accidents.
In summary, the playing method provided by the present invention performs corresponding verification on the m3u8 index file and each m3u8 slice file and the target multimedia file before playing, so as to ensure consistency between the played content and the target multimedia file, effectively prevent the file content from being replaced, and further ensure correctness of the played content.
Furthermore, the method is applied to the playing end, the playing process can be stopped in time in the playing process, and the playing accident is effectively avoided.
In the following, the multimedia file tamper-resistant processing apparatus provided in the embodiment of the present invention is introduced, and the multimedia file tamper-resistant processing apparatus described below may be regarded as a functional module architecture that needs to be set in the central device to implement the multimedia file tamper-resistant processing method provided in the embodiment of the present invention; the following description may be cross-referenced with the above.
Referring to fig. 4, fig. 4 is a block diagram illustrating a structure of a multimedia file tamper-resistant processing apparatus according to an embodiment of the present invention, and referring to fig. 4, the apparatus may include:
a second obtaining unit 10, configured to obtain a multimedia file to be processed and an identification code of the multimedia file to be processed;
the file processing unit 20 is configured to transcode the multimedia file to be processed to obtain a corresponding m3u8 index file and a plurality of m3u8 slice files;
a calculating unit 30 for calculating hash values of the m3u8 index file, the m3u8 slice file, and the first N data packets of the m3u8 slice file, respectively;
wherein the hash value of the m3u8 index file is used as a preset index hash value of the m3u8 index file, the hash values of the first N data packets of each m3u8 slice file are used as a first preset file hash value of the corresponding m3u8 slice file, and the hash value of each m3u8 slice file is used as a second preset file hash value of the corresponding m3u8 slice file;
the first naming unit 40 is used for naming the m3u8 index file based on the preset index hash value and the identification code;
and a second naming unit 50 for naming, for any m3u8 slice file, the m3u8 slice file based on the first preset file hash value and the second preset file hash value corresponding to the m3u8 slice file and the identification code.
Optionally, referring to fig. 5, fig. 5 is a block diagram of another multimedia file tamper-resistant processing apparatus according to an embodiment of the present invention, and on the basis of the embodiment shown in fig. 4, the apparatus further includes:
a storage unit 60 for transmitting each m3u8 slice file to a content distribution network; and sending the storage address of the m3u8 index file and the identification code to a database.
The following introduces a multimedia file tamper-resistant playing device provided in the embodiment of the present invention, where the multimedia file tamper-resistant playing device described below may be regarded as a functional module architecture that needs to be set in a central device to implement the multimedia file tamper-resistant playing method provided in the embodiment of the present invention; the following description may be cross-referenced with the above.
Referring to fig. 6, fig. 6 is a block diagram illustrating a structure of a multimedia file tamper-resistant playing apparatus according to an embodiment of the present invention, and referring to fig. 6, the apparatus may include:
a first obtaining unit 70, configured to respond to a play instruction of a target multimedia file, and obtain an m3u8 index file having an association relationship with the target multimedia file;
the first verifying unit 80 is configured to verify whether the m3u8 index file corresponds to the target multimedia file based on a preset index hash value included in the file name of the m3u8 index file;
a determining unit 90 for determining a target m3u8 slice file according to the m3u8 index file if the m3u8 index file corresponds to the target multimedia file;
wherein the target m3u8 slice file is one of a plurality of m3u8 slice files corresponding to the m3u8 index file;
a second checking unit 100, configured to check whether the target m3u8 sliced file corresponds to the target multimedia file based on a preset file hash value included in the file name of the target m3u8 sliced file;
and a first playing unit 110 for playing the target m3u8 slice file if the target m3u8 slice file corresponds to the target multimedia file, and returning to the step of determining the target m3u8 slice file according to the m3u8 index file until the playing is finished.
Optionally, the first verifying unit 80 is configured to verify whether the m3u8 index file corresponds to the target multimedia file based on a preset index hash value included in the file name of the m3u8 index file, and includes:
calculating the hash value of the m3u8 index file to obtain the current index hash value of the m3u8 index file;
if the current index hash value is consistent with the preset index hash value, judging that the m3u8 index file corresponds to the target multimedia file;
and if the current index hash value is not consistent with the preset index hash value, judging that the m3u8 index file is not corresponding to the target multimedia file.
Optionally, the preset file hash values include a first preset file hash value obtained based on the first N file data packets of the m3u8 sliced file of the target multimedia file, and a second preset file hash value obtained based on the m3u8 sliced file of the target multimedia file;
the second checking unit 100 is configured to check whether the target m3u8 sliced file corresponds to the target multimedia file based on a preset file hash value included in the file name of the target m3u8 sliced file, and includes:
acquiring the first N file data packets of a target m3u8 slice file;
wherein N is a natural number;
calculating hash values of the previous N file data packets to obtain a first current file hash value;
if the first current file hash value is consistent with the first preset file hash value, acquiring the residual file data packets in the target m3u8 sliced file to obtain a complete target m3u8 sliced file;
calculating the hash value of the target m3u8 slice file to obtain a second current file hash value;
if the second current file hash value is consistent with the second preset file hash value, judging that the target m3u8 slice file corresponds to the target multimedia file;
and if the first current file hash value is inconsistent with the first preset file hash value or the second actual file hash value is inconsistent with the second preset file hash value, judging that the target m3u8 slice file is not corresponding to the target multimedia file.
Optionally, the first obtaining unit 70 is configured to obtain an m3u8 index file having an association relationship with a target multimedia file, and includes:
acquiring the storage address of the m3u8 index file of the target multimedia file and the identification code of the target multimedia file
And acquiring an m3u8 index file which is associated with the target multimedia file according to the m3u8 index file storage address and the identification code.
Optionally, referring to fig. 7, fig. 7 is a block diagram of another multimedia file tamper-resistant playing apparatus provided in the embodiment of the present invention, and on the basis of the embodiment shown in fig. 6, the apparatus further includes:
the second playing unit 120 is configured to play the multimedia content corresponding to the first N file data packets.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims (10)
1. A multimedia file tamper-proof playing method is applied to a playing end, and comprises the following steps:
responding to a playing instruction of a target multimedia file, and acquiring an m3u8 index file which is associated with the target multimedia file;
checking whether the m3u8 index file corresponds to the target multimedia file based on a preset index hash value included in the file name of the m3u8 index file;
the preset index hash value is obtained based on an m3u8 index file of the target multimedia file;
determining a target m3u8 slice file according to the m3u8 index file in case that the m3u8 index file corresponds to the target multimedia file;
wherein the target m3u8 slice file is one of a plurality of m3u8 slice files corresponding to the m3u8 index file;
checking whether the target m3u8 sliced file corresponds to the target multimedia file based on a preset file hash value included in the file name of the target m3u8 sliced file;
wherein the preset file hash value is obtained based on an m3u8 slice file of the target multimedia file;
and in the case that the target m3u8 slice file corresponds to the target multimedia file, playing the target m3u8 slice file, and returning to the step of determining the target m3u8 slice file according to the m3u8 index file until the playing is finished.
2. The method for playing a multimedia file according to claim 1, wherein the checking whether the m3u8 index file corresponds to the target multimedia file based on a preset index hash value included in a file name of the m3u8 index file comprises:
calculating the hash value of the m3u8 index file to obtain the current index hash value of the m3u8 index file;
if the current index hash value is consistent with the preset index hash value, judging that the m3u8 index file corresponds to the target multimedia file;
and if the current index hash value is not consistent with the preset index hash value, judging that the m3u8 index file is not corresponding to the target multimedia file.
3. The method for playing a multimedia file according to claim 1, wherein the predetermined file hash values include a first predetermined file hash value obtained based on the first N file packets of the m3u8 slice file of the target multimedia file, and a second predetermined file hash value obtained based on the m3u8 slice file of the target multimedia file;
the checking whether the target m3u8 sliced file corresponds to the target multimedia file based on a preset file hash value included in the file name of the target m3u8 sliced file includes:
acquiring the first N file data packets of the target m3u8 slice file;
wherein N is a natural number;
calculating the hash values of the first N file data packets to obtain a first current file hash value;
if the first current file hash value is consistent with the first preset file hash value, acquiring the remaining file data packets in the target m3u8 slice file to obtain a complete target m3u8 slice file;
calculating the hash value of the target m3u8 slice file to obtain a second current file hash value;
if the second current file hash value is consistent with the second preset file hash value, judging that the target m3u8 slice file corresponds to the target multimedia file;
and if the first current file hash value is inconsistent with the first preset file hash value, or the second actual file hash value is inconsistent with the second preset file hash value, judging that the target m3u8 slice file is not corresponding to the target multimedia file.
4. The method for playing a multimedia file according to claim 3, further comprising, before obtaining the remaining file data packets in the target m3u8 file:
playing the multimedia content corresponding to the first N file data packets;
the playing the target m3u8 slice file comprises:
and playing the multimedia content corresponding to the rest file data packets except the N file data packets in the target m3u8 slice file.
5. The method for playing a multimedia file according to claim 1, wherein the obtaining an m3u8 index file having an association relationship with the target multimedia file comprises:
acquiring an m3u8 index file storage address of the target multimedia file and an identification code of the target multimedia file;
and acquiring an m3u8 index file which is associated with the target multimedia file according to the m3u8 index file storage address and the identification code.
6. The method for playing a multimedia file according to claim 1, wherein the condition for determining the end of the playing comprises: the target m3u8 slice file does not correspond to the target multimedia file or traverses the m3u8 index file.
7. A multimedia file tamper-resistant processing method is applied to a server side, and comprises the following steps:
acquiring a multimedia file to be processed and an identification code of the multimedia file to be processed;
transcoding the multimedia file to be processed to obtain a corresponding m3u8 index file and a plurality of m3u8 slice files;
respectively calculating the hash value of the m3u8 index file, the hash value of each m3u8 slice file and the hash values of the first N data packets of each m3u8 slice file;
wherein N is a natural number, the hash value of the m3u8 index file is used as a preset index hash value of the m3u8 index file, the hash values of the first N data packets of each m3u8 slice file are used as first preset file hash values of the corresponding m3u8 slice file, and the hash value of each m3u8 slice file is used as second preset file hash values of the corresponding m3u8 slice file;
naming the m3u8 index file based on the preset index hash value and the identification code;
for any m3u8 slice file, naming the m3u8 slice file based on the first and second preset file hash values corresponding to the m3u8 slice file and the identification code.
8. The method for tamper-proofing a multimedia file according to claim 7, further comprising:
transmitting each m3u8 slice file to a content distribution network;
and sending the storage address of the m3u8 index file and the identification code to a database.
9. A multimedia file tamper-proof playing device is applied to a playing end, and comprises:
the device comprises a first acquisition unit, a second acquisition unit and a third acquisition unit, wherein the first acquisition unit is used for responding to a playing instruction of a target multimedia file and acquiring an m3u8 index file which is associated with the target multimedia file;
a first checking unit, configured to check whether the m3u8 index file corresponds to the target multimedia file based on a preset index hash value included in a file name of the m3u8 index file;
a determining unit, configured to determine a target m3u8 slice file according to the m3u8 index file if the m3u8 index file corresponds to the target multimedia file;
wherein the target m3u8 slice file is one of a plurality of m3u8 slice files corresponding to the m3u8 index file;
a second checking unit, configured to check whether the target m3u8 sliced file corresponds to the target multimedia file based on a preset file hash value included in a filename of the target m3u8 sliced file;
and the first playing unit is used for playing the target m3u8 slice file if the target m3u8 slice file corresponds to the target multimedia file, and returning to the step of determining the target m3u8 slice file according to the m3u8 index file until the playing is finished.
10. A multimedia file tamper-proofing processing device, applied to a server, the device comprising:
the second acquisition unit is used for acquiring a multimedia file to be processed and an identification code of the multimedia file to be processed;
the file processing unit is used for transcoding the multimedia file to be processed to obtain a corresponding m3u8 index file and a plurality of m3u8 slice files;
a calculating unit, configured to calculate a hash value of the m3u8 index file, a hash value of each of the m3u8 slice files, and a hash value of the first N data packets of each of the m3u8 slice files, respectively;
wherein the hash value of the m3u8 index file is used as a preset index hash value of the m3u8 index file, the hash values of the first N data packets of each m3u8 slice file are used as a first preset file hash value of the corresponding m3u8 slice file, and the hash value of each m3u8 slice file is used as a second preset file hash value of the corresponding m3u8 slice file;
the first naming unit is used for naming the m3u8 index file based on the preset index hash value and the identification code;
and the second naming unit is used for naming the m3u8 slice files based on the first preset file hash value and the second preset file hash value corresponding to the m3u8 slice files and the identification codes aiming at any one of the m3u8 slice files.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111600373.9A CN114040222A (en) | 2021-12-24 | 2021-12-24 | Multimedia file tamper-proof playing method, processing method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111600373.9A CN114040222A (en) | 2021-12-24 | 2021-12-24 | Multimedia file tamper-proof playing method, processing method and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114040222A true CN114040222A (en) | 2022-02-11 |
Family
ID=80141144
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111600373.9A Pending CN114040222A (en) | 2021-12-24 | 2021-12-24 | Multimedia file tamper-proof playing method, processing method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114040222A (en) |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105912705A (en) * | 2016-04-27 | 2016-08-31 | 乐视控股(北京)有限公司 | Acquisition method and device of multimedia file playing duration |
CN105933799A (en) * | 2016-05-19 | 2016-09-07 | 成都虚拟世界科技有限公司 | Method and device for playing video |
CN111181989A (en) * | 2020-01-02 | 2020-05-19 | 烽火通信科技股份有限公司 | Method and system for realizing HLS distribution tamper resistance |
CN112218166A (en) * | 2020-10-13 | 2021-01-12 | 湖南快乐阳光互动娱乐传媒有限公司 | Play starting method and related device for memory play of on-demand video |
CN112395253A (en) * | 2020-11-17 | 2021-02-23 | 北京字节跳动网络技术有限公司 | Index file generation method, terminal device, electronic device and medium |
CN112632129A (en) * | 2020-12-31 | 2021-04-09 | 联想未来通信科技(重庆)有限公司 | Code stream data management method, device and storage medium |
CN112822260A (en) * | 2020-12-31 | 2021-05-18 | 北京天融信网络安全技术有限公司 | File transmission method and device, electronic equipment and storage medium |
-
2021
- 2021-12-24 CN CN202111600373.9A patent/CN114040222A/en active Pending
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105912705A (en) * | 2016-04-27 | 2016-08-31 | 乐视控股(北京)有限公司 | Acquisition method and device of multimedia file playing duration |
CN105933799A (en) * | 2016-05-19 | 2016-09-07 | 成都虚拟世界科技有限公司 | Method and device for playing video |
CN111181989A (en) * | 2020-01-02 | 2020-05-19 | 烽火通信科技股份有限公司 | Method and system for realizing HLS distribution tamper resistance |
CN112218166A (en) * | 2020-10-13 | 2021-01-12 | 湖南快乐阳光互动娱乐传媒有限公司 | Play starting method and related device for memory play of on-demand video |
CN112395253A (en) * | 2020-11-17 | 2021-02-23 | 北京字节跳动网络技术有限公司 | Index file generation method, terminal device, electronic device and medium |
CN112632129A (en) * | 2020-12-31 | 2021-04-09 | 联想未来通信科技(重庆)有限公司 | Code stream data management method, device and storage medium |
CN112822260A (en) * | 2020-12-31 | 2021-05-18 | 北京天融信网络安全技术有限公司 | File transmission method and device, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8959202B2 (en) | Generating statistics of popular content | |
CN106936441B (en) | Data compression method and device | |
CN110888838A (en) | Object storage based request processing method, device, equipment and storage medium | |
KR101992779B1 (en) | Forensic marking apparatus and method for realtime contents service | |
CN112165482B (en) | Data processing method, data processing device, computer equipment and medium | |
CN114139135B (en) | Equipment login management method, device and storage medium | |
CN111460394A (en) | Copyright file verification method and device and computer readable storage medium | |
CN110213671B (en) | Hotspot short video determination method and device | |
CN114040222A (en) | Multimedia file tamper-proof playing method, processing method and device | |
CN111294613A (en) | Video processing method, client and server | |
CN111031117B (en) | Multimedia file downloading method and related device | |
CN111210826B (en) | Voice information processing method and device, storage medium and intelligent terminal | |
CN113434561A (en) | Live broadcast data verification method and system, electronic device and storage medium | |
EP2378441A1 (en) | Method and system for comparing media assets | |
CN111400630A (en) | Resource preloading method and related equipment | |
CN115297104B (en) | File uploading method and device, electronic equipment and storage medium | |
US20220191345A1 (en) | System and method for determining compression rates for images comprising text | |
CN111479140B (en) | Data acquisition method, data acquisition device, computer device and storage medium | |
US10065121B2 (en) | Method and apparatus for recording data of network interaction protocol | |
CN110413800B (en) | Method and equipment for providing novel information | |
CN114398659A (en) | Resource checking method, device, equipment and storage medium | |
CN114449052A (en) | Data compression method and device, electronic equipment and storage medium | |
CN114598930B (en) | Test method, test device, electronic equipment and computer storage medium | |
CN107465744B (en) | Data downloading control method and system | |
CN112153061A (en) | Data access method, device, equipment and computer readable storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |