Video file compression method and device, computer equipment and readable storage medium
By intelligently compressing the resolution and code rate of video data on the power grid, combined with multimedia processing tools, the problem of distortion caused by video compression in the existing technology is solved, and efficient video data compression and storage space savings are achieved.
Patent Information
- Application Number
- CN202411255543.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-09
- Publication Date
- 2024-12-17
AI Technical Summary
The prior art can easily lead to video distortion when compressing unstructured video data, poor compression effect, and difficult to effectively reduce storage space usage.
By obtaining video files collected by different types of video terminal equipment during on-site operation of the power grid, extracting video data and audio data, and compressing them according to the resolution and code rate of the video data to ensure that the code rate of the compressed data is not lower than the second code rate Threshold, resolution is not lower than resolution threshold, merge video and audio data to generate compressed video files.
It realizes avoiding distortion during the process of compressing video data, improves compression efficiency, ensures video quality, and saves storage space.
Smart Images

Figure CN119155449A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of video processing technology, and in particular to a video file compression method, device, computer equipment and readable storage medium. Background Art
[0002] With the continuous development of the on-site video surveillance business of power grids, a large amount of unstructured on-site production video data (referred to as unstructured video data or operation videos) will be generated every year for on-site operations such as production, marketing, and safety monitoring. The amount of centrally stored unstructured video data is large, for example, it can reach the PB (Petabytes) level, which occupies a large storage space. Therefore, it is necessary to compress the unstructured video data to minimize the storage space occupied by the operation video.
[0003] In traditional technology, in order to compress unstructured video data, open source compression tools such as FFmpeg can be used for compression. FFmpeg is a set of audio and video codec tools, as well as a set of video codec development kits, which provides developers with a rich audio and video calling interface.
[0004] Then, simply relying on open source compression tools for compression can easily lead to video distortion and poor compression effect. Summary of the invention
[0005] Based on this, it is necessary to provide a video file compression method, device, computer equipment and readable storage medium that can improve the compression effect in response to the above technical problems.
[0006] On the one hand, the present application provides a video file compression method, including: obtaining video files collected by different types of video terminal devices during field operations of a power grid; for each of the video files, extracting video data and audio data from the video file; determining the resolution of the video data and the bit rate of the video data; when the resolution of the video data is greater than a resolution threshold and the bit rate of the video data is greater than a first bit rate threshold, compressing the resolution and bit rate of the video data to obtain compressed video data, the bit rate of the compressed video data is not lower than a second bit rate threshold, and the resolution of the compressed video data is not lower than the resolution threshold, and the second bit rate threshold is lower than the first bit rate threshold; merging based on the compressed video data and the audio data to obtain a compressed video file corresponding to the video file.
[0007] On the other hand, the present application also provides a video file compression device, including: a video file acquisition module, used to acquire video files collected by different types of video terminal devices during field operations of a power grid; a data extraction module, used to extract video data and audio data from the video file for each of the video files; a bit rate determination module, used to determine the resolution of the video data and the bit rate of the video data; a video compression module, used to compress the resolution and bit rate of the video data when the resolution of the video data is greater than a resolution threshold and the bit rate of the video data is greater than a first bit rate threshold, to obtain compressed video data, the bit rate of the compressed video data is not lower than a second bit rate threshold, and the resolution of the compressed video data is not lower than the resolution threshold, and the second bit rate threshold is less than the first bit rate threshold; a data merging module, used to merge based on the compressed video data and the audio data to obtain a compressed video file corresponding to the video file.
[0008] In some embodiments, the video compression module is further used to compress the resolution of the video data according to a resolution threshold to obtain resolution-compressed video data, and the resolution of the resolution-compressed video data is consistent with the resolution threshold; compress the bit rate of the resolution-compressed video data according to a second bit rate threshold to obtain compressed video data, and the bit rate of the compressed video data is consistent with the second bit rate threshold.
[0009] In some embodiments, the video compression module is also used to call the video encoder through a multimedia processing tool, and instruct the video encoder to compress the resolution of the video data according to a resolution threshold to obtain resolution-compressed video data; call the video encoder through the multimedia processing tool, and instruct the video encoder to compress the bit rate of the resolution-compressed video data according to a second bit rate threshold to obtain compressed video data.
[0010] In some embodiments, the video compression module is also used to compress the bit rate of the video data to obtain compressed video data when the bit rate of the video data is greater than a second bit rate threshold and less than a first bit rate threshold, and the bit rate of the compressed video data is equal to the second bit rate threshold; when the bit rate of the video data is less than the second bit rate threshold, compress the video data using a preset video compression method to obtain compressed video data.
[0011] In some embodiments, the video compression module is also used to determine the target field operation type corresponding to the video data, the target field operation type corresponding to the video data refers to the type of power grid field operation from which the video data originates; determine the resolution threshold, first bit rate threshold and second bit rate threshold corresponding to the target field operation type; when the resolution of the video data is greater than the resolution threshold corresponding to the target field operation type, and the bit rate of the video data is greater than the first bit rate threshold corresponding to the target field operation type, compress the resolution and bit rate of the video data to obtain compressed video data, and the compressed video data is not lower than the second bit rate threshold corresponding to the target field operation type.
[0012] In some embodiments, the data merging module is also used to determine the audio format of the audio data; when the audio format of the audio data is consistent with the target audio format, the compressed video data and the audio data are merged to obtain a compressed video file corresponding to the video file; when the audio format of the audio data is inconsistent with the target audio format, the audio data is format-converted to the target audio format to obtain format-converted audio data, and the compressed video data and the format-converted audio data are merged to obtain a compressed video file corresponding to the video file.
[0013] On the other hand, the present application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps in the above-mentioned video file compression method when executing the computer program.
[0014] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps in the above-mentioned video file compression method are implemented.
[0015] In a fifth aspect, the present application also provides a computer program product, including a computer program, which implements the steps in the above-mentioned video file compression method when executed by a processor.
[0016] The above-mentioned video file compression method, device, computer equipment, computer-readable storage medium and computer program product obtain video files collected by different types of video terminal devices during the field operation of the power grid, extract video data and audio data from the video file for each video file, determine the resolution of the video data and the bit rate of the video data, and compress the resolution and bit rate of the video data when the resolution of the video data is greater than the resolution threshold and the bit rate of the video data is greater than the first bit rate threshold to obtain compressed video data, and merge the compressed video data and audio data to obtain a compressed video file corresponding to the video file. Therefore, the video collection collected by different types of video terminal devices during the field operation of the power grid is compressed in a unified compression method, and because the bit rate of the compressed video data is not lower than the second bit rate threshold, and the resolution of the compressed video data is not lower than the resolution threshold, in the process of compressing the video data, the bit rate is not too low or the resolution is not too low, thereby achieving compression and ensuring the quality of the video data, avoiding distortion caused by compression, and improving compression efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0018] FIG1 is a diagram showing an application environment of a video file compression method according to an embodiment;
[0019] FIG2 is a schematic diagram of a flow chart of a video file compression method in one embodiment;
[0020] FIG3 is a schematic diagram of a video file compression method in one embodiment;
[0021] FIG4 is a structural block diagram of a video file compression device in one embodiment;
[0022] FIG5 is a diagram showing the internal structure of a computer device in one embodiment;
[0023] FIG. 6 is a diagram showing the internal structure of a computer device in another embodiment. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0025] The video file compression method provided in the embodiment of the present application can be applied to an application environment as shown in FIG. 1, which includes different types of video terminal devices 102 and computer devices 104. Among them, the video terminal device 102 communicates with the computer device 104 through a network. The data storage system can store the data that the computer device 104 needs to process. The data storage system can be integrated on the computer device 104, or it can be placed on a cloud or other network server. Each video terminal device 102 can transfer the collected video file to the computer device 104. For each video file, the computer device 104 can extract video data and audio data from the video file, determine the resolution of the video data and the bit rate of the video data, compress the video data according to the resolution of the video data and the bit rate of the video data, obtain compressed video data, and then merge based on the compressed video data and audio data to obtain a compressed video file corresponding to the video file. Among them, the computer device 104 can be a terminal or a server, and the terminal can be but not limited to various desktop computers, laptops, smart phones, tablet computers, etc. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.
[0026] In some embodiments, as shown in FIG2 , a video file compression method is provided, which can be applied to a terminal or a server, and is described by taking the method applied to the computer device in FIG1 as an example, including the following steps 202 to 210. Among them:
[0027] Step 202: Obtain video files collected by different types of video terminal devices during the field operation of the power grid.
[0028] The grid field operation refers to the field operation in the grid. The grid field operation may be, but is not limited to, production, marketing, or security inspection. The different types of video terminal devices may be video terminal devices in the same grid field operation. Alternatively, at least two of the different types of video terminal devices belong to different grid field operations.
[0029] The video terminal device may be, but is not limited to, a fixed gun camera, a ball camera, a mobile law enforcement device, or a surveillance ball, etc. The encoding features of the video data in the video files collected or recorded by different types of video terminal devices may be different.
[0030] Video files are one of the important multimedia contents on the Internet, including video data and audio data. Video files can be in the formats of MP4, MOV, FLV, AVI or RMVB, but are not limited to them. MP4 is the abbreviation of MPEG-4 Part 14, which is a multimedia container format. MPEG is the abbreviation of Moving Picture Experts Group, which is a collection of video and audio compression standards. MOV is the abbreviation of QuickTime Movie. FLV is the abbreviation of Flash Video. AVI is the abbreviation of AudioVideo Interleave, which is an audio video interleave format. RMVB is the abbreviation of RealMedia Variable Bitrate.
[0031] Specifically, the computer device obtains a video file sent to it by the video terminal device, compresses the video file using the video file compression method provided by the present application, and obtains a compressed video file corresponding to the video file.
[0032] Step 204: for each video file, extract video data and audio data from the video file.
[0033] The video data may be in a format such as AVI, MPEG, MP4, WMV, FLV, MOV or MKV, but is not limited to such formats. The audio data may be in a format such as WAV, MP3, WMA, AAC or FLAC, but is not limited to such formats. MP3 is the abbreviation of MPEG-1 AudioLayer 3, which is an audio compression format. WMV is the abbreviation of Windows Media Video. MKV is the abbreviation of Matroska. AAC is the abbreviation of Advanced Audio Coding. FLAC is the abbreviation of free Lossless Audio Codec. WAV is the abbreviation of waveform Audio File Format, which is a lossless audio file format. WMA is the abbreviation of Windows Media Audio.
[0034] Step 206: Determine the resolution of the video data and the bit rate of the video data.
[0035] The video data includes video frames, each of which is an image. The resolution of the video data refers to the resolution and pixels of the video frames in the video data. The resolution is usually expressed by multiplying the width of the image by the height. The unit of resolution is pixel. For example, the resolution is 1920×1080, 1280×720 or 720×480.
[0036] The bit rate of video data indicates how many bits are needed to represent the video data per second, that is, the amount of image data displayed per second. The larger the bit rate, the larger the amount of image data displayed per second. The bit rate of video data can also be called bit rate, which can also indicate the rate at which video data is transmitted per unit time, that is, the data traffic used per unit time. The higher the bit rate, the larger the amount of video data. The higher the bit rate, the higher the video quality, because more data can be transmitted, thereby retaining more video details and reducing distortion caused by compression.
[0037] Specifically,
[0038] Step 208 : When the resolution of the video data is greater than the resolution threshold and the bit rate of the video data is greater than the first bit rate threshold, compress the resolution and bit rate of the video data to obtain compressed video data.
[0039] The resolution threshold can be set as needed, for example, 720P, where 720P represents a video resolution of 1280×720. The first bit rate threshold can be set as needed, for example, 2Mpbs (megabits per second). The bit rate of the compressed video data is not lower than the second bit rate threshold, and the resolution of the compressed video data is not lower than the resolution threshold, and the second bit rate threshold is lower than the first bit rate threshold. For example, the second bit rate threshold is 1Mpbs, and the first bit rate threshold is 2Mpbs.
[0040] Specifically, when the resolution of the video data is greater than a resolution threshold and the bit rate of the video data is greater than a first bit rate threshold, the computer device may first compress the resolution of the video data and then further compress the bit rate to obtain compressed video data; or, the computer device may first compress the bit rate of the video data and then further compress the resolution to obtain compressed video data.
[0041] In some embodiments, when the resolution of the video data is greater than or equal to a resolution threshold and the bit rate of the video data is greater than or equal to a first bit rate threshold, the computer device compresses the resolution and bit rate of the video data to obtain compressed video data.
[0042] In some embodiments, the resolution of the compressed video data is consistent with the resolution threshold and the bit rate of the compressed video data is consistent with the second bit rate threshold. When the resolution of the video data is greater than the resolution threshold and the bit rate of the video data is greater than the first bit rate threshold, the computer device can compress the resolution of the video data to the resolution threshold and the bit rate of the video data to the second bit rate threshold according to the resolution threshold and the second bit rate threshold to obtain compressed video data.
[0043] In some embodiments, the computer device may split the video data to obtain multiple video segments, compress the resolution and bit rate of each video segment respectively to obtain compressed video segments corresponding to each video segment, and then combine the compressed video segments corresponding to each video segment according to the order of the video segments in the video data to obtain compressed video data. The higher the order of the video segment in the video data, the higher the order of the compressed video segment corresponding to the video segment in the compressed video data.
[0044] In some embodiments, for each video clip, the computer device may calculate the difference between each video frame except the first video frame in the video clip and its previous video frame, the difference value is used to characterize the difference between the two video frames, and perform comprehensive calculation on the calculated difference values to obtain a comprehensive difference value corresponding to the video clip, the comprehensive calculation may be but not limited to average calculation or sum calculation. The computer device may determine the second bitrate threshold value according to the comprehensive difference value corresponding to the video clip, and the comprehensive difference value is positively correlated with the second bitrate threshold value.
[0045] Step 210: Merge the compressed video data and audio data to obtain a compressed video file corresponding to the video file.
[0046] Specifically, the computer device may directly merge the compressed video data with the audio data to obtain the compressed video data. Alternatively, the computer device may perform format conversion on the audio data to obtain the format-converted audio data and merge it with the compressed video data to obtain the compressed video file.
[0047] In some embodiments, the computer device can store the compressed video file in a database. Since the data volume of the compressed video file is smaller than the data volume of the video file, the storage space occupied by the compressed video file is smaller than the storage space occupied by the video file, thereby saving storage space.
[0048] In the above-mentioned video file compression method, the video files collected by different types of video terminal devices during the field operation of the power grid are obtained, and for each video file, video data and audio data are extracted from the video file, and the resolution of the video data and the bit rate of the video data are determined. When the resolution of the video data is greater than the resolution threshold and the bit rate of the video data is greater than the first bit rate threshold, the resolution and bit rate of the video data are compressed to obtain compressed video data, and the compressed video data and audio data are merged to obtain a compressed video file corresponding to the video file. Therefore, the video collection collected by different types of video terminal devices during the field operation of the power grid is compressed using a unified compression method, and because the bit rate of the compressed video data is not lower than the second bit rate threshold, and the resolution of the compressed video data is not lower than the resolution threshold, in the process of compressing the video data, the bit rate is not too low or the resolution is not too low, thereby achieving compression and ensuring the quality of the video data, avoiding distortion caused by compression, and improving compression efficiency.
[0049] In some embodiments, the resolution and bit rate of video data are compressed to obtain compressed video data, including: compressing the resolution of video data according to a resolution threshold to obtain resolution-compressed video data, wherein the resolution of the resolution-compressed video data is consistent with the resolution threshold; compressing the bit rate of the resolution-compressed video data according to a second bit rate threshold to obtain compressed video data, wherein the bit rate of the compressed video data is consistent with the second bit rate threshold.
[0050] Specifically, the computer device may compress the bit rate of the video data according to the second bit rate threshold to obtain the video data after bit rate compression, and the bit rate of the video data after bit rate compression is not lower than the second bit rate threshold. Further, the computer device may compress the resolution of the video data after bit rate compression according to the resolution threshold to obtain the compressed video data, and the resolution of the compressed video data is not lower than the resolution threshold.
[0051] In this embodiment, since the resolution of the video data after resolution compression is not lower than the resolution threshold, and the bit rate of the compressed video data is not lower than the second bit rate threshold, the resolution and bit rate of the video data are compressed, the data volume of the video data is reduced, and the quality of the video data is guaranteed, thereby saving storage space and ensuring video quality.
[0052] In some embodiments, the resolution of the video data is compressed according to a resolution threshold to obtain resolution-compressed video data, including: calling a video encoder through a multimedia processing tool, and instructing the video encoder to compress the resolution of the video data according to the resolution threshold to obtain resolution-compressed video data; compressing the bit rate of the resolution-compressed video data according to a second bit rate threshold to obtain compressed video data, including: calling the video encoder through a multimedia processing tool, and instructing the video encoder to compress the bit rate of the resolution-compressed video data according to the second bit rate threshold to obtain compressed video data.
[0053] Among them, the multimedia processing tool can be but is not limited to FFmpeg. FFmpeg is an audio and video codec tool, and also a set of audio and video codec development kits, which provides a rich audio and video calling interface, supports the encapsulation and decapsulation of multiple media formats, including multiple audio and video encoding, multiple protocols of streaming media, multiple color format conversion, multiple sampling rate conversion, multiple bit rate conversion, etc. The FFmpeg framework provides a variety of rich plug-in modules, including plug-ins for encapsulation and decapsulation, plug-ins for encoding and decoding, etc.
[0054] The video encoder can be, but is not limited to, libx264. libx264 is an open source H.264 video encoder library, and FFmpeg can integrate and use libx264 for video encoding.
[0055] Of course, the multimedia processing tool may also be other tools that can compress the video, and the video encoder may also be other encoders that can encode the video to change the resolution and bit rate of the video. This application does not limit the types of multimedia processing tools and video encoders.
[0056] Traditional video compression based on multimedia processing tools such as FFmpeg is difficult to meet the different encoding characteristics of videos recorded by various types of terminal cameras in the power industry's field operations. Compression processing is difficult to balance video quality and video file size, and it is easy to have a high compression rate but severe video distortion, and it is also easy to have a small video distortion but a low compression rate.
[0057] In this embodiment, the video encoder is called by the multimedia processing tool, and the video encoder is instructed to compress the resolution of the video data according to the resolution threshold, and the video encoder is called by the multimedia processing tool, and the video encoder is instructed to compress the bit rate of the video data after the resolution compression according to the second bit rate threshold, so that the bit rate control and resolution adjustment can be more accurately achieved, and the problems existing in the multimedia processing tool can be alleviated. The size and video quality of the video file can be effectively balanced during compression, and compared with the default setting of the multimedia processing tool, the video quality can be guaranteed while reducing the file size. That is, compared with the video data in the video file, the data volume of the compressed video data is smaller and the quality is still good.
[0058] In some embodiments, the video file compression method also includes at least one of the following: when the bit rate of the video data is greater than a second bit rate threshold and less than a first bit rate threshold, compressing the bit rate of the video data to obtain compressed video data, and the bit rate of the compressed video data is less than or equal to the second bit rate threshold; when the bit rate of the video data is less than the second bit rate threshold, compressing the video data using a preset video compression method to obtain compressed video data.
[0059] The second bit rate threshold is less than the first bit rate threshold. The preset video compression method can be any method that can compress a video, and can be but is not limited to libx264.
[0060] Specifically, when the bit rate of the video data is greater than or equal to the second bit rate threshold and less than or equal to the first bit rate threshold, the computer device may compress the bit rate of the video data to obtain compressed video data.
[0061] In some embodiments, when the bit rate of the video data is less than the second bit rate threshold, the computer device may compress the video data using the default compression parameters in the preset video compression method to obtain compressed video data.
[0062] In this embodiment, when the bit rate of the video data is greater than the second bit rate threshold and less than the first bit rate threshold, the bit rate of the video data is compressed to the second bit rate threshold. By reasonably setting the second bit rate threshold, the compressed video data can reduce the data volume compared to the video data, but still maintain good video quality, thereby improving the video compression effect; and when the bit rate of the video data is less than the second bit rate threshold, the video data is compressed using a preset video compression method, which can improve the compression efficiency of video data with a bit rate less than the second bit rate threshold.
[0063] In some embodiments, when the resolution of the video data is greater than a resolution threshold and the bit rate of the video data is greater than a first bit rate threshold, the resolution and bit rate of the video data are compressed to obtain compressed video data, including: determining the target field operation type corresponding to the video data, the target field operation type corresponding to the video data refers to the type of power grid field operation from which the video data originates; determining the resolution threshold, the first bit rate threshold, and the second bit rate threshold corresponding to the target field operation type; when the resolution of the video data is greater than the resolution threshold corresponding to the target field operation type, and the bit rate of the video data is greater than the first bit rate threshold corresponding to the target field operation type, compressing the resolution and bit rate of the video data to obtain compressed video data, the compressed video data is not lower than the second bit rate threshold corresponding to the target field operation type.
[0064] The power grid field operation from which the video data originates refers to the power grid field operation to which the video terminal device that collects and obtains the video data belongs.
[0065] Specifically, since there may be many types of power grid field operations and different power grid field operations may have different requirements on the quality of video data, the resolution threshold, the first bit rate threshold and the second bit rate threshold used in compression may be determined according to the type of power grid field operation.
[0066] In this embodiment, the resolution threshold, the first code rate threshold, and the second code rate threshold used in compression can be determined according to the type of power grid field operation, thereby improving the flexibility of compression.
[0067] In some embodiments, a compressed video file corresponding to a video file is obtained based on merging compressed video data and audio data, including: determining the audio format of the audio data; when the audio format of the audio data is consistent with the target audio format, merging the compressed video data and the audio data to obtain the compressed video data corresponding to the video file; when the audio format of the audio data is inconsistent with the target audio format, format-converting the audio data to the target audio format to obtain format-converted audio data, and merging the compressed video data with the format-converted audio data to obtain the compressed video file corresponding to the video file.
[0068] The target audio format can be preset as needed, and the target audio format can be, but is not limited to, WAV, MP3, WMA, AAC or FLAC. The audio format of the audio data after format conversion is the target audio format. The audio format can be understood as the encoding format of the audio.
[0069] Specifically, the target audio format may be AAC format. When the computer device determines that the audio format of the audio data is AAC, the computer device merges the compressed video data and the audio data to obtain a compressed video file; when the computer device determines that the audio format of the audio data is not AAC, the computer device re-encodes the audio data according to the AAC format to obtain format-converted audio data, and then merges the compressed video data and the format-converted audio data to obtain a compressed video file corresponding to the video file. In this way, the audio data in the compressed video file can be in AAC format, and the audio data in AAC format can ensure the quality of the audio data, thereby avoiding problems with the audio quality due to compression.
[0070] In some embodiments, when the audio format of the audio data is inconsistent with the target audio format, the computer device converts the audio data according to the target audio format, and when the frequency of the audio data is inconsistent with the preset frequency, the frequency of the audio data is converted to the preset frequency to obtain the audio data after the format conversion. The preset frequency can be set as needed, and the preset frequency can be but is not limited to 6000HZ (Hertz), 8000HZ or 9000HZ, etc.
[0071] In some embodiments, when the audio format of the audio data is inconsistent with the target audio format, the computer device converts the format of the audio data according to the target audio format, and when the frequency of the audio data is greater than the preset frequency, the frequency of the audio data is converted to the preset frequency to obtain the audio data after format conversion.
[0072] In this embodiment, when the audio format of the audio data is inconsistent with the target audio format, the audio data is format-converted into the target audio format, so that the converted audio data of the target audio format can be obtained. Therefore, audio data of different audio formats can be uniformly converted into the target audio format, thereby realizing the format unification of the audio data in the video files generated during the field operation of the power grid.
[0073] As shown in FIG3 , the principle diagram of the video file compression method in some examples is shown. In FIG3 , the original video file is a video file collected by the video terminal device during the field operation of the power grid, 720P is the resolution threshold, 1Mpbs is the second bit rate threshold, and 2Mpbs is the first bit rate threshold. There is a video file compression tool in the computer device, and the computer device inputs the original video file into the video file compression tool, and extracts the video part data, namely the video data (also referred to as the original video data), from the original video file through the video file compression tool, and extracts the audio part data, namely the audio data, from the original video file. The video file compression tool determines the resolution of the original video data and the bit rate of the original video data, that is, the original bit rate, and compares the original bit rate with the second bit rate threshold. When the original bit rate is less than the second bit rate threshold, the video data is re-encoded according to the libx264 encoder. For example, the libx264 encoder can be called by FFmpeg for re-encoding, and of course, the libx264 encoder can be directly called for re-encoding; when the original bit rate is greater than or equal to the second bit rate threshold and less than or equal to the first bit rate threshold, the original video data is re-encoded according to the ibx264 encoder, and the bit rate is controlled to be the second bit rate threshold, and compressed video data with a bit rate consistent with the second bit rate threshold is obtained; when the original bit rate is greater than or equal to the first bit rate threshold, the resolution of the original video data is compared with the resolution threshold. When the resolution of the original video data is greater than the resolution threshold, the resolution of the original video data is reduced to the resolution threshold by using the libx264 encoder, and the original video data is re-encoded according to the libx264 encoder, and the bit rate is controlled to be the second bit rate threshold, and compressed video data with a resolution consistent with the resolution threshold and a bit rate consistent with the second bit rate threshold is obtained. For the extracted audio data, if the format of the audio data is AAC, then the audio data and the compressed video data are merged to obtain a compressed video file; if the format of the audio data is not AAC, then the audio data is converted to AAC format to obtain format-converted audio data, and then the format-converted audio data is merged with the compressed video data to obtain a compressed video file. The video file compression method provided by the present application can automatically determine the compression strategy according to the resolution and bit rate of the video data in the video file, thereby improving the flexibility and efficiency of compressing the video data.
[0074] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0075] Based on the same inventive concept, the embodiment of the present application also provides a video file compression device for implementing the video file compression method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more video file compression device embodiments provided below can refer to the limitations on the video file compression method above, and will not be repeated here.
[0076] In some embodiments, as shown in FIG. 4 , a video file compression device is provided, including: a video file acquisition module 402, a data extraction module 404, a bit rate determination module 406, a video compression module 408 and a data merging module 410, wherein:
[0077] The video file acquisition module 402 is used to acquire video files collected by different types of video terminal devices during the on-site operation of the power grid.
[0078] The data extraction module 404 is used to extract video data and audio data from each video file.
[0079] The bit rate determination module 406 is used to determine the resolution of the video data and the bit rate of the video data.
[0080] The video compression module 408 is used to compress the resolution and bit rate of the video data to obtain compressed video data when the resolution of the video data is greater than the resolution threshold and the bit rate of the video data is greater than the first bit rate threshold.
[0081] The data merging module 410 is used to merge the compressed video data and the audio data to obtain a compressed video file corresponding to the video file.
[0082] In some embodiments, the video compression module 408 is further used to compress the resolution of the video data according to a resolution threshold to obtain resolution-compressed video data, and the resolution of the resolution-compressed video data is consistent with the resolution threshold; compress the bit rate of the resolution-compressed video data according to a second bit rate threshold to obtain compressed video data, and the bit rate of the compressed video data is consistent with the second bit rate threshold.
[0083] In some embodiments, the video compression module 408 is also used to call the video encoder through a multimedia processing tool, and instruct the video encoder to compress the resolution of the video data according to a resolution threshold to obtain resolution-compressed video data; call the video encoder through the multimedia processing tool, and instruct the video encoder to compress the bit rate of the resolution-compressed video data according to a second bit rate threshold to obtain compressed video data.
[0084] In some embodiments, the video compression module 408 is also used to compress the bit rate of the video data when the bit rate of the video data is greater than the second bit rate threshold and less than the first bit rate threshold to obtain compressed video data, and the bit rate of the compressed video data is equal to the second bit rate threshold; when the bit rate of the video data is less than the second bit rate threshold, compress the video data using a preset video compression method to obtain compressed video data.
[0085] In some embodiments, the video compression module 408 is also used to determine the target field operation type corresponding to the video data, the target field operation type corresponding to the video data refers to the type of power grid field operation from which the video data originates; determine the resolution threshold, the first bit rate threshold and the second bit rate threshold corresponding to the target field operation type; when the resolution of the video data is greater than the resolution threshold corresponding to the target field operation type, and the bit rate of the video data is greater than the first bit rate threshold corresponding to the target field operation type, compress the resolution and bit rate of the video data to obtain compressed video data, and the compressed video data is not lower than the second bit rate threshold corresponding to the target field operation type.
[0086] In some embodiments, the data merging module 410 is also used to determine the audio format of the audio data; when the audio format of the audio data is consistent with the target audio format, the compressed video data and the audio data are merged to obtain a compressed video file corresponding to the video file; when the audio format of the audio data is inconsistent with the target audio format, the audio data is format-converted to the target audio format to obtain format-converted audio data, and the compressed video data and the format-converted audio data are merged to obtain a compressed video file corresponding to the video file.
[0087] Each module in the above video file compression device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0088] In some embodiments, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG5. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data involved in the video file compression method. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a video file compression method is implemented.
[0089] In some embodiments, a computer device is provided, which may be a terminal, and its internal structure diagram may be shown in FIG6. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. The processor, the memory, and the input / output interface are connected via a system bus, and the communication interface, the display unit, and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner may be implemented through WIFI, a mobile cellular network, near field communication (NFC) or other technologies. When the computer program is executed by the processor, a video file compression method is implemented. The display unit of the computer device is used to form a visually visible picture, which may be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0090] Those skilled in the art will understand that the structures shown in FIGS. 5 and 6 are merely block diagrams of partial structures related to the scheme of the present application, and do not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device may include more or fewer components than those shown in the figures, or combine certain components, or have a different arrangement of components.
[0091] In some embodiments, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.
[0092] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above embodiments are implemented.
[0093] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above embodiments when executed by a processor.
[0094] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0095] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0096] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0097] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A video file compression method, characterized in that: The method comprises: Obtain video files collected by different types of video terminal devices during on-site power grid operations; For each of the video files, extracting video data and audio data from the video file; Determining a resolution of the video data and a bit rate of the video data; When the resolution of the video data is greater than the resolution threshold and the bit rate of the video data is greater than the first bit rate threshold, compressing the resolution and bit rate of the video data to obtain compressed video data, wherein the bit rate of the compressed video data is not less than the second bit rate threshold, and the resolution of the compressed video data is not less than the resolution threshold, and the second bit rate threshold is less than the first bit rate threshold; The compressed video data and the audio data are merged to obtain a compressed video file corresponding to the video file.
2. The method according to claim 1, characterized in that The step of compressing the resolution and bit rate of the video data to obtain compressed video data includes: Compressing the resolution of the video data according to the resolution threshold to obtain resolution-compressed video data, wherein the resolution of the resolution-compressed video data is consistent with the resolution threshold; According to the second bit rate threshold, the bit rate of the video data after the resolution compression is compressed to obtain compressed video data, and the bit rate of the compressed video data is consistent with the second bit rate threshold.
3. The method according to claim 2, characterized in that The step of compressing the resolution of the video data according to the resolution threshold to obtain the video data after the resolution is compressed includes: Calling a video encoder through a multimedia processing tool, and instructing the video encoder to compress the resolution of the video data according to a resolution threshold, so as to obtain video data after resolution compression; The step of compressing the bit rate of the video data after the resolution compression according to the second bit rate threshold to obtain compressed video data includes: The video encoder is called by the multimedia processing tool, and the video encoder is instructed to compress the bit rate of the resolution-compressed video data according to a second bit rate threshold to obtain compressed video data.
4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises at least one of the following: When the bit rate of the video data is greater than the second bit rate threshold and less than the first bit rate threshold, compressing the bit rate of the video data to obtain compressed video data, wherein the bit rate of the compressed video data is equal to the second bit rate threshold; When the bit rate of the video data is less than the second bit rate threshold, the video data is compressed using a preset video compression method to obtain compressed video data.
5. The method according to any one of claims 1 to 3, characterized in that: When the resolution of the video data is greater than a resolution threshold and the bit rate of the video data is greater than a first bit rate threshold, compressing the resolution and bit rate of the video data to obtain compressed video data includes: Determine a target field operation type corresponding to the video data, where the target field operation type corresponding to the video data refers to a type of power grid field operation from which the video data originates; Determine a resolution threshold, a first bit rate threshold, and a second bit rate threshold corresponding to the target on-site operation type; When the resolution of the video data is greater than the resolution threshold corresponding to the target on-site operation type, and the bit rate of the video data is greater than the first bit rate threshold corresponding to the target on-site operation type, the resolution and bit rate of the video data are compressed to obtain compressed video data, and the compressed video data is not lower than the second bit rate threshold corresponding to the target on-site operation type.
6. The method according to claim 1, characterized in that The step of merging the compressed video data and the audio data to obtain a compressed video file corresponding to the video file includes: determining an audio format of the audio data; When the audio format of the audio data is consistent with the target audio format, merging the compressed video data and the audio data to obtain a compressed video file corresponding to the video file; When the audio format of the audio data is inconsistent with the target audio format, the audio data is format-converted into the target audio format to obtain format-converted audio data, and the compressed video data and the format-converted audio data are merged to obtain a compressed video file corresponding to the video file.
7. A video file compression device, characterized in that: The device comprises: A video file acquisition module is used to acquire video files collected by different types of video terminal devices during on-site power grid operations; A data extraction module, for extracting video data and audio data from each video file; A bit rate determination module, used to determine the resolution of the video data and the bit rate of the video data; a video compression module, configured to compress the resolution and bit rate of the video data to obtain compressed video data when the resolution of the video data is greater than a resolution threshold and the bit rate of the video data is greater than a first bit rate threshold, wherein the bit rate of the compressed video data is not less than a second bit rate threshold, the resolution of the compressed video data is not less than the resolution threshold, and the second bit rate threshold is less than the first bit rate threshold; The data merging module is used to merge the compressed video data and the audio data to obtain a compressed video file corresponding to the video file.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
