WO2021109892A1 - Video data transmission method and terminal - Google Patents

Video data transmission method and terminal Download PDF

Info

Publication number
WO2021109892A1
WO2021109892A1 PCT/CN2020/130868 CN2020130868W WO2021109892A1 WO 2021109892 A1 WO2021109892 A1 WO 2021109892A1 CN 2020130868 W CN2020130868 W CN 2020130868W WO 2021109892 A1 WO2021109892 A1 WO 2021109892A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
state
rate
buffer queue
video
Prior art date
Application number
PCT/CN2020/130868
Other languages
French (fr)
Chinese (zh)
Inventor
李昭早
Original Assignee
深圳市道通智能航空技术股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳市道通智能航空技术股份有限公司 filed Critical 深圳市道通智能航空技术股份有限公司
Publication of WO2021109892A1 publication Critical patent/WO2021109892A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/433Content storage operation, e.g. storage operation in response to a pause request, caching operations
    • H04N21/4331Caching operations, e.g. of an advertisement for later insertion during playback
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs
    • H04N21/44004Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving video buffer management, e.g. video decoder buffer or video display buffer
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs
    • H04N21/4402Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display
    • H04N21/440218Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display by transcoding between formats or standards, e.g. from MPEG-2 to MPEG-4
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/442Monitoring of processes or resources, e.g. detecting the failure of a recording device, monitoring the downstream bandwidth, the number of times a movie has been viewed, the storage space available from the internal hard disk
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/45Management operations performed by the client for facilitating the reception of or the interaction with the content or administrating data related to the end-user or to the client device itself, e.g. learning user preferences for recommending movies, resolving scheduling conflicts
    • H04N21/462Content or additional data management, e.g. creating a master electronic program guide from data received from the Internet and a Head-end, controlling the complexity of a video stream by scaling the resolution or bit-rate based on the client capabilities
    • H04N21/4621Controlling the complexity of the content stream or additional data, e.g. lowering the resolution or bit-rate of the video stream for a mobile client with a small screen

Definitions

  • the present invention relates to the technical field of data processing, in particular to a method and terminal for transmitting video data.
  • SD card is a data storage device based on semiconductor flash memory. Due to its small size and fast data transmission speed, it is widely used as a large-capacity storage device. For example, SD cards are used to store high-quality video data. In the process of use, if the code rate of the data to be stored is too high, when the data is directly stored in the SD card, it is easy to lose data, which will cause problems such as blurring.
  • the embodiment of the present invention provides a video data transmission method and terminal, which can solve the technical problem that data loss is prone to occur when the SD card stores data.
  • the first technical solution provided by the embodiments of the present invention is to provide a method for transmitting video data, which is applied to a terminal, and the method includes:
  • Run an encoding thread and a storage thread of the terminal where the encoding thread is used to write video data into a buffer queue, and the storage thread is used to write video data in the buffer queue into a storage unit;
  • the working mode of the encoding thread is determined according to the data state, and the video data is transmitted in the determined working mode of the encoding thread.
  • the detecting the data status of the video data in the buffer queue includes:
  • the data status is determined according to the retention rate and the fluctuation status, wherein the data status includes a data retention status, a data empty window status, and a data circulation status.
  • the determining the data status according to the retention rate and the fluctuation status includes:
  • the retention rate of the video data is greater than the first preset threshold and the fluctuation state is the rising state
  • the number of rises within the preset time is acquired, and the data state is determined according to the retention rate and the number of rises Whether it is the data retention state;
  • the retention rate of the video data is less than a second preset threshold and the fluctuation state is a non-increasing state
  • the retention rate of the video data within the preset time is acquired, and the video data retention rate is obtained according to the preset time.
  • the retention rate of data determines whether the data state is the data empty window state
  • the data state of the video data is not the data retention state and is not the data empty window state, it is determined that the data state of the video data is the data circulation state.
  • the determining whether the data status is the data retention status according to the retention rate and the number of rises includes:
  • the data status is the data retention status, otherwise, it is not the data retention status
  • the preset conditions include:
  • the determining whether the data state is the data empty window state according to the retention rate of the video data within the preset time includes:
  • the data state is the data empty window state; otherwise, it is not the data empty window state.
  • the determining the working mode of the encoding thread according to the data state includes:
  • the working mode of the encoding thread is a reduced code rate mode
  • the working mode of the encoding thread is an up-rate mode.
  • the code reduction mode specifically includes:
  • bit rate up mode specifically includes:
  • the storage unit is an SD card.
  • the second technical solution provided by the embodiment of the present invention is to provide a terminal, the terminal includes: an SD card; a main controller connected to the SD card; wherein, the main controller It includes at least one processor; and a buffer in communication with the at least one processor; wherein the buffer stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor. Executing, so that the at least one processor executes the video data transmission method as described above.
  • the video data transmission method and terminal provided by the embodiments of the present invention, by running the encoding thread and the storage thread at the same time, first write the video data to be written into the storage unit into the buffer queue and read from the buffer queue. Take the video data and write it into the storage unit instead of directly writing the video data into the storage unit, thereby reducing the probability of video data loss and reducing the probability of problems such as blurring.
  • the data status of the buffer queue is also monitored in real time, and the working mode of the encoding thread is adjusted according to the data status of the buffer queue, so as to avoid problems such as data overflow in the buffer queue, and improve the overall video Stability and reliability of data transmission.
  • FIG. 1 is a flowchart of a method for transmitting video data according to an embodiment of the present invention
  • FIG. 2 is a flowchart of a method for detecting the data state of the video data in the buffer queue in a video data transmission method provided by an embodiment of the present invention
  • FIG. 3 is a schematic structural diagram of a video data transmission device provided by an embodiment of the present invention.
  • Fig. 4 is a schematic structural diagram of a terminal provided by an embodiment of the present invention.
  • the video data provided by the encoding unit is obtained through the encoding thread, and the video data is stored in the buffer queue, and the video data is read from the buffer queue through the storage thread and stored in the storage unit.
  • the encoding thread and the storage thread run in parallel at the same time, and the encoding thread releases the currently occupied system resources after storing the video data in the buffer queue, and continues to obtain the next video data from the encoding unit.
  • the storage thread also releases the system resources currently occupied by the storage thread after storing the video data in the storage unit, and continues to read the next video data from the buffer queue.
  • the data status of the video data in the buffer queue is monitored in real time, and the working mode of the encoding thread is determined according to the storage status of the video data in the buffer queue, so that the video data transmission can be adjusted in time Speed to avoid abnormal situations such as data overflow or empty data in the buffer queue.
  • embodiments of the present invention provide a method for transmitting video data.
  • the method may be applied to a terminal, and the terminal may be other terminal devices including an SD card such as a drone.
  • the terminal may be other terminal devices including an SD card such as a drone.
  • the method shown in Figure 1, the method:
  • the encoding thread refers to an operation process used to transmit data edited by the encoding unit to the buffer queue.
  • the encoding unit may specifically be an encoding module integrated in the video signal generating device, and the encoding unit converts image data into a video signal.
  • the data may specifically be video data.
  • the storage thread refers to an operation process used to write data in the buffer queue into the storage unit.
  • the storage unit may specifically be an SD card.
  • the buffer queue may be a cache chip integrated in the video signal generating device.
  • the encoding thread and the storage thread run in parallel at the same time.
  • the programming thread fetches the video data from the coding unit and sends it to the buffer queue, and then continues to fetch the video data from the coding unit.
  • the storage thread fetches the video data from the buffer queue, sends it to the storage unit for SD card storage, and then continues back to fetch the video data from the buffer queue after the storage is complete.
  • the data transmission speed of the storage thread is generally greater than the data transmission speed of the encoding thread. Therefore, when the encoding thread inputs data into the buffer queue, the input data will be transferred by the storage thread immediately. As a result, the data can be read from the buffer queue quickly, avoiding data generated in the buffer queue. At the same time, the data buffering effect of the buffer queue can reduce the occurrence of problems such as data overflow in the storage unit.
  • the above-mentioned transmitted data is video data
  • the video data may be a video edited based on coding standards such as H264 and H265.
  • the data may be other data in addition to video data, such as pictures, audio, and so on.
  • the storage thread may easily be blocked, so that the data transmitted by the storage thread cannot be smoothly written into the storage unit.
  • the encoding thread will not be affected, and will continue to transmit video data to the buffer queue, resulting in more and more data stranded in the buffer queue.
  • the stranded data exceeds the preset threshold, the data in the buffer queue overflows, resulting in Huaping phenomenon occurs. Therefore, it is of great significance to monitor the data status of the data stored in the buffer queue in real time, and adjust the running process according to the data status.
  • the data status refers to the data storage status of the video data in the buffer queue, including data storage amount, data size, data type, dynamic change trend of data (such as rising or falling or stable) and so on.
  • the buffer queue is a cache chip integrated in the video signal generating device
  • the data state of the video data in the buffer queue can be detected by a controller integrated in the video signal generating device.
  • the S12, detecting the data status of the video data in the buffer queue includes:
  • S122 Determine the data status according to the retention rate and the fluctuation status, where the data status includes a data retention status, a data empty window status, and a data circulation status.
  • the retention rate refers to the percentage of the retained video data in the total video data that can be stored in the buffer queue when video data is retained in the buffer queue.
  • the rising and falling state refers to the dynamic change trend of video data in the buffer queue.
  • the rising and falling state can be detected in a time period, and the size of the time period can be self-defined by the system.
  • the rising and falling state includes a data rising state and a data falling state.
  • the data status includes a data retention status, a data empty window status, and a data circulation status.
  • the data retention state refers to a state in which the data storage amount of the video data in the buffer queue within the first preset time is greater than a first preset threshold.
  • the data empty window state refers to a state in which the data storage amount of the video data in the buffer queue within the second preset time is less than a second preset threshold.
  • the buffer queue is in the data circulation state, that is, when the data is in the data circulation state There will be no data retention in the buffer queue, and no window opportunity for data waiting.
  • the determining the data status according to the retention rate and the fluctuation status specifically includes:
  • the retention rate of the video data is greater than the first preset threshold and the fluctuation state is the rising state, obtain the number of rises within the preset time, and determine the number of rises according to the retention rate and the number of rises Whether the data state is the data retention state.
  • the first preset threshold may be set by the system based on experience, and the size of the first preset threshold may be related to the maximum amount of data that can be stored in the buffer queue. For example, the first preset threshold is the total 50% of data storage, etc.
  • the rising state means that the data held in the buffer queue is in a continuously increasing state.
  • the preset time can be system-defined equipment, such as half a minute, 1 minute, etc.
  • the number of rises may be the number of consecutive rises within a preset time.
  • Determining whether the data state is a data detention state according to the detention rate and the number of rises includes: when the detention rate is greater than the first preset threshold, and the number of rises meets the preset time of continuous rise Times, it is determined that the data state is a data retention state.
  • the data status is the data retention status, otherwise, it is not the data retention status.
  • the preset conditions include:
  • the retention rate of the video data is less than the second preset threshold and the fluctuation state is a non-rising state
  • the retention rate of the video data within the preset time is acquired, and the retention rate of the video data within the preset time
  • the retention rate of the video data determines whether the data state is the data empty window state.
  • the second preset threshold may be set by the system based on experience, and the size of the second preset threshold may be related to the maximum amount of data that can be stored in the buffer queue. For example, the second preset threshold is the total 10% of data storage, etc.
  • the non-rising state includes a falling state and a non-increasing or non-decreasing state.
  • the determining whether the data state is the data empty window state according to the retention rate of the video data within the preset time includes: when the retention rate of the video data is detected within the preset time When both are less than the second preset threshold, it is determined that the data state is the data empty window state; otherwise, it is not the data empty window state.
  • the data state is the data empty window state.
  • the data state is the data empty window state.
  • the data state when the data state is the data retention state, it indicates that more and more data are stored in the buffer queue, and a data overflow problem may occur.
  • the data state is the data empty window state, it means that the data stored in the buffer queue is getting less and less, or the data stuck in the buffer queue is empty for a long time, which means that the storage unit is fast enough and needs to be increased.
  • the data transmission speed of the large encoding thread can improve the efficiency of data storage.
  • the data state is the data circulation state, it indicates that the current data transmission process is reasonable and can meet the storage requirements of the storage unit.
  • the following steps of the embodiment of the present invention further determine the working mode of the encoding thread according to the data state, especially when the data state is a data retention state or a data empty window state, adjust the work of the encoding thread mode.
  • the working mode of the encoding thread includes an up-rate mode and a down-rate mode.
  • the up-rate mode refers to increasing the data encoding rate of the encoding thread
  • the down-rate mode refers to The purpose is to reduce the data encoding rate of the encoding thread.
  • the data state is a data retention state
  • the working mode of the encoding thread is an increased code rate mode, that is, the data transmission speed of the encoding thread is increased.
  • the code rate reduction mode specifically includes: obtaining the current video encoding rate according to the last video encoding rate, and if the video data is transmitted according to the current video encoding rate, the data status is still the data retention Status, then continue to obtain the current video encoding rate according to the last video encoding rate until the data status is not the data retention state, wherein the current video encoding rate is the last video encoding rate M% of the coding rate, where M is a positive number less than 100.
  • the video encoding rate of the current encoding thread For example, reduce the video encoding rate of the current encoding thread to 80% of the previous time, and then determine whether the buffer queue is still in a data retention state, if so, continue to reduce the video encoding rate of the encoding thread, and change the encoding
  • the video encoding rate of the thread is reduced to 80% of the last time, and then it is judged whether the buffer queue is still in the data retention state under the new video encoding rate. If so, the above process is repeated until the adjusted video encoding
  • the rate is the minimum video encoding rate, or until the data state is not a data retention state.
  • the minimum video encoding rate may be 10% of the highest video encoding rate.
  • the highest video encoding rate is 3Mbps (ie 3M bits per second), a reduction of 80% is 2.4Mbps, and a further reduction of 80% is 1.92 Mbps, another 80% reduction is 1.536Mbps, and so on, the lowest can be reduced to 0.3Mbps.
  • the bit rate up mode specifically includes: obtaining the current video coding bit rate according to the last video coding bit rate, if the video data is transmitted according to the current video coding bit rate, the data status is still the data empty Window state, continue to obtain the current video encoding rate according to the last video encoding rate until the current video encoding rate is the maximum encoding rate, wherein the current video encoding rate is above N% of the one-time video encoding bit rate, where N is a positive number greater than 100.
  • the video encoding rate of the encoding thread is increased to 110% of the previous time, and then it is judged whether the data state of the buffer queue is the data empty window state, if so, Then continue to increase the video encoding rate by 110% until the data state is not a data empty window state, or the video encoding rate is the maximum encoding rate.
  • the above-mentioned code-up rate mode and code-down mode can be triggered according to the data state corresponding to the buffer queue, and the coding thread can run in one of the coding modes, or it can be in one of the two coding modes. Convert between.
  • the embodiment of the present invention mainly adjusts the working mode of the encoding thread according to the data state of the buffer queue.
  • the working mode of the storage thread can also be adjusted, or the encoding thread and the storage are adjusted at the same time. The working mode of the thread.
  • the aforementioned bit rate reduction condition will not be triggered when the video data is stored through the SD card, and the video data can be transmitted at the highest bit rate state.
  • the SD card is a high-speed card and the fluctuation is large, the above code rate condition will be triggered when the SD card fluctuation is blocked, and the above code rate condition will be triggered when the SD card fluctuation ends.
  • the video data transmission can be The highest bit rate status transmission. If the SD card is a low-speed card, the storage thread speed is slow, and the aforementioned code reduction rate condition will continue to be triggered.
  • the video encoding rate When the video encoding rate is reduced to the point where the speed of the storage thread exceeds the speed of the encoding thread, the data stuck in the buffer queue It will gradually decrease. If the data in the buffer queue is empty for a long time, the above-mentioned rate-up rate condition will be triggered. After several down-code adjustments and up-code adjustments, the video encoding rate will eventually be maintained at a certain value, and the encoding thread and storage thread will maintain A balance to achieve the result of adaptive SD card storage rate.
  • the video data transmission method provided by the embodiment of the present invention can be applied to the recording process, such as drone recording.
  • the embodiment of the present invention provides a video data transmission method.
  • the method writes the video data to be written into the storage unit into the buffer queue first, reads the video data from the buffer queue by running the encoding thread and the storage thread at the same time, and then reads the video data from the buffer queue.
  • Write to the storage unit instead of directly writing the video data to the storage unit, thereby reducing the probability of video data loss and reducing the probability of problems such as blurring.
  • the data status of the buffer queue is also monitored in real time, and the working mode of the encoding thread is adjusted according to the data status of the buffer queue, so as to avoid problems such as data overflow and data empty windows in the buffer queue. The above improves the stability and reliability of video data transmission.
  • an embodiment of the present invention provides a video data transmission device 20.
  • the device 20 is applied to a terminal.
  • the device 20 includes an operation module 21, a detection module 22, and a processing module 23.
  • the running module 21 is used to run the encoding thread and the storage thread of the terminal, wherein the encoding thread is used to write video data into the buffer queue, and the storage thread is used to transfer the video in the buffer queue. Data is written to the storage unit.
  • the detection module 22 is used to detect the data state of the video data in the buffer queue.
  • the processing module 23 is configured to determine the working mode of the encoding thread according to the data state, and transmit the video data in the determined working mode of the encoding thread.
  • the detection module 22 includes a first acquisition unit 221 and a first processing unit 222.
  • the first obtaining unit 221 is configured to obtain the retention rate and the fluctuation status of the video data in the buffer queue.
  • the first processing unit 222 is configured to determine the data status according to the retention rate and the fluctuation status, where the data status includes a data retention status, a data empty window status, and a data circulation status.
  • the first processing unit 222 is specifically configured to:
  • the retention rate of the video data is greater than the first preset threshold and the fluctuation state is the rising state
  • the number of rises within the preset time is acquired, and the data state is determined according to the retention rate and the number of rises Whether it is the data retention state;
  • the retention rate of the video data is less than a second preset threshold and the fluctuation state is a non-increasing state
  • the retention rate of the video data within the preset time is acquired, and the video data retention rate is obtained according to the preset time.
  • the retention rate of data determines whether the data state is the data empty window state
  • the data state of the video data is not the data retention state and is not the data empty window state, it is determined that the data state of the video data is the data circulation state.
  • the determining whether the data state is the data detention state according to the detention rate and the number of rises includes: when the detention rate and the number of rises meet any one of the following preset conditions , It is determined that the data status is the data retention status, otherwise, it is not the data retention status.
  • the preset conditions include:
  • the determining whether the data state is the data empty window state according to the retention rate of the video data within the preset time includes: when the retention rate of the video data is detected within the preset time When both are less than the second preset threshold, it is determined that the data state is the data empty window state; otherwise, it is not the data empty window state.
  • the processing module 23 is specifically configured to: when the data state is a data retention state, determine that the working mode of the encoding thread is a reduced code rate mode; when the data state is a data window state, determine that The working mode of the encoding thread is an up-rate mode, and the video data is transmitted in the determined working mode of the encoding thread.
  • the bit rate reduction mode specifically includes: obtaining the current video coding bit rate according to the last video coding bit rate, and if the video data is transmitted according to the current video coding bit rate, the data status is still the Data retention status, then continue to obtain the current video encoding bit rate according to the last video encoding bit rate until the data status is not the data retention status, wherein the current video encoding bit rate is the last time M% of the video encoding bit rate of, where M is a positive number less than 100.
  • the bit rate up mode specifically includes: obtaining the current video coding bit rate according to the last video coding bit rate, if the video data is transmitted according to the current video coding bit rate, the data status is still the data empty Window state, continue to obtain the current video encoding rate according to the last video encoding rate until the current video encoding rate is the maximum encoding rate, wherein the current video encoding rate is above N% of the one-time video encoding bit rate, where N is a positive number greater than 100.
  • FIG. 4 it is a schematic structural diagram of a terminal provided by an embodiment of the present invention.
  • the internal structure of the terminal 30 includes, but is not limited to: a processor 31 and a memory 32.
  • the memory 32 includes an encoding thread 321, a buffer queue 322, and a storage thread 323.
  • the processor 31 and the memory 32 in the terminal 30 may be connected by a bus or other methods.
  • a bus connection is taken as an example.
  • the processor 31 is the computing core and control core of the terminal 30, which can process various data of the terminal. For example, the processor 31 can control the encoding thread 321 to obtain the video data that needs to be stored, and store the video data. To the buffer queue 322; for another example, the processor 31 may control the storage thread 323 to read video data from the buffer queue 322 and store the video data in an SD card, and so on.
  • the memory 32 is a memory device in the terminal 30 for storing data and programs. It is understandable that the memory 32 may include a built-in memory of the terminal 30 or an extended memory supported by the terminal 30. In the embodiment of the present invention, the storage space of the memory 32 also stores an encoding thread 321, a buffer queue 322, and a storage thread 323.
  • the one or more modules are stored in the memory 32, and when executed by the one or more processors 31, the video data transmission method in any of the foregoing method embodiments is executed, for example, as shown in FIG. 1
  • the method steps S11 to S13 and the method steps S121 to S122 shown in FIG. 2 implement the functions of the modules 21-23 and units 221-222 in FIG. 3.
  • the terminals of the embodiments of the present invention exist in various forms, including but not limited to other devices with video recording functions and SD card storage such as drones.
  • the device embodiments described above are merely illustrative, where the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in One place, or it can be distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • each implementation manner can be implemented by means of software plus a general hardware platform, and of course, it can also be implemented by hardware.
  • a person of ordinary skill in the art can understand that all or part of the processes in the method of the foregoing embodiments can be implemented by instructing relevant hardware through a computer program.
  • the program can be stored in a computer readable storage medium. When executed, it may include the procedures of the above-mentioned method embodiments.
  • the storage medium may be a magnetic disk, an optical disc, a read-only memory (Read-Only Memory, ROM), or a random access memory (Random Access Memory, RAM), etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Databases & Information Systems (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

Embodiments of the present invention relate to the technical field of data processing, and in particular, to a video data transmission method and a terminal. The method comprises: operating a coding thread and a storage thread of the terminal, wherein the coding thread is used for writing video data into a buffer queue, and the storage thread is used for writing the video data in the buffer queue into a storage unit; detecting a data state of the video data in the buffer queue; and determining a working mode of the coding thread according to the data state, and transmitting the video data in the determined working mode of the coding thread. The embodiments of the present invention can prevent the problems of data overflow and the like of the buffer queue, and the stability and reliability of video data transmission are improved on the whole.

Description

一种视频数据的传输方法及终端Video data transmission method and terminal 【技术领域】【Technical Field】
本发明涉及数据处理技术领域,尤其涉及一种视频数据的传输方法及终端。The present invention relates to the technical field of data processing, in particular to a method and terminal for transmitting video data.
【背景技术】【Background technique】
SD卡是一种基于半导体闪存记忆体的数据存储设备,由于具备体积小,数据传输速度快等优势,其作为大容量存储设备被广泛使用。比如,SD卡用于存储高画质的视频数据。在使用过程中,如果待存储的数据码率过高,直接将数据存储至SD卡中时,容易出现丢数据,从而导致花屏等问题。SD card is a data storage device based on semiconductor flash memory. Due to its small size and fast data transmission speed, it is widely used as a large-capacity storage device. For example, SD cards are used to store high-quality video data. In the process of use, if the code rate of the data to be stored is too high, when the data is directly stored in the SD card, it is easy to lose data, which will cause problems such as blurring.
【发明内容】[Summary of the invention]
本发明实施例提供了一种视频数据的传输方法及终端,能够解决SD卡存储数据时容易出现数据丢失的技术问题。The embodiment of the present invention provides a video data transmission method and terminal, which can solve the technical problem that data loss is prone to occur when the SD card stores data.
为解决上述技术问题,本发明实施例提供的第一个技术方案是:提供一种视频数据的传输方法,应用于终端,所述方法包括:In order to solve the above technical problems, the first technical solution provided by the embodiments of the present invention is to provide a method for transmitting video data, which is applied to a terminal, and the method includes:
运行所述终端的编码线程和存储线程,其中,所述编码线程用于向缓冲队列中写入视频数据,所述存储线程用于将所述缓冲队列中的视频数据写入存储单元;Run an encoding thread and a storage thread of the terminal, where the encoding thread is used to write video data into a buffer queue, and the storage thread is used to write video data in the buffer queue into a storage unit;
检测所述缓冲队列中所述视频数据的数据状态;Detecting the data state of the video data in the buffer queue;
根据所述数据状态确定所述编码线程的工作模式,并在确定的所述编码线程的工作模式下传输所述视频数据。The working mode of the encoding thread is determined according to the data state, and the video data is transmitted in the determined working mode of the encoding thread.
可选地,所述检测所述缓冲队列中所述视频数据的数据状态,包括:Optionally, the detecting the data status of the video data in the buffer queue includes:
获取所述缓冲队列中所述视频数据的滞留率和涨跌状态;Acquiring the retention rate and fluctuation status of the video data in the buffer queue;
根据所述滞留率和所述涨跌状态确定所述数据状态,其中,所述数据状态包括数据滞留状态、数据空窗状态以及数据流通状态。The data status is determined according to the retention rate and the fluctuation status, wherein the data status includes a data retention status, a data empty window status, and a data circulation status.
可选地,所述根据所述滞留率和所述涨跌状态确定所述数据状态,包括:Optionally, the determining the data status according to the retention rate and the fluctuation status includes:
当所述视频数据的滞留率大于第一预设阈值并且所述涨跌状态为上涨状态时,获取预设时间内的上涨次数,并根据所述滞留率和所述上涨次数确定所述数据状态是否为所述数据滞留状态;When the retention rate of the video data is greater than the first preset threshold and the fluctuation state is the rising state, the number of rises within the preset time is acquired, and the data state is determined according to the retention rate and the number of rises Whether it is the data retention state;
当所述视频数据的滞留率小于第二预设阈值并且所述涨跌状态为非上涨状态时,获取预设时间内所述视频数据的滞留率,并根据所述预设时间内所述视频数据的滞留率确定所述数据状态是否为所述数据空窗状态;When the retention rate of the video data is less than a second preset threshold and the fluctuation state is a non-increasing state, the retention rate of the video data within the preset time is acquired, and the video data retention rate is obtained according to the preset time. The retention rate of data determines whether the data state is the data empty window state;
当所述视频数据的数据状态不是所述数据滞留状态并且不是所述数据空窗状态时,确定所述视频数据的数据状态为所述数据流通状态。When the data state of the video data is not the data retention state and is not the data empty window state, it is determined that the data state of the video data is the data circulation state.
可选地,所述根据所述滞留率和所述上涨次数确定所述数据状态是否为所述数据滞留状态,包括:Optionally, the determining whether the data status is the data retention status according to the retention rate and the number of rises includes:
当所述滞留率和所述上涨次数满足以下预设条件中的任意一种时,则确定所述数据状态为数据滞留状态,否则,不是所述数据滞留状态;When the retention rate and the number of rises meet any one of the following preset conditions, it is determined that the data status is the data retention status, otherwise, it is not the data retention status;
其中,所述预设条件包括:Wherein, the preset conditions include:
检测到所述缓冲队列中滞留数据超过90%,且所述缓冲队列中滞留数据正在上涨;It is detected that more than 90% of the data retained in the buffer queue is exceeded, and the data retained in the buffer queue is increasing;
检测到所述缓冲队列中滞留数据超过80%,且持续2次检测到所述缓冲队列中滞留数据正在上涨;It is detected that more than 80% of the data retained in the buffer queue is exceeded, and it is continuously detected that the data retained in the buffer queue is increasing for 2 times;
检测到所述缓冲队列中滞留数据超过70%,且持续3次检测到所述缓冲队列中滞留数据正在上涨;It is detected that more than 70% of the data held in the buffer queue is exceeded, and it is detected that the data held in the buffer queue is rising continuously for 3 times;
检测到所述缓冲队列中滞留数据超过60%,且持续4次检测到所述缓冲队列中滞留数据正在上涨;It is detected that the data retained in the buffer queue exceeds 60%, and it is continuously detected that the data retained in the buffer queue is rising for 4 times;
检测到所述缓冲队列中滞留数据超过50%,且持续5次检测到所述缓冲队列中滞留数据正在上涨。It is detected that the data retained in the buffer queue exceeds 50%, and it is detected that the data retained in the buffer queue is rising continuously for 5 times.
可选地,所述根据所述预设时间内所述视频数据的滞留率确定所述数据状态是否为所述数据空窗状态,包括:Optionally, the determining whether the data state is the data empty window state according to the retention rate of the video data within the preset time includes:
当所述预设时间内检测到所述视频数据的滞留率均小于所述第二预设阈值时,则确定所述数据状态为数据空窗状态,否则,不是所述数据空窗状态。When it is detected that the retention rate of the video data is less than the second preset threshold within the preset time, it is determined that the data state is the data empty window state; otherwise, it is not the data empty window state.
可选地,所述根据所述数据状态确定所述编码线程的工作模式,包括:Optionally, the determining the working mode of the encoding thread according to the data state includes:
当所述数据状态为数据滞留状态时,确定所述编码线程的工作模式为降 码率模式;When the data state is a data retention state, it is determined that the working mode of the encoding thread is a reduced code rate mode;
当所述数据状态为数据空窗状态时,确定所述编码线程的工作模式为升码率模式。When the data state is a data empty window state, it is determined that the working mode of the encoding thread is an up-rate mode.
可选地,所述降码率模式具体包括:Optionally, the code reduction mode specifically includes:
根据上一次的视频编码码率获取当前的视频编码码率,如果根据所述当前的视频编码码率传输视频数据时,所述数据状态仍为所述数据滞留状态,则继续根据所述上一次的视频编码码率获取当前的视频编码码率,直至所述数据状态不为所述数据滞留状态,其中,所述当前的视频编码码率为上一次的视频编码码率的M%,所述M为小于100的正数。Obtain the current video encoding rate according to the previous video encoding rate. If video data is transmitted according to the current video encoding rate, and the data status is still the data retention state, continue according to the last video encoding rate. Obtain the current video encoding rate until the data state is not the data retention state, wherein the current video encoding rate is M% of the previous video encoding rate, and the M is a positive number less than 100.
可选地,所述升码率模式具体包括:Optionally, the bit rate up mode specifically includes:
根据上一次的视频编码码率获取当前的视频编码码率,如果根据所述当前的视频编码码率传输视频数据时,所述数据状态仍为所述数据空窗状态,则继续根据所述上一次的视频编码码率获取当前的视频编码码率,直至所述当前的视频编码码率为最大编码码率,其中,所述当前的视频编码码率为上一次的视频编码码率的N%,所述N为大于100的正数。Obtain the current video encoding rate according to the last video encoding rate. If video data is transmitted according to the current video encoding rate, the data state is still the data empty window state, then continue to be based on the previous video encoding rate. Obtain the current video encoding bit rate for one video encoding rate until the current video encoding rate is the maximum encoding rate, where the current video encoding rate is N% of the previous video encoding rate , The N is a positive number greater than 100.
可选地,所述存储单元为SD卡。Optionally, the storage unit is an SD card.
为解决上述技术问题,本发明实施例提供的第二个技术方案是:提供一种终端,所述终端包括:SD卡;主控制器,与所述SD卡连接;其中,所述主控制器包括至少一个处理器;以及与所述至少一个处理器通信连接的缓存器;其中,所述缓存器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器执行如上所述的视频数据的传输方法。In order to solve the above technical problem, the second technical solution provided by the embodiment of the present invention is to provide a terminal, the terminal includes: an SD card; a main controller connected to the SD card; wherein, the main controller It includes at least one processor; and a buffer in communication with the at least one processor; wherein the buffer stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor. Executing, so that the at least one processor executes the video data transmission method as described above.
与现有技术相比较,本发明实施例提供的视频数据的传输方法和终端,通过同时运行编码线程和存储线程,将待写入存储单元的视频数据先写入缓冲队列,从缓冲队列中读取视频数据,再写入存储单元,而不直接将视频数据写入存储单元,从而能够降低视频数据丢失的概率,降低花屏等问题发生的概率。此外,在传输视频数据的过程中,还对缓冲队列的数据状态进行实时监测,根据缓冲队列的数据状态调整编码线程的工作模式,从而能够避免缓冲队列出现数据溢出等问题,总体上提高了视频数据传输的稳定性和可靠 性。Compared with the prior art, the video data transmission method and terminal provided by the embodiments of the present invention, by running the encoding thread and the storage thread at the same time, first write the video data to be written into the storage unit into the buffer queue and read from the buffer queue. Take the video data and write it into the storage unit instead of directly writing the video data into the storage unit, thereby reducing the probability of video data loss and reducing the probability of problems such as blurring. In addition, in the process of transmitting video data, the data status of the buffer queue is also monitored in real time, and the working mode of the encoding thread is adjusted according to the data status of the buffer queue, so as to avoid problems such as data overflow in the buffer queue, and improve the overall video Stability and reliability of data transmission.
【附图说明】【Explanation of the drawings】
一个或多个实施例通过与之对应的附图中的图片进行示例性说明,这些示例性说明并不构成对实施例的限定,附图中具有相同参考数字标号的元件表示为类似的元件,除非有特别申明,附图中的图不构成比例限制。One or more embodiments are exemplified by the pictures in the corresponding drawings. These exemplified descriptions do not constitute a limitation on the embodiments. The elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the attached drawings do not constitute a scale limitation.
图1为本发明实施例提供的一种视频数据的传输方法的流程图;FIG. 1 is a flowchart of a method for transmitting video data according to an embodiment of the present invention;
图2为本发明实施例提供的一种视频数据的传输方法中检测所述缓冲队列中所述视频数据的数据状态的方法的流程图;2 is a flowchart of a method for detecting the data state of the video data in the buffer queue in a video data transmission method provided by an embodiment of the present invention;
图3为本发明实施例提供的一种视频数据的传输装置的结构示意图;3 is a schematic structural diagram of a video data transmission device provided by an embodiment of the present invention;
图4为本发明实施例提供的一种终端的结构示意图。Fig. 4 is a schematic structural diagram of a terminal provided by an embodiment of the present invention.
【具体实施方式】【Detailed ways】
为了便于理解本发明,下面结合附图和具体实施例,对本发明进行更详细的说明。需要说明的是,当元件被表述“固定于”另一个元件,它可以直接在另一个元件上、或者其间可以存在一个或多个居中的元件。当一个元件被表述“连接”另一个元件,它可以是直接连接到另一个元件、或者其间可以存在一个或多个居中的元件。本说明书所使用的术语“上”、“下”、“内”、“外”、“底部”等指示的方位或位置关系为基于附图所示的方位或位置关系,仅是为了便于描述本发明和简化描述,而不是指示或暗示所指的装置或元件必须具有特定的方位、以特定的方位构造和操作,因此不能理解为对本发明的限制。此外,术语“第一”、“第二”“第三”等仅用于描述目的,而不能理解为指示或暗示相对重要性。In order to facilitate the understanding of the present invention, the present invention will be described in more detail below with reference to the accompanying drawings and specific embodiments. It should be noted that when an element is expressed as being "fixed to" another element, it can be directly on the other element, or there may be one or more elements in between. When an element is said to be "connected" to another element, it can be directly connected to the other element, or there may be one or more intervening elements in between. The terms "upper", "lower", "inner", "outer", "bottom", etc. used in this specification indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention. The invention and simplified description do not indicate or imply that the pointed device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation of the present invention. In addition, the terms "first", "second", "third", etc. are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance.
除非另有定义,本说明书所使用的所有的技术和科学术语与属于本发明的技术领域的技术人员通常理解的含义相同。本说明书中在本发明的说明书中所使用的术语只是为了描述具体的实施例的目的,不是用于限制本发明。本说明书所使用的术语“和/或”包括一个或多个相关的所列项目的任意的和所有的组合。Unless otherwise defined, all technical and scientific terms used in this specification have the same meaning as commonly understood by those skilled in the technical field of the present invention. The terms used in the specification of the present invention in this specification are only for the purpose of describing specific embodiments, and are not used to limit the present invention. The term "and/or" used in this specification includes any and all combinations of one or more related listed items.
此外,下面所描述的本发明不同实施例中所涉及的技术特征只要彼此之间未构成冲突就可以相互结合。In addition, the technical features involved in the different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
本发明实施例通过编码线程获取编码单元提供的视频数据,并将该视频数据存储至缓冲队列中,通过存储线程从所述缓冲队列中读取所述视频数据,并存储至存储单元中。其中,编码线程和存储线程同时并行运行,所述编码线程在将该视频数据存储至缓冲队列后就释放其当前所占用的系统资源,继续从编码单元获取下一视频数据。所述存储线程在将该视频数据存储至存储单元后也释放其当前所占用的系统资源,继续从缓冲队列中读取下一视频数据。此外,在所述视频数据传输过程中,对所述缓冲队列的视频数据的数据状态进行实时监测,根据缓冲队列中视频数据的存储状态确定编码线程的工作模式,从而可以及时调整视频数据的传输速度,避免缓冲队列中数据溢出或者数据为空等异常情况。In the embodiment of the present invention, the video data provided by the encoding unit is obtained through the encoding thread, and the video data is stored in the buffer queue, and the video data is read from the buffer queue through the storage thread and stored in the storage unit. Wherein, the encoding thread and the storage thread run in parallel at the same time, and the encoding thread releases the currently occupied system resources after storing the video data in the buffer queue, and continues to obtain the next video data from the encoding unit. The storage thread also releases the system resources currently occupied by the storage thread after storing the video data in the storage unit, and continues to read the next video data from the buffer queue. In addition, during the video data transmission process, the data status of the video data in the buffer queue is monitored in real time, and the working mode of the encoding thread is determined according to the storage status of the video data in the buffer queue, so that the video data transmission can be adjusted in time Speed to avoid abnormal situations such as data overflow or empty data in the buffer queue.
基于上述原理,本发明实施例提供了一种视频数据的传输方法,该方法可以应用于终端,所述终端可以是无人机等其他包含SD卡的终端设备。如图1所示,所述方法:Based on the foregoing principles, embodiments of the present invention provide a method for transmitting video data. The method may be applied to a terminal, and the terminal may be other terminal devices including an SD card such as a drone. As shown in Figure 1, the method:
S11、运行所述终端的编码线程和存储线程,其中,所述编码线程用于向缓冲队列中写入视频数据,所述存储线程用于将所述缓冲队列中的视频数据写入存储单元。S11. Run an encoding thread and a storage thread of the terminal, where the encoding thread is used to write video data into a buffer queue, and the storage thread is used to write video data in the buffer queue into a storage unit.
所述编码线程指的是用于将编码单元编辑的数据传输至缓冲队列的操作进程。所述编码单元具体可以是视频信号生成装置中集成的一编码模块,所述编码单元将图像数据转换成视频信号。所述数据具体可以是视频数据。所述存储线程指的是用于将缓冲队列中的数据写入存储单元的操作进程。所述存储单元具体可以是SD卡。所述缓冲队列可以是集成于所述视频信号生成装置中的高速缓存芯片。The encoding thread refers to an operation process used to transmit data edited by the encoding unit to the buffer queue. The encoding unit may specifically be an encoding module integrated in the video signal generating device, and the encoding unit converts image data into a video signal. The data may specifically be video data. The storage thread refers to an operation process used to write data in the buffer queue into the storage unit. The storage unit may specifically be an SD card. The buffer queue may be a cache chip integrated in the video signal generating device.
在本实施例中,所述编码线程和所述存储线程同时并行运行。在工作过程中,所述编程线程从编码单元取视频数据送给缓冲队列,然后再继续回去从编码单元取视频数据。存储线程从缓冲队列中取视频数据,送给存储单元进行SD卡存储,存完后再继续回去从缓冲队列中取视频数据。In this embodiment, the encoding thread and the storage thread run in parallel at the same time. In the working process, the programming thread fetches the video data from the coding unit and sends it to the buffer queue, and then continues to fetch the video data from the coding unit. The storage thread fetches the video data from the buffer queue, sends it to the storage unit for SD card storage, and then continues back to fetch the video data from the buffer queue after the storage is complete.
其中,当SD卡不出现波动、存储顺畅时,所述存储线程的数据传输速度通常会大于所述编码线程的数据传输速度。因此,当编码线程往所述缓冲队列中输入数据后,就会立即被所述存储线程调走该输入数据,由此,数据能够较快的从缓冲队列中读走,避免缓冲队列中产生数据滞留现象,与此同时, 通过缓冲队列的数据缓冲作用,可以降低存储单元中数据溢出等问题的发生概率。Wherein, when the SD card does not fluctuate and the storage is smooth, the data transmission speed of the storage thread is generally greater than the data transmission speed of the encoding thread. Therefore, when the encoding thread inputs data into the buffer queue, the input data will be transferred by the storage thread immediately. As a result, the data can be read from the buffer queue quickly, avoiding data generated in the buffer queue. At the same time, the data buffering effect of the buffer queue can reduce the occurrence of problems such as data overflow in the storage unit.
需要说明的是,上述传输的数据是视频数据,所述视频数据可以是基于H264、H265等编码标准编辑的视频。当然,在实际应用中,所述数据除了是视频数据之外还可以是其他数据,比如图片、音频等等。It should be noted that the above-mentioned transmitted data is video data, and the video data may be a video edited based on coding standards such as H264 and H265. Of course, in practical applications, the data may be other data in addition to video data, such as pictures, audio, and so on.
当SD卡出现波动时,所述存储线程会容易出现阻塞,以至于存储线程传输的数据不能顺畅的写入存储单元。而编码线程不会受到影响,会继续往缓冲队列中传输视频数据,从而导致缓冲队列中滞留的数据越来越多,当滞留的数据超过预设阈值时,缓冲队列中的数据溢出,从而造成花屏现象发生。因此,对缓冲队列中存储的数据的数据状态进行实时监测,根据数据状态调整运行的进程具有重要意义。When the SD card fluctuates, the storage thread may easily be blocked, so that the data transmitted by the storage thread cannot be smoothly written into the storage unit. The encoding thread will not be affected, and will continue to transmit video data to the buffer queue, resulting in more and more data stranded in the buffer queue. When the stranded data exceeds the preset threshold, the data in the buffer queue overflows, resulting in Huaping phenomenon occurs. Therefore, it is of great significance to monitor the data status of the data stored in the buffer queue in real time, and adjust the running process according to the data status.
S12、检测所述缓冲队列中所述视频数据的数据状态。S12. Detect the data status of the video data in the buffer queue.
所述数据状态指的是所述视频数据在所述缓冲队列中的数据存储状态,包括数据存储量、数据大小、数据类型、数据的动态变化趋势(比如上涨或者下跌或者平稳)等等。当所述缓冲队列为集成于所述视频信号生成装置中的高速缓存芯片时,可以通过集成于所述视频信号生成装置中的控制器来检测所述缓冲队列中所述视频数据的数据状态。The data status refers to the data storage status of the video data in the buffer queue, including data storage amount, data size, data type, dynamic change trend of data (such as rising or falling or stable) and so on. When the buffer queue is a cache chip integrated in the video signal generating device, the data state of the video data in the buffer queue can be detected by a controller integrated in the video signal generating device.
具体地,请参阅图2,所述S12、检测所述缓冲队列中所述视频数据的数据状态包括:Specifically, referring to FIG. 2, the S12, detecting the data status of the video data in the buffer queue includes:
S121、获取所述缓冲队列中所述视频数据的滞留率和涨跌状态;S121. Obtain the retention rate and the fluctuation status of the video data in the buffer queue.
S122、根据所述滞留率和所述涨跌状态确定所述数据状态,其中,所述数据状态包括数据滞留状态、数据空窗状态以及数据流通状态。S122. Determine the data status according to the retention rate and the fluctuation status, where the data status includes a data retention status, a data empty window status, and a data circulation status.
所述滞留率指的是当视频数据在所述缓冲队列中滞留时,所滞留的视频数据占所述缓冲队列能够存储的总视频数据的百分比。当所述视频数据在所述缓冲队列中停留的时间超过预设时间阈值时,则可以认为所述缓冲队列中出现了数据滞留现象。在出现数据滞留现象时,所述存储线程从缓冲队列读取数据的速度比编码线程向缓冲队列写入数据的速度慢。The retention rate refers to the percentage of the retained video data in the total video data that can be stored in the buffer queue when video data is retained in the buffer queue. When the time that the video data stays in the buffer queue exceeds a preset time threshold, it can be considered that a data retention phenomenon has occurred in the buffer queue. When the phenomenon of data retention occurs, the speed at which the storage thread reads data from the buffer queue is slower than the speed at which the encoding thread writes data to the buffer queue.
所述涨跌状态指的是视频数据在所述缓冲队列中的动态变化趋势,可以以一个时间周期来检测所述涨跌状态,所述时间周期的大小可以由系统自定 义设置。所述涨跌状态包括数据上涨状态和数据下跌状态。The rising and falling state refers to the dynamic change trend of video data in the buffer queue. The rising and falling state can be detected in a time period, and the size of the time period can be self-defined by the system. The rising and falling state includes a data rising state and a data falling state.
在本实施例中,所述数据状态包括数据滞留状态、数据空窗状态和数据流通状态。所述数据滞留状态指的是第一预设时间内所述缓冲队列中的视频数据的数据存储量均大于第一预设阈值的状态。所述数据空窗状态指的是第二预设时间内所述缓冲队列中的视频数据的数据存储量均小于第二预设阈值的状态。当所述缓冲队列为数据空窗状态时,可以是所述缓冲队列中出现了数据等待的空窗时机,在该空窗时机所述缓冲队列中存储的视频数据可以为空。其中,所述第一预设时间和第二预设时间,以及所述第一预设阈值和所述第二预设阈值可以由系统自定义设置。通常在所述存储线程的数据传输速度明显小于所述编码线程的数据传输速度时会导致所述缓冲队列出现数据滞留状态,在存储线程的数据传输速度明显大于所述编码线程的数据传输速度时会导致所述缓冲队列中出现数据空窗状态。而当所述存储线程的数据传输速度与所述编码线程的数据传输速度相同或者二者的差异在预设范围内时,则所述缓冲队列为数据流通状态,即,在数据流通状态时所述缓冲队列不会发生数据滞留,也不会出现数据等待的空窗时机。In this embodiment, the data status includes a data retention status, a data empty window status, and a data circulation status. The data retention state refers to a state in which the data storage amount of the video data in the buffer queue within the first preset time is greater than a first preset threshold. The data empty window state refers to a state in which the data storage amount of the video data in the buffer queue within the second preset time is less than a second preset threshold. When the buffer queue is in the data empty window state, it may be that an empty window opportunity for data waiting occurs in the buffer queue, and the video data stored in the buffer queue may be empty at the empty window opportunity. Wherein, the first preset time and the second preset time, as well as the first preset threshold and the second preset threshold may be customized by the system. Generally, when the data transmission speed of the storage thread is significantly lower than the data transmission speed of the encoding thread, a data stagnation state occurs in the buffer queue, and when the data transmission speed of the storage thread is significantly greater than the data transmission speed of the encoding thread This will cause a data empty window state to appear in the buffer queue. When the data transmission speed of the storage thread is the same as the data transmission speed of the encoding thread or the difference between the two is within a preset range, the buffer queue is in the data circulation state, that is, when the data is in the data circulation state There will be no data retention in the buffer queue, and no window opportunity for data waiting.
在本实施例中,所述根据所述滞留率和所述涨跌状态确定所述数据状态具体包括:In this embodiment, the determining the data status according to the retention rate and the fluctuation status specifically includes:
a、当所述视频数据的滞留率大于第一预设阈值并且所述涨跌状态为上涨状态时,获取预设时间内的上涨次数,并根据所述滞留率和所述上涨次数确定所述数据状态是否为所述数据滞留状态。a. When the retention rate of the video data is greater than the first preset threshold and the fluctuation state is the rising state, obtain the number of rises within the preset time, and determine the number of rises according to the retention rate and the number of rises Whether the data state is the data retention state.
所述第一预设阈值可以根据经验由系统设置,所述第一预设阈值的大小可以与所述缓冲队列所能够最大存储的数据量大小相关,比如,所述第一预设阈值为总数据存储量的50%,等。所述上涨状态是指所述缓冲队列中滞留的数据为一个持续增长的状态。所述预设时间可以系统自定义设备,比如半分钟,1分钟等。所述上涨次数可以是预设时间内连续上涨的次数。The first preset threshold may be set by the system based on experience, and the size of the first preset threshold may be related to the maximum amount of data that can be stored in the buffer queue. For example, the first preset threshold is the total 50% of data storage, etc. The rising state means that the data held in the buffer queue is in a continuously increasing state. The preset time can be system-defined equipment, such as half a minute, 1 minute, etc. The number of rises may be the number of consecutive rises within a preset time.
根据所述滞留率和所述上涨次数确定所述数据状态是否为数据滞留状态包括:当所述滞留率大于所述第一预设阈值,并且所述上涨次数满足预设时间内连续上涨预设次数,则确定所述数据状态为数据滞留状态。Determining whether the data state is a data detention state according to the detention rate and the number of rises includes: when the detention rate is greater than the first preset threshold, and the number of rises meets the preset time of continuous rise Times, it is determined that the data state is a data retention state.
在一些实施例中,当所述滞留率和所述上涨次数满足以下预设条件中的 任意一种时,则确定所述数据状态为数据滞留状态,否则,不是所述数据滞留状态。In some embodiments, when the retention rate and the number of rises meet any one of the following preset conditions, it is determined that the data status is the data retention status, otherwise, it is not the data retention status.
其中,所述预设条件包括:Wherein, the preset conditions include:
检测到所述缓冲队列中滞留数据超过90%,且所述缓冲队列中滞留数据正在上涨;It is detected that more than 90% of the data retained in the buffer queue is exceeded, and the data retained in the buffer queue is increasing;
检测到所述缓冲队列中滞留数据超过80%,且持续2次检测到所述缓冲队列中滞留数据正在上涨;It is detected that more than 80% of the data retained in the buffer queue is exceeded, and it is continuously detected that the data retained in the buffer queue is increasing for 2 times;
检测到所述缓冲队列中滞留数据超过70%,且持续3次检测到所述缓冲队列中滞留数据正在上涨;It is detected that more than 70% of the data held in the buffer queue is exceeded, and it is detected that the data held in the buffer queue is rising continuously for 3 times;
检测到所述缓冲队列中滞留数据超过60%,且持续4次检测到所述缓冲队列中滞留数据正在上涨;It is detected that the data retained in the buffer queue exceeds 60%, and it is continuously detected that the data retained in the buffer queue is rising for 4 times;
检测到所述缓冲队列中滞留数据超过50%,且持续5次检测到所述缓冲队列中滞留数据正在上涨。It is detected that the data retained in the buffer queue exceeds 50%, and it is detected that the data retained in the buffer queue is rising continuously for 5 times.
b、当所述视频数据的滞留率小于第二预设阈值并且所述涨跌状态为非上涨状态时,获取预设时间内所述视频数据的滞留率,并根据所述预设时间内所述视频数据的滞留率确定所述数据状态是否为所述数据空窗状态。b. When the retention rate of the video data is less than the second preset threshold and the fluctuation state is a non-rising state, the retention rate of the video data within the preset time is acquired, and the retention rate of the video data within the preset time The retention rate of the video data determines whether the data state is the data empty window state.
所述第二预设阈值可以根据经验由系统设置,所述第二预设阈值的大小可以与所述缓冲队列所能够最大存储的数据量大小相关,比如,所述第二预设阈值为总数据存储量的10%,等。所述非上涨状态包括下降状态和不增不跌状态。The second preset threshold may be set by the system based on experience, and the size of the second preset threshold may be related to the maximum amount of data that can be stored in the buffer queue. For example, the second preset threshold is the total 10% of data storage, etc. The non-rising state includes a falling state and a non-increasing or non-decreasing state.
其中,所述根据所述预设时间内所述视频数据的滞留率确定所述数据状态是否为所述数据空窗状态,包括:当所述预设时间内检测到所述视频数据的滞留率均小于所述第二预设阈值时,则确定所述数据状态为数据空窗状态,否则,不是所述数据空窗状态。Wherein, the determining whether the data state is the data empty window state according to the retention rate of the video data within the preset time includes: when the retention rate of the video data is detected within the preset time When both are less than the second preset threshold, it is determined that the data state is the data empty window state; otherwise, it is not the data empty window state.
比如,持续三分钟检测到所述缓冲队列中视频数据的滞留率都小于10%,则确定所述数据状态为数据空窗状态。For example, if it is detected that the retention rate of the video data in the buffer queue is less than 10% for three minutes, it is determined that the data state is the data empty window state.
又比如,持续10次检测到所述缓冲队列中视频数据的滞留率都小于10%,则确定所述数据状态为数据空窗状态。For another example, if it is continuously detected that the retention rate of the video data in the buffer queue is less than 10% for 10 times, it is determined that the data state is the data empty window state.
c、当所述视频数据的数据状态不是所述数据滞留状态并且不是所述数据 空窗状态时,确定所述视频数据的数据状态为所述数据流通状态。c. When the data state of the video data is not the data retention state and the data empty window state, it is determined that the data state of the video data is the data circulation state.
可以理解的是,当所述数据状态为数据滞留状态时,说明所述缓冲队列中存储的数据越来越多,可能会发生数据溢出问题。当所述数据状态为数据空窗状态时,说明所述缓冲队列中存储的数据越来越少,或者缓冲队列中滞留的数据长时间为空,由此说明存储单元存储速度够快,需要增大编码线程的数据传输速度,从而来提升数据存储的效率。当所述数据状态为数据流通状态时,说明当前数据传输的过程是合理的,能够满足存储单元的存储要求。It can be understood that when the data state is the data retention state, it indicates that more and more data are stored in the buffer queue, and a data overflow problem may occur. When the data state is the data empty window state, it means that the data stored in the buffer queue is getting less and less, or the data stuck in the buffer queue is empty for a long time, which means that the storage unit is fast enough and needs to be increased. The data transmission speed of the large encoding thread can improve the efficiency of data storage. When the data state is the data circulation state, it indicates that the current data transmission process is reasonable and can meet the storage requirements of the storage unit.
因此,本发明实施例下述步骤根据所述数据状态来进一步确定所述编码线程的工作模式,特别是在所述数据状态为数据滞留状态或者数据空窗状态时,调整所述编码线程的工作模式。Therefore, the following steps of the embodiment of the present invention further determine the working mode of the encoding thread according to the data state, especially when the data state is a data retention state or a data empty window state, adjust the work of the encoding thread mode.
S13、根据所述数据状态确定所述编码线程的工作模式,并在确定的所述编码线程的工作模式下传输所述视频数据。S13. Determine a working mode of the encoding thread according to the data state, and transmit the video data in the determined working mode of the encoding thread.
在本实施例中,所述编码线程的工作模式包括升码率模式和降码率模式,所述升码率模式指的是提高所述编码线程的数据编码率,所述降码率模式指的是降低所述编码线程的数据编码率。当所述数据状态为数据滞留状态时,确定所述编码线程的工作模式为降码率模式,即降低编码线程的数据传输速度。当所述数据状态为数据空窗状态时,确定所述编码线程的工作模式为升码率模式,即升高编码线程的数据传输速度。In this embodiment, the working mode of the encoding thread includes an up-rate mode and a down-rate mode. The up-rate mode refers to increasing the data encoding rate of the encoding thread, and the down-rate mode refers to The purpose is to reduce the data encoding rate of the encoding thread. When the data state is a data retention state, it is determined that the working mode of the encoding thread is a reduced code rate mode, that is, the data transmission speed of the encoding thread is reduced. When the data state is a data empty window state, it is determined that the working mode of the encoding thread is an increased code rate mode, that is, the data transmission speed of the encoding thread is increased.
所述降码率模式具体包括:根据上一次的视频编码码率获取当前的视频编码码率,如果根据所述当前的视频编码码率传输视频数据时,所述数据状态仍为所述数据滞留状态,则继续根据所述上一次的视频编码码率获取当前的视频编码码率,直至所述数据状态不为所述数据滞留状态,其中,所述当前的视频编码码率为上一次的视频编码码率的M%,所述M为小于100的正数。The code rate reduction mode specifically includes: obtaining the current video encoding rate according to the last video encoding rate, and if the video data is transmitted according to the current video encoding rate, the data status is still the data retention Status, then continue to obtain the current video encoding rate according to the last video encoding rate until the data status is not the data retention state, wherein the current video encoding rate is the last video encoding rate M% of the coding rate, where M is a positive number less than 100.
例如,将当前的编码线程的视频编码率降低为上一次的80%,然后判断所述缓冲队列是否仍为数据滞留状态,若是,则继续降低所述编码线程的视频编码率,将所述编码线程的视频编码率降低为最近一次的80%,然后再判断在新的视频编码率下所述缓冲队列是否仍为数据滞留状态,如果是,则重复上述过程,直至调整后的所述视频编码率为最小视频编码率,或者直至所 述数据状态不是数据滞留状态。其中,所述最小视频编码率可以是最高视频编码率的10%,比如,最高视频编码率为3Mbps(即每秒3M比特),降低为80%即是2.4Mbps,再降80%即是1.92Mbps,再降80%即是1.536Mbps,依次类推,最低可以降低到0.3Mbps。For example, reduce the video encoding rate of the current encoding thread to 80% of the previous time, and then determine whether the buffer queue is still in a data retention state, if so, continue to reduce the video encoding rate of the encoding thread, and change the encoding The video encoding rate of the thread is reduced to 80% of the last time, and then it is judged whether the buffer queue is still in the data retention state under the new video encoding rate. If so, the above process is repeated until the adjusted video encoding The rate is the minimum video encoding rate, or until the data state is not a data retention state. Wherein, the minimum video encoding rate may be 10% of the highest video encoding rate. For example, the highest video encoding rate is 3Mbps (ie 3M bits per second), a reduction of 80% is 2.4Mbps, and a further reduction of 80% is 1.92 Mbps, another 80% reduction is 1.536Mbps, and so on, the lowest can be reduced to 0.3Mbps.
所述升码率模式具体包括:根据上一次的视频编码码率获取当前的视频编码码率,如果根据所述当前的视频编码码率传输视频数据时,所述数据状态仍为所述数据空窗状态,则继续根据所述上一次的视频编码码率获取当前的视频编码码率,直至所述当前的视频编码码率为最大编码码率,其中,所述当前的视频编码码率为上一次的视频编码码率的N%,所述N为大于100的正数。The bit rate up mode specifically includes: obtaining the current video coding bit rate according to the last video coding bit rate, if the video data is transmitted according to the current video coding bit rate, the data status is still the data empty Window state, continue to obtain the current video encoding rate according to the last video encoding rate until the current video encoding rate is the maximum encoding rate, wherein the current video encoding rate is above N% of the one-time video encoding bit rate, where N is a positive number greater than 100.
例如,当所述数据状态为数据空窗状态时,将所述编码线程的视频编码率提升为上一次的110%,然后判断所述缓冲队列的数据状态是否是数据空窗状态,如果是,则继续将所述视频编码率提升110%,直到所述数据状态不是数据空窗状态,或者所述视频编码率为最大编码率。For example, when the data state is the data empty window state, the video encoding rate of the encoding thread is increased to 110% of the previous time, and then it is judged whether the data state of the buffer queue is the data empty window state, if so, Then continue to increase the video encoding rate by 110% until the data state is not a data empty window state, or the video encoding rate is the maximum encoding rate.
需要说明的是,上述升码率模式和降码率模式可以根据所述缓冲队列对应的数据状态来触发,所述编码线程可以是运行其中一种编码模式,也可以是在两种编码模式之间转换。此外,本发明实施例主要是根据缓冲队列的数据状态调整编码线程的工作模式,在其他一些实施例中,还可以调整所述存储线程的工作模式,或者同时调整所述编码线程和所述存储线程的工作模式。It should be noted that the above-mentioned code-up rate mode and code-down mode can be triggered according to the data state corresponding to the buffer queue, and the coding thread can run in one of the coding modes, or it can be in one of the two coding modes. Convert between. In addition, the embodiment of the present invention mainly adjusts the working mode of the encoding thread according to the data state of the buffer queue. In some other embodiments, the working mode of the storage thread can also be adjusted, or the encoding thread and the storage are adjusted at the same time. The working mode of the thread.
下面以所述存储单元为SD卡来进行具体的举例说明。The following takes the storage unit as an SD card for specific examples.
例如,如果所述SD卡为高速卡,并且波动不大,则通过所述SD卡存储视频数据时不会触发上述降码率条件,视频数据可以以最高码率状态传输。如果所述SD卡为高速卡,并且波动较大,在SD卡波动阻塞时会触发上述降码率条件,在SD卡波动结束时会触发上述升码率条件,此时视频数据的传输可以以最高码率状态传输。如果所述SD卡为低速卡,存储线程速度较慢,会持续触发上述降码率条件,当视频编码率降低到存储线程的运转速度超过编码线程的速度时,所述缓冲队列中滞留的数据就会慢慢减少。如果所述缓冲队列中的数据长时间为空,则会触发上述升码率条件,通过几次降码调整和升码调整,视频编码率最终会维持在某一个值,编码线程和存储线程维持一 个平衡,从而到达自适应SD卡存储速率的结果。For example, if the SD card is a high-speed card and has little fluctuation, the aforementioned bit rate reduction condition will not be triggered when the video data is stored through the SD card, and the video data can be transmitted at the highest bit rate state. If the SD card is a high-speed card and the fluctuation is large, the above code rate condition will be triggered when the SD card fluctuation is blocked, and the above code rate condition will be triggered when the SD card fluctuation ends. At this time, the video data transmission can be The highest bit rate status transmission. If the SD card is a low-speed card, the storage thread speed is slow, and the aforementioned code reduction rate condition will continue to be triggered. When the video encoding rate is reduced to the point where the speed of the storage thread exceeds the speed of the encoding thread, the data stuck in the buffer queue It will gradually decrease. If the data in the buffer queue is empty for a long time, the above-mentioned rate-up rate condition will be triggered. After several down-code adjustments and up-code adjustments, the video encoding rate will eventually be maintained at a certain value, and the encoding thread and storage thread will maintain A balance to achieve the result of adaptive SD card storage rate.
本发明实施例提供的视频数据的传输方法可以应用于录像过程中,比如无人机录像等。The video data transmission method provided by the embodiment of the present invention can be applied to the recording process, such as drone recording.
通过上述升码率策略和降码率策略可以解决各种SD卡兼容性问题,以及SD卡存储波动性问题,并且还提供了低速卡存储方案。Various SD card compatibility issues and SD card storage volatility issues can be solved through the above-mentioned bit rate up strategy and bit rate down strategy, and a low-speed card storage solution is also provided.
本发明实施例提供了一种视频数据的传输方法,该方法通过同时运行编码线程和存储线程,将待写入存储单元的视频数据先写入缓冲队列,从缓冲队列中读取视频数据,再写入存储单元,而不直接将视频数据写入存储单元,从而能够降低视频数据丢失的概率,降低花屏等问题发生的概率。此外,在传输视频数据的过程中,还对缓冲队列的数据状态进行实时监测,根据缓冲队列的数据状态调整编码线程的工作模式,从而能够避免缓冲队列出现数据溢出、数据空窗等问题,总体上提高了视频数据传输的稳定性和可靠性。The embodiment of the present invention provides a video data transmission method. The method writes the video data to be written into the storage unit into the buffer queue first, reads the video data from the buffer queue by running the encoding thread and the storage thread at the same time, and then reads the video data from the buffer queue. Write to the storage unit instead of directly writing the video data to the storage unit, thereby reducing the probability of video data loss and reducing the probability of problems such as blurring. In addition, in the process of transmitting video data, the data status of the buffer queue is also monitored in real time, and the working mode of the encoding thread is adjusted according to the data status of the buffer queue, so as to avoid problems such as data overflow and data empty windows in the buffer queue. The above improves the stability and reliability of video data transmission.
如图3所示,本发明实施例提供了一种视频数据的传输装置20,所述装置20应用于终端,所述装置20包括:运行模块21、检测模块22以及处理模块23。As shown in FIG. 3, an embodiment of the present invention provides a video data transmission device 20. The device 20 is applied to a terminal. The device 20 includes an operation module 21, a detection module 22, and a processing module 23.
所述运行模块21,用于运行所述终端的编码线程和存储线程,其中,所述编码线程用于向缓冲队列中写入视频数据,所述存储线程用于将所述缓冲队列中的视频数据写入存储单元。所述检测模块22,用于检测所述缓冲队列中所述视频数据的数据状态。所述处理模块23,用于根据所述数据状态确定所述编码线程的工作模式,并在确定的所述编码线程的工作模式下传输所述视频数据。The running module 21 is used to run the encoding thread and the storage thread of the terminal, wherein the encoding thread is used to write video data into the buffer queue, and the storage thread is used to transfer the video in the buffer queue. Data is written to the storage unit. The detection module 22 is used to detect the data state of the video data in the buffer queue. The processing module 23 is configured to determine the working mode of the encoding thread according to the data state, and transmit the video data in the determined working mode of the encoding thread.
其中,所述检测模块22包括第一获取单元221和第一处理单元222。所述第一获取单元221,用于获取所述缓冲队列中所述视频数据的滞留率和涨跌状态。所述第一处理单元222,用于根据所述滞留率和所述涨跌状态确定所述数据状态,其中,所述数据状态包括数据滞留状态、数据空窗状态以及数据流通状态。Wherein, the detection module 22 includes a first acquisition unit 221 and a first processing unit 222. The first obtaining unit 221 is configured to obtain the retention rate and the fluctuation status of the video data in the buffer queue. The first processing unit 222 is configured to determine the data status according to the retention rate and the fluctuation status, where the data status includes a data retention status, a data empty window status, and a data circulation status.
其中,所述第一处理单元222具体用于:Wherein, the first processing unit 222 is specifically configured to:
当所述视频数据的滞留率大于第一预设阈值并且所述涨跌状态为上涨状 态时,获取预设时间内的上涨次数,并根据所述滞留率和所述上涨次数确定所述数据状态是否为所述数据滞留状态;When the retention rate of the video data is greater than the first preset threshold and the fluctuation state is the rising state, the number of rises within the preset time is acquired, and the data state is determined according to the retention rate and the number of rises Whether it is the data retention state;
当所述视频数据的滞留率小于第二预设阈值并且所述涨跌状态为非上涨状态时,获取预设时间内所述视频数据的滞留率,并根据所述预设时间内所述视频数据的滞留率确定所述数据状态是否为所述数据空窗状态;When the retention rate of the video data is less than a second preset threshold and the fluctuation state is a non-increasing state, the retention rate of the video data within the preset time is acquired, and the video data retention rate is obtained according to the preset time. The retention rate of data determines whether the data state is the data empty window state;
当所述视频数据的数据状态不是所述数据滞留状态并且不是所述数据空窗状态时,确定所述视频数据的数据状态为所述数据流通状态。When the data state of the video data is not the data retention state and is not the data empty window state, it is determined that the data state of the video data is the data circulation state.
其中,所述根据所述滞留率和所述上涨次数确定所述数据状态是否为所述数据滞留状态,包括:当所述滞留率和所述上涨次数满足以下预设条件中的任意一种时,则确定所述数据状态为数据滞留状态,否则,不是所述数据滞留状态。其中,所述预设条件包括:Wherein, the determining whether the data state is the data detention state according to the detention rate and the number of rises includes: when the detention rate and the number of rises meet any one of the following preset conditions , It is determined that the data status is the data retention status, otherwise, it is not the data retention status. Wherein, the preset conditions include:
检测到所述缓冲队列中滞留数据超过90%,且所述缓冲队列中滞留数据正在上涨;It is detected that more than 90% of the data retained in the buffer queue is exceeded, and the data retained in the buffer queue is increasing;
检测到所述缓冲队列中滞留数据超过80%,且持续2次检测到所述缓冲队列中滞留数据正在上涨;It is detected that more than 80% of the data retained in the buffer queue is exceeded, and it is continuously detected that the data retained in the buffer queue is increasing for 2 times;
检测到所述缓冲队列中滞留数据超过70%,且持续3次检测到所述缓冲队列中滞留数据正在上涨;It is detected that more than 70% of the data held in the buffer queue is exceeded, and it is detected that the data held in the buffer queue is rising continuously for 3 times;
检测到所述缓冲队列中滞留数据超过60%,且持续4次检测到所述缓冲队列中滞留数据正在上涨;It is detected that the data retained in the buffer queue exceeds 60%, and it is continuously detected that the data retained in the buffer queue is rising for 4 times;
检测到所述缓冲队列中滞留数据超过50%,且持续5次检测到所述缓冲队列中滞留数据正在上涨。It is detected that the data retained in the buffer queue exceeds 50%, and it is detected that the data retained in the buffer queue is rising continuously for 5 times.
其中,所述根据所述预设时间内所述视频数据的滞留率确定所述数据状态是否为所述数据空窗状态,包括:当所述预设时间内检测到所述视频数据的滞留率均小于所述第二预设阈值时,则确定所述数据状态为数据空窗状态,否则,不是所述数据空窗状态。Wherein, the determining whether the data state is the data empty window state according to the retention rate of the video data within the preset time includes: when the retention rate of the video data is detected within the preset time When both are less than the second preset threshold, it is determined that the data state is the data empty window state; otherwise, it is not the data empty window state.
其中,所述处理模块23具体用于,当所述数据状态为数据滞留状态时,确定所述编码线程的工作模式为降码率模式;当所述数据状态为数据空窗状态时,确定所述编码线程的工作模式为升码率模式,并在确定的所述编码线程的工作模式下传输所述视频数据。Wherein, the processing module 23 is specifically configured to: when the data state is a data retention state, determine that the working mode of the encoding thread is a reduced code rate mode; when the data state is a data window state, determine that The working mode of the encoding thread is an up-rate mode, and the video data is transmitted in the determined working mode of the encoding thread.
其中,所述降码率模式具体包括:根据上一次的视频编码码率获取当前的视频编码码率,如果根据所述当前的视频编码码率传输视频数据时,所述数据状态仍为所述数据滞留状态,则继续根据所述上一次的视频编码码率获取当前的视频编码码率,直至所述数据状态不为所述数据滞留状态,其中,所述当前的视频编码码率为上一次的视频编码码率的M%,所述M为小于100的正数。Wherein, the bit rate reduction mode specifically includes: obtaining the current video coding bit rate according to the last video coding bit rate, and if the video data is transmitted according to the current video coding bit rate, the data status is still the Data retention status, then continue to obtain the current video encoding bit rate according to the last video encoding bit rate until the data status is not the data retention status, wherein the current video encoding bit rate is the last time M% of the video encoding bit rate of, where M is a positive number less than 100.
所述升码率模式具体包括:根据上一次的视频编码码率获取当前的视频编码码率,如果根据所述当前的视频编码码率传输视频数据时,所述数据状态仍为所述数据空窗状态,则继续根据所述上一次的视频编码码率获取当前的视频编码码率,直至所述当前的视频编码码率为最大编码码率,其中,所述当前的视频编码码率为上一次的视频编码码率的N%,所述N为大于100的正数。The bit rate up mode specifically includes: obtaining the current video coding bit rate according to the last video coding bit rate, if the video data is transmitted according to the current video coding bit rate, the data status is still the data empty Window state, continue to obtain the current video encoding rate according to the last video encoding rate until the current video encoding rate is the maximum encoding rate, wherein the current video encoding rate is above N% of the one-time video encoding bit rate, where N is a positive number greater than 100.
值得说明的是,上述装置内的模块、单元之间的信息交互、执行过程等内容,由于与本发明的方法实施例基于同一构思,具体内容可参见本发明方法实施例中的叙述,此处不再赘述。It is worth noting that the information interaction between the modules and units in the above-mentioned device, the execution process, etc., are based on the same concept as the method embodiment of the present invention. For specific content, please refer to the description in the method embodiment of the present invention. No longer.
如图4所示,为本发明实施例提供的一种终端的结构示意图,该终端30的内部结构包括但不限于:处理器31和存储器32。存储器32包括编码线程321、缓冲队列322和存储线程323。其中,终端30内的处理器31和存储器32可以通过总线或其他方式连接,在本发明实施例所示的图4中以总线连接为例。As shown in FIG. 4, it is a schematic structural diagram of a terminal provided by an embodiment of the present invention. The internal structure of the terminal 30 includes, but is not limited to: a processor 31 and a memory 32. The memory 32 includes an encoding thread 321, a buffer queue 322, and a storage thread 323. Wherein, the processor 31 and the memory 32 in the terminal 30 may be connected by a bus or other methods. In FIG. 4 shown in the embodiment of the present invention, a bus connection is taken as an example.
其中,处理器31是终端30的计算核心以及控制核心,其可以处理终端的各类数据,例如:处理器31可以控制所述编码线程321获取需要存储的视频数据,并将所述视频数据存储到缓冲队列322;再比如所述处理器31可以控制所述存储线程323从所述缓冲队列322读取视频数据并将该视频数据存储至SD卡中等等。The processor 31 is the computing core and control core of the terminal 30, which can process various data of the terminal. For example, the processor 31 can control the encoding thread 321 to obtain the video data that needs to be stored, and store the video data. To the buffer queue 322; for another example, the processor 31 may control the storage thread 323 to read video data from the buffer queue 322 and store the video data in an SD card, and so on.
存储器32是所述终端30中的记忆设备,用于存放数据和程序。可以理解的是,所述存储器32既可以包括终端30的内置存储器,也可以包括终端30所支持的扩展存储器。在本发明实施例中,所述存储器32的存储空间还存储了编码线程321、缓冲队列322和存储线程323。The memory 32 is a memory device in the terminal 30 for storing data and programs. It is understandable that the memory 32 may include a built-in memory of the terminal 30 or an extended memory supported by the terminal 30. In the embodiment of the present invention, the storage space of the memory 32 also stores an encoding thread 321, a buffer queue 322, and a storage thread 323.
所述一个或者多个模块存储在所述存储器32中,当被所述一个或者多个处理器31执行时,执行上述任意方法实施例中的视频数据的传输方法,例如,执行图1所示的方法步骤S11至S13,图2所示的方法步骤S121至S122,实现图3中的模块21-23,单元221-222的功能。The one or more modules are stored in the memory 32, and when executed by the one or more processors 31, the video data transmission method in any of the foregoing method embodiments is executed, for example, as shown in FIG. 1 The method steps S11 to S13 and the method steps S121 to S122 shown in FIG. 2 implement the functions of the modules 21-23 and units 221-222 in FIG. 3.
上述产品可执行本发明实施例所提供的方法,具备执行方法相应的功能模块和有益效果。未在本实施例中详尽描述的技术细节,可参见本发明实施例所提供的方法。The above-mentioned products can execute the methods provided in the embodiments of the present invention, and have corresponding functional modules and beneficial effects for executing the methods. For technical details that are not described in detail in this embodiment, refer to the method provided in the embodiment of the present invention.
本发明实施例的终端以多种形式存在,包括但不限于无人机等其他具有视频录像功能以及SD卡存储的设备。The terminals of the embodiments of the present invention exist in various forms, including but not limited to other devices with video recording functions and SD card storage such as drones.
以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。The device embodiments described above are merely illustrative, where the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in One place, or it can be distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
通过以上的实施方式的描述,本领域普通技术人员可以清楚地了解到各实施方式可借助软件加通用硬件平台的方式来实现,当然也可以通过硬件来实现。本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)或随机存储记忆体(Random Access Memory,RAM)等。Through the description of the above implementation manners, a person of ordinary skill in the art can clearly understand that each implementation manner can be implemented by means of software plus a general hardware platform, and of course, it can also be implemented by hardware. A person of ordinary skill in the art can understand that all or part of the processes in the method of the foregoing embodiments can be implemented by instructing relevant hardware through a computer program. The program can be stored in a computer readable storage medium. When executed, it may include the procedures of the above-mentioned method embodiments. Wherein, the storage medium may be a magnetic disk, an optical disc, a read-only memory (Read-Only Memory, ROM), or a random access memory (Random Access Memory, RAM), etc.
最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制;在本发明的思路下,以上实施例或者不同实施例中的技术特征之间也可以进行组合,步骤可以以任意顺序实现,并存在如上所述的本发明的不同方面的许多其它变化,为了简明,它们没有在细节中提供;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, not to limit them; under the idea of the present invention, the technical features of the above embodiments or different embodiments can also be combined. The steps can be implemented in any order, and there are many other variations of the different aspects of the present invention as described above. For the sake of brevity, they are not provided in the details; although the present invention has been described in detail with reference to the foregoing embodiments, it is common in the art The skilled person should understand that: they can still modify the technical solutions recorded in the foregoing embodiments, or equivalently replace some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the implementations of the present invention. Examples of the scope of technical solutions.

Claims (10)

  1. 一种视频数据的传输方法,应用于终端,其特征在于,所述方法包括:A method for transmitting video data, applied to a terminal, characterized in that the method includes:
    运行所述终端的编码线程和存储线程,其中,所述编码线程用于向缓冲队列中写入视频数据,所述存储线程用于将所述缓冲队列中的视频数据写入存储单元;Run an encoding thread and a storage thread of the terminal, where the encoding thread is used to write video data into a buffer queue, and the storage thread is used to write video data in the buffer queue into a storage unit;
    检测所述缓冲队列中所述视频数据的数据状态;Detecting the data state of the video data in the buffer queue;
    根据所述数据状态确定所述编码线程的工作模式,并在确定的所述编码线程的工作模式下传输所述视频数据。The working mode of the encoding thread is determined according to the data state, and the video data is transmitted in the determined working mode of the encoding thread.
  2. 根据权利要求1所述的方法,其特征在于,所述检测所述缓冲队列中所述视频数据的数据状态,包括:The method according to claim 1, wherein the detecting the data status of the video data in the buffer queue comprises:
    获取所述缓冲队列中所述视频数据的滞留率和涨跌状态;Acquiring the retention rate and fluctuation status of the video data in the buffer queue;
    根据所述滞留率和所述涨跌状态确定所述数据状态,其中,所述数据状态包括数据滞留状态、数据空窗状态以及数据流通状态。The data status is determined according to the retention rate and the fluctuation status, wherein the data status includes a data retention status, a data empty window status, and a data circulation status.
  3. 根据权利要求2所述的方法,其特征在于,所述根据所述滞留率和所述涨跌状态确定所述数据状态,包括:The method according to claim 2, wherein the determining the data status according to the retention rate and the fluctuation status comprises:
    当所述视频数据的滞留率大于第一预设阈值并且所述涨跌状态为上涨状态时,获取预设时间内的上涨次数,并根据所述滞留率和所述上涨次数确定所述数据状态是否为所述数据滞留状态;When the retention rate of the video data is greater than the first preset threshold and the fluctuation state is the rising state, the number of rises within the preset time is acquired, and the data state is determined according to the retention rate and the number of rises Whether it is the data retention state;
    当所述视频数据的滞留率小于第二预设阈值并且所述涨跌状态为非上涨状态时,获取预设时间内所述视频数据的滞留率,并根据所述预设时间内所述视频数据的滞留率确定所述数据状态是否为所述数据空窗状态;When the retention rate of the video data is less than a second preset threshold and the fluctuation state is a non-increasing state, the retention rate of the video data within the preset time is acquired, and the video data retention rate is obtained according to the preset time. The retention rate of data determines whether the data state is the data empty window state;
    当所述视频数据的数据状态不是所述数据滞留状态并且不是所述数据空窗状态时,确定所述视频数据的数据状态为所述数据流通状态。When the data state of the video data is not the data retention state and is not the data empty window state, it is determined that the data state of the video data is the data circulation state.
  4. 根据权利要求3所述的方法,其特征在于,所述根据所述滞留率和所述上涨次数确定所述数据状态是否为所述数据滞留状态,包括:The method according to claim 3, wherein the determining whether the data state is the data detention state according to the detention rate and the number of rises comprises:
    当所述滞留率和所述上涨次数满足以下预设条件中的任意一种时,则确 定所述数据状态为数据滞留状态,否则,不是所述数据滞留状态;When the retention rate and the number of rises meet any one of the following preset conditions, it is determined that the data status is the data retention status, otherwise, it is not the data retention status;
    其中,所述预设条件包括:Wherein, the preset conditions include:
    检测到所述缓冲队列中滞留数据超过90%,且所述缓冲队列中滞留数据正在上涨;It is detected that more than 90% of the data retained in the buffer queue is exceeded, and the data retained in the buffer queue is increasing;
    检测到所述缓冲队列中滞留数据超过80%,且持续2次检测到所述缓冲队列中滞留数据正在上涨;It is detected that more than 80% of the data retained in the buffer queue is exceeded, and it is continuously detected that the data retained in the buffer queue is increasing for 2 times;
    检测到所述缓冲队列中滞留数据超过70%,且持续3次检测到所述缓冲队列中滞留数据正在上涨;It is detected that more than 70% of the data held in the buffer queue is exceeded, and it is detected that the data held in the buffer queue is rising continuously for 3 times;
    检测到所述缓冲队列中滞留数据超过60%,且持续4次检测到所述缓冲队列中滞留数据正在上涨;It is detected that the data retained in the buffer queue exceeds 60%, and it is continuously detected that the data retained in the buffer queue is rising for 4 times;
    检测到所述缓冲队列中滞留数据超过50%,且持续5次检测到所述缓冲队列中滞留数据正在上涨。It is detected that the data retained in the buffer queue exceeds 50%, and it is detected that the data retained in the buffer queue is rising continuously for 5 times.
  5. 根据权利要求3所述的方法,其特征在于,所述根据所述预设时间内所述视频数据的滞留率确定所述数据状态是否为所述数据空窗状态,包括:The method according to claim 3, wherein the determining whether the data state is the data empty window state according to the retention rate of the video data within the preset time comprises:
    当所述预设时间内检测到所述视频数据的滞留率均小于所述第二预设阈值时,则确定所述数据状态为数据空窗状态,否则,不是所述数据空窗状态。When it is detected that the retention rate of the video data is less than the second preset threshold within the preset time, it is determined that the data state is the data empty window state; otherwise, it is not the data empty window state.
  6. 根据权利要求2至5任一项所述的方法,其特征在于,所述根据所述数据状态确定所述编码线程的工作模式,包括:The method according to any one of claims 2 to 5, wherein the determining the working mode of the encoding thread according to the data state comprises:
    当所述数据状态为数据滞留状态时,确定所述编码线程的工作模式为降码率模式;When the data state is a data retention state, determining that the working mode of the encoding thread is a reduced code rate mode;
    当所述数据状态为数据空窗状态时,确定所述编码线程的工作模式为升码率模式。When the data state is a data empty window state, it is determined that the working mode of the encoding thread is an up-rate mode.
  7. 根据权利要求6所述的方法,其特征在于,所述降码率模式具体包括:The method according to claim 6, wherein the code rate reduction mode specifically comprises:
    根据上一次的视频编码码率获取当前的视频编码码率,如果根据所述当前的视频编码码率传输视频数据时,所述数据状态仍为所述数据滞留状态,则继续根据所述上一次的视频编码码率获取当前的视频编码码率,直至所述 数据状态不为所述数据滞留状态,其中,所述当前的视频编码码率为上一次的视频编码码率的M%,所述M为小于100的正数。Obtain the current video encoding rate according to the previous video encoding rate. If video data is transmitted according to the current video encoding rate, and the data status is still the data retention state, continue to follow Obtain the current video encoding rate until the data state is not the data retention state, wherein the current video encoding rate is M% of the previous video encoding rate, and the M is a positive number less than 100.
  8. 根据权利要求6所述的方法,其特征在于,所述升码率模式具体包括:The method according to claim 6, wherein the bit rate up mode specifically comprises:
    根据上一次的视频编码码率获取当前的视频编码码率,如果根据所述当前的视频编码码率传输视频数据时,所述数据状态仍为所述数据空窗状态,则继续根据所述上一次的视频编码码率获取当前的视频编码码率,直至所述当前的视频编码码率为最大编码码率,其中,所述当前的视频编码码率为上一次的视频编码码率的N%,所述N为大于100的正数。Obtain the current video encoding rate according to the last video encoding rate. If video data is transmitted according to the current video encoding rate, the data state is still the data empty window state, then continue to be based on the previous video encoding rate. Obtain the current video encoding bit rate for one video encoding rate until the current video encoding rate is the maximum encoding rate, where the current video encoding rate is N% of the previous video encoding rate , The N is a positive number greater than 100.
  9. 根据权利要求1至5任一项所述的方法,其特征在于,所述存储单元为SD卡。The method according to any one of claims 1 to 5, wherein the storage unit is an SD card.
  10. 一种终端,其特征在于,所述终端包括:A terminal, characterized in that the terminal includes:
    至少一个处理器;以及At least one processor; and
    与所述至少一个处理器通信连接的存储器;其中,A memory communicatively connected with the at least one processor; wherein,
    所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行权利要求1至9任一项所述的方法。The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor, so that the at least one processor can execute any one of claims 1 to 9 method.
PCT/CN2020/130868 2019-12-03 2020-11-23 Video data transmission method and terminal WO2021109892A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911221282.7A CN111225268A (en) 2019-12-03 2019-12-03 Video data transmission method and terminal
CN201911221282.7 2019-12-03

Publications (1)

Publication Number Publication Date
WO2021109892A1 true WO2021109892A1 (en) 2021-06-10

Family

ID=70827723

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/130868 WO2021109892A1 (en) 2019-12-03 2020-11-23 Video data transmission method and terminal

Country Status (2)

Country Link
CN (1) CN111225268A (en)
WO (1) WO2021109892A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111225268A (en) * 2019-12-03 2020-06-02 深圳市道通智能航空技术有限公司 Video data transmission method and terminal
CN112822494A (en) * 2020-12-30 2021-05-18 稿定(厦门)科技有限公司 Double-buffer coding system and control method thereof

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104301648A (en) * 2014-10-27 2015-01-21 厦门雅迅网络股份有限公司 Method for avoiding data loss when SD card stores video
US20160373810A1 (en) * 2009-11-13 2016-12-22 At&T Intellectual Property I, L.P. Centralized broadband gateway for a wireless communication system
CN108520569A (en) * 2018-03-30 2018-09-11 深圳市华宝电子科技有限公司 Storage method, device, system and the storage medium of video data
CN109429070A (en) * 2017-08-23 2019-03-05 杭州海康威视系统技术有限公司 A kind of mobile terminal video coding method, device and mobile terminal
CN110121089A (en) * 2019-06-10 2019-08-13 杭州米络星科技(集团)有限公司 A kind of RTMP live streaming code rate adaptive approach
CN111225268A (en) * 2019-12-03 2020-06-02 深圳市道通智能航空技术有限公司 Video data transmission method and terminal

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102761741B (en) * 2012-06-26 2014-04-02 中国科学技术大学 Video encoding code rate control system and method on basis of caches at encoding and decoding ends
US9756112B2 (en) * 2015-02-11 2017-09-05 At&T Intellectual Property I, L.P. Method and system for managing service quality according to network status predictions
CN106488176A (en) * 2015-08-26 2017-03-08 重庆西线科技有限公司 A kind of video frequency transmitter
CN108495142B (en) * 2018-04-11 2021-05-25 腾讯科技(深圳)有限公司 Video coding method and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160373810A1 (en) * 2009-11-13 2016-12-22 At&T Intellectual Property I, L.P. Centralized broadband gateway for a wireless communication system
CN104301648A (en) * 2014-10-27 2015-01-21 厦门雅迅网络股份有限公司 Method for avoiding data loss when SD card stores video
CN109429070A (en) * 2017-08-23 2019-03-05 杭州海康威视系统技术有限公司 A kind of mobile terminal video coding method, device and mobile terminal
CN108520569A (en) * 2018-03-30 2018-09-11 深圳市华宝电子科技有限公司 Storage method, device, system and the storage medium of video data
CN110121089A (en) * 2019-06-10 2019-08-13 杭州米络星科技(集团)有限公司 A kind of RTMP live streaming code rate adaptive approach
CN111225268A (en) * 2019-12-03 2020-06-02 深圳市道通智能航空技术有限公司 Video data transmission method and terminal

Also Published As

Publication number Publication date
CN111225268A (en) 2020-06-02

Similar Documents

Publication Publication Date Title
US8893146B2 (en) Method and system of an I/O stack for controlling flows of workload specific I/O requests
WO2021109892A1 (en) Video data transmission method and terminal
US10768823B2 (en) Flow control for unaligned writes in network storage device
US7457892B2 (en) Data communication flow control device and methods thereof
US9305620B2 (en) Techniques for reducing a rate of data transfer to at least a portion of memory
US10990322B2 (en) Memory buffer chip, memory system and method of controlling the memory buffer chip
US9342245B2 (en) Method and system for allocating a resource of a storage device to a storage optimization operation
EP2466824A1 (en) Service scheduling method and device
US8745335B2 (en) Memory arbiter with latency guarantees for multiple ports
US8606992B2 (en) Dynamically switching command types to a mass storage drive
CN101794263B (en) Access method of storage unit and access controller
KR102516484B1 (en) Data transfer apparatus and data transfer method
US11144481B2 (en) Techniques for dynamically adjusting the manner in which I/O requests are transmitted between a computing device and a storage device
US20190369919A1 (en) Task management method and host for electronic storage device
CN108205478B (en) Intelligent sequential SCSI physical layer power management
WO2020118601A1 (en) Method, apparatus, electronic device, and storage medium for video encoding
US20150331616A1 (en) Set head flag of request
US20140379846A1 (en) Technique for coordinating memory access requests from clients in a mobile device
US10936044B2 (en) Quality of service based memory throttling
US8769167B2 (en) Channel device, information processing system and data transfer method
KR102334473B1 (en) Adaptive Deep Learning Accelerator and Method thereof
US8769175B2 (en) Adjustment of post and non-post packet transmissions in a communication interconnect
JP5678923B2 (en) Storage system, input / output control device, input / output control method, and computer program
CN110764710A (en) Data access method and storage system of low-delay and high-IOPS
TWI645298B (en) Methods for reducing data error in transceiving of flash storage interface and apparatuses using the same

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20896600

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20896600

Country of ref document: EP

Kind code of ref document: A1