Video transmission method and device, equipment and medium
By adopting Ethernet connection and UDP protocol methods in video transmission technology, the problems of high cost, poor interface versatility and complex configuration in the prior art video transmission in the industrial field are solved, and plug-and-play video transmission is realized without configuration, reducing latency, and meeting the fast response needs of industrial scenarios.
Patent Information
- Application Number
- CN202411970989.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-03-25
AI Technical Summary
The existing video transmission technology has high cost application in the industrial field, the inability to reuse cables to transmit industrial control signals, poor interface versatility, and the cumbersome configuration process of the Internet video protocol, and does not support plug-and-play without configuration, resulting in large startup delays and playback delays, which cannot meet the needs of rapid response industrial scenarios.
Through a video transmission method, using Ethernet connection, the device IP address and broadcast address are obtained according to the device type code, the acquired image is obtained and compressed into video frames, and the broadcast packet is sent based on the UDP protocol, including the video frame and the device IP address, realizing plug-and-play video transmission without configuration.
It realizes configuration-free plug-and-play video transmission in the context of Ethernet transmission, and completes device discovery and communication link establishment in a very short time, reducing user operation complexity and delays, and meeting the rapid response needs of the industrial field.
Smart Images

Figure CN119697424A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of video transmission technology, and in particular to a video transmission method, device, equipment and medium. Background Art
[0002] Existing video transmission technologies such as AHD and HDMI rely on specific host hardware and interfaces, and have the following disadvantages in industrial applications: 1. High cost. Video parsing requires specific hardware and driver support.
[0003] 2. The cable can only transmit video signals and cannot be reused to transmit industrial control signals.
[0004] 3. The interface is far less versatile than the Ethernet port. Common embedded development boards and industrial control tablets are almost all equipped with network ports, but they do not have a unified video interface, so they cannot connect to each other.
[0005] Existing network video technologies, such as RTSP, RTMP, WebRTC and other Internet video protocols, do not support plug-and-play without configuration, and have large startup and playback delays (both over 3 seconds), making them unsuitable for industrial scenarios that require quick response (within 100ms). Summary of the invention
[0006] The invention provides a video transmission method to solve the problem that the configuration process of Internet video protocol is complicated and does not support plug-and-play video transmission without configuration.
[0007] In a first aspect, the present invention provides a video transmission method, the method comprising: Obtain the device IP address and broadcast address based on the device type code on the device side; Acquire a captured image according to a capture device, and compress the captured image to obtain a video frame; A broadcast packet is sent to a broadcast address based on the UDP protocol, wherein the broadcast packet includes a video frame and the device IP address.
[0008] In a second aspect, the present invention provides a video transmission device, comprising: An acquisition unit, used to acquire a device IP address and a broadcast address according to a device type code of the device end; A compression unit, configured to obtain a captured image according to the capture device, and compress the captured image to obtain a video frame; The sending unit is used to send a broadcast packet to a broadcast address based on the UDP protocol, wherein the broadcast packet includes a video frame and the device IP address.
[0009] In a third aspect, an electronic device is provided, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory, used to store computer programs; The processor is used to implement the steps of the video transmission method described in any one of the embodiments of the first aspect when executing the program stored in the memory.
[0010] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the video transmission method as described in any embodiment of the first aspect are implemented.
[0011] The above technical solution provided by the embodiment of the present invention has the following advantages compared with the prior art: In the context of Ethernet transmission, it realizes plug-and-play without configuration and in a very short time, and can complete the device discovery protocol of UDP broadcast in a very short time. The camera and display device connected by network cable can automatically discover each other's existence and automatically establish a communication link. When using this case, users do not need to master network configuration knowledge or perform complicated operations. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0013] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0014] Figure 1 A schematic diagram of a flow chart of a video transmission method provided by an embodiment of the present invention; Figure 2 A schematic diagram of the structure of a video transmission device provided by an embodiment of the present invention; Figure 3 A schematic diagram of the structure of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0015] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0016] Example 1 Figure 1 A schematic flow chart of a video transmission method provided by an embodiment of the present invention. The embodiment of the present invention proposes a video transmission method, wherein a video transmission system comprises a device end and a client end, wherein the device end and the client end are connected via Ethernet, and the video transmission method is applied to the device end, and comprises the following steps S101-S103.
[0017] S101, acquiring a device IP address and a broadcast address according to a device type code of the device end.
[0018] In the specific implementation, the device end and the client end are connected via Ethernet. For example, the device end is set on the smart camera, which consists of a shell, a lens, a photosensitive element, and an embedded computer. It is responsible for capturing the application scene screen and sending video frames with or without algorithm recognition results through the Ethernet port according to business needs. The client end is set on a tablet computer, which runs the Android operating system and receives the video frames sent by the smart camera through the Ethernet port and draws the video frames on the screen. The client end assigns IP addresses to itself and other devices connected to the Ethernet port, and sends broadcast packets to the broadcast address with the client end's own IP address. The device IP address is the IP address assigned by the client end corresponding to the device end.
[0019] In one embodiment, the device IP address is allocated by the client by starting a DHCP server to the device connected to the Ethernet.
[0020] In the specific implementation, the client is a tablet computer, and the "share network via Ethernet" function of the tablet computer is turned on. In this mode, the tablet computer will start a DHCP server to assign IP addresses to itself and other devices connected to the Ethernet port.
[0021] In one embodiment, the broadcast address is set by the client, and a default value of the broadcast address is (255.255.255.255).
[0022] In a specific implementation, the broadcast address is applied to all devices in the network. In this embodiment, the broadcast is based on the UDP protocol, and the broadcast address is 255.255.255.255.
[0023] S102, acquiring a captured image according to a capture device, and compressing the captured image to obtain a video frame.
[0024] In a specific implementation, the device side compresses the images collected by the collection device in jpg format to obtain video frames.
[0025] In one embodiment, the above step S102 includes the steps of: acquiring a captured image through the underlying interface of the capture device; compressing the captured image based on the jpg format, and determining whether the data volume of the compressed image is less than a preset threshold; if so, using the compressed image as a video frame.
[0026] In a specific implementation, the device obtains the captured image through the underlying interface, compresses it in jpg format (preferably, the compression ratio can be 75), and determines whether the compressed image file is less than 64KB. If so, the compressed image is used as a video frame.
[0027] In one embodiment, compressing the acquired image based on the jpg format and judging whether the data volume of the compressed image is less than a preset threshold value comprises: if not, compressing the acquired image based on the jpg format and a preset compression rate and using the compressed image as a video frame.
[0028] In a specific implementation, it is determined whether the compressed image file is smaller than 64KB. If not, the compression rate is reduced (preferably, the compression rate is reduced to 80% of the current value), and the compressed image is used as a video frame.
[0029] S103, sending a broadcast packet to a broadcast address based on the UDP protocol, wherein the broadcast packet includes a video frame and the device IP address.
[0030] In a specific implementation, the byte stream of the video frame is used as a payload and sent to the client using the UDP protocol. The broadcast packet content includes the video frame, the device type identification code and the device IP address.
[0031] In one embodiment, the step of sending the video frame to the broadcast address based on the UDP protocol is performed periodically with the second time interval as a period.
[0032] In the specific implementation, the second time interval is 33ms, and the device periodically sends video frames to the client through the broadcast address at a period of 33ms. Through multi-level optimization of communication protocols, communication formats, encoding methods, rendering methods, etc., the startup delay of the first frame is controlled within 150 milliseconds, and the playback delay from the camera capturing the picture to the display screen displaying the picture is controlled within 50 milliseconds. Ultra-low latency ensures the real-time response of the system in the industrial field.
[0033] In one embodiment, the method further includes the step of: periodically detecting, with a first time interval as a period, whether the step of acquiring a captured image according to the acquisition device and compressing the captured image to obtain a video frame is executed; if not, determining that the device side has failed.
[0034] In the specific implementation, the first time interval is 100ms. In this embodiment, the device creates a frame counter with an initial value of 0 to detect whether the step of obtaining the collected image according to the acquisition device and compressing the collected image to obtain the video frame is executed. Every time the device receives a video frame, it performs a rendering operation through the coroutine. The specific process of the rendering operation is as follows: the device compresses the collected image to obtain a video frame, saves the video frame into the memory, and the frame counter value is incremented by one; the client decodes the video frame data by jpg to obtain a bitmap, preferably, decodes it into ARGB8888 format, and calls the Android Surface component to draw the bitmap on the screen. The device reads the value of the frame counter and saves it as a historical frame counter; starts a coroutine and performs the following steps every 100ms: S21, compares the value of the historical frame counter with the value of the current frame counter. If the value of the historical frame counter is less than the value of the current frame counter, it is determined that the smart camera is normal. If the value of the historical frame counter is not less than the value of the current frame counter, it is determined that the smart camera is invalid and the corresponding invalidation processing flow is executed; S22, assigns the value of the current frame counter to the historical frame counter. By periodically checking whether step S102 is executed and quickly detecting failures, and adopting a connectionless communication mode, camera failures can be detected within 200 milliseconds, minimizing the impact of hardware failures on industrial production. The embodiments of the present invention can achieve the following advantages: In the context of Ethernet transmission, it realizes plug-and-play without configuration and in a very short time, and can complete the device discovery protocol of UDP broadcast in a very short time. The camera and display device connected by network cable can automatically discover each other's existence and automatically establish a communication link. When using this case, users do not need to master network configuration knowledge or perform complicated operations.
[0035] Lower startup delay and playback delay: Through multi-level optimization of communication protocols, communication formats, encoding methods, rendering methods, etc., the startup delay of the first frame is controlled within 150 milliseconds, and the playback delay from the camera capturing the picture to the display screen displaying the picture is controlled within 50 milliseconds. Ultra-low latency ensures the real-time response of the system in the industrial field.
[0036] Higher reliability, less prone to disconnection or delay fluctuations, based on the UDP connectionless transmission protocol, each data frame is independent of each other. Therefore, this case has strong resistance to network interference and will not cause freezes due to key frame packet loss and other reasons. This case uses dynamic compression technology instead of traditional fragmentation technology, so there will be no delay fluctuations due to waiting for fragment reassembly.
[0037] Lower implementation cost, occupies less hardware resources, and can run without special hardware such as h264 encoder.
[0038] Fast failure detection, using a connectionless communication mode, can detect camera failure within 200 milliseconds, minimizing the impact of hardware failures on industrial production.
[0039] See also Figure 2 The embodiment of the present invention further provides a video transmission device 400 , which includes an acquisition unit 401 , a compression unit 402 , and a sending unit 403 .
[0040] The acquisition unit 401 is used to acquire the device IP address and broadcast address according to the device type code of the device end.
[0041] In one embodiment, the device IP address is allocated to the device connected to the Ethernet by starting a DHCP server by the client.
[0042] In one embodiment, the broadcast address is set by the client, and a default value of the broadcast address is (255.255.255.255).
[0043] The compression unit 402 is used to obtain a captured image according to the capture device, and compress the captured image to obtain a video frame.
[0044] In one embodiment, the step of acquiring a captured image according to a capture device and compressing the captured image to obtain a video frame includes: Acquire the collected image through the bottom layer interface of the collection device; Compressing the collected image based on the jpg format, and determining whether the data volume of the compressed image is less than a preset threshold; If yes, the compressed image is used as the video frame.
[0045] In one embodiment, compressing the acquired image based on the jpg format and determining whether the data volume of the compressed image is less than a preset threshold includes: If not, the captured image is compressed based on the jpg format and a preset compression rate, and the compressed image is used as a video frame.
[0046] The sending unit 403 is used to send a broadcast packet to a broadcast address based on the UDP protocol, where the broadcast packet includes a video frame and the device IP address.
[0047] In one embodiment, the step of sending the video frame to the broadcast address based on the UDP protocol is performed periodically with the second time interval as a period.
[0048] In one embodiment, the video transmission device also includes a detection unit for periodically detecting whether the step of acquiring a captured image according to the acquisition device and compressing the captured image to obtain a video frame is executed at a first time interval; if not, it is determined that the device end has failed.
[0049] like Figure 3 As shown, Figure 3 5 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 500 may be a terminal or a server, wherein the terminal may be an electronic device with communication functions such as a smart phone, a tablet computer, a laptop computer, a desktop computer, a personal digital assistant, and a wearable device. The server may be an independent server or a server cluster composed of multiple servers.
[0050] The computer device 500 includes a processor 502 , a memory, and a network interface 505 connected via a system bus 501 , wherein the memory may include a non-volatile storage medium 503 and an internal memory 504 .
[0051] The non-volatile storage medium 503 may store an operating system 5031 and a computer program 5032. When the computer program 5032 is executed, the processor 502 may execute a video transmission method.
[0052] The processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500 .
[0053] The internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a video transmission method.
[0054] The network interface 505 is used to communicate with other devices over the network. Those skilled in the art will appreciate that the above structure is only a block diagram of a portion of the structure related to the present application solution, and does not constitute a limitation on the computer device 500 to which the present application solution is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0055] It should be understood that in the embodiment of the present application, the processor 502 may be a central processing unit (CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0056] It is understood by those skilled in the art that all or part of the processes in the method for implementing the above embodiment can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a storage medium, which is a computer-readable storage medium. The computer program is executed by at least one processor in the computer system to implement the process steps of the embodiment of the above method.
[0057] Therefore, the present invention also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program.
[0058] The storage medium is a physical, non-transient storage medium, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk, etc., which can store program codes. The computer-readable storage medium can be non-volatile or volatile.
[0059] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0060] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of each unit is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0061] The steps in the method of the embodiment of the present invention can be adjusted in order, combined and deleted according to actual needs. The units in the device of the embodiment of the present invention can be combined, divided and deleted according to actual needs. In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0062] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, terminal, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention.
[0063] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0064] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
[0065] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A video transmission method, characterized in that: The video transmission system includes a device end and a client end, wherein the device end and the client end are connected via Ethernet. The method is applied to the device end and includes: Obtain the device IP address and broadcast address based on the device type code on the device side; Acquire a captured image according to a capture device, and compress the captured image to obtain a video frame; A broadcast packet is sent to a broadcast address based on the UDP protocol, wherein the broadcast packet includes a video frame and the device IP address.
2. The method according to claim 1, characterized in that The device IP address is obtained by the client starting the DHCP server and allocating it to the device connected to the Ethernet.
3. The method according to claim 1, characterized in that The broadcast address is set by the client, and the default value of the broadcast address is (255.255.255.255).
4. The method according to claim 1, characterized in that: The method of acquiring a captured image according to a capture device and compressing the captured image to obtain a video frame includes: Acquire the collected image through the bottom layer interface of the collection device; Compressing the collected image based on the jpg format, and determining whether the data volume of the compressed image is less than a preset threshold; If yes, the compressed image is used as the video frame.
5. The method according to claim 4, characterized in that The step of compressing the collected image based on the jpg format and determining whether the data volume of the compressed image is less than a preset threshold value includes: If not, the captured image is compressed based on the jpg format and a preset compression rate, and the compressed image is used as a video frame.
6. The method according to claim 1, characterized in that The method further comprises: Taking the first time interval as a period, periodically detecting whether the step of acquiring a captured image according to the acquisition device and compressing the captured image to obtain a video frame is performed; If not, it is determined that the device is invalid.
7. The method according to claim 1, characterized in that The step of sending the video frame to the broadcast address based on the UDP protocol is performed periodically with the second time interval as a period.
8. A video transmission device, characterized in that: include: An acquisition unit, used to acquire a device IP address and a broadcast address according to a device type code of the device end; A compression unit, configured to obtain a captured image according to the capture device, and compress the captured image to obtain a video frame; The sending unit is used to send a broadcast packet to a broadcast address based on the UDP protocol, wherein the broadcast packet includes a video frame and the device IP address.
9. A computer device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the steps of the method described in any one of claims 1 to 7 when executing a program stored in a memory.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.