Method and system for preventing frame loss during 4KP60 video source disk recording
Patent Information
- Application Number
- CN202411534536.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-01-28
AI Technical Summary
The prior art is difficult to realize disk recording without frame dropping under the conditions of the highest input resolution of 3840x2160 and the highest frame rate of 60fps (4KP60), especially when the maximum 80Mbps bit rate, there is frame dropping.
By increasing the recording cache queue, dynamic FAT32 file system adaptation, open the file in advance, automatically switch the disk, set a stable rate to write disk, and increase the disk writing into the configuration of each data to ensure the stable writing of the data.
有效解决了4KP60视频源录制丢帧的问题,保障了文件录制的连续性和更换磁盘的稳定性,确保了4K视频源的稳定录制。
Smart Images

Figure CN119380765A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of disk recording technology, and more specifically, to a method and system for disk recording of 4KP60 video sources without frame loss. Background Art
[0002] The main reasons for disk recording frame loss usually include insufficient storage performance of the hard disk, excessive disk fragmentation, the hard disk read and write speed cannot keep up with the recording requirements, resource setting problems, improper operation, etc. These problems will cause frame loss during the recording process. Moreover, with the increasing popularity of 4K video sources, the frame loss problem faced by disk recording is becoming increasingly severe. The traditional approach of adjusting a single defect or a few defects lacks systematicity and is difficult to meet the recording requirements of 4K video sources, especially under the conditions of the highest input resolution of 3840x2160 and the highest frame rate of 60fps (4KP60), the frame loss phenomenon exists when recording at the highest bit rate of 80Mbps. In addition, it also involves the continuity of file recording and the problem of replacing disks. A method and system for disk recording of 4KP60 video sources without frame loss is needed to solve the above problems. Summary of the invention
[0003] The technical problem to be solved by the present invention is that, in view of the above-mentioned defects of the prior art, a method for recording a 4KP60 video source disk without frame loss is provided, and a system for recording a 4KP60 video source disk without frame loss is provided.
[0004] The technical solution adopted by the present invention to solve its technical problem is:
[0005] A method for recording a 4KP60 video source disk without frame loss is constructed, wherein the method comprises the following steps:
[0006] When the system is turned on, add a recording cache queue and set the corresponding configuration to increase the size of each data write to the disk;
[0007] Recording starts, setting the corresponding configuration to write to disk at a steady rate;
[0008] Determine whether the next file to be written has been opened. If so, proceed to the next step. Otherwise, open the next file in advance.
[0009] Determine whether the disk currently being written is full, if not, proceed to the next step, if yes, automatically switch to another available disk;
[0010] Write audio and video data into the cache queue, and write the data in the cache queue to the disk at a steady speed;
[0011] Check whether the command to stop recording is received, if yes, proceed to the next step, otherwise return to the step of determining whether the next file to be written has been opened;
[0012] Recording stops.
[0013] The method for recording a 4KP60 video source disk without frame loss of the present invention, wherein the adding of a recording cache queue comprises the steps of:
[0014] Get the maximum number of packets max_pk_cnt and the maximum packet size max_pk_size from the system;
[0015] Create a circular buffer queue that can cache max_pk_cnt packets, with a total size of max_pk_cnt*max_pk_size.
[0016] The method for recording a 4KP60 video source disk without frame loss of the present invention further comprises the steps of:
[0017] When recording starts, data is taken from the video and audio interfaces;
[0018] Determine whether the difference between write_cnt and read_cnt is less than max_pk_cnt. If so, find the location of the current write queue, write the data to the current queue, add 1 to the write_cnt count, and return to the previous step. Otherwise, determine that the queue is full, discard the current data packet, display an alarm, and return to the previous step.
[0019] At the same time, take video and audio data from the ring queue;
[0020] Determine whether write_cnt is greater than read_cnt. If so, find the position of the current read queue and obtain the current data packet through the pointer, add 1 to the read_cnt count, and proceed to the next step; otherwise, discard the current data packet, display an alarm, and return to the previous step;
[0021] Determine whether the data is video or audio. If it is audio data, call the audio data interface to write the data to disk, and return to the step of taking video and audio data from the circular queue; if it is video data, call the video data interface to write the data to disk, and return to the step of taking video and audio data from the circular queue;
[0022] When recording stops, stop taking video and audio data from the ring queue; stop taking data from the video and audio interfaces;
[0023] Exit recording.
[0024] The method for recording 4KP60 video source disk without frame loss of the present invention further comprises the steps of: dynamic FAT32 file system adaptation configuration, and the dynamic FAT32 file system adaptation configuration adopts the steps of:
[0025] When recording starts, determine whether the file system of the current recording disk is FAT32 system. If yes, the file segmentation during recording is based on the FAT32 segmentation method and proceed to the next step. Otherwise, the file segmentation during recording is based on the set time segmentation size.
[0026] Write data to disk and calculate the size of the written audio and video data in real time;
[0027] Determine whether the data size is greater than or equal to 3.8G. If so, close the current file, reopen a new file to continue writing to the disk, and return to the previous step. Otherwise, return directly to the previous step.
[0028] The method for recording a 4KP60 video source disk without frame loss of the present invention further comprises opening the file in advance, and the opening of the file in advance adopts the steps of:
[0029] When recording starts:
[0030] Open the current file, the file pointer is currentFile, and the system writes data to the file pointed to by the currentFile pointer; at the same time, the next recording file is also opened, and the file pointer is nextFile; the closed file pointer closeFile is empty at this time;
[0031] The split time arrives and the file needs to be split;
[0032] The closeFile file pointer points to currentFile; the currentFile file pointer points to nextFile; the system continues to write data to the file pointed to by the currentFile pointer; closes the file pointed to by the closeFile file pointer, and writes the data to the disk synchronously; reopens a new file, and uses the nextFile file pointer to point to this file.
[0033] The method for recording a 4KP60 video source disk without frame loss of the present invention further comprises the steps of: automatically switching the recording disk configuration, and automatically switching the recording disk configuration adopts the steps of:
[0034] When recording starts:
[0035] Check whether the current disk has enough capacity to continue recording. If yes, proceed to the next step. Otherwise, switch to another disk as the recording disk path and proceed to the next step.
[0036] Open the current file, the file pointer is currentFile, and the system writes data to the file pointed to by the currentFile pointer; at the same time, the next recording file is also opened, and the file pointer is nextFile; the closed file pointer closeFile is empty at this time;
[0037] The split time arrives and the file needs to be split;
[0038] Check whether the current disk has enough capacity to continue recording. If yes, proceed to the next step. Otherwise, switch to another disk as the recording disk path and proceed to the next step.
[0039] The closeFile file pointer points to currentFile; the currentFile file pointer points to nextFile; the system continues to write data according to the file pointed to by the currentFile pointer; closes the file pointed to by the closeFile file pointer, and writes the synchronous data to the disk; reopens a new file, and uses the nextFile file pointer to point to this file;
[0040] The return split time has arrived and the file needs to be split.
[0041] The method for recording 4KP60 video source on disk without frame loss of the present invention, wherein the setting corresponds to the configuration, so that the size of each data written to the disk is increased by the following steps:
[0042] Set the kernel parameters in the disk driver to 1024.
[0043] The method for recording a 4KP60 video source to a disk without frame loss of the present invention, wherein the setting corresponds to the configuration, and the steps of writing the disk at a steady rate are adopted:
[0044] In Linux, set the parameter / proc / sys / vm / dirty_background_ratio to 0.
[0045] A system for recording 4KP60 video source disk without frame loss, wherein the system comprises: an HMDI signal conversion module, an audio and video data processing module, a UI management module and a recording module; the HMDI signal conversion module, the UI management module and the recording module are all connected to the audio and video data processing module in communication;
[0046] The HDMI signal conversion module is used to receive an external HDMI signal source and convert the signal into MIPICSI;
[0047] The audio and video data processing module is used to execute the above-mentioned method for recording 4KP60 video source disk without frame loss;
[0048] The UI management module is used for drawing and displaying using LVGL, receiving instructions sent by peripherals, and UI interface management;
[0049] The recording module is used for disk recording.
[0050] The system for recording 4KP60 video source disk without frame loss described in the present invention, wherein the audio and video data processing module adopts the RK3588S chip.
[0051] The beneficial effect of the present invention is that: by applying the method of the present application, the settings of writing disk at a steady rate, increasing the size of each data written to the disk, increasing the cache, dynamic FAT32 file system adaptation, opening files in advance and automatically switching disks are systematically integrated. Through these methods, the problem of frame loss during recording under the conditions of the highest input resolution of 3840x2160 and the highest frame rate of 60fps (4KP60) can be well solved. At the same time, the continuity of file recording and the problem of disk replacement can be well solved, thereby ensuring the stable recording of 4K video sources. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the present invention will be further described below in conjunction with the accompanying drawings and embodiments. The drawings described below are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work:
[0053] Figure 1a It is a logic flow chart of a method for recording 4KP60 video source disk without frame loss in a preferred embodiment of the present invention (part one);
[0054] Figure 1b This is a logic flow chart of a method for recording 4KP60 video source disk without frame loss according to a preferred embodiment of the present invention (Part 2, the three lines on the left side of the figure are Figure 1a The three lines on the right side are connected accordingly)
[0055] Figure 2 This is a screenshot of the recording software interface of the method for recording 4KP60 video source disk without frame loss in a preferred embodiment of the present invention;
[0056] Figure 3a It is a method for adding cache logic flow chart (part 1) of a preferred embodiment of the present invention for recording 4KP60 video source disk without frame loss;
[0057] Figure 3b This is a method for increasing the cache logic flow chart of the 4KP60 video source disk recording without frame loss according to the preferred embodiment of the present invention (Part 2, the left line in the figure is Figure 1aA line on the right side of the middle corresponds to the connection);
[0058] Figure 4 It is a logic flow chart of dynamic FAT32 file system adaptation of a method for recording 4KP60 video source disk without frame loss in a preferred embodiment of the present invention;
[0059] Figure 5 It is a logical flow chart of opening files in advance for a method of recording 4KP60 video source disk without frame loss in a preferred embodiment of the present invention;
[0060] Figure 6 It is a logical flow chart of automatically switching recording disks for a method of recording 4KP60 video source disks without frame loss according to a preferred embodiment of the present invention;
[0061] Figure 7 It is a system principle block diagram of 4KP60 video source disk recording without frame loss in a preferred embodiment of the present invention. DETAILED DESCRIPTION
[0062] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the following will be described clearly and completely in combination with the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are partial embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work belong to the protection scope of the present invention.
[0063] The method and system for recording 4KP60 video source disk without frame loss in the preferred embodiment of the present invention are as follows: Figure 1a and Figure 1b See also Figure 2 , Figure 3a , Figure 3b , Figure 4-Figure 6 , including the following steps:
[0064] When the system is turned on, add a recording cache queue;
[0065] Specifically, the frame loss phenomenon caused by disk recording is essentially caused by the fact that the audio and video data is coming in too fast, while the disk is writing too slowly. At this time, we need to use the system memory at the application layer to add a buffer space to reconcile the problem of data being generated too fast and consumed too slowly; Figure 3a , Figure 3b As shown:
[0066] In the actual project, max_pk_cnt is set to 600, and the maximum packet size of each packet max_pk_size is set to 2.5M, so the size of the ring queue is about 1.5G. At this time, the system with 4G memory can still have about 1.3G remaining, which can still meet the system requirements normally. According to the current setting parameters, the U disk (such as Samsung 128G, Samsung 64G, SanDisk 128G, Kingston 128G, etc.), SD card, and SATA were tested for a long time, and the recording effect was good without frame loss. For different processing scenarios, max_pk_cnt and max_pk_size can be appropriately adjusted to meet the corresponding requirements;
[0067] The ring buffer queue optimizes the data writing strategy for 4KP60 video sources. The queue can cache the maximum number of data packets and achieve efficient data writing through the following steps:
[0068] A circular buffer queue is dynamically created based on system parameters to ensure that the queue can accommodate the maximum number and size of packets.
[0069] The read and write status of the queue is monitored in real time through the write_cnt and read_cnt counters to ensure the orderly writing and reading of data packets.
[0070] When the queue is not full, the video and audio data are written into the queue; when the queue is full, an alarm mechanism is used to prompt and discard the current data packet, thereby ensuring the priority of critical data.
[0071] This technology has significant advantages in improving disk writing efficiency and reducing frame loss rate;
[0072] The specific implementation method of dynamically creating a ring buffer queue according to system parameters can be carried out according to the following steps:
[0073] Step 1: Get system parameters
[0074] Get key parameters from the system, including the maximum number of packets (max_pk_cnt) and the maximum packet size (max_pk_size). These parameters can be determined based on factors such as the characteristics of the video source, disk write speed, and system memory resources.
[0075] Step 2: Calculate the buffer queue size
[0076] According to the maximum number of packets and the maximum packet size obtained, the total size of the ring buffer queue is calculated, and the formula is: total size = max_pk_cnt*max_pk_size.
[0077] Step 3: Allocate memory space
[0078] Allocate a contiguous space in the system memory with the calculated total size to create a ring buffer queue.
[0079] Step 4: Initialize the ring buffer queue
[0080] Initialize the structure of the ring buffer queue, including the head pointer, tail pointer, write_cnt (write counter) and read_cnt (read counter).
[0081] Set the head pointer and tail pointer to point to the beginning of the memory space.
[0082] Initialize write_cnt and read_cnt to 0, indicating that the queue is empty at the beginning.
[0083] Step 5: Implement the operation function of the ring buffer queue
[0084] Write a function to write a data packet to the queue, including: checking whether the queue is full (write_cnt-read_cnt==max_pk_cnt).
[0085] If the queue is not full, write the packet to the location pointed to by the tail pointer and move the tail pointer to the next location (looping back to the beginning of the queue).
[0086] If the queue is full, the packet drop policy is executed and an alarm may be triggered.
[0087] After writing the data, the write_cnt counter is incremented.
[0088] Write a function to read data packets from the queue, including: checking whether the queue is empty (write_cnt == read_cnt).
[0089] If the queue is not empty, read the packet from the location pointed to by the head pointer and move the head pointer to the next location.
[0090] After reading the data, increase the read_cnt counter.
[0091] Step 6: Memory Management of Ring Buffer Queue
[0092] Ensure that the memory space of the ring buffer queue remains valid during system operation to avoid memory leaks.
[0093] When the system is shut down or the buffer queue is no longer needed, the allocated memory space is released.
[0094] Step 7: Test the Ring Buffer Queue
[0095] Stress test the ring buffer queue to ensure that it works correctly under various operations, including normal writes, reads, and queue full and empty conditions;
[0096] Set the corresponding configuration to increase the size of each data write to the disk;
[0097] In the current RK3588S recording system, max_sectors_kb is a kernel parameter in the disk driver, which indicates the maximum number of sectors that the device can process in one I / O operation. This parameter is automatically negotiated to a value based on the disk's capabilities after the disk is inserted into the system. Different disks will have different values, generally 120, which means that the maximum number of sectors that the device can process in one I / O operation is 120 in the software. Considering that the size of each sector is 0.5K bytes, the data stream size of one I / O operation (such as read or write) is 120x0.5K=60K bytes of data.
[0098] Considering that the system will automatically negotiate the data with the disk, and when recording starts, the data is continuously and very quickly input from the HMDI, the system must quickly write these large amounts of data to the disk in a timely manner. Therefore, it is very necessary to increase the data flow of each IO write. Therefore, we force the driver to set it to 1024, that is, the maximum data size written or read at the software level is 512K bytes each time, which will greatly improve the efficiency of writing to the disk.
[0099] In addition, considering that the amount of IO writes to the disk each time is affected by the disk hardware capabilities, that is, affected by max_hw_sectors_kb, even if max_sectors_kb exceeds the capacity of max_hw_sectors_kb, the disk will eventually be written according to the disk hardware capabilities.
[0100] Recording starts, setting the corresponding configuration to write to disk at a steady rate;
[0101] In Linux systems, / proc / sys / vm / dirty_background_ratio is a kernel parameter that controls the memory threshold at which the kernel starts to write (flush) dirty pages (memory pages that have been modified but not yet written to disk) in the background. The value of this parameter is a percentage. For example, if it is set to 10, then when dirty pages occupy 10% of the total system memory, the kernel will start writing dirty pages in the background, that is, start writing dirty page data to disk. The purpose of this parameter is to gradually write dirty pages to disk before the number of dirty pages in memory becomes too large, thereby avoiding the accumulation of too many dirty pages in memory, which may cause the system to respond slowly when memory is insufficient, or lose a large amount of data when the system crashes.
[0102] Combined with the actual situation, in the RK3588S recording system, assuming that this parameter is set to 10, that is, 10% of the total memory of RK3588S 4G, which is about 400M, when writing to the disk, there is a period of time when there is no IO operation, and then when it accumulates to 400M, the system starts to execute the IO write operation that consumes the 400M data. This is no problem for some disks with good write rates (such as SATA), but for some disks with poor write rates, this sudden write operation may cause frame loss, and a steady rate write operation is more suitable for such disks; in addition, considering that the characteristics of recorded data are continuous and large in volume, in actual operation, we will set this parameter to 0, so that the system does not need to cache the data to the memory before writing to the disk, and it will always write directly to the disk at a steady rate. Since RK3588S is an 8-core processing chip, such continuous IO write operations do not have to consider affecting the performance of the entire system, and there is no need to worry about losing a large amount of data when the system crashes.
[0103] Determine whether the next file to be written has been opened. If so, proceed to the next step. Otherwise, open the next file in advance.
[0104] like Figure 5 As shown, when recording a file, you need to configure the time to split the file. In actual projects, it is found that when the system closes the currently recorded file and then opens a new file to be written, the data stream will continue to be transmitted from HDMI. At this time, this part of the data will be discarded, which causes the recorded file to lose frames.
[0105] The current solution is to open the next file at the same time as opening the current file. When closing the currently recorded file, the write pointer of the current data is directly pointed to the next file. The system writes data seamlessly according to the file pointed by the current pointer, so as to achieve the effect of no frame loss when cutting files.
[0106] Determine whether the disk currently being written is full, if not, proceed to the next step, if yes, automatically switch to another available disk;
[0107] The specific implementation method of automatically identifying the file system type of the current recording disk and dynamically adjusting the file segmentation strategy according to the file system type can be divided into the following steps:
[0108] Step 1: Get disk information
[0109] Use the API or command tools provided by the operating system, such as statfs (in Linux system) to obtain the file system type information of the current recording disk.
[0110] Step 2: Identify the file system type
[0111] Based on the information obtained in step 1, identify the file system type used by the disk, such as FAT32, NTFS, EXT4, etc.
[0112] Step 3: Define file segmentation strategy
[0113] Define corresponding file segmentation strategies for different file system types. For example, for FAT32 file system, since the single file size is limited to 4GB, the file segmentation size can be set to about 3.8GB.
[0114] For NTFS or EXT4 file systems, the file size limit is higher. You can set a larger file split size or not split it.
[0115] Step 4: Implement file segmentation logic
[0116] According to the identified file system type, implement the following file segmentation logic: If it is FAT32 or other file system with limited file size, start a timer or monitor the size of the current written file.
[0117] When the file size approaches the defined split size, the file split operation is triggered.
[0118] Step 5: File splitting operation
[0119] When you need to split a file, do the following: Stop writing data to the current file.
[0120] Close the current file.
[0121] Create a new file to continue recording.
[0122] Ensure that when new files are created, the file name or other identifier can be distinguished from the old files to facilitate management and playback.
[0123] Step 6: Record file segmentation information
[0124] When splitting files, the metadata of the split points, such as timestamp, file size, file sequence number, etc., are recorded to facilitate subsequent file management and retrieval.
[0125] Step 7: Exception handling
[0126] During the file splitting process, ensure that any possible exceptions are handled, such as insufficient disk space, file system errors, etc., to avoid data loss;
[0127] like Figure 6As shown, the current system supports simultaneous mounting of SD card and USB flash drive / SATA. If the current disk is full, it can automatically switch to another unrecorded disk, thus achieving seamless switching of disk recording without frame loss.
[0128] Write audio and video data into the cache queue, and write the data in the cache queue to the disk at a steady speed;
[0129] Check whether the command to stop recording is received, if yes, proceed to the next step, otherwise return to the step of determining whether the next file to be written has been opened;
[0130] Recording stopped;
[0131] By applying the method of the present application, the settings of writing disk at a steady rate, increasing the size of each disk write, increasing cache, dynamic FAT32 file system adaptation, opening files in advance and automatically switching disks are systematically integrated. Through these methods, the problem of frame loss in recording under the conditions of the highest input resolution of 3840x2160 and the highest frame rate of 60fps (4KP60) can be well solved. At the same time, the continuity of file recording and the problem of disk replacement can be well solved, ensuring the stable recording of 4K video sources;
[0132] Dynamic FAT32 file system adaptation and automatic disk switching mechanism are used to solve the problems of insufficient disk space and file system compatibility during 4KP60 video source recording.
[0133] The specific steps include:
[0134] When recording starts, the file system type of the current recording disk is automatically identified and the file segmentation strategy is dynamically adjusted according to the file system type.
[0135] Monitor the size of the audio and video data being written in real time. When the data size approaches the limit of the FAT32 file system, it automatically switches to a new file to continue recording, thus avoiding performance issues caused by a single file that is too large.
[0136] When the disk space is insufficient, it automatically switches to another available disk to ensure the continuity and integrity of the recording.
[0137] This technology has significant advantages in improving the adaptability of the recording system and ensuring a stable and reliable recording process.
[0138] like Figure 4 As shown, the method further includes the steps of: dynamic FAT32 file system adaptation configuration, the dynamic FAT32 file system adaptation configuration adopts the steps of:
[0139] When recording starts, determine whether the file system of the current recording disk is FAT32 system. If yes, the file segmentation during recording is based on the FAT32 segmentation method and proceed to the next step. Otherwise, the file segmentation during recording is based on the set time segmentation size.
[0140] Write data to disk and calculate the size of the written audio and video data in real time;
[0141] Determine whether the data size is greater than or equal to 3.8G. If so, close the current file, reopen a new file to continue writing to the disk, and return to the previous step. Otherwise, return directly to the previous step.
[0142] The FAT32 (File Allocation Table 32-bit) file system is an older file system that was once the file system of choice for many removable storage devices and some embedded devices. However, compared to newer file systems such as NTFS or exFAT, FAT32 has several significant flaws, the main one being that the FAT32 file system does not support files larger than 4GB. This means that a single file larger than 4GB cannot be stored on a FAT32 partition, and once this file is exceeded during recording, the file will be corrupted and unusable. The above split file size is positioned at 3.8G, which is a value that is more in line with engineering applications, so that the problem of file unavailability will not occur due to the 4G size limit.
[0143] A system for recording 4KP60 video source to disk without frame loss, such as Figure 7 As shown, the system includes: an HMDI signal conversion module 100, an audio and video data processing module 101, a UI management module 102 and a recording module 103; the HMDI signal conversion module 100, the UI management module 102 and the recording module 103 are all connected to the audio and video data processing module 101 for communication;
[0144] HMDI signal conversion module 100 is used to receive external input HDMI signal source and convert the signal into MIPI CSI; the model can adopt LT6911UXE module; the main function of this module is to convert the external HMDI signal into MIPI CSI, and then give it to RK3588S for processing. Its characteristics are that it can process 3840x2160 data and support YUV444 and YUV422;
[0145] The audio and video data processing module 101 is used to execute the above-mentioned method of recording 4KP60 video source disk without frame loss; the model can adopt RK3588S chip; specifically, it is responsible for processing audio and video data acquisition, encoding, conversion, recording and streaming the processed audio and video data, and processing UI management data. This is the center of the entire audio and video data flow and control and control instructions;
[0146] The UI management module 102 is responsible for drawing and displaying using LVGL, receiving commands sent by peripherals (infrared / buttons), including the start / stop of recording, and the setting and display of corresponding recording parameters, and is responsible for the management UI of the entire system;
[0147] Recording module 103, used for disk recording;
[0148] Mainly responsible for the disk recording function, see Figure 2 , which include:
[0149] 1. Support encoding methods: H.264, H.265;
[0150] 2. The recording bit rate supports 8Mpbs 16Mpbs 30Mpbs 50Mpbs 80Mpbs;
[0151] 3. Supported recording resolution frame rate: 3840x2160P60, 3840x2160P30, 2160x1440P60, 1920x1080P60, 1280x1024P60, 1280x720P60;
[0152] 4. Recording disk support: SD card, USB disk, SATA;
[0153] 5. Whether loop recording is supported or not;
[0154] 6. File recording formats supported: MP4 MOV TS;
[0155] 7. The split file size supports: 10 minutes, 30 minutes, 1 hour, 2 hours, 3 hours, 4 hours, 5 hours, 6 hours, 7 hours, 8 hours, 9 hours, 10 hours;
[0156] 8. Support whether the time watermark switch is turned on;
[0157] The external input HDMI signal source uses 4K signal source input module 2. As the input of HDMI signal source, this module supports input of resolutions such as 3840x2160, 2160x1440, and 1920x1080, and is compatible with most HMDI signal output devices on the market.
[0158] The command input can adopt the infrared / button input module 3; send corresponding control commands to the UI management module through the infrared remote control and the onboard buttons, including: up, down, left, right, confirm, return, start / stop recording, screenshot, volume increase / decrease, fast forward, fast rewind, etc.;
[0159] The system of the present application systematically integrates settings such as writing disk at a steady rate, increasing the size of each data written to the disk, increasing cache, dynamic FAT32 file system adaptation, opening files in advance and automatically switching disks. Through these methods, the problem of frame loss during recording under the conditions of the highest input resolution of 3840x2160 and the highest frame rate of 60fps (4KP60) can be well solved. At the same time, the continuity of file recording and the problem of disk replacement can be well solved, thereby ensuring the stable recording of 4K video sources.
[0160] In summary:
[0161] Technological innovation and problem solving: The purpose of this patent is primarily technological innovation, aiming to solve the frame loss problem of 4K high frame rate video recording in the prior art. By proposing a video recording method based on the RK3588S embedded platform, this patent aims to achieve stable recording of high bit rate 4KP60 video, ensuring video data integrity and picture smoothness.
[0162] Improving storage media compatibility: One of the purposes of this patent is to improve the compatibility of the video recording system with a variety of storage media, including SD cards, USB flash drives, SATA disks, etc. Through this method, users can choose the appropriate storage media according to actual needs without worrying about compatibility issues, thereby improving the flexibility of the system and user experience.
[0163] Optimize recording parameter configuration: This patent aims to provide a recording method that can support multiple recording frame rates (P30, P60, I60) and bit rates (8Mbps, 16Mbps, 30Mbps, 50Mbps, 80Mbps) to meet the different requirements of video quality in different application scenarios. By optimizing parameter configuration, this method aims to achieve high customization and flexibility in the recording process.
[0164] Ensuring recording stability: We paid special attention to ensuring that no frame drops occur when recording at the highest input resolution of 3840x2160 and the highest frame rate of 60fps (4KP60) at the highest bitrate of 80Mbps. The purpose is to ensure the stability and reliability of video recording under various extreme recording conditions.
[0165] Promoting industry development and application popularization: This patent also aims to promote the development of 4K high frame rate video recording technology and provide a reliable solution for related industries. Through the application of this method, the production and popularization of 4K video content can be promoted to meet the market's growing demand for high-quality video content.
[0166] Software features:
[0167] 1. Multi-storage media support function: The software has extensive multi-storage media support function, which can seamlessly connect to SD cards, USB flash drives (including Samsung, SanDisk, Kingston and other commonly used USB flash drives on the market) and SATA disks, providing users with flexible video recording storage options.
[0168] 2. Configurable recording frame rate function: The software provides configurable recording frame rate options, supporting multiple frame rate settings such as P30 and P60 to meet the needs of video smoothness in different scenarios.
[0169] 3. Adjustable recording bit rate function: The software has an adjustable recording bit rate function, allowing users to select different bit rates such as 8Mbps, 16Mbps, 30Mbps, 50Mbps, 80Mbps, etc. according to their needs to adapt to different video quality and storage capacity requirements.
[0170] 4. Multi-resolution input support function: The software supports multiple input resolutions, including 3840x2160, 2160x1440, 1920x1080, etc., to ensure video source adaptability and recording quality.
[0171] 5. File segmentation management function: The software provides the function of automatically segmenting files according to the length of time, supporting segmentation methods ranging from 10 minutes to 10 hours, which is convenient for users to manage and store long-time recorded video content.
[0172] 6. Dynamic FAT32 file system adaptation function: The software has the ability to dynamically support the FAT32 file system and can automatically split the file when the file size reaches the FAT32 file system limit, avoiding storage problems caused by excessively large files.
[0173] 7. Multi-format recording support function: The software supports recording in multiple video file formats, including MP4, MOV, TS, etc., to meet the needs of different users for video file formats.
[0174] 8. The software provides support for multiple encoding formats, allowing users to choose two efficient video encoding formats, H.264 and H.265, for recording. Both encoding formats can effectively compress video data while maintaining high video quality. Compared with H.264, H.265 encoding can provide higher compression rate and better image quality, providing users with flexible video recording and storage solutions.
[0175] 9. High-efficiency recording without frame loss: At the highest input resolution / frame rate of 3840x2160P60 (4KP60), when recording at 80Mbps bit rate, the software uses efficient data processing and cache management technology to ensure that no frame loss occurs when recording using SD cards, USB flash drives, and SATA disks.
[0176] 10. Automatically switch recording disks.
[0177] It should be understood that those skilled in the art can make improvements or changes based on the above description, and all these improvements and changes should fall within the scope of protection of the appended claims of the present invention.
Claims
1. A method for recording 4KP60 video source disk without frame loss, characterized in that: The following steps are involved: When the system is turned on, add a recording cache queue and set the corresponding configuration to increase the size of each data write to the disk; Recording starts, setting the corresponding configuration to write to disk at a steady rate; Determine whether the next file to be written has been opened. If so, proceed to the next step. Otherwise, open the next file in advance. Determine whether the disk currently being written is full, if not, proceed to the next step, if yes, automatically switch to another available disk; Write audio and video data into the cache queue, and write the data in the cache queue to the disk at a steady speed; Check whether the command to stop recording is received, if yes, proceed to the next step, otherwise return to the step of determining whether the next file to be written has been opened; Recording stops.
2. The method for recording 4KP60 video source disk without frame loss according to claim 1, characterized in that: The step of adding a recording cache queue comprises: Get the maximum number of packets max_pk_cnt and the maximum packet size max_pk_size from the system; Create a circular buffer queue that can cache max_pk_cnt packets, with a total size of max_pk_cnt*max_pk_size.
3. The method for recording 4KP60 video source disk without frame loss according to claim 2, characterized in that: The method further comprises the steps of: When recording starts, data is taken from the video and audio interfaces; Determine whether the difference between write_cnt and read_cnt is less than max_pk_cnt. If so, find the location of the current write queue, write the data to the current queue, add 1 to the write_cnt count, and return to the previous step. Otherwise, the queue is determined to be full, the current data packet is discarded, an alarm is displayed, and the process returns to the previous step; At the same time, take video and audio data from the ring queue; Determine whether write_cnt is greater than read_cnt. If so, find the position of the current read queue and obtain the current data packet through the pointer, add 1 to the read_cnt count, and proceed to the next step; Otherwise, the current data packet is discarded, an alarm is displayed, and the process returns to the previous step; Determine whether the data is video or audio. If it is audio data, call the audio data interface to write the data to the disk, and return to the step of taking video and audio data from the circular queue; If it is video data, the video data interface is called to write the data to the disk, and the process returns to the step of taking video and audio data from the circular queue; When recording stops, stop taking video and audio data from the ring queue; stop taking data from the video and audio interfaces; Exit recording.
4. The method for recording 4KP60 video source disk without frame loss according to claim 1, characterized in that: The method further comprises the steps of: dynamic FAT32 file system adaptation configuration, wherein the dynamic FAT32 file system adaptation configuration adopts the steps of: When recording starts, determine whether the file system of the current recording disk is FAT32 system. If yes, the file segmentation during recording is based on the FAT32 segmentation method and proceed to the next step. Otherwise, the file segmentation during recording is based on the set time segmentation size. Write data to disk and calculate the size of the written audio and video data in real time; Determine whether the data size is greater than or equal to 3.8G. If so, close the current file, reopen a new file to continue writing to the disk, and return to the previous step. Otherwise, return directly to the previous step.
5. The method for recording 4KP60 video source disk without frame loss according to claim 4, characterized in that: The method further comprises opening the file in advance, and the opening of the file in advance adopts the steps of: When recording starts: Open the current file, the file pointer is currentFile, and the system writes data to the file pointed to by the currentFile pointer; at the same time, the next recording file is also opened, and the file pointer is nextFile; the closed file pointer closeFile is empty at this time; The split time arrives and the file needs to be split; The closeFile file pointer refers to currentFile; the currentFile file pointer refers to nextFile; the system continues to write data according to the file pointed to by the currentFile pointer; Close the file pointed to by the closeFile file pointer and write the synchronous data to the disk; Reopen a new file and use the nextFile file pointer to point to this file.
6. The method for recording 4KP60 video source disk without frame loss according to claim 5, characterized in that: The method further comprises the steps of: automatically switching the recording disk configuration, wherein the automatically switching the recording disk configuration adopts the steps of: When recording starts: Check whether the current disk has enough capacity to continue recording. If yes, proceed to the next step. Otherwise, switch to another disk as the recording disk path and proceed to the next step. Open the current file, the file pointer is currentFile, and the system writes data to the file pointed to by the currentFile pointer; at the same time, the next recording file is also opened, and the file pointer is nextFile; the closed file pointer closeFile is empty at this time; The split time arrives and the file needs to be split; Check whether the current disk has enough capacity to continue recording. If yes, proceed to the next step. Otherwise, switch to another disk as the recording disk path and proceed to the next step. The closeFile file pointer refers to currentFile; the currentFile file pointer refers to nextFile; the system continues to write data according to the file pointed to by the currentFile pointer; Close the file pointed to by the closeFile file pointer and write the synchronous data to the disk; reopen a new file and use the nextFile file pointer to point to this file; The return split time has arrived and the file needs to be split.
7. The method for recording 4KP60 video source disk without frame loss according to claim 1, characterized in that: The configuration corresponding to the above setting increases the size of each data written to the disk by adopting the following steps: Set the kernel parameters in the disk driver to 1024.
8. The method for recording 4KP60 video source disk without frame loss according to claim 1, characterized in that: The settings correspond to the configuration, and the steps to write to disk at a steady rate are: In Linux, set the parameter / proc / sys / vm / dirty_background_ratio to 0.
9. A system for recording 4KP60 video source disk without frame loss, characterized in that: The system comprises: an HMDI signal conversion module, an audio and video data processing module, a UI management module and a recording module; the HMDI signal conversion module, the UI management module and the recording module are all connected to the audio and video data processing module in communication; The HDMI signal conversion module is used to receive an external HDMI signal source and convert the signal into MIPICSI; The audio and video data processing module is used to execute the method for recording a 4KP60 video source disk without frame loss as described in any one of claims 1 to 8; The UI management module is used for drawing and displaying using LVGL, receiving instructions sent by peripherals, and UI interface management; The recording module is used for disk recording.
10. The system for recording 4KP60 video source disk without frame loss according to claim 9, characterized in that: The audio and video data processing module adopts the RK3588S chip.