Method for determining video encoder parameters, electronic device and storage medium
By automatically adjusting the video encoder parameters using real-time image data and target recognition models in the field of intelligent driving, the problems of strong subjectivity and high cost in the existing methods are solved, and efficient and accurate parameter determination is achieved.
Patent Information
- Application Number
- CN202411579026.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-07
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2044-11-07
AI Technical Summary
The existing methods are highly subjective in the field of intelligent driving, and have high labor and time costs.
By acquiring real-time image data, a first video file that is not encoded and decoded and a second video file that is encoded and decoded is generated. Then, the same numbered images are extracted from these two video files and input them into the preset target recognition model to obtain the target set. The parameters of the video encoder are modified and adjusted based on the target set until the encoded image size meets the preset conditions.
The automatic determination of video encoder parameters is realized, which reduces manual participation, improves the objectivity and accuracy of the results, and saves labor and time costs.
Smart Images

Figure CN119094798B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent driving technology, and in particular to a method for determining video encoder parameters, an electronic device and a storage medium. Background Art
[0002] In the field of intelligent driving, neural network models are usually required, and training neural network models requires a large amount of image data in simulation or real scenes. If these image data are stored in the original image, the amount of storage data is obviously too large and the image acquisition efficiency is too low, so compressed storage is usually required. Compressed storage involves image encoding storage, and the determination of encoder parameters becomes particularly important.
[0003] At present, the parameters of the encoder are manually adjusted, and the video file processed by the encoder is obtained, and the video file is manually judged whether it meets the requirements, so as to determine whether the parameters of the encoder are appropriate. This method is highly subjective and has high labor and time costs. Summary of the invention
[0004] The embodiments of the present invention provide a method for determining parameters of a video encoder, an electronic device and a storage medium to solve the problems that the existing methods are highly subjective and have high labor costs and time costs.
[0005] In a first aspect, an embodiment of the present invention provides a method for determining video encoder parameters, comprising:
[0006] Acquire real-time image data, and obtain a first video file and a second video file based on the real-time image data; the first video file is a video file obtained by directly storing the real-time image data; the second video file is a video file obtained by encoding the real-time image data based on the current values of various parameters of the video encoder and then decoding it;
[0007] Extracting a frame of image from the first video file and the second video file as the first image and the second image respectively, and inputting the first image and the second image into a preset target recognition model respectively, to obtain a first target set and a second target set; the first image and the second image have the same number;
[0008] Based on the first target set and the second target set, modify the current value of the current parameter of the video encoder, re-determine the current value of the current parameter, and encode the first image based on the re-determined current value of the current parameter to obtain an encoded image;
[0009] If the encoded image size is less than or equal to the preset maximum image size, the current values of each parameter are recorded.
[0010] In a possible implementation, based on the first target set and the second target set, modifying a current value of a current parameter of the video encoder to re-determine the current value of the current parameter includes:
[0011] determining a first target quantity for the first target set and a second target quantity for the second target set;
[0012] If the absolute value of the difference between the first target quantity and the second target quantity is greater than the preset quantity threshold, the current value of the current parameter of the video encoder is modified, and the process jumps to the step of acquiring real-time image data to continue execution;
[0013] If the absolute value of the difference between the first target number and the second target number is less than or equal to the preset number threshold, each first target in the first target set and each second target in the second target set are compared respectively, and based on the comparison result, the current value of the current parameter of the video encoder is re-determined.
[0014] In a possible implementation, each first target in the first target set is compared with each second target in the second target set, and according to the comparison result, a current value of a current parameter of the video encoder is re-determined, including:
[0015] For each target number, the position, type and confidence of the first target corresponding to the target number in the first target set are compared with the position, type and confidence of the second target corresponding to the target number in the second target set; if the absolute value of the difference between the position of the first target and the position of the second target is greater than a preset position threshold, or the type of the first target is inconsistent with the type of the second target, or the absolute value of the difference between the confidence of the first target and the confidence of the second target is greater than a preset confidence threshold, the current value of the current parameter of the video encoder is modified, and the step of jumping to the step of obtaining real-time image data is executed in a loop until the preset condition is met;
[0016] The preset conditions include that the absolute value of the difference between the position of the first target corresponding to each target number and the position of the corresponding second target is less than or equal to the preset position threshold, and the type of the first target corresponding to each target number and the type of the corresponding second target are consistent, and the absolute value of the difference between the confidence of the first target corresponding to each target number and the confidence of the corresponding second target is less than or equal to the preset confidence threshold.
[0017] In one possible implementation, the preset quantity threshold, the preset position threshold, and the preset confidence threshold are associated with a preset comparison level;
[0018] The larger the preset comparison level is, the smaller the preset quantity threshold, the preset position threshold and the preset confidence threshold are.
[0019] In a possible implementation, after the current value of the current parameter is modified each time, the method for determining the video encoder parameter further includes:
[0020] Determine whether the modified value of the current parameter after the current modification exceeds the preset value range corresponding to the current parameter;
[0021] If the modified value exceeds the preset value range corresponding to the current parameter, the modification is canceled, and the previous parameter or next parameter of the video encoder is used as the new current parameter, and the process jumps to the step of obtaining real-time image data and executes it in a loop.
[0022] In a possible implementation, after encoding the first image based on the re-determined current value of the current parameter to obtain the encoded image, the method for determining the video encoder parameter further includes:
[0023] If the size of the encoded image is larger than the preset maximum image size, the next parameter of the video encoder is used as the new current parameter, and the process jumps to the step of obtaining real-time image data and executes it in a loop.
[0024] In a possible implementation, if the size of the encoded image is greater than a preset maximum image size, the method for determining the video encoder parameters further includes:
[0025] Determine the cumulative number of frames of acquired real-time image data;
[0026] If the accumulated number of frames is greater than or equal to the preset total number of image frames, the user is prompted to re-determine the preset value ranges corresponding to the various parameters of the video encoder;
[0027] Accordingly, the next parameter of the video encoder is used as the new current parameter, and the step of jumping to the step of obtaining real-time image data is executed in a loop, including:
[0028] If the accumulated number of frames is less than the preset total number of image frames, the next parameter of the video encoder is used as the new current parameter, and the process jumps to the step of obtaining real-time image data and executes it in a loop.
[0029] In a possible implementation manner, the various parameters of the video encoder include at least two of a frame rate, a bit rate, a group of pictures, and a quantization step size.
[0030] In a second aspect, an embodiment of the present invention provides a device for determining video encoder parameters, including:
[0031] The video acquisition module is used to acquire real-time image data, and obtain a first video file and a second video file based on the real-time image data; the first video file is a video file obtained by directly storing the real-time image data; the second video file is a video file obtained by encoding the real-time image data based on the current values of various parameters of the video encoder and then decoding it;
[0032] The target recognition module is used to extract a frame of image from the first video file and the second video file as the first image and the second image respectively, and input the first image and the second image into a preset target recognition model respectively to obtain a first target set and a second target set; the first image and the second image have the same number;
[0033] A parameter correction module, configured to modify a current value of a current parameter of the video encoder based on the first target set and the second target set, re-determine the current value of the current parameter, and encode the first image based on the re-determined current value of the current parameter to obtain an encoded image;
[0034] The parameter determination module is used to record the current values of various parameters if the size of the encoded image is less than or equal to the preset maximum value of the image.
[0035] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a processor and a memory, wherein the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory to execute the method for determining video encoder parameters as described in the first aspect or any possible implementation of the first aspect.
[0036] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for determining video encoder parameters as described in the first aspect or any possible implementation method of the first aspect are implemented.
[0037] The embodiment of the present invention provides a method for determining parameters of a video encoder, an electronic device and a storage medium. The method obtains a first video file that has not been encoded and decoded and a second video file that has been encoded and decoded through real-time image data, extracts a first image and a second image with the same number from the first video file and the second video file, and inputs the first image and the second image into a preset target recognition model respectively to obtain a first target set and a second target set, modifies the current value of the current parameter of the video encoder based on the first target set and the second target set to re-determine the current value of the current parameter, and encodes the first image based on the re-determined current value of the current parameter to obtain an encoded image, and completes the screening of the video encoder parameters when the size of the encoded image is less than or equal to the preset image maximum value, and obtains the parameter value of the video encoder that meets the expected requirements. The method only needs to give the expected requirements, and does not require manual comparison and operation, so that the parameters that meet the expected requirements can be obtained, which can improve the objectivity and accuracy of the final result, and can also save labor costs and time costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0039] Figure 1 is a flow chart of a method for determining video encoder parameters provided by an embodiment of the present invention;
[0040] Figure 2 is a structural schematic diagram of a device for determining video encoder parameters provided by an embodiment of the present invention;
[0041] Figure 3 is a schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0042] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present invention. However, it should be clear to those skilled in the art that the present invention may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present invention.
[0043] In order to make the purpose, technical solutions and advantages of the present invention more clear, specific embodiments will be described below in conjunction with the accompanying drawings.
[0044] See also Figure 1 , which shows an implementation flow chart of the method for determining video encoder parameters provided by an embodiment of the present invention. The execution subject of the method for determining video encoder parameters may be an electronic device. The electronic device may be a controller in a vehicle, or a terminal device outside the vehicle, etc. The method is applicable to the field of commercial vehicles, and may also be applicable to the field of passenger vehicles, and is not specifically limited here.
[0045] See also Figure 1 , the method for determining the video encoder parameters includes:
[0046] In S101, real-time image data is acquired, and a first video file and a second video file are obtained based on the real-time image data; the first video file is a video file obtained by directly storing the real-time image data; the second video file is a video file obtained by encoding the real-time image data based on the current values of various parameters of the video encoder and then decoding it.
[0047] Among them, the real-time image data can be real-time image data captured by a vehicle-mounted camera, for example, it can be image data of the front of the vehicle captured by the vehicle's front-view camera, image data of the rear of the vehicle captured by the vehicle's rear-view camera, or image data of both sides of the vehicle captured by the vehicle's side-view camera, etc. The real-time image data may include multiple frames of images, each frame of the image including a corresponding number and pixel data. The image number may also be referred to as the frame ID of the image or the serial number of the image, etc. The number of frames of the image contained in the real-time image data can be set according to actual needs, and no specific restrictions are made here.
[0048] In this embodiment, the real-time image data can be directly stored as a video file without being encoded and decoded by a video encoder to obtain a first video file. The first video file is a video file directly converted from the original unprocessed real-time image data.
[0049] This embodiment can initialize the video encoder based on the current values of various parameters of the video encoder, and use the video encoder to perform video encoding on real-time image data and store it into a video file to generate a video encoding file, and then decode the video encoding file to obtain a second video file.
[0050] Each parameter of the video encoder has a preset value range corresponding to each parameter. Based on the preset value range corresponding to each parameter, the initial value of each parameter can be determined. The initial value of each parameter can be an upper limit or a lower limit of the corresponding preset value range. The preset value range corresponding to each parameter can be determined based on experience and actual needs.
[0051] If the initial value of each parameter is the upper limit of the corresponding preset value range, then in S103, when the current value of the current parameter is modified, it can be modified in a decreasing direction according to the first step length corresponding to the current parameter, that is, the current value is subtracted from the first step length corresponding to the current parameter to obtain a re-determined current value.
[0052] If the initial value of each parameter is the lower limit of the corresponding preset value range, then in S103, when the current value of the current parameter is modified, it can be modified in the increasing direction according to the second step length corresponding to the current parameter, that is, the current value is added to the second step length corresponding to the current parameter to obtain a re-determined current value.
[0053] Among them, the first step length and the second step length corresponding to each parameter can be set according to actual needs and are not specifically limited here.
[0054] When the value of each parameter is not modified, the current value of each parameter is the initial value of each parameter. When the value of a parameter is modified, the current value of the parameter is the modified value.
[0055] In S102, a frame of image is extracted from the first video file and the second video file respectively as the first image and the second image, and the first image and the second image are respectively input into a preset target recognition model to obtain a first target set and a second target set; the first image and the second image have the same number.
[0056] For example, a frame of image can be randomly or in a predetermined order extracted from the first video file as the first image; the number of the first image is obtained, and the second image with the same number is extracted from the second video file. Alternatively, a frame of image can be randomly or in a predetermined order extracted from the second video file as the second image; the number of the second image is obtained, and the first image with the same number is extracted from the first video file. Alternatively, the image number can be pre-set, the first image with the image number is extracted from the first video file, and the second image with the image number is extracted from the second video file.
[0057] The preset target recognition model can be a neural network model or other target recognition models. The preset target recognition model is a trained target recognition model. The target it recognizes can be determined according to the actual application scenario. For example, it can be a traffic participant, such as various motor vehicles, non-motor vehicles, pedestrians, etc.; it can also be a traffic sign, such as a lane line, road edge, signal light, road sign, road sign, etc.; it can also be a traffic participant and a traffic sign.
[0058] The first image is input into a preset target recognition model to obtain a first target set, which may include first targets recognized by the preset target recognition model from the first image, each first target carrying corresponding information such as position, type and confidence.
[0059] The second image is input into a preset target recognition model to obtain a second target set, which may include each second target recognized by the preset target recognition model from the second image, each second target carrying corresponding information such as position, type and confidence.
[0060] In S103, based on the first target set and the second target set, the current value of the current parameter of the video encoder is modified, the current value of the current parameter is re-determined, and based on the current value of the re-determined current parameter, the first image is encoded to obtain an encoded image.
[0061] The embodiment of the present application modifies the values of various parameters of the video encoder in sequence. When the value of one parameter is modified, the value of the next parameter is modified. Only one parameter is modified each time. The parameter modified this time is called the current parameter. Only the value of the current parameter may change in this modification, and the values of other parameters remain unchanged.
[0062] The current value of the current parameter of the video encoder is modified through the first target set and the second target set to re-determine the current value of the current parameter. The current value of the re-determined current parameter satisfies the preset image quality condition. The preset image quality condition may include that the absolute value of the difference between the number of targets in the first target set and the second target set re-acquired through the current value of the re-determined current parameter is less than or equal to the preset number threshold, and the absolute value of the difference between the position of the first target corresponding to each target number in the first target set and the second target set and the position of the corresponding second target is less than or equal to the preset position threshold, and the type of the first target corresponding to each target number in the first target set and the second target set and the type of the corresponding second target are consistent, and the absolute value of the difference between the confidence of the first target corresponding to each target number in the first target set and the second target set and the confidence of the corresponding second target is less than or equal to the preset position threshold.
[0063] The video encoder is reinitialized by modifying the current parameter of the video encoder to the current value of the re-determined current parameter, while keeping the values of other parameters of the video encoder unchanged. The first image is encoded based on the reinitialized video encoder to obtain an encoded image.
[0064] In S104, if the size of the encoded image is less than or equal to the preset maximum image size, the current values of each parameter are recorded.
[0065] The preset image maximum value is the screening target value. When the size of the encoded image is less than or equal to the preset image maximum value, it means that the size of the image after encoding by the current video encoder meets the use requirements. In the above S103, the current value of the re-determined current parameter meets the preset image quality condition, which means that the image quality after encoding by the current video encoder meets the use requirements. When both the image quality and the image size meet the use requirements, the screening of the values of the various parameters of the video encoder can be ended, and the current values of the various parameters can be recorded so that the subsequent video encoder can work according to the current values of the various parameters.
[0066] In some possible implementations, if the size of the encoded image is less than or equal to a preset maximum image value, the target value range of each parameter of the video encoder may be determined based on the current values of each parameter.
[0067] Exemplarily, for each parameter of the video encoder, if the initial value of the parameter is the upper limit value of the corresponding preset value range, then the target value range of the parameter is from the lower limit value of the preset value range corresponding to the parameter to the current value of the parameter; if the initial value of the parameter is the lower limit value of the corresponding preset value range, then the target value range of the parameter is from the current value of the parameter to the upper limit value of the preset value range corresponding to the parameter.
[0068] This embodiment obtains a first video file that has not been encoded and decoded and a second video file that has been encoded and decoded through real-time image data, extracts a first image and a second image with the same number from the first video file and the second video file, and inputs the first image and the second image into a preset target recognition model respectively to obtain a first target set and a second target set, modifies the current value of the current parameter of the video encoder based on the first target set and the second target set to redetermine the current value of the current parameter, and encodes the first image based on the current value of the redetermined current parameter to obtain an encoded image, and when the size of the encoded image is less than or equal to the preset image maximum value, completes the screening of the video encoder parameters to obtain the parameter values of the video encoder that meet the expected requirements. This method only needs to give the expected requirements, and does not require manual comparison and operation, so that parameters that meet the expected requirements can be obtained, which can improve the objectivity and accuracy of the final result, and can also save labor costs and time costs.
[0069] In some embodiments, in S103, modifying the current value of the current parameter of the video encoder based on the first target set and the second target set to re-determine the current value of the current parameter includes:
[0070] determining a first target quantity for the first target set and a second target quantity for the second target set;
[0071] If the absolute value of the difference between the first target quantity and the second target quantity is greater than the preset quantity threshold, the current value of the current parameter of the video encoder is modified, and the process jumps to the step of acquiring real-time image data to continue execution;
[0072] If the absolute value of the difference between the first target number and the second target number is less than or equal to the preset number threshold, each first target in the first target set and each second target in the second target set are compared respectively, and based on the comparison result, the current value of the current parameter of the video encoder is re-determined.
[0073] The first target quantity is the quantity of first targets included in the first target set. The second target quantity is the quantity of second targets included in the second target set.
[0074] If the absolute value of the difference between the first target number and the second target number is greater than the preset number threshold, it means that the number of targets identified from the first image and the second image is too different, and the first image and the second image are the same image, but the clarity is different. The difference in the number of identified targets is too large, which means that the clarity of the second image is too poor. It is necessary to modify the current value of the current parameter of the video encoder. After the modification, return to S101, re-acquire real-time image data, and then obtain a new first target set and second target set, and verify whether the modified parameters can make the absolute value of the difference between the first target number and the second target number less than or equal to the preset number threshold.
[0075] If the absolute value of the difference between the first target number and the second target number is less than or equal to the preset number threshold, each first target in the first target set is further compared with the corresponding second target in the second target set, and based on the comparison result, it is determined whether to modify the current value of the current parameter to re-determine the current value of the current parameter.
[0076] In some embodiments, the above-mentioned comparing each first target in the first target set with each second target in the second target set, and re-determining the current value of the current parameter of the video encoder according to the comparison result, includes:
[0077] For each target number, the position, type and confidence of the first target corresponding to the target number in the first target set are compared with the position, type and confidence of the second target corresponding to the target number in the second target set; if the absolute value of the difference between the position of the first target and the position of the second target is greater than a preset position threshold, or the type of the first target is inconsistent with the type of the second target, or the absolute value of the difference between the confidence of the first target and the confidence of the second target is greater than a preset confidence threshold, the current value of the current parameter of the video encoder is modified, and the step of jumping to the step of obtaining real-time image data is executed in a loop until the preset condition is met;
[0078] The preset conditions include that the absolute value of the difference between the position of the first target corresponding to each target number and the position of the corresponding second target is less than or equal to the preset position threshold, and the type of the first target corresponding to each target number and the type of the corresponding second target are consistent, and the absolute value of the difference between the confidence of the first target corresponding to each target number and the confidence of the corresponding second target is less than or equal to the preset confidence threshold.
[0079] Each target in the target set identified by the preset target recognition model has a target number. Since the first image and the second image are the same image, only the image quality or clarity is different, therefore, the probability that the target numbers of the same target in the first target set and the second target set are the same is very high. A first target can be directly determined from the first target set according to the target number, and a second target can be determined from the second target set, and the positions, types and confidences of the two can be compared in turn to see if they meet the requirements, that is, the absolute value of the position difference is less than or equal to the preset position threshold, the types are consistent and the absolute value of the confidence difference is less than or equal to the preset confidence threshold. If the requirements are met, the first target and the second target corresponding to the next target number are compared. If the position, type or confidence of the first target and the second target corresponding to any target number does not meet the requirements, the current value of the current parameter is modified, and the loop execution is returned to S101 until the first target set and the second target set meet the preset conditions.
[0080] Among them, when comparing the first target and the second target of each target number, all target numbers can be compared at the same time, or they can be compared in sequence. When the position, type and confidence meet the requirements, the three can be compared at the same time, or they can be compared in sequence. As long as it is found that the position, type or confidence of one of the targets does not meet the requirements, the comparison can be stopped, the current value of the current parameter can be modified, and return to S101 for loop execution.
[0081] In some possible implementations, in order to ensure that the target corresponding to the same target number in the first target set and the second target set is the same target, the first target and the second target at the same position can be determined in advance as the same target number based on the positions of each first target in the first target set and the positions of each second target in the second target set.
[0082] The preset quantity threshold, preset location threshold and preset confidence threshold can be set according to actual usage requirements and are not specifically limited here.
[0083] In some embodiments, the preset quantity threshold, the preset location threshold, and the preset confidence threshold are associated with a preset comparison level;
[0084] The larger the preset comparison level is, the smaller the preset quantity threshold, the preset position threshold and the preset confidence threshold are.
[0085] The preset comparison level is one of the screening conditions, which is used to indicate the strictness of the target comparison between the first target set and the second target set. The larger the preset comparison level, the higher the strictness, and accordingly, the smaller the preset quantity threshold, preset position threshold and preset confidence threshold, that is, the higher the similarity between the first target set and the second target set is required; the smaller the preset comparison level, the lower the strictness, and accordingly, the larger the preset quantity threshold, preset position threshold and preset confidence threshold, that is, the lower the similarity between the first target set and the second target set is required.
[0086] For example, it is assumed that the preset comparison level is divided into three levels, namely 1, 2, and 3. When the preset comparison level is 3, the preset quantity threshold may be 0, that is, the deviation of the number of targets of the first target set and the second target set is required to be 0; when the preset comparison level is 2, the preset quantity threshold may be 1, that is, the maximum deviation of the number of targets of the first target set and the second target set may be 1; when the preset comparison level is 1, the preset quantity threshold may be 2, that is, the maximum deviation of the number of targets of the first target set and the second target set may be 2; and so on. The preset position threshold is similar to the preset confidence threshold, and will not be described in detail.
[0087] The preset contrast level can be set according to actual usage requirements.
[0088] In some embodiments, after each modification of the current value of the current parameter, the method for determining the video encoder parameter further includes:
[0089] Determine whether the modified value of the current parameter after the current modification exceeds the preset value range corresponding to the current parameter;
[0090] If the modified value exceeds the preset value range corresponding to the current parameter, the modification is canceled, and the previous parameter or next parameter of the video encoder is used as the new current parameter, and the process jumps to the step of obtaining real-time image data and executes it in a loop.
[0091] Each parameter of the video encoder has a corresponding preset value range. If the modified value of the current parameter does not exceed the corresponding preset value range, the execution can continue. If the modified value of the current parameter exceeds the corresponding preset value range, it means that all values of the parameter within the corresponding preset value range cannot meet the preset image quality conditions. At this time, the modification can be undone, the current value of the current parameter can be modified to the value before the modification, and other parameters can be modified or adjusted.
[0092] Among them, the above-mentioned taking the previous parameter or next parameter of the video encoder as the new current parameter may include: if the current parameter is not the first parameter to be modified or adjusted, the previous parameter can be taken as the new current parameter; if the current parameter is the first parameter to be modified or adjusted, the next parameter can be taken as the new current parameter.
[0093] When modifying or adjusting the previous parameter or the next parameter, the modification can still be performed in the previous modification direction, or it can be modified in the direction of a clearer image. The direction of a clearer image means that the image encoded using the modified parameter value is clearer than the image encoded using the parameter value before the modification. Since the parameter is modified in this embodiment because the target contrast does not meet the requirements, it can be modified in the direction of a clearer image.
[0094] In some embodiments, after S103, the method for determining the video encoder parameters further includes:
[0095] If the size of the encoded image is larger than the preset maximum image size, the next parameter of the video encoder is used as the new current parameter, and the process jumps to the step of obtaining real-time image data and executes it in a loop.
[0096] If the size of the encoded image is larger than the preset maximum value of the image, it means that although the quality of the encoded image meets the requirements, the encoded image is too large and the size does not meet the requirements. At this time, the next parameter can be modified or adjusted. When modifying or adjusting the next parameter, it can still be modified in the previous modification direction, or it can be modified in the direction of a more blurred image. The direction of a more blurred image means that the image encoded using the modified parameter value is more blurred than the image encoded using the parameter value before the modification. Since the parameters are modified in this embodiment because the size of the encoded image does not meet the requirements, the modification can be made in the direction of a more blurred image.
[0097] In some possible implementations, if the encoded image size is greater than the preset maximum image size, the next parameter of the video encoder is used as the new current parameter, and the step of jumping to the step of obtaining real-time image data is executed in a loop, which may include:
[0098] If the encoded image size is larger than the preset maximum image size, the next parameter of the video encoder is used as the new current parameter, the current value of the new current parameter is modified, and the process jumps to the step of obtaining real-time image data and executes the loop.
[0099] In some embodiments, if the size of the encoded image is larger than the preset maximum image size, the method for determining the video encoder parameters further includes:
[0100] Determine the cumulative number of frames of acquired real-time image data;
[0101] If the accumulated number of frames is greater than or equal to the preset total number of image frames, the user is prompted to re-determine the preset value ranges corresponding to the various parameters of the video encoder;
[0102] Accordingly, the next parameter of the video encoder is used as the new current parameter, and the step of jumping to the step of obtaining real-time image data is executed in a loop, including:
[0103] If the accumulated number of frames is less than the preset total number of image frames, the next parameter of the video encoder is used as the new current parameter, and the process jumps to the step of obtaining real-time image data and executes it in a loop.
[0104] The preset total number of image frames is one of the screening conditions, which is used to limit the program running time. When the cumulative number of frames exceeds the preset total number of image frames and no reasonable parameter combination is screened out, it means that there may be a problem with the preset value range corresponding to each pre-set parameter. The user can be prompted to modify it, re-run the program, and screen again.
[0105] The total number of preset image frames can be determined according to actual usage requirements, for example, it can be 10,000 frames, and so on.
[0106] In some possible implementations, the screening conditions may include, in addition to the above-mentioned preset contrast level and the preset total number of image frames, encoder type, image type, encoder capability level, encoding level, etc.
[0107] The encoder type can be MPEG4, H264, H265, HEVC, or MJPEG, etc. The image type can be YUV420P, YUV420P, or YVU420SP, etc.
[0108] The encoding level refers to the H264 level, which specifies the limits of video bit rate, resolution, frame rate and other parameters. Each level corresponds to this set of parameter limits. The higher the level, the higher the bit rate, resolution and frame rate of the video, and the lower the compression rate. At the same time, it is also necessary to consider whether the hardware device supports it, because the device generally uses a hardware encoder for encoding and decoding. The encoding level can be ENC_H264Level1, 2, 3, 4, 41, 42, 5 or 51, etc.
[0109] The encoder capability level is also a parameter of H264. The standard specifies multiple profiles. Each profile specifies an algorithm feature and a subset of restrictions. These two parameters are determined in advance based on hardware support and consultation with the decoder. The encoder capability level can be BP, MP or HP, etc.
[0110] The values of the above filtering conditions can be determined according to factors such as actual usage requirements and hardware limitations.
[0111] In some embodiments, the various parameters of the video encoder include at least two of a frame rate, a bit rate, a group of pictures, and a quantization step size.
[0112] Among them, frame rate is frame rate; bit rate is bit rate, which can also be called bit stream; Group Of Pictures (GOP) can also be called key frame frame spacing; quantization step can be abbreviated as qp.
[0113] In this embodiment, the order in which the parameters are corrected in sequence may be a preset correction order or a random order. The preset correction order may be set based on experience or actual needs. Exemplarily, when the parameters of the video encoder include frame rate, bit rate, picture group, and quantization step size, the preset correction order may be bit rate, picture group, frame rate, and quantization step size; and so on.
[0114] The method provided in the embodiment of the present application aims to screen out a suitable combination of parameters of the video encoder so that the size of the image encoded by the video encoder is small enough and the image quality is usable by the preset target recognition model. The method provided in the embodiment of the present application can automatically screen the optimal combination of encoder parameters, reduce manual operation costs, and the final result obtained by data comparison is more objective and direct, and can also save manpower and time costs.
[0115] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0116] The following is an embodiment of the device of the present invention. For details not described in detail therein, reference may be made to the corresponding method embodiment described above.
[0117] Figure 2 The structure diagram of the apparatus for determining video encoder parameters provided by an embodiment of the present invention is shown. For the convenience of description, only the part related to the embodiment of the present invention is shown, which is described in detail as follows:
[0118] like Figure 2 As shown, the apparatus 30 for determining parameters of a video encoder may include: a video acquisition module 31 , a target recognition module 32 , a parameter correction module 33 and a parameter determination module 34 .
[0119] The video acquisition module 31 is used to acquire real-time image data, and obtain a first video file and a second video file based on the real-time image data; the first video file is a video file obtained by directly storing the real-time image data; the second video file is a video file obtained by encoding the real-time image data based on the current values of various parameters of the video encoder and then decoding the real-time image data;
[0120] The target recognition module 32 is used to extract a frame of image from the first video file and the second video file as the first image and the second image, respectively, and input the first image and the second image into a preset target recognition model to obtain a first target set and a second target set; the first image and the second image have the same number;
[0121] A parameter correction module 33 is used to modify the current value of the current parameter of the video encoder based on the first target set and the second target set, re-determine the current value of the current parameter, and encode the first image based on the re-determined current value of the current parameter to obtain an encoded image;
[0122] The parameter determination module 34 is used to record the current values of various parameters if the size of the encoded image is less than or equal to the preset maximum value of the image.
[0123] In a possible implementation, in the parameter modification module 33, based on the first target set and the second target set, the current value of the current parameter of the video encoder is modified to re-determine the current value of the current parameter, including:
[0124] determining a first target quantity for the first target set and a second target quantity for the second target set;
[0125] If the absolute value of the difference between the first target quantity and the second target quantity is greater than the preset quantity threshold, the current value of the current parameter of the video encoder is modified, and the process jumps to the step of acquiring real-time image data to continue execution;
[0126] If the absolute value of the difference between the first target number and the second target number is less than or equal to the preset number threshold, each first target in the first target set and each second target in the second target set are compared respectively, and based on the comparison result, the current value of the current parameter of the video encoder is re-determined.
[0127] In a possible implementation, in the parameter modification module 33, each first target in the first target set is compared with each second target in the second target set, and according to the comparison result, a current value of the current parameter of the video encoder is re-determined, including:
[0128] For each target number, the position, type and confidence of the first target corresponding to the target number in the first target set are compared with the position, type and confidence of the second target corresponding to the target number in the second target set; if the absolute value of the difference between the position of the first target and the position of the second target is greater than a preset position threshold, or the type of the first target is inconsistent with the type of the second target, or the absolute value of the difference between the confidence of the first target and the confidence of the second target is greater than a preset confidence threshold, the current value of the current parameter of the video encoder is modified, and the step of jumping to the step of obtaining real-time image data is executed in a loop until the preset condition is met;
[0129] The preset conditions include that the absolute value of the difference between the position of the first target corresponding to each target number and the position of the corresponding second target is less than or equal to the preset position threshold, and the type of the first target corresponding to each target number and the type of the corresponding second target are consistent, and the absolute value of the difference between the confidence of the first target corresponding to each target number and the confidence of the corresponding second target is less than or equal to the preset confidence threshold.
[0130] In one possible implementation, the preset quantity threshold, the preset position threshold, and the preset confidence threshold are associated with a preset comparison level;
[0131] The larger the preset comparison level is, the smaller the preset quantity threshold, the preset position threshold and the preset confidence threshold are.
[0132] In a possible implementation, in the parameter modification module 33, after the current value of the current parameter is modified each time, the following steps are further included:
[0133] Determine whether the modified value of the current parameter after the current modification exceeds the preset value range corresponding to the current parameter;
[0134] If the modified value exceeds the preset value range corresponding to the current parameter, the modification is canceled, and the previous parameter or next parameter of the video encoder is used as the new current parameter, and the process jumps to the step of obtaining real-time image data and executes it in a loop.
[0135] In a possible implementation, the parameter determination module 34 further includes:
[0136] After encoding the first image based on the current value of the re-determined current parameter to obtain the encoded image, if the size of the encoded image is larger than the preset image maximum value, the next parameter of the video encoder is used as the new current parameter, and the process jumps to the step of obtaining real-time image data and executes it in a loop.
[0137] In a possible implementation, in the parameter determination module 34, if the size of the encoded image is greater than the preset maximum image size, the following is further included:
[0138] Determine the cumulative number of frames of acquired real-time image data;
[0139] If the accumulated number of frames is greater than or equal to the preset total number of image frames, the user is prompted to re-determine the preset value ranges corresponding to the various parameters of the video encoder;
[0140] Accordingly, the next parameter of the video encoder is used as the new current parameter, and the step of jumping to the step of obtaining real-time image data is executed in a loop, including:
[0141] If the accumulated number of frames is less than the preset total number of image frames, the next parameter of the video encoder is used as the new current parameter, and the process jumps to the step of obtaining real-time image data and executes it in a loop.
[0142] In a possible implementation manner, the various parameters of the video encoder include at least two of a frame rate, a bit rate, a group of pictures, and a quantization step size.
[0143] Figure 3 Schematic diagram of an electronic device provided by an embodiment of the present invention. Figure 3 As shown, the electronic device 4 of this embodiment includes: a processor 40 and a memory 41. The memory 41 is used to store a computer program 42, and the processor 40 is used to call and run the computer program 42 stored in the memory 41 to perform the steps in the above-mentioned various video encoder parameter determination method embodiments, such as Figure 1 Alternatively, the processor 40 is used to call and run the computer program 42 stored in the memory 41 to implement the functions of each module / unit in the above-mentioned device embodiments, for example Figure 2 The functions of each module are shown.
[0144] Exemplarily, the computer program 42 may be divided into one or more modules / units, which are stored in the memory 41 and executed by the processor 40 to implement the present invention. The one or more modules / units may be a series of computer program instruction segments capable of implementing specific functions, which are used to describe the execution process of the computer program 42 in the electronic device 4. For example, the computer program 42 may be divided into Figure 2 The modules shown.
[0145] The electronic device 4 may be a computing device such as a computer or a server, or may be a device such as an ECU (Electronic Control Unit) on a vehicle. The electronic device 4 may include, but is not limited to, a processor 40 and a memory 41. Those skilled in the art may understand that Figure 3 It is only an example of the electronic device 4 and does not constitute a limitation of the electronic device 4. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.
[0146] The processor 40 may be a central processing unit (CPU), or 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. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0147] The memory 41 may be an internal storage unit of the electronic device 4, such as a hard disk or memory of the electronic device 4. The memory 41 may also be an external storage device of the electronic device 4, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 4. Further, the memory 41 may also include both an internal storage unit and an external storage device of the electronic device 4. The memory 41 is used to store the computer program and other programs and data required by the electronic device. The memory 41 may also be used to temporarily store data that has been output or is to be output.
[0148] Corresponding to the above-mentioned electronic device, an embodiment of the present application further provides a vehicle, comprising the above-mentioned electronic device.
[0149] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0150] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0151] 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, or a combination of computer software and electronic hardware. 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.
[0152] In the embodiments provided by the present invention, it should be understood that the disclosed devices / electronic devices and methods can be implemented in other ways. For example, the device / electronic device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0153] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0154] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0155] If the integrated module / 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 computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned various video encoder parameter determination method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device that can carry the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal and software distribution medium.
[0156] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A method for determining video encoder parameters, characterized in that: include: Acquire real-time image data, and obtain a first video file and a second video file based on the real-time image data; The first video file is a video file directly stored in the real-time image data; The second video file is a video file obtained by performing video encoding and then decoding the real-time image data based on current values of various parameters of the video encoder; Extracting a frame of image from the first video file and the second video file as a first image and a second image respectively, and inputting the first image and the second image into a preset target recognition model respectively to obtain a first target set and a second target set; the first image and the second image have the same number; Based on the first target set and the second target set, modify the current value of the current parameter of the video encoder, re-determine the current value of the current parameter, and encode the first image based on the re-determined current value of the current parameter to obtain an encoded image; If the encoded image size is less than or equal to the preset maximum image size, then the current values of each parameter are recorded; The modifying, based on the first target set and the second target set, a current value of a current parameter of the video encoder to re-determine the current value of the current parameter includes: determining a first target quantity of the first target set and a second target quantity of the second target set; If the absolute value of the difference between the first target number and the second target number is greater than a preset number threshold, modifying the current value of the current parameter of the video encoder, and jumping to the step of acquiring real-time image data to continue execution; If the absolute value of the difference between the first target number and the second target number is less than or equal to the preset number threshold, each first target in the first target set and each second target in the second target set are compared respectively, and based on the comparison result, the current value of the current parameter of the video encoder is re-determined.
2. The method for determining video encoder parameters according to claim 1, characterized in that: The comparing each first target in the first target set with each second target in the second target set, and re-determining a current value of a current parameter of the video encoder according to the comparison result, includes: For each target number, the position, type and confidence of the first target corresponding to the target number in the first target set are compared with the position, type and confidence of the second target corresponding to the target number in the second target set; if the absolute value of the difference between the position of the first target and the position of the second target is greater than a preset position threshold, or the type of the first target is inconsistent with the type of the second target, or the absolute value of the difference between the confidence of the first target and the confidence of the second target is greater than a preset confidence threshold, the current value of the current parameter of the video encoder is modified, and the step of jumping to the step of acquiring real-time image data is executed in a loop until a preset condition is met; The preset conditions include that the absolute value of the difference between the position of the first target corresponding to each target number and the position of the corresponding second target is less than or equal to the preset position threshold, and the type of the first target corresponding to each target number and the type of the corresponding second target are consistent, and the absolute value of the difference between the confidence of the first target corresponding to each target number and the confidence of the corresponding second target is less than or equal to the preset confidence threshold.
3. The method for determining video encoder parameters according to claim 2, characterized in that: The preset quantity threshold, the preset position threshold and the preset confidence threshold are associated with a preset comparison level; The greater the preset comparison level, the smaller the preset quantity threshold, the preset position threshold and the preset confidence threshold.
4. The method for determining video encoder parameters according to claim 2, characterized in that: After each modification of the current value of the current parameter, the method for determining the video encoder parameter further includes: Determine whether the modified value of the current parameter after the current modification exceeds the preset value range corresponding to the current parameter; If the modified value exceeds the preset value range corresponding to the current parameter, the modification is canceled, and the previous parameter or the next parameter of the video encoder is used as the new current parameter, and the process jumps to the step of obtaining real-time image data and executes it in a loop.
5. The method for determining video encoder parameters according to any one of claims 1 to 4, characterized in that: After encoding the first image based on the current value of the re-determined current parameter to obtain the encoded image, the method for determining the video encoder parameter further includes: If the encoded image size is larger than the preset maximum image size, the next parameter of the video encoder is used as the new current parameter, and the process jumps to the step of acquiring real-time image data and executes the step in a loop.
6. The method for determining video encoder parameters according to claim 5, characterized in that: If the encoded image size is greater than the preset maximum image size, the method for determining the video encoder parameters further includes: Determine the cumulative number of frames of acquired real-time image data; If the accumulated number of frames is greater than or equal to the preset total number of image frames, prompting the user to redetermine the preset value ranges corresponding to the various parameters of the video encoder; Accordingly, the step of taking the next parameter of the video encoder as the new current parameter and jumping to the step of acquiring the real-time image data is executed cyclically, including: If the accumulated number of frames is less than the preset total number of image frames, the next parameter of the video encoder is used as the new current parameter, and the process jumps to the step of acquiring real-time image data and executes the step in a loop.
7. The method for determining video encoder parameters according to any one of claims 1 to 4, characterized in that: The various parameters of the video encoder include at least two of a frame rate, a bit rate, a group of pictures, and a quantization step size.
8. An electronic device, characterized in that: The system comprises a processor and a memory, wherein the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory to execute the method for determining video encoder parameters as claimed in any one of claims 1 to 7.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method for determining video encoder parameters according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Video coding method, model training method, equipment and storage medium
CN116095328A