Video source preview method, device, electronic device and storage medium
By encoding and compressing video signals to generate target video signals and packaging them for transmission, the problem of requiring multiple professional codec chips to support multiple formats in existing technologies is solved, achieving the effects of cost reduction and efficient display.
Patent Information
- Application Number
- CN202311656146.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-05
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2043-12-05
AI Technical Summary
In existing technologies, video source preview requires multiple specialized codec chips to support various encoding formats, resulting in high costs.
By acquiring video signals, encoding and compressing them to generate target video signals, and then packaging and sending them to user terminals for decoding and display, the direct encoding and decoding operations on professional codec chips are avoided.
It reduces the cost of video source preview and enables efficient display of video signals in multiple formats on user terminals.
Smart Images

Figure CN117641063B
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of video sources, and in particular to a video source preview method, device, electronic device and storage medium. Background Art
[0002] Video source preview refers to previewing video files or previewing video files for quick search and screening. Users can quickly determine the files they want to query through video source preview. Video source preview generally uses professional codec chips to encode and decode the signal output by the video source and preview it.
[0003] Specifically, the video source to be previewed is connected to the input end of a professional codec chip, which analyzes the input video source, decodes the video signal into a digital signal, and outputs the decoded digital signal to a display device to implement the decoding process of the video source.
[0004] However, different video sources may use different encoding formats and compression algorithms. A professional codec chip may only support a part of the encoding formats and compression algorithms, and professional codec chips usually require higher manufacturing costs. In other words, if you want to be able to encode and decode video sources in multiple formats, you often need more than one professional codec chip for encoding and decoding, which makes video source previewing more expensive. With the widespread application of video source preview, how to reduce the cost of video source preview is an urgent problem to be solved. Summary of the invention
[0005] In order to reduce the cost of video source preview, the present application provides a video source preview method, device, electronic device and storage medium.
[0006] In a first aspect, the present application provides a video source preview method, which adopts the following technical solution:
[0007] A video source preview method, comprising:
[0008] Acquire a video signal, where the video signal is a signal output by a video source to be previewed;
[0009] Encoding the video signal to obtain a target video signal;
[0010] The target video signal is packaged and sent to a user terminal, so that the packaged target video signal is decoded and displayed by the user terminal.
[0011] By adopting the above technical solution, the signal of the video output to be previewed, that is, the original video image signal, is obtained, the video signal is numbered to obtain the target video signal, the target video signal is packaged, and sent to the user terminal, so that the user terminal can decode and display the packaged target video signal to realize video source preview, without the need for a professional codec chip to encode and decode the video source, thereby reducing the cost of video source preview.
[0012] In a possible implementation manner, encoding the video signal to obtain a target video signal includes:
[0013] Determine the size, compressed horizontal size, and compressed vertical size of the video signal, wherein the size includes the horizontal size and the vertical size;
[0014] Determining a compression factor of the video signal based on the size of the video signal, the compressed horizontal size, and the compressed vertical size;
[0015] Based on the compression coefficient, the video signal is compressed to obtain a target video signal.
[0016] By adopting the above technical solution, by determining the size of the video signal, the horizontal size after compression and the vertical size after compression, the compression coefficient of the video signal is determined, and the video signal is compressed based on the compression coefficient, thereby providing an implementation method for obtaining the target video signal.
[0017] In a possible implementation manner, determining the compression coefficient of the video signal based on the size of the video signal, the compressed horizontal size, and the compressed vertical size includes:
[0018] Determining a horizontal compression coefficient of the video signal based on the horizontal size of the video signal and the horizontal size after compression;
[0019] Determining a longitudinal compression coefficient of the video signal based on the transverse size of the video signal and the longitudinal size after compression;
[0020] Based on the horizontal compression coefficient and the vertical compression coefficient, a compression coefficient of the video signal is determined.
[0021] By adopting the above technical scheme, the horizontal compression coefficient of the video signal is determined based on the horizontal size of the video signal and the horizontal size after compression, and the vertical compression coefficient of the video signal is determined based on the vertical size of the video signal and the vertical size after compression, and the compression coefficient of the video signal is determined based on the horizontal compression coefficient and the vertical compression coefficient, thereby providing an implementation method for determining the compression coefficient of a video signal.
[0022] In a possible implementation manner, compressing the video signal based on the compression coefficient to obtain a target video signal includes:
[0023] Acquire a pixel matrix corresponding to the video signal, and determine the number of row pixels in each row and the number of column pixels in each column in the pixel matrix;
[0024] Determining the number of horizontal pixels based on the horizontal compression coefficient and the number of pixels in the row;
[0025] Determining the number of vertical pixels based on the vertical compression coefficient and the number of column pixels;
[0026] Based on the horizontal number of pixels and the vertical number of pixels, the video signal is compressed to obtain a target video signal.
[0027] By adopting the above technical solution, by obtaining the pixel matrix corresponding to the video signal, and determining the number of row pixels in each row and the number of column pixels in the pixel matrix, the horizontal pixel number is determined based on the horizontal compression coefficient and the number of row pixels, and the vertical pixel number can be obtained similarly, and based on the horizontal pixel number and the vertical pixel number, the video signal is compressed to obtain the target video signal, that is, the pixel matrix corresponding to the video signal is compressed by the compression coefficient, without considering the format of the video source, thereby reducing the cost of video source preview.
[0028] In a possible implementation manner, compressing the video signal based on the horizontal number of pixels and the vertical number of pixels to obtain a target video signal includes:
[0029] Based on the horizontal number of pixels and the vertical number of pixels, the pixel matrix is divided into a plurality of sub-pixel matrices, wherein the number of row pixels in each row of each sub-pixel matrix is the same as the horizontal number of pixels, and the number of column pixels in each column is the same as the vertical number of pixels;
[0030] Merging each row of pixels in each of the sub-pixel matrixes into a pixel data, and compressing the merged pixel data to obtain a target pixel data;
[0031] The data of each target pixel is format-converted to obtain a target video signal.
[0032] By adopting the above technical solution, based on the horizontal pixel number and the vertical pixel number, the pixel matrix is divided into multiple sub-pixel matrices, each sub-pixel matrix is compressed into a target pixel data, and each target pixel is format converted. After the format conversion of each target pixel data is completed, a target video signal is obtained, thereby providing an implementation method for obtaining the target video signal.
[0033] In a possible implementation, the pixel point data is RBG data, and the format conversion of each target pixel point data to obtain a target video signal includes:
[0034] Determine the linear conversion relationship between the RBG data and the YUV data corresponding to each target pixel point data;
[0035] Based on the linear conversion relationship, each target pixel point data is converted into YUV data to obtain a target video signal.
[0036] By adopting the above technical solution, the RBG data corresponding to each target pixel point data is converted into YUV data through the linear conversion relationship between RBG data and YUV data to obtain the target video signal, and the data format is converted into YUV so that the image can be correctly displayed on the display device.
[0037] In a possible implementation, packaging the target video signal and sending it to the user terminal includes:
[0038] Based on the video signal, determining a number of segmentations;
[0039] Splitting the target video signal into a split number of data packets;
[0040] Send each data packet to the user terminal.
[0041] By adopting the above technical solution, the target video signal is segmented by determining the number of segments, obtaining the segmented number of data packets, and each data packet is sent to the user terminal to improve the efficiency and success rate of data transmission.
[0042] In a second aspect, the present application provides a video source preview device, which adopts the following technical solution:
[0043] A video source preview device, comprising:
[0044] An acquisition module, used for acquiring a video signal, wherein the video signal is a signal output by a video source to be previewed;
[0045] An encoding module, used for encoding the video signal to obtain a target video signal;
[0046] The packaging module is used to package the target video signal and send it to the user terminal so that the packaged target video signal can be decoded and displayed by the user terminal.
[0047] In a third aspect, the present application provides an electronic device, which adopts the following technical solution:
[0048] An electronic device, comprising:
[0049] at least one processor;
[0050] Memory;
[0051] At least one application, wherein the at least one application is stored in a memory and configured to be executed by at least one processor, and the at least one application is configured to: execute the video source preview method described in the first aspect above.
[0052] In a fourth aspect, the present application provides a computer-readable storage medium, which adopts the following technical solution:
[0053] A computer-readable storage medium includes: a computer program that can be loaded by a processor and execute the video source preview method described in the first aspect.
[0054] To summarize, the present application includes the following beneficial technical effects: obtaining a signal of a video output to be previewed, that is, the original video image signal, numbering the video signal to obtain a target video signal, packaging the target video signal, and sending it to a user terminal, so that the user terminal can decode and display the packaged target video signal to realize video source preview, without the need for a professional codec chip to encode and decode the video source, thereby reducing the cost of video source preview. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 It is a flowchart of a video source preview method provided by an embodiment of the present application;
[0056] Figure 2 This is a schematic diagram of a pixel matrix division method provided in an embodiment of the present application;
[0057] Figure 3 is a block diagram of a video source preview device provided in an embodiment of the present application;
[0058] Figure 4 It is a schematic diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0059] The following is combined with Figure 1-4 This application is described in further detail.
[0060] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0061] Video source preview refers to previewing video files or previewing video files for quick search and screening. Users can quickly determine the files they want to query through video source preview. Video source preview generally encodes and decodes the signal output by the video source through a professional codec chip, and previews and displays it. Specifically, the video source to be previewed is connected to the input end of the professional codec chip, the professional codec chip parses the input video source, decodes the video signal into a digital signal, and outputs the decoded digital signal to the display device to realize the decoding process of the video source. However, different video sources may use different encoding formats and compression algorithms. A professional codec chip may only support a part of the encoding formats and compression algorithms, and professional codec chips usually require higher manufacturing costs. That is to say, if you want to be able to encode and decode video sources in multiple formats, you often need more than one professional codec chip for encoding and decoding, which makes video source previewing require a large cost. With the widespread application of video source preview, how to reduce the cost of video source preview is an urgent problem to be solved.
[0062] In view of this, an embodiment of the present application provides a video source preview method, which obtains a signal of a video output to be previewed, that is, an original video image signal, numbers the video signal, obtains a target video signal, packages the target video signal, and sends it to a user terminal, so that the user terminal can decode and display the packaged target video signal to realize video source preview, without the need for a professional codec chip to encode and decode the video source, thereby reducing the cost of video source preview.
[0063] See also Figure 1 , an embodiment of the present application provides a video source preview method, which is executed by an electronic device, and the method includes:
[0064] Step S101: Acquire a video signal.
[0065] The video signal is a signal output by the video source to be previewed. Specifically, the signal output by the video source to be previewed is the original image data of the video source to be previewed, for example, the video signal is RBG data of the video source to be previewed.
[0066] Specifically, the user selects the input interface for preview according to the needs, such as DVI (Digital Visual Interface), HDMI (High Definition Multimedia Interface), VGA (Video Graphics Array) and SDI input interfaces, and the electronic device receives the signal output by the video source to be previewed corresponding to the input interface. The signal output by the video source to be previewed can be a single signal or a multi-channel signal, such as a four-channel signal, a two-channel signal, an eight-channel signal, etc. It is worth noting that the following embodiments are all described by taking a single signal as an example.
[0067] Step S102: Encode the video signal to obtain a target video signal.
[0068] The encoding process generally includes compression, encoding and packaging. Specifically, after obtaining the video signal, the video signal is compressed to remove redundant information in the video signal for easy storage and transmission. More specifically, the video signal can be compressed by video compression software, network transmission, microwave transmission and other methods.
[0069] After the video signal is compressed, the compressed video signal is encoded to convert the data of the video signal into data in a machine-readable format. Specifically, the compressed video data can be encoded using encoding algorithms such as H.264 or H.265. Further, after the video signal is compressed and encoded, the compressed and encoded video signal is placed in a file according to a certain format to complete the encapsulation of the compressed and encoded video signal, and the encapsulated video signal is the target video signal. Among them, the encapsulation format is selected according to actual needs, and the embodiments of the present application are not limited to this.
[0070] Step S103: Pack the target video signal and send it to the user terminal, so that the packed target video signal is decoded and displayed by the user terminal.
[0071] Specifically, the target video signal can be packaged by using special video compression software or encoder, and the packaged target video signal is sent to the user terminal, so that the packaged target video signal is decoded and displayed by the user terminal. More specifically, after the electronic device completes the packaging of the target video signal, it triggers a notification signal to notify the control card to read the packaged target video signal, and after the control card reads the packaged target video signal, it sends the packaged target video signal to the user terminal through the protocol. After receiving the packaged target video signal, the user terminal decodes the packaged target video signal and displays it to complete the preview of the video source. More specifically, the electronic device can send the packaged target video signal to the user terminal through the UDP protocol (User Datagram Protocol).
[0072] A possible implementation method of the embodiment of the present application is that in the above-mentioned step S102, the video signal is encoded to obtain a target video signal, which may specifically include: determining the size of the video signal, the horizontal size after compression, and the vertical size after compression; determining the compression coefficient of the video signal based on the size of the video signal, the horizontal size after compression, and the vertical size after compression; based on the compression coefficient, compressing the video signal to obtain the target video signal.
[0073] The size includes the horizontal size and the vertical size. Specifically, the size of a video signal usually refers to the resolution of the video, that is, the number of pixels of the image in the vertical and horizontal directions.
[0074] Specifically, based on the number of pixels of the video signal in the vertical and horizontal directions, the size of the video signal output by the video source to be previewed is determined, and the compressed horizontal size and the compressed vertical size are obtained. The compressed horizontal size and the compressed vertical size are preset in advance. Excessive compression may cause loss of video quality. Therefore, the compressed horizontal size and the compressed vertical size can be set according to actual conditions. For example, the size of the video signal is: horizontal size 1920, vertical size 1080, and the compressed horizontal size is 240, and the compressed vertical size is 136.
[0075] Further, after determining the size of the video signal, the horizontal size after compression, and the vertical size after compression, the compression coefficient of the video signal is determined, and based on the compression coefficient, the video signal is compressed to obtain a target video signal. Specifically, based on the horizontal size of the video signal and the horizontal size after compression, the horizontal compression coefficient is calculated, and the vertical compression coefficient is obtained similarly, and the horizontal compression coefficient and the vertical compression coefficient are used as the compression coefficient of the video signal.
[0076] Furthermore, after obtaining the compression coefficient of the video signal, the video signal is compressed to obtain the target video signal. Specifically, the video signal is horizontally compressed based on the horizontal compression coefficient, and the video signal is vertically compressed based on the vertical compression coefficient, and the compressed video signal is used as the target video signal.
[0077] A possible implementation method of the embodiment of the present application is that in the above embodiment, the compression coefficient of the video signal is determined based on the size of the video signal, the horizontal size after compression, and the vertical size after compression. Specifically, it may include: determining the horizontal compression coefficient of the video signal based on the horizontal size of the video signal and the horizontal size after compression; determining the vertical compression coefficient of the video signal based on the horizontal size of the video signal and the vertical size after compression; determining the compression coefficient of the video signal based on the horizontal compression coefficient and the vertical compression coefficient.
[0078] The compression coefficient includes a transverse compression coefficient and a longitudinal compression coefficient.
[0079] Specifically, after determining the size of the video signal, the horizontal size after compression, and the vertical size after compression, the horizontal compression coefficient of the video signal can be obtained by calculating the ratio of the horizontal size of the video signal to the horizontal size after compression based on the horizontal size of the video signal and the horizontal size after compression; similarly, the ratio of the vertical size of the video signal to the vertical size after compression can be calculated to obtain the vertical compression coefficient of the video signal. Exemplarily, in the above example, when the horizontal size of the video signal is 1920, the vertical size is 1080, the horizontal size after compression is 240, and the vertical size after compression is 136, the horizontal compression coefficient is calculated to be 1920 / 240, that is, the horizontal compression coefficient is 8, and the vertical compression coefficient is calculated to be 1080 / 136, that is, the vertical compression coefficient is 7.94.
[0080] Furthermore, after the horizontal compression coefficient and the vertical compression coefficient are determined, the horizontal compression coefficient and the vertical compression coefficient are used as the compression coefficients of the video signal.
[0081] A possible implementation method of the embodiment of the present application is that in the above embodiment, based on the compression coefficient, the video signal is compressed to obtain the target video signal, which may specifically include: obtaining a pixel point matrix corresponding to the video signal, and determining the number of row pixels in each row and the number of column pixels in each column in the pixel point matrix; determining the horizontal number of pixels based on the horizontal compression coefficient and the number of row pixels; determining the vertical number of pixels based on the vertical compression coefficient and the number of column pixels; compressing the video signal based on the horizontal number of pixels and the vertical number of pixels to obtain the target video signal.
[0082] Specifically, based on the size of the video signal, a pixel matrix corresponding to the video signal is obtained, and the number of pixels in each row of the pixel matrix, i.e., the number of row pixels, and the number of pixels in each column, i.e., the number of column pixels, are determined. Exemplarily, in the above example, when the horizontal size of the video signal is 1920 and the vertical size is 1080, the number of row pixels of the pixel matrix is 1920 and the number of column pixels is 1080.
[0083] Furthermore, after obtaining the number of row pixels and the number of column pixels, the number of horizontal pixels can be determined based on the horizontal compression coefficient and the number of row pixels. Specifically, the horizontal compression coefficient is used as the number of horizontal pixels; similarly, the number of vertical pixels can be obtained.
[0084] Furthermore, after determining the horizontal pixel number and the vertical pixel number, the video signal can be compressed based on the horizontal pixel number and the vertical pixel number to obtain the target video signal. Specifically, horizontal pixel number*vertical pixel number pixel points are selected from the pixel matrix as the target pixel point, and the target pixel point is compressed into one pixel point, and uncompressed horizontal pixel number*vertical pixel number pixel points are selected from the pixel matrix again, and so on, until all the pixel points in the pixel matrix are compressed to obtain the target video signal.
[0085] A possible implementation method of the embodiment of the present application is that in the above embodiment, based on the horizontal pixel number and the vertical pixel number, the video signal is compressed to obtain a target video signal, including: based on the horizontal pixel number and the vertical pixel number, the pixel matrix is divided into multiple sub-pixel matrixes; each row of pixels in each sub-pixel matrix is merged into a pixel data, and the merged pixel data is compressed to obtain a target pixel data; each target pixel data is format converted to obtain a target video signal.
[0086] Among them, the number of row pixels in each row of each sub-pixel matrix is the same as the number of horizontal pixel points, and the number of column pixels in each column is the same as the number of vertical pixel points. The sub-pixel matrix belongs to the pixel matrix.
[0087] Specifically, after determining the number of horizontal pixels and the number of vertical pixels, the pixel matrix can be divided into a plurality of sub-pixel matrices of a size of horizontal pixel number * vertical pixel number, and each sub-pixel matrix is compressed. More specifically, the division starts from the first row and the first column in the pixel matrix, and a row division is performed every other vertical pixel row, and a column division is performed every other horizontal pixel column, so as to obtain a plurality of sub-pixel matrices of a size of horizontal pixel number * vertical pixel number. For example, in the above example, see Figure 2The number of row pixels of the pixel matrix is 1920, the number of column pixels is 1080, the horizontal compression factor is 8, and the vertical compression factor is 7.94, that is, a division is performed every 7.94 rows and 8 columns to obtain multiple sub-pixel matrixes of size 8*7.94.
[0088] Further, after obtaining the sub-pixel matrix, the sub-pixel matrix is compressed to obtain the target video signal. Specifically, for each sub-pixel matrix, each row of pixels in the sub-pixel matrix can be fused into one pixel data, and the fused pixel is compressed to obtain a target pixel data; or, each column of pixels in the sub-pixel matrix is fused into one pixel data, and the fused pixel is compressed to obtain a target pixel data. Exemplarily, in the above example, when the pixel data is RBG data, every 8 pixels are grouped in the horizontal direction and every 7.94 pixels are grouped in the vertical direction, which are fused into the RGB value of one pixel, that is, the target pixel data. Specifically, 64 pixels in 8 rows can be horizontally fused into 8 points, H_RGB1=(RGB1+RGB2+...+RGB8) / 8, and then vertically fused, RGB=(H_RGB1+H_RGB2+H_RGB3+...+H_RGB7+H_RGB8*0.94) / 7.94, to obtain the target pixel data. RGB1 is the RBG data corresponding to the pixel in the first row and the first column.
[0089] Furthermore, after each sub-pixel matrix is compressed, a plurality of target pixel data are obtained, and each target pixel data is format-converted to obtain a target video signal. Specifically, based on the respective formats of each target pixel data, the format of each target pixel data is converted to a preset format, and after the format conversion of each target pixel is completed, a target video signal is obtained.
[0090] A possible implementation method of an embodiment of the present application, in the above embodiment, when the pixel point data is RBG data, each target pixel point data is format converted to obtain a target video signal, which may specifically include: determining a linear conversion relationship between the RBG data and YUV data corresponding to each target pixel point data; based on the linear conversion relationship, converting each target pixel point data into YUV data to obtain a target video signal.
[0091] Among them, in the YUV format, Y represents the brightness signal, and U and V represent the color difference signals. In the RGB format, R, G, and B represent the intensity of red, green, and blue, respectively.
[0092] Specifically, determine the linear conversion relationship between the RBG data and the YUV data corresponding to each target pixel data. More specifically, obtain some color sample data in RGB and YUV formats for calculating the conversion relationship. Use mathematical tools, such as linear regression analysis, to process the RGB and YUV color data to find the linear relationship between them. Based on the processed data, determine the linear conversion formula from YUV to RGB. Exemplarily, the linear conversion relationship between RBG data and YUV data can be: Y=0.299R+0.587G+0.114B; U=-0.147R-0.289G+0.436B=0.492*(BY); V=0.615R-0.515G-0.100B=0.877(RY).
[0093] Further, after the linear conversion relationship between the RBG data and the YUV data is determined, each target pixel point data is converted from the RBG format to the YUV format, and after all target pixel points are converted, a target video signal is obtained.
[0094] Furthermore, when the pixel data is YUV data, each target pixel data can be converted from YUV format to RBG format based on R=Y+1.140V; G=Y -0.394U-0.581V; B=Y+2.032U; and after completing the conversion of all target pixels, a target video signal is obtained.
[0095] A possible implementation method of the embodiment of the present application is to package the target video signal in the above embodiment and send it to the user terminal, which may specifically include: determining the number of segmentations based on the video signal; segmenting the target video signal into data packets of the number of segmentations; and sending each data packet to the user terminal.
[0096] Specifically, the number of segmentations is determined based on the size of the video signal. The size of each video signal corresponds to a preset number of segmentations, and the number of segmentations can be directly obtained based on the size of the video signal. Further, after the number of segmentations is obtained, the target video signal is segmented into the number of segmentation data packets, and each data packet is sent to the user terminal. Specifically, the target video signal can be segmented by using segmentation methods such as random segmentation method, system segmentation method, hierarchical segmentation method, model segmentation method and integrated segmentation method.
[0097] Specifically, after the target video signal is divided into the number of data packets, each data packet can be packaged, and after the packaging is completed, it can be sent. More specifically, the data packet can be packaged based on the data packaging format: slot (slot number-1 byte) + port (interface number-1 byte) + package ID (package ID-1 byte (0-33)) + 1440Bytes data = 1443 bytes, where the slot number and the interface number can be used to identify and locate the parameters and channels of the data. The slot number can be used to identify the slot in a physical device or the component position in the slot. Each slot can accommodate a specific type of component, such as a processor, a memory module, an expansion card, etc. The slot number can be numbered according to the specification or standard of the hardware design. The interface number can be used to identify different interfaces or connection channels in a device or system. In a computer network, each network interface is assigned a unique interface number for network communication and resource sharing. The interface number can also be used to represent different types of device interfaces, such as a USB interface, an HDMI interface, etc. Exemplarily, in the above example, when the number of row pixels of the pixel matrix is 1920, the number of column pixels is 1080, the horizontal compression coefficient is 8, and the vertical compression coefficient is 7.94, the data format can be: the first row of data: Y0, U0, Y1, Y2, U1, Y3...Y238, U119, Y239; the second row of data: Y240, V0, Y241, Y242, V1, Y243...Y478, V119, Y479; the third row of data: Y480, U120, Y481, Y482, U121, Y483...Y718, U239, Y719; the fourth row of data: Y720, V120, Y721, Y722, V121Y723...Y958, V239, Y959.
[0098] The above embodiment introduces a video source preview method from the perspective of the method flow, wherein the signal output by the video source to be previewed can be a single signal or a multi-channel signal, such as a four-channel signal, a two-channel signal, an eight-channel signal, etc. The above embodiment is described by taking a single signal as an example. When the signal output by the video source to be previewed is a multi-channel signal, the electronic device processes each signal in the same manner, which is consistent with the processing process of the single signal in the above embodiment. Specifically, when the video source to be previewed is multi-channel, the multi-channel signals output by the video source to be previewed are obtained, each video signal is encoded, and the target video signal corresponding to each video signal is obtained. The target video signal corresponding to each video signal is packaged respectively and sent to the user terminal, and the packaged target video signal is decoded and displayed by the user terminal. More specifically, for the detailed processing process of the multi-channel signals output by the video source to be previewed, refer to the above embodiment, and the embodiment of the present application will not be repeated here.
[0099] The above embodiment introduces a video source preview method from the perspective of method flow, and the following embodiment introduces a video source preview device from the perspective of a virtual module or a virtual unit. Please refer to the following embodiment for details.
[0100] See also Figure 3 , an embodiment of the present application provides a video source preview device 30, including: an acquisition model 301, an encoding module 302 and a packaging module 303.
[0101] A video source preview device 30 may specifically include:
[0102] The acquisition module 301 is used to acquire a video signal, where the video signal is a signal output by a video source to be previewed;
[0103] The encoding module 302 is used to encode the video signal to obtain a target video signal;
[0104] The packing module 303 is used to pack the target video signal and send it to the user terminal, so that the packed target video signal can be decoded and displayed by the user terminal.
[0105] In a possible implementation of the embodiment of the present application, when the encoding module 302 encodes the video signal to obtain the target video signal, it can be specifically used to:
[0106] Determine the size of the video signal, the compressed horizontal size, and the compressed vertical size, where the size includes the horizontal size and the vertical size;
[0107] Determining a compression factor of the video signal based on the size of the video signal, the horizontal size after compression, and the vertical size after compression;
[0108] Based on the compression coefficient, the video signal is compressed to obtain a target video signal.
[0109] In a possible implementation of the embodiment of the present application, the encoding module 302 determines the compression coefficient of the video signal based on the size of the video signal, the horizontal size after compression, and the vertical size after compression, which can be specifically used for:
[0110] Determining a horizontal compression coefficient of the video signal based on the horizontal size of the video signal and the horizontal size after compression;
[0111] Determine a longitudinal compression factor of the video signal based on the lateral size of the video signal and the longitudinal size after compression;
[0112] Based on the horizontal compression coefficient and the vertical compression coefficient, a compression coefficient of the video signal is determined.
[0113] In a possible implementation of the embodiment of the present application, the encoding module 302 compresses the video signal based on the compression coefficient to obtain the target video signal, which can be specifically used for:
[0114] Obtain a pixel matrix corresponding to the video signal, and determine the number of row pixels in each row and the number of column pixels in each column in the pixel matrix;
[0115] Determine the number of horizontal pixels based on the horizontal compression coefficient and the number of row pixels;
[0116] Determine the number of vertical pixels based on the vertical compression coefficient and the number of column pixels;
[0117] Based on the horizontal pixel number and the vertical pixel number, the video signal is compressed to obtain the target video signal.
[0118] In a possible implementation of the embodiment of the present application, the encoding module 302 compresses the video signal based on the horizontal pixel number and the vertical pixel number to obtain the target video signal, which can be specifically used for:
[0119] Based on the horizontal number of pixels and the vertical number of pixels, the pixel matrix is divided into a plurality of sub-pixel matrixes, wherein the number of row pixels in each row of each sub-pixel matrix is the same as the horizontal number of pixels, and the number of column pixels in each column is the same as the vertical number of pixels;
[0120] Each row of pixels in each sub-pixel matrix is merged into a pixel data, and the merged pixel data is compressed to obtain a target pixel data;
[0121] The data of each target pixel is format-converted to obtain a target video signal.
[0122] In a possible implementation of the embodiment of the present application, the pixel point data is RBG data, and the encoding module 302 converts the format of each target pixel point data to obtain a target video signal, which can be specifically used for:
[0123] Determine the linear conversion relationship between the RBG data and the YUV data corresponding to each target pixel point data;
[0124] Based on the linear conversion relationship, each target pixel data is converted into YUV data to obtain a target video signal.
[0125] In a possible implementation of the embodiment of the present application, when the packaging module 303 packages the target video signal and sends it to the user terminal, it can be specifically used to:
[0126] Based on the video signal, determining the number of segmentations;
[0127] dividing the target video signal into a divided number of data packets;
[0128] Send each data packet to the user terminal.
[0129] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0130] The present application also introduces an electronic device from the perspective of a physical device, such as Figure 4 As shown, Figure 4 The electronic device 400 shown includes: a processor 401 and a memory 403. The processor 401 and the memory 403 are connected, such as through a bus 402. Optionally, the electronic device 400 may also include a transceiver 404. It should be noted that in actual applications, the transceiver 404 is not limited to one, and the structure of the electronic device 400 does not constitute a limitation on the embodiments of the present application.
[0131] Processor 401 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. Processor 401 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0132] The bus 402 may include a path to transmit information between the above components. The bus 402 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus 402 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0133] The memory 403 may be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto.
[0134] The memory 403 is used to store the application code for executing the solution of the present application, and the execution is controlled by the processor 401. The processor 401 is used to execute the application code stored in the memory 403 to implement the contents shown in the above method embodiment.
[0135] The electronic devices include but are not limited to: mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc., and can also be servers, etc. Figure 4 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0136] An embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer-readable storage medium is run on a computer, the computer can execute the corresponding content in the aforementioned method embodiment.
[0137] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0138] The above are only some implementation methods of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A video source preview method, characterized in that: include: Acquire a video signal, where the video signal is a signal output by a video source to be previewed; Encoding the video signal to obtain a target video signal; The target video signal is packaged and sent to the user terminal, so that the packaged target video signal is decoded and displayed by the user terminal, wherein each time a data packet is encapsulated, a notification signal is triggered to notify the control card to read the packaged data packet, and the read data packet is sent to the user terminal through the protocol; The step of encoding the video signal to obtain a target video signal comprises: Determine the size, compressed horizontal size, and compressed vertical size of the video signal, wherein the size includes the horizontal size and the vertical size; Determining a compression factor of the video signal based on the size of the video signal, the compressed horizontal size, and the compressed vertical size; Based on the compression coefficient, compressing the video signal to obtain a target video signal; The step of determining the compression coefficient of the video signal based on the size of the video signal, the compressed horizontal size, and the compressed vertical size includes: Determining a horizontal compression coefficient of the video signal based on the horizontal size of the video signal and the horizontal size after compression; Determining a longitudinal compression coefficient of the video signal based on the transverse size of the video signal and the longitudinal size after compression; Determining a compression coefficient of the video signal based on the horizontal compression coefficient and the vertical compression coefficient; The compressing the video signal based on the compression coefficient to obtain a target video signal includes: Acquire a pixel matrix corresponding to the video signal, and determine the number of row pixels in each row and the number of column pixels in each column in the pixel matrix; Determining the number of horizontal pixels based on the horizontal compression coefficient and the number of pixels in the row; Determining the number of vertical pixels based on the vertical compression coefficient and the number of column pixels; Based on the horizontal number of pixels and the vertical number of pixels, compressing the video signal to obtain a target video signal; The compressing the video signal based on the horizontal pixel number and the vertical pixel number to obtain a target video signal includes: Based on the horizontal number of pixels and the vertical number of pixels, the pixel matrix is divided into a plurality of sub-pixel matrices, wherein the number of row pixels in each row of each sub-pixel matrix is the same as the horizontal number of pixels, and the number of column pixels in each column is the same as the vertical number of pixels; Merging each row of pixels in each of the sub-pixel matrixes into a pixel data, and compressing the merged pixel data to obtain a target pixel data; Convert the format of each target pixel data to obtain a target video signal; The step of packaging the target video signal and sending it to the user terminal includes: Based on the video signal, determining a number of segmentations; Splitting the target video signal into a split number of data packets; Send each data packet to the user terminal; Among them, packaging is performed based on the data packaging format: slot (slot number - 1 byte) + port (interface number - 1 byte) + packageID (package ID - 1 byte) + data packet data; each time a data packet is encapsulated, a notification signal is triggered to notify the control card to read the packaged data packet, and the read data packet is sent to the user terminal through the protocol.
2. The video source preview method according to claim 1, characterized in that: The pixel point data is RBG data, and the format of each target pixel point data is converted to obtain a target video signal, including: Determine the linear conversion relationship between the RBG data and the YUV data corresponding to each target pixel point data; Based on the linear conversion relationship, each target pixel point data is converted into YUV data to obtain a target video signal.
3. A video source preview device, characterized in that: include: An acquisition module, used for acquiring a video signal, wherein the video signal is a signal output by a video source to be previewed; An encoding module, used for encoding the video signal to obtain a target video signal; A packaging module is used to package the target video signal and send it to the user terminal so that the packaged target video signal can be decoded and displayed by the user terminal; wherein, each time a data packet is packaged, a notification signal is triggered to notify the control card to read the packaged data packet, and the read data packet is sent to the user terminal through the protocol; The encoding module encodes the video signal to obtain a target video signal, which is used for: Determine the size, compressed horizontal size, and compressed vertical size of the video signal, wherein the size includes the horizontal size and the vertical size; Determining a compression factor of the video signal based on the size of the video signal, the compressed horizontal size, and the compressed vertical size; Based on the compression coefficient, compressing the video signal to obtain a target video signal; The encoding module determines a compression coefficient of the video signal based on the size of the video signal, the compressed horizontal size, and the compressed vertical size, for: Determining a horizontal compression coefficient of the video signal based on the horizontal size of the video signal and the horizontal size after compression; Determining a longitudinal compression coefficient of the video signal based on the transverse size of the video signal and the longitudinal size after compression; Determining a compression coefficient of the video signal based on the horizontal compression coefficient and the vertical compression coefficient; The encoding module compresses the video signal based on the compression coefficient to obtain a target video signal, which is used to: Acquire a pixel matrix corresponding to the video signal, and determine the number of row pixels in each row and the number of column pixels in each column in the pixel matrix; Determining the number of horizontal pixels based on the horizontal compression coefficient and the number of pixels in the row; Determining the number of vertical pixels based on the vertical compression coefficient and the number of column pixels; Based on the horizontal number of pixels and the vertical number of pixels, compressing the video signal to obtain a target video signal; The encoding module compresses the video signal based on the horizontal pixel number and the vertical pixel number to obtain a target video signal, for: Based on the horizontal number of pixels and the vertical number of pixels, the pixel matrix is divided into a plurality of sub-pixel matrices, wherein the number of row pixels in each row of each sub-pixel matrix is the same as the horizontal number of pixels, and the number of column pixels in each column is the same as the vertical number of pixels; Merging each row of pixels in each of the sub-pixel matrixes into a pixel data, and compressing the merged pixel data to obtain a target pixel data; The step of packaging the target video signal and sending it to the user terminal includes: Based on the video signal, determining a number of segmentations; Splitting the target video signal into a split number of data packets; Send each data packet to the user terminal; Among them, packaging is performed based on the data packaging format: slot (slot number - 1 byte) + port (interface number - 1 byte) + packageID (package ID - 1 byte) + data packet data; each time a data packet is encapsulated, a notification signal is triggered to notify the control card to read the packaged data packet, and the read data packet is sent to the user terminal through the protocol.
4. An electronic device, characterized in that: The electronic device includes: at least one processor; Memory; At least one application, wherein the at least one application is stored in a memory and configured to be executed by at least one processor, and the at least one application is configured to: execute the video source preview method according to any one of claims 1 to 2.
5. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed in a computer, the computer is caused to execute the video source preview method according to any one of claims 1 to 2.
Citation Information
Patent Citations
Processing method and processing device for image zooming
CN101572821A
Video preview method
CN107172366A
Pre-monitoring image display method and system
CN111669541A
Method, device and equipment for fusing image scaling and color space conversion
CN115147695A
Image compression transmission method and device, electronic equipment and storage medium
CN116847106A
