A video file playing and transmitting method and device

By verifying the index file and cached data before video playback, the problem of slow video playback speed is solved. This allows for simultaneous verification and playback of the video during the download process, thereby improving playback speed.

CN115914185BActive Publication Date: 2025-12-12HUNAN HAPPLY SUNSHINE INTERACTIVE ENTERTAINMENT MEDIA CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211376051.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-04
Publication Date
2025-12-12
Estimated Expiration
2042-11-04

AI Technical Summary

Technical Problem

In existing technologies, hash-based anti-tampering techniques for video files require downloading the complete video segment before verification, resulting in slow video playback speed.

Method used

The first verification value is generated by generating an index file, and the video stream segment is requested after verifying that it matches the first verification value before downloading the video stream segment. When the cached data reaches the target data volume of the logical segment, a second verification value is generated to verify and play the logical segment data.

Benefits of technology

This technology reduces video playback waiting time and improves video playback speed while verifying that the video has not been tampered with.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115914185B_ABST
    Figure CN115914185B_ABST
Patent Text Reader

Abstract

The application provides a video file playing and transmitting method and device. After verifying that the first verification value generated based on an index file is consistent with the received first check value, the server is requested for a video stream segment. Whenever the data amount of the video stream segment obtained from the server reaches the target data amount of a logical segment, the second verification value of the logical segment is generated based on the cached data of the logical segment, and when the second verification value is the same as the second check value of the logical segment in the index file, the data of the logical segment is outputted, so that the video stream segment can be played after verifying the safety of the data of a logical segment in the video stream segment, the video data can be played while the video data is checked in the video stream transmission process, the waiting time for video playing is reduced, and the playing speed is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of video processing, and more particularly to a video file playing and transmitting method and device. BACKGROUND

[0002] With the continuous development of Internet technology, network video is becoming more and more important in people's daily life. Due to the openness of the network, security problems such as hacker attacks and content tampering occur from time to time. For some important videos, if the video content is attacked and tampered with, it will cause unpredictable losses.

[0003] At present, in order to avoid video content tampering, the server can generate a hash of the video file, and the video receiving end can verify whether the hash value of the video is correct to verify whether the video file is tampered with. However, in the hash-based tamper-proofing technology of the video file, the client needs to download the complete video slice before performing hash calculation, and can play the video slice only after verifying that the entire video slice has not been tampered with based on the hash calculation result, which results in a long waiting time before playing the video, affecting the video playing speed. SUMMARY

[0004] Therefore, the present application provides a video file playing and transmitting method and device, which can play the video in time under the condition of verifying that the video has not been tampered with, reduce the waiting time for playing the video, and improve the playing speed of the video.

[0005] To achieve the above purpose, in one aspect, the present application provides a video file playing method, comprising:

[0006] obtaining an index file of a video to be played and a first check value for checking the index file from a server, the index file comprising: network addresses of each video stream slice in a video stream file of the video, check value information and check reference information, the check value information of the video stream slice comprising: second check values of at least one logical segment corresponding to the video stream slice respectively;

[0007] generating a first verification value for verifying the index file based on the index file;

[0008] if the first check value is the same as the first verification value, requesting the video stream slice from the server based on the network address of the video stream slice;

[0009] caching data of the video stream slice transmitted by the server;

[0010] generating a second verification value of the logical segment according to the cached data of the logical segment, if it is confirmed that the cached data of the video stream segment reaches a target data amount of a logical segment based on the check reference information;

[0011] outputting the cached data of the logical segment to play the data of the logical segment, if the second verification value of the logical segment is same as the second check value of the logical segment.

[0012] Preferably, the generating the first verification value for verifying the index file based on the index file comprises:

[0013] generating the first verification value for verifying the index file based on the content of the index file, the video stream name of the video and a key, the key being a key agreed in advance by the server and the client.

[0014] Preferably, the check reference information comprises: a check level, a file size of the video stream segment and a file time length of the video stream segment, the check level being used to represent a division manner of each logical segment in the video stream segment.

[0015] Before the generating the second verification value of the logical segment, the method further comprises:

[0016] determining a target data amount of each logical segment in the video stream segment based on the check level, the file size of the video stream segment and the file time length of the video stream segment.

[0017] The generating the second verification value of the logical segment according to the cached data of the logical segment, if it is confirmed that the cached data of the video stream segment reaches a target data amount of a logical segment based on the check reference information comprises:

[0018] if it is confirmed that the cached data of the video stream segment reaches a target data amount of a logical segment based on the target data amount of each logical segment, acquiring verification data for verifying the logical segment from the cached data of the video stream segment based on an end position of the logical segment;

[0019] generating the second verification value based on the verification data corresponding to the logical segment.

[0020] Preferably, the acquiring the verification data for verifying the logical segment from the cached data of the video stream segment based on the end position of the logical segment comprises:

[0021] The verification data of a set data amount after the end position of the logical segment is obtained from the cached data of the video stream segment.

[0022] Preferably, the check level represents a number of sampling points per second in the video stream segment, and the video stream segment is divided into at least one logical segment by the sampling points.

[0023] The target data amount of each logical segment in the video stream segment is determined based on the check level, a file size of the video stream segment, and a file duration of the video stream segment.

[0024] A target duration corresponding to the video stream segment is determined based on the file duration of the video stream segment and a set unit time, and the target duration is an integer multiple of the unit time and is a maximum duration not exceeding the file duration of the video stream segment.

[0025] A file data amount per second in the video stream segment is determined based on the target duration and the file size of the video stream segment.

[0026] A target file number corresponding to the video stream segment is determined based on the file data amount, and the target file number is a minimum data amount not less than the file data amount and an integer multiple of a set data amount unit.

[0027] A number of sampling points per second in the video stream segment is determined based on the check level.

[0028] The target data amount of each logical segment in the video stream segment is determined based on the target file number and the number of sampling points.

[0029] Preferably, the check value information is an encrypted array.

[0030] Before generating the second verification value, the method further includes:

[0031] The array included in the check value information is decrypted.

[0032] The second check value corresponding to each logical segment in the video stream segment is extracted from the array.

[0033] Preferably, the method further includes:

[0034] If the first check value and the first verification value are different, prompt information for prompting that the video stream segment has data anomaly is output.

[0035] In another aspect, the application further provides a video file transmission method applied to a server, and the method includes:

[0036] obtaining a video file request sent by a client, the video file request indicating information of a requested video;

[0037] based on the video file request, obtaining an index file of the video and a first check value for checking the index file, the index file including network addresses of each video stream segment in a video stream file of the video, check value information and check reference information;

[0038] returning the index file and the first check value to the client;

[0039] obtaining a video stream request sent by the client, the video stream request being used to request data of a video stream segment;

[0040] transmitting the data of the video stream segment to the client.

[0041] Preferably, in the case that the server is a content distribution node, obtaining the index file of the video and the first check value for checking the index file comprises:

[0042] if the content distribution node stores the index file of the video and the first check value of the index file, sending the stored index file of the video and the first check value to the client;

[0043] if the content distribution node does not store the index file of the video and the first check value of the index file, obtaining the index file of the video and the first check value of the index file from a source server of the video, returning the index file of the video and the first check value of the index file to the client, and storing the index file of the video and the first check value of the index file in the content distribution node.

[0044] In another aspect, the application further provides a video file playing device, comprising:

[0045] a video obtaining unit configured to obtain an index file of a video to be played and a first check value for checking the index file from a server, the index file including network addresses of each video stream segment in a video stream file of the video, check value information and check reference information, the check value information of the video stream segment including second check values of at least one logical segment corresponding to the video stream segment;

[0046] a first verification value generating unit configured to generate a first verification value for verifying the index file based on the index file;

[0047] a video requesting unit configured to request the server for the video stream segment based on the network addresses of the video stream segment if the first check value is the same as the first verification value.

[0048] a video buffer unit, configured to buffer data of the video stream segment transmitted by the server;

[0049] a second verification value generating unit, configured to generate a second verification value of the logical segment according to the buffered data of the logical segment if it is confirmed that the amount of the buffered data of the video stream segment reaches the target data amount of one logical segment based on the check reference information;

[0050] an output data unit, configured to output the buffered data of the logical segment to play the data of the logical segment if the second verification value of the logical segment is same as the second check value of the logical segment.

[0051] In the present application, the first verification value based on the index file of the video is generated, and after the first verification value is verified to be consistent with the received first check value, the server is requested for the video stream segment of the video, so that the error video stream caused by the tampered index file can be reduced. On this basis, whenever the amount of the data of the video stream segment obtained from the server reaches the target data amount of one logical segment, the second verification value of the logical segment is generated based on the buffered data of the logical segment, and when the second verification value is verified to be same as the second check value of the logical segment in the index file, the data of the logical segment can be outputted, so that the video stream segment can be played without waiting for the entire video stream segment to be downloaded and then parsed and played, the data of one logical segment in the video stream segment can be played after the safety of the data of the logical segment is verified, and the video can be played while the video data is checked in the process of the video stream transmission, the waiting time for playing the video is reduced, and the playing speed is improved. BRIEF DESCRIPTION OF DRAWINGS

[0052] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced. Obviously, the drawings in the following description are only embodiments of the present application, and other drawings can be obtained by those skilled in the art without any creative effort on the basis of the provided drawings.

[0053] Figure 1 a flowchart of a video file playing provided by an embodiment of the present application;

[0054] Figure 2 a schematic diagram of a logical segment provided by an embodiment of the present application;

[0055] Figure 3 a flowchart of determining the target data amount of a logical segment provided by an embodiment of the present application;

[0056] Figure 4 This application provides an example of an interactive process for video file transmission.

[0057] Figure 5 This is a schematic diagram of a video file playback device provided in an embodiment of this application. Detailed Implementation

[0058] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0059] The following describes a video file playback and transmission method provided by an embodiment of this application.

[0060] like Figure 1 This illustration shows a flowchart of a video file playback process provided in an embodiment of this application. This application can be applied to clients that support video playback, such as mobile phones or laptops where multimedia playback applications like media players reside, without any limitations.

[0061] The method in this embodiment includes:

[0062] Step S100: Obtain the index file of the video to be played and the first check value used to verify the index file from the server.

[0063] For example, when a client sends a video file request to a server, the request includes the path information of the requested video. To prevent videos with the same name from existing in different paths, this path information includes both the video's directory and its name.

[0064] The first checksum of the index file is used to verify whether the received index file has been tampered with.

[0065] The video's index file is a plain text file that records the index information of a video. This index file is used to locate the video's data resources. Specifically, the index file includes at least the network addresses of each video stream segment in the video stream file.

[0066] In this application, the video file is provided to the client in the form of a video stream; therefore, the video file consists of at least one video stream segment. The network address of the video stream segment in the index file is used to indicate the storage location of the video stream segment, so as to request the video stream segment corresponding to the network address of the video stream segment from the server.

[0067] In the present application, in order to verify whether the file content of the video is tampered, the index file further comprises: check value information and check reference information of each video stream segment in the video stream file of the video.

[0068] Specifically, the check value information is used to verify whether the video stream segment is tampered. The check value information of the video stream segment can comprise: a second check value of each logical segment corresponding to the video stream segment.

[0069] In the present application, the video stream segment is divided into several logical segments, so as to subsequently check each logical segment individually. Therefore, each logical segment in the video stream segment corresponds to a second check value, which is used to verify whether the data of the logical segment in the video stream segment is tampered. In a possible implementation, in order to further improve the security of the video data, the check value information can be an encrypted array. An array is an ordered arrangement of several data elements of the same type for the convenience of processing data. The collection of these ordered arrangements of the same type of data elements is called an array. An array is generally applied in program design, and an array can be decomposed into multiple data elements. In the present application, the array is composed of the second check value of each logical segment. The encryption method can be various, such as symmetric encryption of the array by using 3DES, AES, etc. In the present application, the method of encrypting the array is not limited.

[0070] It can be understood that, since the check value information is obtained by encryption, the check value information needs to be decrypted before the video stream is verified, and the array contained in the check value information is extracted. Then, the second check value can be extracted from the array.

[0071] In the present application, the specific decryption method is related to the encryption method, and the decryption rule can be configured in advance on the client side, or the decryption method can be negotiated in advance by the client and the server. The decryption method is not limited herein.

[0072] Step S110: generating a first check value for verifying the index file based on the index file.

[0073] The first check value can be generated in various ways. For example, if the server side generates the first check value by calculating the hash value of the index file, the client can calculate the hash value of the index file to obtain the first check value.

[0074] For example, in order to further improve the security of the index file, the server side in the present application can generate a first check value in combination with the content of the index file, the name of the video stream and the key. Correspondingly, the client can generate a first verification value for checking the index file according to the content of the index file, the name of the video stream and the key, using the message digest algorithm. By comparing whether the generated first check value and the received first check value are the same, it is determined whether the received index file has been tampered with.

[0075] The key is a parameter input when plaintext is converted into ciphertext or ciphertext is converted into plaintext, which can effectively protect the transmitted data. The key in the present application is agreed in advance by the server and the client. For example, the key can be a pre-set string, or a dynamically updated string between the server and the client. In the present application, the setting of the key is not limited.

[0076] Further, the present application can also determine whether the video data of the video needs to be checked by the server according to the importance of the video. Before generating the first verification value, it is also necessary to determine whether the index file has a tamper-proof identifier. If the index file does not have a tamper-proof identifier, it means that the data of the video does not need to be checked, and therefore the client can directly request the video stream segments from the server. On the contrary, if the index file has a tamper-proof identifier, the first verification value needs to be generated, and the first verification value of the index file is compared with the first check value to determine whether the index file has been tampered with.

[0077] Step S120, if the first check value is the same as the first verification value, the video stream segments are requested from the server based on the network address of the video stream segments.

[0078] When the first check value is the same as the first verification value, it means that the received index file has not been tampered with, and therefore the data of the video stream segments can be obtained based on the network address of the video stream segments in the index file.

[0079] Correspondingly, when the first check value is different from the first verification value, it means that the received index file is not the original index file generated by the server, i.e. the content of the received index file has been tampered with. After the content of the index file is tampered with, the network addresses of the video segments indicated in the index file are also wrong, so that the client obtains video data that does not belong to the video based on the index file, resulting in incorrect or abnormal video data playback.

[0080] Further, when the first verification value is different from the first check value, prompt information for prompting that the video stream segments have data abnormalities is output. The prompt information can be output in various ways, such as displaying the words "unable to play", displaying warning information that the video may have been tampered with, etc.

[0081] It can be understood that the at least one video stream segment in the video file of the video has a sequence order, and therefore, the application can determine the video stream segment to be requested in sequence according to the sequence order of the at least one video stream segment, and request the video stream segment from the server. Of course, the application does not limit the specific request process of the client for requesting the video stream segment.

[0082] It should be noted that since there can be multiple video stream segments in the video file, the action of requesting the video stream segment from the server can be performed multiple times until all video stream segments in the video file are requested by the client.

[0083] Step S130, cache the data of the video stream segment transmitted by the server.

[0084] The server finds the corresponding video stream segment according to the network address of the video stream segment, and transmits the video stream segment to the client in the form of a video stream. During the transmission of the data by the server, the client caches the data belonging to the video stream segment, so that when the data amount of the cached data reaches a condition, the subsequent operation is performed.

[0085] Step S140, if it is confirmed based on the verification reference information that the data amount of the cached video stream segment reaches the target data amount of one logical segment, generate a second verification value of the logical segment according to the cached data of the logical segment.

[0086] The verification reference information can include information for confirming each logical segment to be verified in the video stream segment, and therefore, each logical segment in the video stream segment can be determined based on the verification reference information.

[0087] In the application, one video stream segment can be divided into one or more logical segments, which are not obtained by actually dividing the video stream segment, but are only logically divided into small segments.

[0088] The verification reference information can indicate the positions of each logical segment in the video stream segment in various forms, and therefore, the specific information contained in the verification reference information can also have various possibilities. For example, the verification reference information can include the start time point and the end time point of each logical segment in the video stream segment.

[0089] In an optional manner, the verification reference information can include a verification level, a file size of the video stream segment, and a file duration of the video stream segment.

[0090] The check level is used to represent the division manner of each logical segment in the video stream segment. Different check levels can be set according to the importance of the video file. The higher the level is, the more logical segments the video file is divided into, and the more accurate the check is. In actual application, a field can be used in the index file to represent the check field, for example, the EXT-X-CHECK-LEVEL field can be used to record the check level.

[0091] The file size of the video stream segment reflects the data size of the video stream segment, and the file duration of the video stream segment is the overall duration of the video stream segment.

[0092] In this application, the client can determine the division manner of each logical segment in the video stream segment through the check level, and the determined division manner can be used to determine each logical segment in the video stream segment. On this basis, the client determines the target data size of each logical segment in the video stream segment according to the file size of the video stream segment and the file duration of the video stream segment.

[0093] It can be understood that the check level in the video stream segment is used to represent the division manner of each logical segment in the video stream segment. Based on this, the size of each logical segment in the video stream segment, i.e. the target data size of the logical segment, can be determined in combination with the check level. In order to distinguish, the target data size of the logical segment is referred to as the target data size. Therefore, based on the target data size of each logical segment, it can be determined whether the data size of the buffered video stream segment reaches the target data size of a logical segment, so that it can be determined whether the data of a logical segment in the video stream segment has been buffered.

[0094] In combination with Figure 2 , it is explained how to determine the division manner of each logical segment in the video stream segment by using the check level, and then divide each logical segment. As shown in Figure 2 , since the higher the check level is, the more accurate the check is, in the example, the check level is 4, and correspondingly, the video stream segment is divided into 4 logical segments, and then each logical segment is checked.

[0095] Correspondingly, when the client confirms that the data size of the buffered video stream segment reaches the target data size of a logical segment, the data of the buffered logical segment can be verified. The data of the logical segment can be verified by generating a second verification value of the logical segment.

[0096] In an optional manner, the verification data used to verify the logical segment can be obtained based on the end position of the logical segment. The second verification value of the logical segment is generated based on the obtained verification data.

[0097] The verification data can be obtained by using the end position of the logical segment as a reference and acquiring a set amount of data received after the end position of the logical segment; or it can be obtained by using the end position of the logical segment as a reference and acquiring a set amount of data already cached before the end position of the logical segment. The set amount of data can be set according to actual conditions, such as 1KB or 2KB. This application does not impose any restrictions on the set amount of data.

[0098] For example: Figure 2 As shown, when the cached video stream segment data is logical segment 2, the verification data is obtained from the end position of logical segment 2, i.e., end position 2. The data 1KB after end position 2 can be obtained as the verification data.

[0099] There are several ways to generate the second checksum of logical segments using verification data. This application introduces one optional method: the client first calculates the checksum of the verification data to obtain the checksum result. The checksum operation is used to verify whether the received data is correct. When performing the checksum operation at the receiving end, the content to be verified is treated as a number in 16-bit units, and binary one's complement summation is performed sequentially. Next, a shift operation is performed on the checksum result to obtain the second verification value.

[0100] For example, perform a checksum calculation on 1KB of verification data to obtain a 2Byte checksum result. Then, shift the checksum result 8 bits to the right to obtain 1Byte of data, which is the second verification value.

[0101] Furthermore, the verification reference information in this application may also include a verification initiation identifier. This identifier is used to determine whether anti-tampering verification is enabled for the video stream segment. This initiation identifier can be represented by a field in the index file, such as the EXT-X-CHECK field. When the EXT-X-CHECK field value is 0, it indicates that the video stream segment does not require verification, and the client directly outputs the cached video stream segment data to the player for rendering. When the EXT-X-CHECK field value is 1, it indicates that the video stream segment requires verification, and the client needs to decrypt the verification value information of the video stream segment.

[0102] Step S150: If the second verification value of the logical segment is the same as the second check value of the logical segment, output the cached data of the logical segment to play the data of the logical segment.

[0103] The second verification value of the logical segment is compared with the second check value of the logical segment decrypted from the check value information, so as to determine whether the data of the logical segment is tampered with. When the second verification value of the logical segment is different from the second check value, it indicates that the data of the logical segment is tampered with or abnormal.

[0104] As an optional mode, when the second verification value is different from the second check value, the client can output a data abnormality prompt.

[0105] When the second verification value of the logical segment is the same as the second check value, it indicates that the data of the logical segment is normal, and then the client outputs the buffered data of the logical segment for playing.

[0106] The client outputs the buffered logical segment to the player, which can be buffering the verified logical segment into a playing queue. If the current data to be played by the player is the logical segment at this moment, the logical segment can be played. If the video data before the logical segment is being played at this moment, the logical segment needs to be played after the playing time of the video segment is reached.

[0107] The scheme of the present application generates the first verification value based on the index file of the video, and verifies that the first verification value is consistent with the received first check value, and then requests the video stream segment of the video from the server, so as to reduce the error video stream caused by the tampering of the index file. On this basis, whenever the data amount of the video stream segment obtained from the server reaches the target data amount of a logical segment, the second verification value of the logical segment is generated based on the buffered data of the logical segment, and when the second verification value is verified to be the same as the second check value of the logical segment in the index file, the data of the logical segment can be outputted, so that the video stream segment does not need to be parsed and played after the entire video stream segment is downloaded. The data of a logical segment in the video stream segment can be played after the safety of the data of the logical segment is verified, so that the video can be played while the video data is checked during the transmission of the video stream, the waiting time for playing the video is reduced, and the playing speed is improved.

[0108] In the present application, considering that the file size of the video stream segment is not an integer multiple of the unit time, and the file duration of the video stream segment is not necessarily an integer multiple of the data unit, in order to more reasonably determine the target data amount of the logical segment in the video stream segment, an implementation mode for determining the target data amount of the logical segment is taken as an example for description. As shown in FIG. 1, Figure 3 FIG. 2 shows a flowchart for determining the target data amount of the logical segment in the present application, which can include the following steps:

[0109] Step S200, determining a target time length of the video stream slice according to a file time length of the video stream slice and a set unit time.

[0110] The unit time can be set according to actual needs of the video stream slice, for example, the unit time can be one second, one minute, etc. In actual application, the unit time in the logical segment in the video stream slice is usually set as a second, therefore, in order to facilitate division of the logical segment, the unit time of the video stream slice is also set as a second.

[0111] Specifically, when the file time length of the video stream slice is an integer multiple of the unit time, the file time length of the video stream slice is directly set as the target time length. When the file time length of the video stream slice is not an integer multiple of the unit time, the target time length is set as an integer multiple of the unit time and a maximum time length not exceeding the file time length of the video stream slice.

[0112] For example, the file time length of the video stream slice is 1 hour 5 minutes and 6 seconds, and the target time length of the video stream slice is 1 hour 5 minutes and 6 seconds. Or, the file time length of the video stream slice is 1 hour 5 minutes and 6 seconds and 20 milliseconds, and the target time length of the video stream slice is 1 hour 5 minutes and 6 seconds.

[0113] Step S210, determining a target file quantity corresponding to the video stream slice based on the target time length and a file size of the video stream slice.

[0114] The target file quantity is not less than a file data quantity per second in the video stream slice and is a minimum data quantity of a data quantity unit. The file of the video stream slice can also be set as a corresponding data quantity unit according to actual needs, for example, MB, KB, etc. In this application, the data quantity unit can be set according to actual needs, which is not limited.

[0115] Specifically, according to the target time length and the file size of the video stream slice, a file data quantity per second in the video stream slice can be calculated. When the file data quantity per second is an integer multiple of the data quantity unit, the file data quantity is directly set as the target file quantity. When the file data quantity per second is not an integer multiple of the data quantity unit, the target file quantity is set as a minimum data quantity not less than the file data quantity and an integer multiple of the data quantity unit.

[0116] Step S220, determining a quantity of sampling points per second in the video stream slice based on a check level.

[0117] The check level represents the quantity of sampling points per second in the video stream slice, therefore, the video stream slice can be divided into at least one logical segment by using the sampling points.

[0118] Step S230, determining the target data amount of each logical segment in the video stream slice based on the target file quantity and the number of sampling points.

[0119] In an embodiment, the number of sampling points can be determined based on the verification level, and the number of logical segments in the video stream slice division is further determined. Based on the obtained target file quantity, the target data amount of each logical segment in the video stream slice can be determined.

[0120] In this application, the file size of the video stream slice and the file duration of the video stream slice are rounded by setting the file size of the video stream slice per unit time and the data amount unit of the file duration of the video stream slice, so as to more reasonably determine the target data amount of the logical segment, and make the calculation of the logical segment more orderly and reasonable.

[0121] In this application, the server and the client both use the method of the embodiment to determine the target data amount of the logical segment, so that the logical segment determined by the client and the server is the same, and the generation method of the second verification value generated by the server and the second verification value generated by the client is consistent, and then the second verification value and the second check value can be used to verify whether the data of the logical segment is tampered. Figure 2

[0122] Next, the video file transmission method of the application embodiment is introduced from the perspective of the server, and the video file transmission method is described in combination with the method of the server shown in FIG. 8. The scheme of this embodiment can be applied to a server, which can be a source server of a video, and can also be a content distribution node in a content distribution network (Content Delivery Network, CDN) for storing a video. The method of this embodiment can include: Figure 4

[0123] Step S300, obtaining a video file request sent by a client, the video file request containing information of a requested video.

[0124] In this embodiment, the server receives a video file request sent by a client, and the request contains information of a requested video, such as the name of the video, the address of the video, etc., so that the server can find the video file.

[0125] Step S310, obtaining an index file of the video and a first check value for checking the index file based on the video file request.

[0126] In this embodiment, the index file includes the network address of each video stream slice in the video stream file of the video, the check value information, and the check reference information.

[0127] ​​Specifically, the index file, the first check value and the information contained in the index file have been introduced in the foregoing, and will not be described herein again.

[0128] In order to improve the security of the transmitted index file, the source server of the present application can generate a first check value for checking whether the index file is tampered. The first check value can be generated based on the content of the index file, the name of the video stream and the key. The key has been introduced in the foregoing, and will not be described herein again.

[0129] The check value information contained in the index file is generated by the source server, and is used for checking whether the video stream segment is tampered.

[0130] For example, the source server can divide the video stream segment into a plurality of logical segments, and generate a second check value corresponding to each logical segment based on the data of the logical segment. Correspondingly, the check value information can include the second check value corresponding to each logical segment in the video stream segment.

[0131] In a possible implementation, the check value information can be an encrypted array. Specifically, the check value information can be obtained by sequentially storing the generated second check values of the logical segments in the video stream segment into an array, and encrypting the array.

[0132] In the present application, the implementation process of generating the second check value is the same as that of the second verification value, and will not be described herein again.

[0133] The server can be a source server or a content distribution node. The content distribution node can cache data such as videos or index files from the source server, and can provide a nearby response for a terminal of an Internet user.

[0134] Specifically, when the server is a content distribution node, if the content distribution node stores the video file requested by the client, the index file and the first check value for checking the index file are obtained at the content distribution node. If the content distribution node does not store the video file, the index file and the first check value for checking the index file are obtained from the source server. At the same time, the content distribution node caches the index file of the video and the first check value for checking the index file, so that when the client requests the video again, the content distribution node can directly send the related information of the video.

[0135] In step S320, the index file and the first check value are returned to the client.

[0136] After obtaining the index file and the first check value, the server returns the index file and the first check value to the client according to the request of the client, so that the client can perform checking. In the present application, the specific manner of returning information is not limited.

[0137] Step S330, obtaining a video stream request sent by the client, the video stream request being used to request data of a video stream segment.

[0138] Wherein, since one video is composed of several video stream segments, when requesting a video, the client requests the video stream segments from the server in sequence according to the network addresses of the video stream segments contained in the index file.

[0139] Step S340, transmitting data of the video stream segment to the client.

[0140] Wherein, the server acquires the corresponding video stream segment according to the network address of the video stream segment in the request of the client and returns data of the video stream segment to the client.

[0141] In the present application, from the perspective of the server, the server sends the index file and the first check value used to check the index file to the client, and the check value information used to check the video stream segment is also included in the index file, which is beneficial to the client to check whether the data in the received index file and the video stream segment is correct.

[0142] The video file playing device provided by the embodiment of the present application is described below, and the video file playing device described below can be correspondingly referred to the video file playing method described above.

[0143] As shown in Figure 5 , a structural schematic diagram of the video file playing device in the present application is shown, and the video file playing device comprises:

[0144] The video acquisition unit 400 is configured to acquire, from the server, an index file of a video to be played and a first check value used to check the index file, the index file comprising: network addresses of video stream segments in a video stream file of the video, check value information and check reference information, the check value information of the video stream segment comprising: second check values of at least one logical segment corresponding to the video stream segment respectively;

[0145] The first verification value generation unit 410 is configured to generate, based on the index file, the first verification value used to verify the index file;

[0146] The video request unit 420 is configured to, if the first check value is the same as the first verification value, request the video stream segment from the server based on the network address of the video stream segment;

[0147] The video cache unit 430 is configured to cache data of the video stream segment transmitted by the server;

[0148] The second verification value generation unit 440 is configured to generate a second verification value of the logical segment according to the buffered data of the logical segment if it is confirmed that the data amount of the buffered video stream segment reaches the target data amount of one logical segment based on the check reference information.

[0149] The output data unit 450 is configured to output the buffered data of the logical segment to play the data of the logical segment if the second verification value of the logical segment is the same as the second check value of the logical segment.

[0150] Optionally, the check reference information in the index file acquired by the video acquisition unit can include: a check level, a file size of the video stream segment and a file time length of the video stream segment, and the check level is used to represent a division manner of each logical segment in the video stream segment.

[0151] On this basis, the video file playing device provided by the application further includes:

[0152] The target data amount determination unit is configured to determine the target data amount of each logical segment in the video stream segment based on the check level, the file size of the video stream segment and the file time length of the video stream segment before the second verification value generation unit generates the second verification value of the logical segment.

[0153] Correspondingly, the second verification value generation unit can include:

[0154] The verification data acquisition unit is configured to acquire verification data of the logical segment from the buffered data of the video stream segment based on the end position of the logical segment if it is confirmed that the data amount of the buffered video stream segment reaches the target data amount of one logical segment based on the target data amount of each logical segment.

[0155] The second verification value generation sub-unit is configured to generate the second verification value based on the verification data corresponding to the logical segment.

[0156] Optionally, the check level represents the number of sampling points per second in the video stream segment, and the video stream segment is divided into at least one logical segment by the sampling points.

[0157] On this basis, the target data amount determination unit can include:

[0158] The target time length determination unit is configured to determine a target time length corresponding to the video stream segment based on the file time length of the video stream segment and a set unit time, and the target time length is an integer multiple of the unit time and is not more than the maximum time length of the file time length of the video stream segment.

[0159] The file data amount determination unit is configured to determine a file data amount per second in the video stream segment based on the target time length and the file size of the video stream segment.

[0160] a target file quantity determination unit configured to determine a target file quantity corresponding to the video stream slice based on the file data quantity, the target file quantity being a minimum data quantity that is not less than the file data quantity and is an integer multiple of a set data quantity unit;

[0161] a sample point quantity determination unit configured to determine a quantity of sample points per second in the video stream slice based on the verification level;

[0162] a target data quantity determination unit configured to determine a target data quantity of each logical segment in the video stream slice based on the target file quantity and the quantity of sample points.

[0163] Optionally, the index file obtained by the video acquisition unit has the check value information being an encrypted array.

[0164] On this basis, the video file playing device further comprises:

[0165] a decryption array unit configured to decrypt the array included in the check value information before the second verification value generation unit generates the second verification value of the logical segment;

[0166] a second check value extraction unit configured to extract the second verification value corresponding to each logical segment in the video stream slice from the array.

[0167] Finally, it should be noted that in this document, relational terms such as first and second and the like can only be used to distinguish one entity or action from another entity or action, without necessarily requiring or implying any such actual relationship or order between such entities or actions. Moreover, the terms "comprises", "comprising", or any other variations thereof, are intended to cover a non-exclusive inclusion, so that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without more limitations, an element defined by the statement "comprising a" does not exclude the existence of additional identical elements in the process, method, article, or apparatus including the element.

[0168] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the difference from other embodiments, and the same or similar parts between the various embodiments can be referred to each other.

[0169] The foregoing description of the disclosed embodiments enables a person skilled in the art to make or use the application. Modifications of these embodiments will occur to persons of skill in the art, and that the generic principles defined herein can be applied to other embodiments without departing from the spirit or scope of the application. Therefore, the present application 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

1. A method for playing video files, characterized in that, Applied to the client side, including: The index file of the video to be played and a first check value for verifying the index file are obtained from the server. The index file includes: the network address, check value information and check reference information of each video stream segment in the video stream file of the video. The check value information of the video stream segment includes: the second check value of each of the at least one logical segment corresponding to the video stream segment. Based on the index file, a first verification value is generated for verifying the index file; If the first check value is the same as the first verification value, request the video stream segment from the server based on the network address of the video stream segment; Cache the video stream segments transmitted by the server; If, based on the verification reference information, it is confirmed that the amount of data in the cached video stream segment reaches the target amount of a logical segment, a second verification value for the logical segment is generated according to the data in the cached logical segment. If the second verification value of the logical segment is the same as the second check value of the logical segment, output the cached data of the logical segment to play the data of the logical segment; The verification reference information includes: verification level, file size of the video stream segment, and file duration of the video stream segment. The verification level is used to characterize the division method of each logical segment in the video stream segment. Before generating the second verification value for the logical segment, the method further includes: Based on the verification level, the file size of the video stream segment, and the file duration of the video stream segment, the target data volume of each logical segment in the video stream segment is determined. If, based on the verification reference information, it is confirmed that the amount of data in the cached video stream segment reaches the target data amount of a logical segment, then, based on the data of the cached logical segment, a second verification value for the logical segment is generated, including: If, based on the target data volume of each logical segment, it is confirmed that the data volume of the cached video stream segment reaches the target data volume of a logical segment, then, taking the end position of the logical segment as a reference, verification data for verifying the logical segment is obtained from the cached video stream segment data. A second verification value is generated based on the verification data corresponding to the logical segments. The step of obtaining verification data for verifying the logical segment from the cached video stream segment data, based on the end position of the logical segment, includes: Based on the end position of the logical segment, the verification data of the data volume is set after obtaining the end position of the logical segment from the cached video stream segment data; The verification level represents the number of sampling points per second in the video stream segment, and the video stream segment is divided into at least one logical segment by the sampling points; The determination of the target data volume for each logical segment in the video stream segment based on the verification level, the file size of the video stream segment, and the file duration of the video stream segment includes: Based on the file duration of the video stream segment and the set unit time, the target duration corresponding to the video stream segment is determined. The target duration is an integer multiple of the unit time and does not exceed the maximum duration of the file duration of the video stream segment. Based on the target duration and the file size of the video stream segment, determine the amount of file data per second in the video stream segment; Based on the file data volume, the number of target files corresponding to the video stream segment is determined. The number of target files is the minimum data volume that is not less than the file data volume and is an integer multiple of the set data volume unit. Based on the verification level, determine the number of sampling points per second in the video stream segment; Based on the number of target files and the number of sampling points, the target data volume of each logical segment in the video stream is determined.

2. The method according to claim 1, characterized in that, The step of generating a first verification value for verifying the index file based on the index file includes: Based on the content of the index file, the video stream name of the video, and the key, a first verification value for verifying the index file is generated using an information digest algorithm. The key is a key pre-agreed upon by the server and the client.

3. The method according to claim 1, characterized in that, The verification value information is an encrypted array; Before generating the second verification value, the following steps are also included: Decrypt the array contained in the verification value information; Extract the second check value corresponding to each logical segment in the video stream segment from the array.

4. The method according to claim 1, characterized in that, Also includes: If the first check value and the first verification value are different, output a prompt message indicating that there is a data anomaly in the video stream segment.

5. A method for transmitting video files, characterized in that, Applied to a server, the method includes: Obtain a video file request sent by the client, wherein the video file request indicates information about a requested video; Based on the video file request, an index file of the video and a first checksum for verifying the index file are obtained. The index file includes: the network address, checksum information, and checksum reference information of each video stream segment in the video stream file of the video. The checksum reference information includes: checksum level, file size of the video stream segment, and file duration of the video stream segment. The checksum level is used to characterize the division method of each logical segment in the video stream segment. The client divides the video stream into several logical segments and generates a second verification value corresponding to each logical segment based on the data in each segment. Specifically, the target data volume for each logical segment within the video stream is determined based on the verification level, the file size of the video stream segment, and the file duration of the video stream segment. If, based on the target data volume of each logical segment, it is confirmed that the cached data volume of the video stream segment reaches the target data volume of a logical segment, verification data for verifying the logical segment is obtained from the cached data of the video stream segment, using the end position of the logical segment as a reference. A second verification value is generated based on the verification data corresponding to the logical segment. Returning the index file and the first verification value to the client; wherein, the step of obtaining verification data for verifying the logical segment from the cached video stream segment data based on the end position of the logical segment includes: obtaining verification data with a set data volume after the end position of the logical segment from the cached video stream segment data based on the end position of the logical segment; wherein, the verification level characterizes the number of sampling points per second in the video stream segment, and the video stream segment is divided into at least one logical segment by the sampling points; the step of determining the target data volume of each logical segment in the video stream segment based on the verification level, the file size of the video stream segment, and the file duration of the video stream segment includes: based on the video stream... Based on the file duration of the video stream segments and the set unit time, the target duration corresponding to each video stream segment is determined. The target duration is an integer multiple of the unit time and does not exceed the maximum duration of the video stream segment's file duration. Based on the target duration and the file size of the video stream segment, the amount of file data per second in the video stream segment is determined. Based on the amount of file data, the target number of files corresponding to the video stream segment is determined. The target number of files is a minimum amount of data that is not less than the amount of file data and is an integer multiple of the set data amount unit. Based on the verification level, the number of sampling points per second in the video stream segment is determined. Based on the number of target files and the number of sampling points, the target data amount of each logical segment in the video stream segment is determined. Obtain a video stream request sent by the client, the video stream request being used to request data for video stream segments; The video stream segments are transmitted to the client.

6. The method according to claim 5, characterized in that, When the server is a content distribution node, obtaining the index file of the video and a first checksum for verifying the index file includes: If the content distribution node stores the index file of the video and the first verification value of the index file, it sends the stored index file of the video and the first verification value to the client. If the content distribution node does not store the video's index file and the first verification value of the index file, it obtains the video's index file and the first verification value of the index file from the video's source server, returns the video's index file and the first verification value of the index file to the client, and stores the video's index file and the first verification value of the index file in the content distribution node.

7. A video file playback device, characterized in that, include: The video acquisition unit is used to acquire an index file of the video to be played and a first check value for verifying the index file from the server. The index file includes: the network address, check value information and check reference information of each video stream segment in the video stream file of the video. The check value information of the video stream segment includes: the second check value of each of the at least one logical segment corresponding to the video stream segment. The first verification value generation unit is used to generate a first verification value for verifying the index file based on the index file; A video request unit is configured to request a video stream segment from the server based on the network address of the video stream segment if the first verification value is the same as the first verification value. A video caching unit is used to cache the video stream segments transmitted by the server; The second verification value generation unit is used to generate a second verification value for the logical segment based on the data of the cached logical segment when it is confirmed based on the verification reference information that the amount of data of the cached video stream segment reaches the target amount of a logical segment. An output data unit is configured to output the cached data of the logical segment if the second verification value of the logical segment is the same as the second check value of the logical segment, so as to play the data of the logical segment. The verification reference information includes: verification level, file size of the video stream segment, and file duration of the video stream segment. The verification level is used to characterize the division method of each logical segment in the video stream segment. Before generating the second verification value for the logical segment, the method further includes: Based on the verification level, the file size of the video stream segment, and the file duration of the video stream segment, the target data volume of each logical segment in the video stream segment is determined. If, based on the verification reference information, it is confirmed that the amount of data in the cached video stream segment reaches the target data amount of a logical segment, then, based on the data of the cached logical segment, a second verification value for the logical segment is generated, including: If, based on the target data volume of each logical segment, it is confirmed that the data volume of the cached video stream segment reaches the target data volume of a logical segment, then, taking the end position of the logical segment as a reference, verification data for verifying the logical segment is obtained from the cached video stream segment data. A second verification value is generated based on the verification data corresponding to the logical segments. The step of obtaining verification data for verifying the logical segment from the cached video stream segment data, based on the end position of the logical segment, includes: Based on the end position of the logical segment, the verification data of the data volume is set after obtaining the end position of the logical segment from the cached video stream segment data; The verification level represents the number of sampling points per second in the video stream segment, and the video stream segment is divided into at least one logical segment by the sampling points; The determination of the target data volume for each logical segment in the video stream segment based on the verification level, the file size of the video stream segment, and the file duration of the video stream segment includes: Based on the file duration of the video stream segment and the set unit time, the target duration corresponding to the video stream segment is determined. The target duration is an integer multiple of the unit time and does not exceed the maximum duration of the file duration of the video stream segment. Based on the target duration and the file size of the video stream segment, determine the amount of file data per second in the video stream segment; Based on the file data volume, the number of target files corresponding to the video stream segment is determined. The number of target files is the minimum data volume that is not less than the file data volume and is an integer multiple of the set data volume unit. Based on the verification level, determine the number of sampling points per second in the video stream segment; Based on the number of target files and the number of sampling points, the target data volume of each logical segment in the video stream is determined.

Citation Information

Patent Citations

  • HLS streaming media transmission method and apparatus

    CN106686410A

  • Safe cross-platform video stream playing method

    CN111556340A