A multimedia file tamper-proof playback method, processing method and device
By hash value verification of the m3u8 index file and slice file of the multimedia file under the HLS protocol, the problem of content tampering during the multimedia file playback is solved, and the correctness and security of the playback content is achieved.
Patent Information
- Application Number
- CN202111600373.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-24
- Publication Date
- 2025-04-22
- Estimated Expiration
- 2041-12-24
AI Technical Summary
In the process of playing multimedia files based on the HLS protocol, the prior art fails to effectively ensure the correctness of media content, and cannot prevent the slicing file set of video files from being replaced.
By hashing the actual obtained m3u8 index file and m3u8 slice file and the target multimedia file on the playback side, the correspondence of the file is ensured, thereby preventing tampering.
Effectively prevent multimedia file content from being tampered with, ensure the correctness of the playback content, and timely terminate the playback accident during the playback process.
Smart Images

Figure CN114040222B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of Internet technology, and in particular relates to a multimedia file tamper-proof playback method, processing method and device. Background Art
[0002] The HLS (HTTP Live Streaming) protocol is a streaming media network transmission protocol based on HTTP. The biggest feature of this protocol is that it segments continuous, large-capacity multimedia files, and then obtains a large number of m3u8 slice files for transmission. When the client plays the video, it only needs to obtain small-capacity m3u8 slice files in sequence based on the m3u8 index files synchronized during the segmentation process, which can reduce the requirements for network data transmission capabilities and achieve smooth playback.
[0003] As the HLS protocol becomes the mainstream playback protocol for multimedia playback on the Internet, how to ensure that multimedia files are not tampered with during multimedia playback based on the HLS protocol has become a technical focus in this field. However, most of the existing technologies only focus on how to prevent multimedia file data from being destroyed on the server side, and are committed to protecting multimedia file data, without considering how to ensure the correctness of media content. For example, the set of m3u8 slice files corresponding to video A is set a, and the set of m3u8 slice files corresponding to video B is set b. How to prevent the set corresponding to video A from being replaced by set b, thereby ensuring the correctness of the playback content, is what the existing technology lacks. Summary of the invention
[0004] In view of this, the object of the present invention is to provide a multimedia file tamper-proof playback method, processing method and device, for the actual obtained m3u8 index file and m3u8 slice file, corresponding verification is performed with the target multimedia file to ensure that the actual obtained m3u8 slice file corresponds to the target multimedia file, thereby ensuring the correctness of the playback content, the specific scheme is as follows:
[0005] In a first aspect, the present invention provides a multimedia file tamper-proof playback method, which is applied to a playback end, and the method comprises:
[0006] In response to a play instruction of a target multimedia file, an m3u8 index file associated with the target multimedia file is obtained;
[0007] 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;
[0008] Wherein, the preset index hash value is obtained based on the m3u8 index file of the target multimedia file;
[0009] When the m3u8 index file corresponds to the target multimedia file, determining the target m3u8 slice file according to the m3u8 index file;
[0010] Wherein, the target m3u8 slice file is one of the multiple m3u8 slice files corresponding to the m3u8 index file;
[0011] Verify whether the target m3u8 slice file corresponds to the target multimedia file based on a preset file hash value included in the file name of the target m3u8 slice file;
[0012] Among them, the preset file hash value is obtained based on the m3u8 slice file of the target multimedia file.
[0013] When the target m3u8 slice file corresponds to the target multimedia file, the target m3u8 slice file is played, and the step of determining the target m3u8 slice file according to the m3u8 index file is returned until the playback ends.
[0014] Optionally, the verifying 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:
[0015] Calculate the hash value of the m3u8 index file to obtain the current index hash value of the m3u8 index file;
[0016] If the current index hash value is consistent with the preset index hash value, it is determined that the m3u8 index file corresponds to the target multimedia file;
[0017] If the current index hash value is inconsistent with the preset index hash value, it is determined that the m3u8 index file does not correspond to the target multimedia file.
[0018] Optionally, the preset file hash value includes a first preset file hash value obtained based on first N file data 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;
[0019] The verifying whether the target m3u8 slice file corresponds to the target multimedia file based on the preset file hash value included in the file name of the target m3u8 slice file includes:
[0020] Get the first N file data packets of the target m3u8 slice file;
[0021] Wherein, N is a natural number;
[0022] Calculate the hash values of the first N file data packets to obtain a first current file hash value;
[0023] If the first current file hash value is consistent with the first preset file hash value, obtain the remaining file data packets in the target m3u8 slice file to obtain the complete target m3u8 slice file;
[0024] Calculate the hash value of the target m3u8 slice file to obtain a second current file hash value;
[0025] If the second current file hash value is consistent with the second preset file hash value, it is determined that the target m3u8 slice file corresponds to the target multimedia file;
[0026] 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, it is determined that the target m3u8 slice file does not correspond to the target multimedia file.
[0027] Optionally, before obtaining the remaining file data packets in the target m3u8 file, the method further includes:
[0028] Play the multimedia content corresponding to the first N file data packets;
[0029] The playing of the target m3u8 slice file includes:
[0030] Play the multimedia content corresponding to the remaining file data packets other than the N file data packets in the target m3u8 slice file.
[0031] Optionally, the acquiring of the m3u8 index file associated with the target multimedia file includes:
[0032] Get the m3u8 index file storage address of the target multimedia file and the identification code of the target multimedia file
[0033] The m3u8 index file associated with the target multimedia file is obtained according to the m3u8 index file storage address and the identification code.
[0034] Optionally, the conditions for determining the end of playback include: the target m3u8 slice file does not correspond to the target multimedia file, or the m3u8 index file is traversed.
[0035] In a second aspect, the present invention provides a multimedia file tamper-proof processing method, which is applied to a server, and the method comprises:
[0036] Acquire a multimedia file to be processed and an identification code of the multimedia file to be processed;
[0037] Transcode the multimedia file to be processed to obtain a corresponding m3u8 index file and multiple m3u8 slice files;
[0038] Calculate the hash value of the m3u8 index file, the hash value of each of the m3u8 slice files, and the hash value of the first N data packets of each of the m3u8 slice files respectively;
[0039] Wherein, N is a natural number, the hash value of the m3u8 index file is used as the preset index hash value of the m3u8 index file, the hash value of the first N data packets of each of the m3u8 slice files is used as the first preset file hash value of the corresponding m3u8 slice file, and the hash value of each of the m3u8 slice files is used as the second preset file hash value of the corresponding m3u8 slice file;
[0040] Naming the m3u8 index file based on the preset index hash value and the identification code;
[0041] For any of the m3u8 slice files, the m3u8 slice file is named 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.
[0042] Optionally, the multimedia file tamper-proof processing method provided by the second aspect of the present invention further includes:
[0043] Send each of the m3u8 slice files to a content distribution network;
[0044] The storage address of the m3u8 index file and the identification code are sent to the database.
[0045] In a third aspect, the present invention provides a multimedia file tamper-proof playback device, applied to a playback end, the device comprising:
[0046] A first acquisition unit, configured to respond to a play instruction of a target multimedia file and acquire an m3u8 index file associated with the target multimedia file;
[0047] A first verification unit, 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;
[0048] A determination 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;
[0049] Wherein, the target m3u8 slice file is one of the multiple m3u8 slice files corresponding to the m3u8 index file;
[0050] A second verification unit, configured to verify whether the target m3u8 slice file corresponds to the target multimedia file based on a preset file hash value included in the file name of the target m3u8 slice file;
[0051] The first playback unit is used to play the target m3u8 slice file if the target m3u8 slice file corresponds to the target multimedia file, and return to the step of determining the target m3u8 slice file according to the m3u8 index file until the playback ends.
[0052] In a fourth aspect, the present invention provides a multimedia file tamper-proof processing device, which is applied to a server, and the device includes:
[0053] A second acquisition unit, used to acquire a multimedia file to be processed and an identification code of the multimedia file to be processed;
[0054] A file processing unit, used for transcoding the multimedia file to be processed to obtain a corresponding m3u8 index file and a plurality of m3u8 slice files;
[0055] A calculation unit, used to respectively calculate the hash value of the m3u8 index file, the hash value of each of the m3u8 slice files, and the hash value of the first N data packets of each of the m3u8 slice files;
[0056] The hash value of the m3u8 index file is used as the preset index hash value of the m3u8 index file, the hash value of the first N data packets of each of the m3u8 slice files is used as the first preset file hash value of the corresponding m3u8 slice file, and the hash value of each of the m3u8 slice files is used as the second preset file hash value of the corresponding m3u8 slice file;
[0057] A first naming unit, used for naming the m3u8 index file based on the preset index hash value and the identification code;
[0058] The second naming unit is used to name any of the m3u8 slice files 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.
[0059] Based on the above technical scheme, the multimedia file tamper-proof playback method provided by the present invention, the playback end responds to the playback instruction of the target multimedia file, obtains the m3u8 index file with an association relationship with the target multimedia file, and verifies whether the m3u8 index file corresponds to the target multimedia file based on the preset index hash value of the m3u8 index file, if the m3u8 index file corresponds to the target multimedia file, then the target m3u8 slice file is determined according to the m3u8 index file, and further verifies whether the target m3u8 slice file corresponds to the target multimedia file based on the preset file hash value of the target m3u8 slice file, and the target m3u8 slice file corresponds to the target multimedia file, plays the target m3u8 slice file, and then judges the correspondence of the next target m3u8 slice file until the end of playback. By the playback method provided by the present invention, before playing, the m3u8 index file and each m3u8 slice file are checked correspondingly with the target multimedia file, ensuring that the playback content is consistent with the target multimedia file, effectively preventing the file content from being replaced, and then ensuring the correctness of the playback content.
[0060] Furthermore, the method is applied to the playback end, and the playback process can be terminated in time during the playback process, effectively avoiding playback accidents. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0062] Figure 1 is a flow chart of a multimedia file tamper-proof processing method provided by an embodiment of the present invention;
[0063] Figure 2 It is a flow chart of a multimedia file tamper-proof playback method provided by an embodiment of the present invention;
[0064] Figure 3 It is a flow chart of the m3u8 slice file verification method provided by an embodiment of the present invention;
[0065] Figure 4 It is a structural block diagram of a multimedia file tamper-proof processing device provided by an embodiment of the present invention;
[0066] Figure 5 is a structural block diagram of another multimedia file tamper-proof processing device provided by an embodiment of the present invention;
[0067] Figure 6It is a structural block diagram of a multimedia file tamper-proof playback device provided by an embodiment of the present invention;
[0068] Figure 7 It is a structural block diagram of another multimedia file tamper-proof playback device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0069] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0070] To facilitate understanding of the multimedia file tamper-proof processing method and playback method provided by the present invention, the implementation process of the multimedia file tamper-proof processing method is first introduced below, the processing process of the multimedia file is explained, and then the tamper-proof processing of the multimedia file performed by the present invention is explained. On this basis, the multimedia file tamper-proof playback method provided by an embodiment of the present invention is introduced, and the implementation process of tamper-proof playback based on the processed multimedia file is explained.
[0071] The multimedia file anti-tampering processing method provided in the embodiment of the present invention can be applied to an electronic device that can be applied to a server. The electronic device can be a terminal device with data analysis capabilities such as a notebook computer, a PC (personal computer), etc. Obviously, the electronic device can also be a server dedicated to multimedia file processing and storage; Figure 1 The multimedia file anti-tampering processing method provided by the embodiment of the present invention may include:
[0072] S100: Acquire a multimedia file to be processed and an identification code of the multimedia file to be processed.
[0073] The multimedia file to be processed mentioned in the present invention can be any multimedia file that can be played and processed based on the HLS technology in practical applications. In practical applications, it can be an audio file or a video file. Of course, it can also be other forms of multimedia files, which are not listed one by one here. The present invention does not limit the specific selection of the multimedia file to be processed.
[0074] The identification code of the multimedia file to be processed has a one-to-one correspondence with the multimedia file to be processed, and the multimedia file corresponding to the identification code can be uniquely determined by the identification code. As an optional implementation, the identification code can be implemented using UUID (Universally Unique Identifier).
[0075] S110, transcoding the multimedia file to be processed to obtain a corresponding m3u8 index file and multiple m3u8 slice files.
[0076] According to the file transfer requirements of the HLS protocol, it is necessary to transcode the multimedia file to be processed to obtain the m3u8 index file and multiple m3u8 slice files corresponding to the multimedia file to be processed. Based on the basic principle of the HLS protocol, the storage address of each m3u8 slice file is recorded in the m3u8 index file. When downloading and playing the m3u8 slice file, it is necessary to follow the order and address recorded in the m3u8 index file.
[0077] As for the specific process of transcoding the multimedia file to be processed, it can be implemented with reference to the prior art, and the present invention does not limit this.
[0078] S120, respectively calculating the hash value of the m3u8 index file, the hash value of each m3u8 slice file, and the hash value of the first N data packets of each m3u8 slice file.
[0079] First of all, it should be noted that N is a natural number. Considering that generally only 3 video data packets and 3 audio data packets are needed for playback, N can be 6. Of course, other values can also be selected according to needs, which will not be described in detail here.
[0080] For the calculation of hash values, in practical applications, commonly used algorithms such as MD5 (Message-Digest Algorithm) and CRC (Cyclic Redundancy Check) can be used.
[0081] Furthermore, for each m3u8 slice file, the hash value of the first N data packets of the m3u8 slice file is used as the first preset file hash value of the corresponding m3u8 slice file, and the hash value of the m3u8 slice file is used as the second preset file hash value of the corresponding m3u8 slice file; accordingly, the hash value of the m3u8 index file is used as the preset index hash value of the m3u8 index file.
[0082] S130: Name the m3u8 index file based on the preset index hash value and the identification code.
[0083] After the hash values of the above-mentioned files are obtained, the corresponding files are named 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.
[0084] For example, the m3u8 index file may be named md5(file_index)_uuid.m3u8, wherein 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.
[0085] S140: For any m3u8 slice file, name 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.
[0086] Correspondingly, for each m3u8 slice file, the m3u8 slice file is named based on the first preset file hash value and the second preset file hash value of the m3u8 slice file and the identification code.
[0087] For example, any m3u8 slice file can be named: md5(packet)_md5(file)_uuid.ts, where md5(packet) represents the hash value of the first N file data packets of the m3u8 slice file, that is, the first preset file hash value, md5(file) represents the hash value of the entire m3u8 slice file, that is, the second preset file hash value, and uuid still represents the identification code of the multimedia file to be processed.
[0088] It should be noted that there is no need to distinguish the order of execution for S130 and S140. The two can be executed simultaneously, or S140 can be executed first and then S130. This embodiment provides a specific execution order to facilitate the explanation of the execution process of the method, but it does not serve as a specific limitation on the naming process.
[0089] Optionally, after completing the naming of the above-mentioned files, each m3u8 slice file can also be sent to the content distribution network. 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 the database for use when the terminal side obtains the multimedia file to be processed.
[0090] In summary, the multimedia file tamper-proof processing method provided by the embodiment of the present invention names the m3u8 index file based on the hash value of the m3u8 index file, and establishes a correspondence between the m3u8 index file and the preset index hash value, so that when the terminal side plays the target multimedia file, it can verify whether the obtained m3u8 index file corresponds to the multimedia file based on the preset index hash value; further, the aforementioned first preset file hash value and the second preset file hash value are calculated by the multimedia file, and the hash values calculated for different multimedia files are naturally different. The corresponding m3u8 slice file is named with the first preset file hash value and the second preset file hash value, and a correspondence between the preset file hash value and the m3u8 slice file is established. Then, the preset file hash value can be used to determine whether the obtained m3u8 slice file corresponds to the multimedia file, which can effectively prevent the multimedia file from being tampered with, and prevent the actually obtained m3u8 slice file from not corresponding to the multimedia file to be accessed, thereby ensuring the correctness of the playback content.
[0091] The following describes the process of implementing tamper-proof playback of multimedia files processed by the tamper-proof processing method. The tamper-proof playback method provided by the present invention is applied to an electronic device at the playback end, which can be a laptop, PC, smart phone, tablet computer, etc., which can play multimedia files. Figure 2 , Figure 2 1 is a flowchart of a method for tamper-proof playback of multimedia files provided by an embodiment of the present invention. The process of this method may include:
[0092] S200, responding to a play instruction of a target multimedia file, and acquiring an m3u8 index file associated with the target multimedia file.
[0093] In this embodiment, the target multimedia file refers to the multimedia file that the user needs to play. In practical applications, the target multimedia file can be any multimedia file that the user can choose to play. The play instruction of the target multimedia file can be obtained through various ways, such as the play instruction input by the user through a command input device, such as a mouse or a keyboard, or the play instruction input by the user by clicking on a touch screen. The present invention does not limit the specific way of obtaining the play instruction.
[0094] Optionally, in response to the play instruction, the m3u8 index file storage address of the target multimedia file and the identification code of the target multimedia file are obtained from an API (Application Programming Interface), and then the m3u8 index file associated with the target multimedia file is obtained according to the obtained m3u8 index file storage address and identification code.
[0095] It should be noted that the specific implementation process of obtaining the m3u8 index file of the multimedia file and the identification code of the multimedia file based on the distributed network or other media storage network established based on the HLS protocol can be implemented with reference to the existing technology, and the present invention is not limited to this.
[0096] It should also be noted that, considering that the target multimedia file may have been tampered with, the m3u8 index file obtained in this step is not necessarily the m3u8 index file obtained based on the target multimedia file, and it may be the index file of other multimedia files after tampering, and just because of this, in subsequent steps, it is first necessary to judge whether the gained m3u8 index file corresponds to the target multimedia file. "having an associated relationship with the target multimedia file" described in the present embodiment refers to the m3u8 index file storage address of the target multimedia file, and the m3u8 index file can be obtained, and it is not determined that the gained m3u8 index file is corresponding to the target multimedia file.
[0097] S210: 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.
[0098] It can be seen from the above embodiments that 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 with the m3u8 index file of the target multimedia file. After the m3u8 index file is obtained in S200, the content of the field corresponding to the file name in the index file is extracted to obtain the preset index hash value.
[0099] Furthermore, the hash value of the obtained m3u8 index file is calculated to obtain the current index hash value of the m3u8 index file. If the obtained current index hash value is consistent with the preset index hash value in the file name, it is determined that the obtained m3u8 index file corresponds to the target multimedia file; on the contrary, if the current index hash value is inconsistent with the preset index hash value, it is determined that the m3u8 index file does not correspond to the target multimedia file.
[0100] When the obtained m3u8 index file does not correspond to the target multimedia file, exit the current playback process to avoid playback accidents.
[0101] S220. When the m3u8 index file corresponds to the target multimedia file, determine the target m3u8 slice file according to the m3u8 index file.
[0102] As mentioned above, HLS technology stores multimedia files in the form of multiple m3u8 slice files in the network system, and the m3u8 index file records the storage address of each m3u8 slice file. All m3u8 slice files can be obtained by traversing the m3u8 index file. The target m3u8 slice file mentioned in this step is one of the multiple m3u8 slice files corresponding to the m3u8 index file.
[0103] It should be noted that although the m3u8 index file has been determined to correspond to the target multimedia file through the above steps, in actual applications, it cannot be guaranteed that the m3u8 slice file obtained according to the m3u8 index file must correspond to the target multimedia file, and further verification is required.
[0104] S230: Verify whether the target m3u8 slice file corresponds to the target multimedia file based on the preset file hash value included in the file name of the target m3u8 slice file.
[0105] As mentioned above, the file name of the m3u8 slice file is named based on the hash value of the slice file. Specifically, the preset file hash value in the file name of the target m3u8 slice file includes a first preset file hash value obtained based on the first N file data 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.
[0106] Optionally, based on the above content, for optional implementation methods of this step, please refer to Figure 3 As shown:
[0107] S2301. Obtain the first N file data packets of the target m3u8 slice file.
[0108] For the value of N, please refer to the above content and will not be repeated here. As for the specific acquisition process of the first N file data packets, it can be implemented based on the HLS protocol, and the present invention does not make specific limitations on this.
[0109] S2302. Calculate the hash values of the first N file data packets to obtain a first current file hash value.
[0110] Optionally, the specific calculation process can be implemented using the MD5 algorithm or the CRC algorithm. Figure 1 The same calculation algorithm may be used in the illustrated embodiment.
[0111] S2303: Determine whether the first current file hash value is consistent with the first preset file hash value. If so, execute S2304; if not, execute S2308.
[0112] If the first current file hash value is consistent with the first preset file hash value, then continue to execute S2304. On the contrary, if the first current file hash value is inconsistent with the first preset file hash value, then execute S2308.
[0113] Optionally, if the first current file hash value is consistent with the first preset file hash value, it can at least be shown that the first N file packets of the target m3u8 slice file correspond to the target multimedia file, and the multimedia content corresponding to the first N file packets can be played first, which can not only improve the playback efficiency, but also reduce the hardware performance requirements of the playback end electronic device. Of course, the multimedia content corresponding to the first N file packets may not be played here, but it may be played again after the entire target m3u8 slice file is determined to correspond to the target multimedia file.
[0114] S2304. Obtain the remaining file data packets in the target m3u8 slice file to obtain a complete target m3u8 slice file.
[0115] When it is determined that the first N file data packets correspond to the target multimedia file, the remaining file data packets in the target m3u8 slice file are further obtained in an asynchronous download manner to obtain a complete target m3u8 slice file.
[0116] S2305. Calculate the hash value of the target m3u8 slice file to obtain a second current file hash value.
[0117] After obtaining the complete target m3u8 slice file, the hash value of the target m3u8 slice file is calculated to obtain the second current file hash value.
[0118] S2306: Determine whether the second current file hash value is consistent with the second preset file hash value. If so, execute S2307; if not, execute S2308.
[0119] S2307. Determine whether the target m3u8 slice file corresponds to the target multimedia file.
[0120] When the second current file hash value is consistent with the second preset file hash value, it is determined that the target m3u8 slice file corresponds to the target multimedia file.
[0121] S2308: Determine whether the target m3u8 slice file does not correspond to the target multimedia file.
[0122] When 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, it is determined that the target m3u8 slice file does not correspond to the target multimedia file.
[0123] S240. When the target m3u8 slice file corresponds to the target multimedia file, play the target m3u8 slice file, and return to S220 until the playback ends.
[0124] When it is determined that the target m3u8 slice file corresponds to the target multimedia file, the target m3u8 slice file can be played. Optionally, if the multimedia content corresponding to the first N file packets has been played in S2303, the multimedia content after the first N file packets only needs to be played in this step.
[0125] At the same time, return to S220, continue to judge the next target m3u8 slice file according to the m3u8 index file, until the m3u8 index file is traversed, the playback of all m3u8 slice files is completed, and the playback of the target multimedia file is ended.
[0126] Of course, if during the loop process, any target m3u8 slice file does not correspond to the target multimedia file, the playback process can be ended directly to prevent playback accidents.
[0127] In summary, the playback 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 playback, ensuring the consistency of the playback content with the target multimedia file, effectively preventing the file content from being replaced, and thus ensuring the correctness of the playback content.
[0128] Furthermore, the method is applied to the playback end, and the playback process can be terminated in time during the playback process, effectively avoiding playback accidents.
[0129] The multimedia file anti-tampering processing device provided in an embodiment of the present invention is introduced below. The multimedia file anti-tampering processing device described below can be considered as a functional module architecture that needs to be set in the central device to implement the multimedia file anti-tampering processing method provided in an embodiment of the present invention; the content described below can be cross-referenced with the above.
[0130] See also Figure 4 , Figure 4 A structural block diagram of a multimedia file anti-tampering processing device provided by an embodiment of the present invention, referring to Figure 4 , the device may include:
[0131] The second acquisition unit 10 is used to acquire the multimedia file to be processed and the identification code of the multimedia file to be processed;
[0132] The file processing unit 20 is used to transcode the multimedia file to be processed to obtain a corresponding m3u8 index file and a plurality of m3u8 slice files;
[0133] A calculation unit 30 is used to respectively calculate the hash value of the m3u8 index file, the hash value of each m3u8 slice file, and the hash value of the first N data packets of each m3u8 slice file;
[0134] The hash value of the m3u8 index file is used as the preset index hash value of the m3u8 index file, the hash value of the first N data packets of each m3u8 slice file is used as the first preset file hash value of the corresponding m3u8 slice file, and the hash value of each m3u8 slice file is used as the second preset file hash value of the corresponding m3u8 slice file;
[0135] A first naming unit 40, used for naming the m3u8 index file based on a preset index hash value and an identification code;
[0136] The second naming unit 50 is used to name any 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.
[0137] Optional, see Figure 5 , Figure 5 is a structural block diagram of another multimedia file anti-tampering processing device provided by an embodiment of the present invention. Figure 4 Based on the embodiment shown, the device also includes:
[0138] The storage unit 60 is used to send each m3u8 slice file to the content distribution network; and send the storage address and identification code of the m3u8 index file to the database.
[0139] The multimedia file tamper-proof playback device provided in an embodiment of the present invention is introduced below. The multimedia file tamper-proof playback device described below can be considered as a functional module architecture that needs to be set in the central device to implement the multimedia file tamper-proof playback method provided in an embodiment of the present invention; the content described below can be cross-referenced with the above.
[0140] See also Figure 6 , Figure 6 A structural block diagram of a multimedia file tamper-proof playback device provided by an embodiment of the present invention, referring to Figure 6 , the device may include:
[0141] A first acquisition unit 70 is used to respond to a play instruction of a target multimedia file and acquire an m3u8 index file associated with the target multimedia file;
[0142] A first verification unit 80 is used 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;
[0143] A determination unit 90 is used to determine the target m3u8 slice file according to the m3u8 index file if the m3u8 index file corresponds to the target multimedia file;
[0144] The target m3u8 slice file is one of the multiple m3u8 slice files corresponding to the m3u8 index file;
[0145] A second verification unit 100 is used to verify whether the target m3u8 slice file corresponds to the target multimedia file based on a preset file hash value included in the file name of the target m3u8 slice file;
[0146] The first playing unit 110 is used to play the target m3u8 slice file if the target m3u8 slice file corresponds to the target multimedia file, and return to the step of determining the target m3u8 slice file according to the m3u8 index file until the playing is finished.
[0147] Optionally, the first verification unit 80 is used 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, including:
[0148] Calculate the hash value of the m3u8 index file and get the current index hash value of the m3u8 index file;
[0149] If the current index hash value is consistent with the preset index hash value, it is determined that the m3u8 index file corresponds to the target multimedia file;
[0150] If the current index hash value is inconsistent with the preset index hash value, it is determined that the m3u8 index file does not correspond to the target multimedia file.
[0151] Optionally, the preset file hash value includes a first preset file hash value obtained based on first N file data packets of an 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;
[0152] The second verification unit 100 is used to verify whether the target m3u8 slice file corresponds to the target multimedia file based on a preset file hash value included in the file name of the target m3u8 slice file, including:
[0153] Get the first N file data packets of the target m3u8 slice file;
[0154] Wherein, N is a natural number;
[0155] Calculate the hash values of the first N file data packets to obtain the first current file hash value;
[0156] If the first current file hash value is consistent with the first preset file hash value, obtain the remaining file data packets in the target m3u8 slice file to obtain a complete target m3u8 slice file;
[0157] Calculate the hash value of the target m3u8 slice file to obtain the second current file hash value;
[0158] If the second current file hash value is consistent with the second preset file hash value, it is determined that the target m3u8 slice file corresponds to the target multimedia file;
[0159] 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, it is determined that the target m3u8 slice file does not correspond to the target multimedia file.
[0160] Optionally, the first acquisition unit 70 is used to acquire an m3u8 index file associated with the target multimedia file, including:
[0161] Get the m3u8 index file storage address of the target multimedia file and the identification code of the target multimedia file
[0162] The m3u8 index file associated with the target multimedia file is obtained according to the m3u8 index file storage address and identification code.
[0163] Optional, see Figure 7 , Figure 7 is a structural block diagram of another multimedia file tamper-proof playback device provided by an embodiment of the present invention. Figure 6 Based on the embodiment shown, the device further includes:
[0164] The second playing unit 120 is used to play the multimedia contents corresponding to the first N file data packets.
[0165] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0166] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0167] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0168] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the core concept or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for tamper-proofing the playback of multimedia files, characterized in that: Applied to the playback end, the method includes: In response to a play instruction of a target multimedia file, an m3u8 index file associated with the target multimedia file is obtained; 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, wherein the file name of the m3u8 index file is named based on the hash value of the m3u8 index file; Wherein, the preset index hash value is obtained based on the m3u8 index file of the target multimedia file; When the m3u8 index file corresponds to the target multimedia file, determining the target m3u8 slice file according to the m3u8 index file; Wherein, the target m3u8 slice file is one of the multiple m3u8 slice files corresponding to the m3u8 index file; Verify whether the target m3u8 slice file corresponds to the target multimedia file based on a preset file hash value included in the file name of the target m3u8 slice file, and the file name of the target m3u8 slice file is named based on the hash value of the target m3u8 slice file; The preset file hash value is obtained based on the m3u8 slice file of the target multimedia file, and the preset file hash value includes a first preset file hash value obtained based on the first N file data 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, where N is a natural number; When the target m3u8 slice file corresponds to the target multimedia file, the target m3u8 slice file is played, and the step of determining the target m3u8 slice file according to the m3u8 index file is returned until the playback ends.
2. The method for tamper-proofing multimedia file playback according to claim 1, characterized in that: The verifying whether the m3u8 index file corresponds to the target multimedia file based on the preset index hash value included in the file name of the m3u8 index file includes: Calculate 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, it is determined that the m3u8 index file corresponds to the target multimedia file; If the current index hash value is inconsistent with the preset index hash value, it is determined that the m3u8 index file does not correspond to the target multimedia file.
3. The multimedia file tamper-proof playback method according to claim 1, characterized in that: The verifying whether the target m3u8 slice file corresponds to the target multimedia file based on the preset file hash value included in the file name of the target m3u8 slice file includes: Get the first N file data packets of the target m3u8 slice file; Calculate 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, obtain the remaining file data packets in the target m3u8 slice file to obtain the complete target m3u8 slice file; Calculate 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, it is determined that the target m3u8 slice file corresponds to the target multimedia file; If the first current file hash value is inconsistent with the first preset file hash value, or the second current file hash value is inconsistent with the second preset file hash value, it is determined that the target m3u8 slice file does not correspond to the target multimedia file.
4. The multimedia file tamper-proof playback method according to claim 3, characterized in that: Before obtaining the remaining file data packets in the target m3u8 slice file, it also includes: Play the multimedia content corresponding to the first N file data packets; The playing of the target m3u8 slice file includes: Play the multimedia content corresponding to the remaining file data packets other than the N file data packets in the target m3u8 slice file.
5. The multimedia file tamper-proof playback method according to claim 1, characterized in that: The step of obtaining an m3u8 index file associated with the target multimedia file includes: Obtain the m3u8 index file storage address of the target multimedia file and the identification code of the target multimedia file; The m3u8 index file associated with the target multimedia file is obtained according to the m3u8 index file storage address and the identification code.
6. The multimedia file tamper-proof playback method according to claim 1, characterized in that: The conditions for determining the end of playback include: the target m3u8 slice file does not correspond to the target multimedia file, or the m3u8 index file is traversed.
7. A method for preventing multimedia files from being tampered with, characterized in that: Applied to the server, the method includes: Acquire a multimedia file to be processed and an identification code of the multimedia file to be processed; Transcode the multimedia file to be processed to obtain a corresponding m3u8 index file and multiple m3u8 slice files; Calculate the hash value of the m3u8 index file, the hash value of each of the m3u8 slice files, and the hash value of the first N data packets of each of the m3u8 slice files respectively; Wherein, N is a natural number, the hash value of the m3u8 index file is used as the preset index hash value of the m3u8 index file, the hash value of the first N data packets of each of the m3u8 slice files is used as the first preset file hash value of the corresponding m3u8 slice file, and the hash value of each of the m3u8 slice files is used as the second preset file hash value of the corresponding m3u8 slice file; Naming the m3u8 index file based on the preset index hash value and the identification code; For any of the m3u8 slice files, the m3u8 slice file is named 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.
8. The multimedia file tamper-proof processing method according to claim 7, characterized in that: Also includes: Send each of the m3u8 slice files to a content distribution network; The storage address of the m3u8 index file and the identification code are sent to the database.
9. A multimedia file tamper-proof playback device, characterized in that: Applied to a playback end, the device comprises: A first acquisition unit, configured to respond to a play instruction of a target multimedia file and acquire an m3u8 index file associated with the target multimedia file; A first verification unit, 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, wherein the file name of the m3u8 index file is named based on the hash value of the m3u8 index file, and the preset index hash value is obtained based on the m3u8 index file of the target multimedia file; A determination 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 the multiple m3u8 slice files corresponding to the m3u8 index file; A second verification unit, configured to verify whether the target m3u8 slice file corresponds to the target multimedia file based on a preset file hash value included in the file name of the target m3u8 slice file, wherein the file name of the target m3u8 slice file is named based on the hash value of the target m3u8 slice file, the preset file hash value is obtained based on the m3u8 slice file of the target multimedia file, the preset file hash value includes a first preset file hash value obtained based on the first N file data 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, where N is a natural number; The first playback unit is used to play the target m3u8 slice file if the target m3u8 slice file corresponds to the target multimedia file, and return to the step of determining the target m3u8 slice file according to the m3u8 index file until the playback ends.
10. A multimedia file tamper-proof processing device, characterized in that: Applied to the server, the device comprises: A second acquisition unit, used to acquire a multimedia file to be processed and an identification code of the multimedia file to be processed; A file processing unit, used for transcoding the multimedia file to be processed to obtain a corresponding m3u8 index file and a plurality of m3u8 slice files; A calculation unit, used to respectively calculate the hash value of the m3u8 index file, the hash value of each of the m3u8 slice files, and the hash value of the first N data packets of each of the m3u8 slice files; The hash value of the m3u8 index file is used as the preset index hash value of the m3u8 index file, the hash value of the first N data packets of each of the m3u8 slice files is used as the first preset file hash value of the corresponding m3u8 slice file, and the hash value of each of the m3u8 slice files is used as the second preset file hash value of the corresponding m3u8 slice file; A first naming unit, used for naming the m3u8 index file based on the preset index hash value and the identification code; The second naming unit is used to name any of the m3u8 slice files 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.
Citation Information
Patent Citations
Method and system for realizing HLS distribution tamper prevention
CN111181989A
Index file generation method, terminal equipment, electronic equipment and medium
CN112395253A
Code stream data management method and device and storage medium
CN112632129A
File transmission method and device, electronic equipment and storage medium
CN112822260A