A method, computer program product and system for realizing simultaneous video recording and transmission
By splitting and uploading video data blocks in real time, calculating check values and generating complete video files, it solves the problem of poor video transmission timeliness, achieves fast and reliable video transmission, and reduces network pressure and storage requirements.
Patent Information
- Application Number
- CN202410796727.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-20
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2044-06-20
AI Technical Summary
The existing technology requires a long time to wait for uploading after video recording is completed, resulting in poor video transmission timeliness and requiring a large amount of local storage and computing resources.
By dividing the video stream into small data blocks in real time, and calculating the check value of each data block during the recording process, uploading it to the server in real time, calculating the check value again at the end of the recording, generating a complete video file and verifying its integrity. If consistent, the video transmission is completed.
It reduces the waiting time for transmission after video recording is completed, improves the timeliness of video recording and transmission, reduces network pressure, and allows real-time monitoring and error handling, avoiding the need to wait for complete video files to be uploaded.
Smart Images

Figure CN118368472B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of video transmission, and in particular to a method, a computer program product and a system for realizing simultaneous video recording and transmission. Background Art
[0002] In multimedia technology, especially in the scenario of processing high-resolution and long-duration video content, the core technical contradiction is how to efficiently process and transmit large amounts of video data while maintaining the continuity and integrity of the video content. Large-scale processing and transmission of video data not only places extremely high demands on computing resources and network bandwidth, but also must ensure that the video will not be interrupted or damaged during the upload process due to network fluctuations or device abnormalities. The existing technical solution is to use streaming media formats such as FLV to compress a series of media data and send the data in segments over the network.
[0003] However, due to untimely technology upgrades or security considerations, some industries can only support traditional media formats, but not streaming media file transmission and playback. This means that when users are performing services that require uploading videos, they can only record and save the video locally first, and then upload the complete video file after the recording is completed. The complete video file requires a large amount of local storage, and directly processing and transmitting the complete video file will cause a huge computing burden and network congestion, especially under limited resources and unstable network conditions. Therefore, dividing the video content into small data blocks for processing and transmission during the recording stage has become a more common video transmission solution in the industry. This solution can effectively control the size of each data block, facilitate parallel processing and storage, and reduce the pressure of network transmission. After the video file is recorded, part of the data content will be rewritten. Therefore, after the data block is transmitted, it is necessary to re-traverse the entire file locally in units of a certain data length, such as 8KByte, to find the changed data block, and then mark the data block to be updated in the message and indicate the offset of the data in the file through the message, and then upload the message signaling to inform the receiving end, and the receiving end updates the specified content in the file through the signaling. This block data transmission method still requires local storage of complete video files, and after local recording is completed, it takes a long time to traverse the entire file, and the timeliness of video transmission is poor. Summary of the invention
[0004] The technical problem to be solved by the present invention is how to reduce the transmission time required to wait after video recording is completed, and improve the timeliness of video recording and transmission.
[0005] In order to solve the above technical problems, the present invention provides a method for realizing simultaneous video recording and transmission, comprising the following steps:
[0006] During the video recording process, the real-time recorded video stream is segmented to obtain data blocks, and adjacent data blocks contain continuous video content; the checksum of each data block is calculated, and the data block is added to the upload queue; the server receives the data block;
[0007] When recording is finished, the local computer recalculates the checksum of each data block, and uploads the increment of the data block with the changed checksum and the checksum of the complete video file to the server; the server receives the updated data block, generates a complete video file and calculates its checksum; the server compares the received and calculated checksums, and if they are consistent, it considers that the video is received successfully and the video transmission is completed;
[0008] The complete video file includes file type ftyp, media data mdat and media information moov. Before calculating the check value of each data block, the data block where the media information moov is located and its length, as well as the data block where the length field of the media data mdat is located are uploaded to the server as data block increments. The server directly generates a complete video file with these uploaded data block increments.
[0009] Before video recording, the position of media data mdat is left vacant, and the file type ftyp of the empty data and the media information moov are placed according to the uploaded position; during video recording, the data blocks of each uploaded media data mdat are appended to the originally vacant position to achieve fast positioning of each data block.
[0010] The file type ftyp includes an encoding format, a file version and a compatible protocol, and the server reads the file type ftyp to match a decoding method.
[0011] In the process of segmenting the real-time recorded video stream, the data blocks are marked by timestamps and frame numbers.
[0012] Specifically, the data blocks are marked by timestamps and frame numbers. The segmented video data blocks are managed using a distributed file system, a unique identifier is assigned to each data block, and metadata information including data block size, start and end timestamps, and sequence tags are attached.
[0013] The server generating a complete video file means that the server reassembles scattered video data blocks into a complete video file in the order of timestamps and frame numbers.
[0014] Among them, generating a complete video file includes the following steps:
[0015] Sorting the video data blocks according to their receiving timestamps to form a preliminary video stream sequence;
[0016] If the timestamps are the same, the video data blocks are further sorted by frame number so that they are in the correct order;
[0017] Get the checksum of each data block and verify the integrity of the data block through the verification algorithm;
[0018] If the checksum indicates that the data block is erroneous, the error recovery information is used to repair the data;
[0019] Determine the data block size to parse out the start and end positions of each data block;
[0020] Parse the video and audio data of each data block through the encoding format information;
[0021] Determine audio and video synchronization information and adjust the synchronization of audio and video data;
[0022] Obtain user session identification information to distinguish and process data streams of different users;
[0023] Reassemble all checksum-repaired data blocks to form a complete video file.
[0024] The calculation of the check value refers to: calculating the check value by using the MD5 hash algorithm.
[0025] The present invention also provides a computer program product, including a computer program, which is executed by a processor to implement the steps of the method for recording and transmitting video simultaneously as described above.
[0026] The present invention also provides a video recording system, including a video recording module and a server that are communicatively connected to each other, and also includes a processor, in which the above-mentioned computer program product is stored.
[0027] The present invention has the following beneficial effects: in the process of real-time video recording on a video recording system, video recording and transmission are realized, the video content is synchronously uploaded to the server in the form of data blocks, and the check value of each data block is recorded. At the end of recording, the check value of each data block is calculated again, and the change of the check value indicates that the information of the data block has changed. The increment of the changed data block and the check value of the complete video file are uploaded to the server. The server receives the updated data block, generates a complete video file and calculates its check value. The server compares the two check values received and calculated, and if the two are consistent, it is considered that the video is successfully received, and the business background is notified to complete the video transmission, completing the business closed loop. The implementation method of the video recording and transmission reduces the need for one-time upload by uploading small data blocks in real time, reduces network pressure, and allows real-time monitoring and error handling of the upload process. After the video recording is completed, only the data block increment needs to be updated, and there is no need to wait until the video recording is completed before uploading the complete video file, which solves the timeliness problem of real-time recording and uploading. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 It is a flowchart of the steps of implementing a method for recording and transmitting a video at the same time.
[0029] Figure 2 It is a flow chart of the steps to generate a complete video file. DETAILED DESCRIPTION
[0030] The present invention is further described in detail below in conjunction with specific implementation methods.
[0031] The video recording system of this embodiment uses the software background of the financial system as the server, and the video device of the mobile terminal such as the user's mobile phone installed with the financial software or the local device terminal of the financial system as the video recording module, and the two realize mutual communication connection in a wireless or wired manner. The process of the user recording the video on the financial software and uploading it to the server is as follows: Figure 1 The implementation method of recording and transmitting the video at the same time is implemented, and the specific instructions are as follows.
[0032] The user records a video in MP4 format on the financial software of the terminal and uploads it to the server. The video file of this embodiment is a structured MP4 file. The complete video file includes the file type ftyp, media data mdat and media information moov:
[0033] The file type ftyp records the MP4 format, including basic information such as encoding format, file version and compatible protocol. The server reads the file type ftyp to match the decoding method.
[0034] The media data mdat records the video media information (the size of mdat is often very large, almost equal to the total size of MP4);
[0035] The media information moov exists like a search table, which records where the data corresponding to each frame is, etc.
[0036] After the server receives the video upload request in MP4 format from the terminal, before recording the video, the server first leaves the position of the media data mdat vacant, and places the file type ftyp of the empty data and the media information moov according to the position to be uploaded.
[0037] During the video recording process, the financial software divides the real-time recorded video stream into data blocks. Adjacent data blocks contain continuous video content to avoid the phenomenon of screen breakage in the complete video file. The financial software calculates the check value of each data block in real time, adds the data block to the upload queue, and the server receives the data block and generates a complete video file after the video recording is completed. Before calculating the check value of each data block, the financial software first uploads the data block where the media information moov is located and its length, as well as the data block where the length field of the media data mdat is located as a data block increment to the server. The server directly generates a complete video file with the uploaded data blocks and these uploaded data block increments, without waiting for the video recording to end before uploading the complete video file, which solves the timeliness problem of real-time recording and uploading. Synchronously, at the end of recording, the local recalculates the check value of each data block, and uploads the data block increment with the changed check value and the check value of the complete video file to the server; the server receives the updated data block, generates a complete video file and calculates its check value; the server compares the received and calculated two check values. If the two are consistent, it is considered that the video is successfully received and the final video transmission is completed. The method for implementing simultaneous video recording and transmission of this embodiment not only ensures the integrity, security and continuity of video data, but also greatly improves the efficiency and reliability of video data processing.
[0038] The MP4 file playback process in the prior art is: 1. Read the ftype part to determine the decoding method; 2. Find and read the moov part to obtain information such as video duration. 3. Read the corresponding media information from mdat according to the search information of moov, and then play it. Therefore, if you want to play MP4, you must let the player read ftyp and moov first, and the real-time recorded video file will generate the moov file at the end, resulting in moov must be after mdat. In this case, you need to wait until all tvo-mdat-moov files are downloaded, which is equivalent to downloading the entire MP4 before it can be played normally.
[0039] MP4 files are composed of multiple Boxes. Boxes can be understood as a structural specification. In addition, Boxes can be nested layer by layer, such as there are many Boxes in Moov. During the upload process, the mdat part is left empty first, and the ftyp and moov parts are placed according to the upload location. The segmented files of mdat are continuously uploaded, such as multiple Boxes, and appended to the specified location. Each Box can be quickly located. The update rules of MP4 are fixed. The content that changes is the length field of mdatBox, the length of moovBox, and the length of the sub-Box. For MP4, the length of mdat and the entire moov can be directly updated to reduce the time-consuming query of changed data blocks.
[0040] In the process of segmenting the real-time recorded video stream, the data blocks are marked by timestamps and frame numbers. The segmented video data blocks are managed using a distributed file system, each data block is assigned a unique identifier, and metadata information including the data block size, start and end timestamps, and sequence markers is attached. After the video recording is completed, the server reassembles the scattered video data blocks in the order of timestamps and frame numbers to generate a complete video file. The steps for generating a complete video file are shown in the flow chart. Figure 2 , including the following steps:
[0041] Sorting the video data blocks according to their receiving timestamps to form a preliminary video stream sequence;
[0042] If the timestamps are the same, the video data blocks are further sorted by frame number so that they are in the correct order;
[0043] Get the checksum of each data block and verify the integrity of the data block through the verification algorithm;
[0044] If the checksum indicates that the data block is erroneous, the error recovery information is used to repair the data;
[0045] Determine the data block size to parse out the start and end positions of each data block;
[0046] Parse the video and audio data of each data block through the encoding format information;
[0047] Determine audio and video synchronization information and adjust the synchronization of audio and video data;
[0048] Obtain user session identification information to distinguish and process data streams of different users;
[0049] Reassemble all checksum-repaired data blocks to form a complete video file.
[0050] After the video file is loaded into the system, the system automatically performs the segmentation operation and cuts the video into multiple data blocks according to the preset time interval. After each data block is segmented, the system generates a unique identifier corresponding to each video data block through an algorithm. The specific size of each data block is obtained, and the system reads the file attributes after segmentation to determine the number of bytes occupied by the data block. The system analyzes each video data block, automatically extracts its start and end timestamps, and locates the specific position of the data block in the original video. For the sequence mark, the system sorts according to the start timestamp of the video data block to ensure the order of the data block during processing and storage. The generated unique identifier, data block size, start and end timestamps, and sequence mark are integrated into a metadata information package and associated with the corresponding video data block. Each video data block and its metadata information are uploaded to the system through the API of the distributed file system to ensure the consistency and correspondence between the data block and the metadata. In the distributed file system, each uploaded video data block is indexed, and the unique identifier is used as a keyword to facilitate quick retrieval. The redundant storage mechanism of the distributed file system is used to back up the uploaded data blocks to increase the stability and reliability of the data.
[0051] Among them, before the data block is added to the upload queue, the check value of each data block is calculated using the MD5 hash algorithm. The generated check value is used to verify the data integrity and ensure that the data has not been tampered with or damaged during network transmission.
[0052] According to the original content of the data block, the MD5 hash algorithm is used to process the data to obtain a 128-bit hash value. If the MD5 hash value of the data block has been generated, this hash value is stored in the database together with the data block ID for subsequent integrity verification. When the data block is ready to be uploaded, the corresponding MD5 hash value is obtained by querying the database and used to compare with the uploaded data. If the upload is completed, the data block content returned by the server is obtained, and its hash value is calculated again using the MD5 hash algorithm. If the calculated MD5 hash value matches the previously stored hash value, it is determined that the data block has not been tampered with or damaged during the upload process. If the hash values match, the upload status of the data block is updated to "successful" and the verification status is marked as "passed". If the hash values do not match, the upload status of the data block is updated to "failed" and the verification status is marked as "failed". When the verification status is "failed", the data block is automatically re-added to the upload queue and waits for the system to try to upload again. For data blocks that fail to upload continuously, the number of failures is recorded, and after reaching the predetermined threshold, an alarm is triggered to notify the system administrator to check.
[0053] Sort the video data blocks according to the receiving timestamp to form a preliminary video stream sequence. If the timestamps are the same, further sort the video data blocks by frame number so that they are arranged in the correct order. Get the checksum of each data block and verify the integrity of the data block through the checksum algorithm. If the checksum indicates that the data block is wrong, use the error recovery information to repair the data. Determine the data block size to parse the start and end position of each data block. Parse the video and audio data of each data block through the encoding format information. Determine the audio and video synchronization information and adjust the synchronization of audio and video data. Get user session identification information to distinguish and process the data streams of different users. Reassemble all the checksum-repaired data blocks to form a complete video file.
[0054] The implementation method of the video recording and transmission realizes the video recording and transmission during the real-time video recording process, synchronously uploads the video content in the form of data blocks to the server, and records the check value of each data block. By uploading small data blocks in real time, the need for one-time upload is reduced, the network pressure is reduced, and the upload process is allowed to be monitored and handled in real time. At the end of recording, the check value of each data block is calculated again, and the change in the check value indicates that the information of the data block has changed. The increment of the changed data block and the check value of the complete video file are uploaded to the server. The server receives the updated data block, generates a complete video file and calculates its check value. The server compares the two check values received and calculated. If the two are consistent, it is considered that the video is successfully received, and the business background is notified to complete the video transmission, completing the business closed loop. After the video recording is completed, only the data block increment needs to be updated, and there is no need to wait until the video recording is completed before uploading the complete video file, which solves the timeliness problem of real-time recording and uploading.
[0055] The above is only an implementation method of the invention, and does not limit the scope of patent protection. Those skilled in the art can make non-substantial changes or substitutions based on the invention, which still fall within the scope of patent protection.
Claims
1. A method for recording and transmitting a video simultaneously, comprising the following steps: During the video recording process, the real-time recorded video stream is segmented to obtain data blocks, and adjacent data blocks contain continuous video content; Calculate the checksum of each data block and add the data block to the upload queue; The server receives the data block; When recording is finished, the local computer recalculates the checksum of each data block, and uploads the data block increment with the change in checksum value and the checksum of the complete video file to the server; The server receives the updated data block, generates a complete video file and calculates its checksum; The server compares the received and calculated check values. If the two check values are consistent, the video is considered to be successfully received and the video transmission is completed. Its characteristic is that the complete video file includes file type ftyp, media data mdat and media information moov, Before video recording, the server leaves the location of media data mdat empty, and places the file type ftyp of the empty data and media information moov according to the location to be uploaded; During the video recording process, before calculating the checksum of each data block, the data block containing the media information moov and its length, as well as the data block containing the length field of the media data mdat are first uploaded to the server as data block increments. The server appends the uploaded data blocks of each media data mdat to the originally vacant positions to achieve fast positioning of each data block; the server generates a complete video file with the received data blocks and these uploaded data block increments.
2. The method for realizing simultaneous video recording and transmission according to claim 1, characterized in that: The file type ftyp includes an encoding format, a file version and a compatible protocol, and the server reads the file type ftyp to match a decoding method.
3. The method for realizing simultaneous video recording and transmission according to claim 1, characterized in that: During the segmentation of the live recorded video stream, the data blocks are marked by timestamps and frame numbers.
4. The method for realizing simultaneous video recording and transmission according to claim 3, characterized in that: The method of marking data blocks by timestamp and frame number specifically includes: managing the segmented video data blocks by using a distributed file system, assigning a unique identifier to each data block, and attaching metadata information including data block size, start and end timestamps, and sequence mark.
5. The method for realizing simultaneous video recording and transmission according to claim 3, characterized in that: The server generates a complete video file, which means that the server reassembles scattered video data blocks into a complete video file in the order of timestamps and frame numbers.
6. The method for realizing simultaneous video recording and transmission according to claim 3, characterized in that: Generating a complete video file includes the following steps: Sorting the video data blocks according to their receiving timestamps to form a preliminary video stream sequence; If the timestamps are the same, the video data blocks are further sorted by frame number so that they are in the correct order; Get the checksum of each data block and verify the integrity of the data block through the verification algorithm; If the checksum indicates that the data block is erroneous, the error recovery information is used to repair the data; Determine the data block size to parse out the start and end positions of each data block; Parse the video and audio data of each data block through the encoding format information; Determine audio and video synchronization information and adjust the synchronization of audio and video data; Obtain user session identification information to distinguish and process data streams of different users; Reassemble all checksum-repaired data blocks to form a complete video file.
7. The method for realizing simultaneous video recording and transmission according to claim 1, characterized in that: Calculating the check value means: calculating the check value through the MD5 hash algorithm.
8. A computer program product comprising a computer program, characterized in that The computer program is executed by a processor to implement the steps of the method for recording and transmitting video simultaneously as described in any one of claims 1 to 7.
9. A video recording system, characterized in that: It includes a video recording module and a server that are communicatively connected to each other, and also includes a processor, in which the computer program product as claimed in claim 8 is stored.
