Method and device for realizing local mosaic based on ffmpeg video frame and related components

By directly performing local mosaic operation on video frames using ffmpeg decoder in video mosaic processing, the inefficiency problem caused by video frame conversion in the prior art is solved, and more efficient video mosaic processing is achieved.

CN119520803APending Publication Date: 2025-02-25深圳牛学长科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411626976.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-14
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

Existing video mosaic processing methods require the conversion of the entire video frame to a specific format, resulting in inefficient processing.

Method used

By decoding video files using ffmpeg decoder, local mosaic operations are performed directly on video frames, avoiding the step of converting video frames to specific formats.

Benefits of technology

Improves the efficiency of video mosaic processing, simplifies the processing flow, and reduces the consumption of computing resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119520803A_ABST
    Figure CN119520803A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a method and device for realizing local mosaic based on an ffmpeg video frame and a related component, and the method comprises the steps: inputting a to-be-processed video file into an ffmpeg decoder for decoding to obtain a plurality of video frames, inputting a to-be-processed mosaic region in each video frame, and dividing the mosaic region to obtain a plurality of mosaic blocks; calculating an index position of each pixel point in each mosaic square block according to the pixel format of each video frame; and unifying all the pixel points in each mosaic square block according to the index position and a preset replacement rule. According to the embodiment of the invention, the local mosaic operation is directly carried out on the video frame decoded by the ffmpeg decoder, the video frame does not need to be converted into a specific format, the format conversion process is omitted, and the video mosaic processing efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of video processing technology, and in particular to a method, apparatus, and related components for implementing local mosaic based on ffmpeg video frames. Background Art

[0002] In some video application scenarios, such as media content publishing and online video sharing, it is often necessary to partially obscure or blur the video content. In particular, sensitive content such as faces and license plate numbers need to be pixelated to protect personal privacy and prevent the leakage of sensitive information.

[0003] However, existing video mosaic processing methods involve first decoding the video using decoding tools to obtain the original video frames. These frames retain the original pixel format, so they need to be converted to a specific format supported by image processing tools. Then, mosaic processing is applied to local areas within the video frames. In other words, existing methods treat the entire video frame as the conversion object, while mosaic processing only targets local areas. This conversion process increases the complexity of video processing, making video mosaic processing inefficient. Summary of the Invention

[0004] This invention provides a method, apparatus, and related components for implementing local mosaic based on ffmpeg video frames, aiming to solve the problem that existing video mosaic processing methods require converting video frames to a specific format, resulting in low mosaic processing efficiency.

[0005] In a first aspect, embodiments of the present invention provide a method for implementing local mosaic based on ffmpeg video frames, including:

[0006] Obtain a video file to be processed, and input the video file into an ffmpeg decoder for decoding to obtain multiple video frames;

[0007] Inputting a mosaic area to be processed in each of the video frames, and dividing the mosaic area to obtain a plurality of mosaic blocks;

[0008] Determining a pixel format of each of the video frames, and calculating an index position of each pixel in each mosaic block according to the pixel format;

[0009] According to the index position, all pixels in each mosaic block are unified according to a preset replacement rule.

[0010] In a second aspect, an embodiment of the present invention provides a device for implementing local mosaic based on ffmpeg video frames, comprising:

[0011] The decoding unit is used to acquire the video file to be processed and input the video file into the ffmpeg decoder for decoding to obtain multiple video frames;

[0012] a dividing unit, configured to input a mosaic area to be processed in each of the video frames, and divide the mosaic area into a plurality of mosaic blocks;

[0013] a calculation unit, configured to determine a pixel format of each of the video frames, and calculate an index position of each pixel point in each mosaic block according to the pixel format;

[0014] A unification unit is used to unify all pixels in each mosaic square according to the index position and a preset replacement rule.

[0015] Thirdly, embodiments of the present invention provide a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the method for implementing local mosaic based on ffmpeg video frames as described above.

[0016] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the method for implementing local mosaic based on ffmpeg video frames as described above.

[0017] An embodiment of the present invention provides a method, device, and related components for implementing local mosaicing based on FFmpeg video frames. The method inputs a video file to be processed into an FFmpeg decoder for decoding to obtain multiple video frames, inputs a mosaic region to be processed in each video frame, and divides the mosaic region into multiple mosaic blocks. The index position of each pixel in each mosaic block is calculated based on the pixel format of each video frame. Based on the index position, all pixels in each mosaic block are unified according to a preset replacement rule. This embodiment directly performs local mosaicing operations on video frames decoded by the FFmpeg decoder, eliminating the need to convert the video frames to a specific format, omitting the format conversion process, and improving the efficiency of video mosaic processing. Attached Figure Description

[0018] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1A flowchart illustrating a method for implementing local mosaic based on ffmpeg video frames, provided in an embodiment of the present invention;

[0020] Figure 2 This is a schematic diagram of a sub-process of a method for implementing local mosaic based on ffmpeg video frames provided in an embodiment of the present invention;

[0021] Figure 3 Schematic diagram of the mosaic processing process provided by the embodiment of the present invention Figure 1 ;

[0022] Figure 4 A schematic diagram of the mosaic processing procedure provided in this embodiment of the invention. Figure 2 ;

[0023] Figure 5 This is a schematic diagram of another sub-process of a method for implementing local mosaic based on ffmpeg video frames provided in an embodiment of the present invention;

[0024] Figure 6 This is a schematic block diagram of a device for implementing local mosaic based on ffmpeg video frames, provided as an embodiment of the present invention. DETAILED DESCRIPTION

[0025] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0026] It will be understood that when used in this specification and the appended claims, the terms “comprises” and “comprising” indicate the presence of described features, integers, steps, operations, elements and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.

[0027] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.

[0028] It should also be further understood that the term "and / or" as used in this specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0029] See also Figure 1 This invention provides a method for implementing local mosaic based on ffmpeg video frames, including steps S10-S40:

[0030] S10. Obtain the video file to be processed, and input the video file into the ffmpeg decoder for decoding to obtain multiple video frames;

[0031] In this step, the video files to be processed are those that need to be pixelated. These video files are stored on storage devices such as hard drives, SSDs, and network storage. The video files have various pixel formats, each with a specific encoding method. The FFmpeg decoder can recognize these various pixel formats and call the corresponding decoding engine to parse the video file, thus obtaining multiple video frames that retain the original pixel format. This step improves decoding efficiency by using the FFmpeg decoder to decode the video file.

[0032] In one embodiment, if Figure 2 As shown, S10 includes:

[0033] S11. Use the decoding engine of the ffmpeg decoder to decode the video file to obtain multiple video frames;

[0034] S12. Store each of the video frames according to a predetermined data structure, wherein the predetermined data structure includes pixel format and frame width.

[0035] In this embodiment, the ffmpeg decoder first identifies the pixel format of the video file. Based on the identified pixel format, it calls the corresponding decoding engine to decode the video file, obtaining multiple video frames. These video frames retain their original pixel format and are stored according to a predetermined data structure. The information stored in the predetermined data structure includes the pixel format, frame width, and frame height, which can be directly used for subsequent processing. This embodiment uses the ffmpeg decoder to decode the video file, ensuring that each decoded video frame retains its original pixel format, eliminating the need to convert the pixel format of the video frames according to the format requirements of other processing tools, thus improving processing efficiency.

[0036] S20. Input the mosaic region to be processed in each of the video frames, and divide the mosaic region to obtain multiple mosaic blocks;

[0037] In this step, each video frame needs to be mosaicked for the content to be processed. The content to be processed can be privacy information such as faces and license plate numbers. When it is confirmed that there is content to be processed in each video frame, the location information of the content to be processed is directly input, and the coverage area of ​​the content to be processed is determined based on the location information. The mosaic area of ​​the content to be processed is obtained based on the location information and the coverage area. The mosaic area is divided into multiple mosaic blocks, and each mosaic block is processed subsequently.

[0038] In one embodiment, S20 includes:

[0039] The position information of all pixels in the mosaic area is obtained, and each mosaic area is divided according to a specified pixel size to obtain a plurality of mosaic blocks corresponding to each mosaic area.

[0040] In this embodiment, after inputting the mosaic region to be processed, it is necessary to obtain the position information of all pixels in the mosaic region. This position information is used to calculate the index position of each pixel and divide the mosaic region according to the specified pixel size. That is, when the specified pixel size is 4x4 pixels, all pixels in the mosaic region are divided into multiple mosaic squares, each containing 4x4 pixels. In specific implementation, the mosaic region can be a fixed area of ​​the content to be processed selected by the user, or the position information of each pixel in the area of ​​the content to be processed in each video frame can be obtained by algorithm tracking. Then, the fixed area or position information can be input.

[0041] In addition, if the mosaic area cannot be an integer multiple of the specified mosaic block size according to the specified pixel size, the pixels within the mosaic area will continue to be processed, and the pixels outside the mosaic area will not be processed. Figure 4 , Figure 4 The entire large box is a mosaic area. Figure 4 Each small square with numbers in it represents a pixel. If the specified pixel size is 4x4 pixels, then each mosaic square after division should contain 4x4 pixels. Figure 4 Among the four mosaic blocks (A, B, C, and D) divided in the image, only mosaic block A contains 4x4 pixels, that is, all the pixels of mosaic block A are within the mosaic area, while mosaic blocks B, C, and D have less than 4x4 pixels, that is, only some of the pixels are within the mosaic area. In this case, only the pixels within the mosaic area are processed.

[0042] S30. Determine the pixel format of each video frame, and calculate the index position of each pixel in each mosaic block according to the pixel format;

[0043] In this step, the storage method of pixels is different for different pixel formats, which will affect the calculation of the pixel index position. Therefore, it is necessary to first determine the pixel format of each video frame, determine the pixel storage method based on the pixel format, and then use the corresponding calculation method to calculate the index position of each pixel in each mosaic block. The index position is used for subsequent mosaic processing.

[0044] In one embodiment, if Figure 5 As shown, S30 includes:

[0045] S31. If the pixel format of the video frame is YUV420P, then the index position of each pixel in each mosaic block is calculated using the first calculation method based on the frame width and the position information of each pixel.

[0046] S32. If the pixel format of the video frame is RGB24, then the index position of each pixel in each mosaic block is calculated using the second calculation method based on the frame width and the position information of each pixel.

[0047] In this embodiment, the pixel formats of the video frames are YUV420P and RGB24. For the YUV420P format, the pixels are stored separately, while for the RGB24 format, the pixels are stored continuously. The index position of each pixel in each mosaic block is then calculated using the corresponding calculation method, thereby accurately locating the position of each mosaic block. This embodiment can ensure that the pixels in the mosaic area in each video frame are operated for different pixel formats, thereby smoothly performing mosaic processing.

[0048] In one embodiment, S31 includes:

[0049] All pixels of the video frame are split and stored as a luminance channel Y, a first chrominance channel U, and a second chrominance channel V;

[0050] Obtain the storage information linesize[w] of the frame width w, and calculate the Y index, U index, and V index according to the storage information linesize[w] and the position information (x, y) of each pixel in the mosaic region using the following formulas:

[0051] Y index = y * linesize[w] + x

[0052] U index = V index = (y / 2)*(linesize[w] / 2)+x / 2

[0053] Among them, the Y index, U index, and V index are the index positions of the corresponding pixels;

[0054] According to the Y index, U index and V index, the corresponding Y value, U value and V value are obtained, wherein the Y value, U value and V value are the data values ​​of each pixel point.

[0055] In this embodiment, when the video frame's pixel format is YUV420P, all pixels within the video frame are split into a luminance channel Y, a first chroma channel U, and a second chroma channel V. These three channels are stored separately. Then, the frame width and the position information of each pixel in the mosaic region stored in step S12 are obtained. This position information can be directly obtained through an algorithm. Based on the frame width and the position information of each pixel, the indices of the three channels are calculated according to the above formula. These three indices are the index positions of the corresponding pixels. The data values ​​of the three channels are calculated as follows:

[0056] Y value = y_data[Y index]

[0057] U value=u_data[U index]

[0058] V value = v_data[V index]

[0059] The calculated Y value, U value, and V value are the data values ​​of the index position of the corresponding pixel point. Among them, the video frame has the frame width w stored in it, which can be directly obtained.

[0060] In one embodiment, S32 includes:

[0061] Continuously storing all pixels of the video frame as channel R, channel G, and channel B;

[0062] Obtain the stored information linesize[w] of the frame width w, and calculate the R index, G index, and B index according to the stored information linesize[w] and the position information (x, y) of each pixel in the mosaic area using the following formula:

[0063] R index = y * linesize[w] + (x * 3)

[0064] G index = y * linesize[w] + (x * 3) + 1

[0065] B index = y * linesize[w] + (x * 3) + 2

[0066] Among them, R index, G index and B index are the index positions of the corresponding pixel points;

[0067] According to the R index, G index and B index, the corresponding R value, G value and B value are obtained, wherein the R value, G value and B value are the data values ​​of each pixel point.

[0068] In this embodiment, when the pixel format of the video frame is RGB24, all pixels in the video frame are divided into channel R, channel G, and channel B. These three channels are stored continuously. Then, the frame width stored in step S12 and the position information of each pixel in the mosaic area are obtained. Similarly, this position information can be directly located by an algorithm. Based on the frame width and the position information of each pixel, the indexes of the three channels are calculated according to the above formula. These three indexes are the index positions of the corresponding pixels. The data values ​​of the three channels are calculated based on the three indexes. Since the three channels are stored continuously, that is, data = RGBRGBRGBRGBRGB, the data values ​​of the three channels are: R value = data[R index], G value = data[G index], and B value = data[B index]. The calculated R value, G value, and B value are the data values ​​of the index positions of the corresponding pixels. Among them, the video frame has the stored information of the frame width w, which can be directly obtained.

[0069] S40. Based on the index position, unify all pixels in each mosaic block according to the preset replacement rules.

[0070] In this step, as we know from the previous steps, each mosaic square is composed of multiple pixels. Each pixel represents a small square, and multiple small squares make up a large square (mosaic square). In order to ensure that the mosaic area presents a consistent visual appearance, all pixels in each mosaic square need to be unified to ensure that the privacy information in the mosaic area is not leaked. Among them, the preset replacement rules can be color replacement, pattern replacement, average value replacement and random value replacement, etc. For color replacement, all pixels in the mosaic block can be replaced with the same color value, such as black, white, gray or other specified colors; for pattern replacement, all pixels in the mosaic block are replaced with specific patterns or textures, such as blurred pixel blocks, grid patterns, dot patterns, etc.; for average value replacement, it is necessary to first calculate the color average or brightness average of all pixels in the mosaic block, and then use the average value as the new color value to replace all pixels in the block; for random value replacement, the color value or brightness value of a pixel point is randomly selected in the mosaic block, and then the color value or brightness value replaces all pixels in the mosaic block, thereby completing the unification of each mosaic block.

[0071] In one embodiment, S40 includes:

[0072] For each mosaic square, iterate through all pixels in the mosaic square, select the value of one pixel in the mosaic square, and replace the values ​​of the remaining pixels in the mosaic square with the value of the selected pixel.

[0073] This embodiment uses a random value replacement rule. For each mosaic square, it iterates through all pixels in the mosaic square, then selects the value of one pixel (this value can be a color value or a brightness value), and then replaces the values ​​of the remaining pixels in the mosaic square with the value of the selected pixel. In specific implementation, refer to... Figure 3 and Figure 4 ( Figure 3 and Figure 4 Each small square in the mosaic represents the value of that pixel. The selected pixel can be the top-left corner pixel of each mosaic square, and then the values ​​of the remaining pixels in the mosaic square are replaced with the value of the top-left corner pixel. Furthermore, before replacing the pixels within the mosaic square, the edges of each adjacent mosaic square can be blurred to produce a smoother transition effect.

[0074] This invention also provides an apparatus for implementing local mosaic based on ffmpeg video frames. This apparatus is used to execute any embodiment of the aforementioned method for implementing local mosaic based on ffmpeg video frames. Specifically, please refer to... Figure 6 , Figure 6 This is a schematic block diagram of an apparatus for implementing local mosaic based on ffmpeg video frames, provided by an embodiment of the present invention. The apparatus 500 for implementing local mosaic based on ffmpeg video frames includes:

[0075] The decoding unit 510 is used to obtain a video file to be processed and input the video file into an ffmpeg decoder for decoding to obtain multiple video frames;

[0076] The segmentation unit 520 is used to input the mosaic region to be processed in each video frame and to segment the mosaic region to obtain multiple mosaic blocks;

[0077] a calculation unit 530, configured to determine a pixel format of each video frame, and calculate an index position of each pixel in each mosaic block according to the pixel format;

[0078] The unification unit 540 is used to unify all pixels in each mosaic square according to the index position and a preset replacement rule.

[0079] In one embodiment, the decoding unit 510 is used for:

[0080] Decoding the video file using a decoding engine of an ffmpeg decoder to obtain multiple video frames;

[0081] Each video frame is stored according to a predetermined data structure, wherein the predetermined data structure includes pixel format and frame width.

[0082] In one embodiment, the partitioning unit 520 is configured to:

[0083] The position information of all pixels in the mosaic region is obtained, and each mosaic region is divided according to a specified pixel size to obtain multiple mosaic blocks corresponding to each mosaic region.

[0084] In one embodiment, the calculation unit 530 includes:

[0085] The first calculation unit is used to calculate the index position of each pixel in each mosaic block according to the frame width and the position information of each pixel point through the first calculation method if the pixel format of the video frame is YUV420P format.

[0086] The second calculation unit is used to calculate the index position of each pixel in each mosaic block according to the frame width and the position information of each pixel point through a second calculation method if the pixel format of the video frame is RGB24 format.

[0087] In one embodiment, the first computing unit is used for:

[0088] All pixels of the video frame are split and stored as a luminance channel Y, a first chrominance channel U, and a second chrominance channel V;

[0089] Obtain the stored information linesize[w] of the frame width w, and calculate the Y index, U index, and V index according to the stored information linesize[w] and the position information (x, y) of each pixel point according to the following formulas:

[0090] Y index = y * linesize[w] + x

[0091] U index = V index = (y / 2)*(linesize[w] / 2)+x / 2

[0092] Among them, the Y index, U index, and V index are the index positions of the corresponding pixels;

[0093] According to the Y index, U index and V index, the corresponding Y value, U value and V value are obtained, wherein the Y value, U value and V value are the data values ​​of each pixel point.

[0094] In one embodiment, the second computing unit is used for:

[0095] Continuously storing all pixels of the video frame as channel R, channel G, and channel B;

[0096] Obtain the stored information linesize[w] of the frame width w, and calculate the R index, G index, and B index according to the stored information linesize[w] and the position information (x, y) of each pixel point using the following formula:

[0097] R index = y * linesize[w] + (x * 3)

[0098] G index = y * linesize[w] + (x * 3) + 1

[0099] B index = y * linesize[w] + (x * 3) + 2

[0100] Among them, R index, G index and B index are the index positions of the corresponding pixel points;

[0101] According to the R index, G index and B index, the corresponding R value, G value and B value are obtained, wherein the R value, G value and B value are the data values ​​of each pixel point.

[0102] In one embodiment, the unification unit 540 is used for:

[0103] For each mosaic block, all pixels in the mosaic block are traversed, and the value of one pixel in the mosaic block is selected, and the values ​​of the remaining pixels in the mosaic block are replaced with the value of the selected pixel in sequence.

[0104] An embodiment of the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the method for realizing local mosaic based on ffmpeg video frames as described in the aforementioned embodiment is implemented.

[0105] An embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method for realizing local mosaic based on ffmpeg video frames as described in the above embodiment is implemented.

[0106] Those skilled in the art will readily understand that, for the sake of convenience and brevity, the specific working processes of the devices, apparatuses, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this invention.

[0107] In the embodiments provided by this invention, it should be understood that the disclosed devices, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Units with the same function may be grouped into one unit. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. In addition, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices, or units, or it may be an electrical, mechanical, or other form of connection.

[0108] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected according to actual needs to achieve the objectives of the embodiments of the present invention.

[0109] In addition, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0110] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), magnetic disks, or optical disks.

[0111] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and such modifications or substitutions are intended to be within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the scope of protection of the claims.

Claims

1. A method for realizing local mosaic based on ffmpeg video frame, characterized in that: include: Obtain a video file to be processed, and input the video file into an ffmpeg decoder for decoding to obtain multiple video frames; Inputting a mosaic area to be processed in each of the video frames, and dividing the mosaic area to obtain a plurality of mosaic blocks; Determining a pixel format of each of the video frames, and calculating an index position of each pixel point in each mosaic block according to the pixel format; According to the index position, all the pixels in each mosaic block are unified according to a preset replacement rule.

2. The method for realizing local mosaic based on ffmpeg video frame according to claim 1, characterized in that: The video file to be processed is obtained, and the video file is input into the ffmpeg decoder for decoding to obtain multiple video frames, including: Decoding the video file using a decoding engine of an ffmpeg decoder to obtain a plurality of video frames; Each of the video frames is stored according to a predetermined data structure, wherein the predetermined data structure includes a pixel format and a frame width.

3. The method for realizing local mosaic based on ffmpeg video frame according to claim 2, characterized in that: The mosaic area to be processed in each of the input video frames is divided into multiple mosaic blocks, including: The position information of all pixels in the mosaic area is obtained, and each mosaic area is divided according to a specified pixel size to obtain a plurality of mosaic blocks corresponding to each mosaic area.

4. The method for realizing local mosaic based on ffmpeg video frame according to claim 3, characterized in that: The step of determining the pixel format of each video frame and calculating the index position of each pixel in each mosaic block according to the pixel format includes: If the pixel format of the video frame is YUV420P format, the index position of each pixel in each mosaic block is calculated by a first calculation method according to the frame width and the position information of each pixel; If the pixel format of the video frame is RGB24 format, the index position of each pixel in each mosaic block is calculated by a second calculation method according to the frame width and the position information of each pixel.

5. The method for realizing local mosaic based on ffmpeg video frame according to claim 4, characterized in that: If the pixel format of the video frame is the YUV420P format, the index position of each pixel in each mosaic block is calculated by a first calculation method according to the frame width and the position information of each pixel, including: Splitting all pixels of the video frame into a luminance channel Y, a first chrominance channel U, and a second chrominance channel V for storage; The stored information linesize[w] of the frame width w is obtained, and the Y index, U index and V index are calculated according to the stored information linesize[w] and the position information (x, y) of each pixel point according to the following formulas: Y index = y*linesize[w]+x U index = V index = (y / 2)*(linesize[w] / 2)+x / 2 Among them, Y index, U index and V index are the index positions of corresponding pixel points; According to the Y index, U index and V index, the corresponding Y value, U value and V value are obtained, wherein the Y value, U value and V value are the data values ​​of each pixel.

6. The method for realizing local mosaic based on ffmpeg video frame according to claim 4, characterized in that: If the pixel format of the video frame is RGB24 format, the index position of each pixel in each mosaic block is calculated by a second calculation method according to the frame width and the position information of each pixel, including: All pixels of the video frame are continuously stored as channel R, channel G and channel B; The stored information linesize[w] of the frame width w is obtained, and the R index, the G index, and the B index are calculated according to the stored information linesize[w] and the position information (x, y) of each pixel point according to the following formula: R index = y*linesize[w]+(x*3) G index = y*linesize[w]+(x*3)+1 B index = y*linesize[w]+(x*3)+2 Among them, R index, G index and B index are the index positions of corresponding pixel points; According to the R index, the G index and the B index, the corresponding R value, G value and B value are obtained, wherein the R value, G value and B value are the data values ​​of each pixel point.

7. The method for realizing local mosaic based on ffmpeg video frame according to claim 1, characterized in that: The step of unifying all pixel points in each mosaic block according to the index position and a preset replacement rule includes: For each mosaic block, all pixels in the mosaic block are traversed, and the value of one pixel in the mosaic block is selected, and the values ​​of the remaining pixels in the mosaic block are replaced with the value of the selected pixel in turn.

8. A device for realizing local mosaic based on ffmpeg video frames, used to realize the method for realizing local mosaic based on ffmpeg video frames as claimed in any one of claims 1 to 7, characterized in that: include: A decoding unit is used to obtain a video file to be processed, and input the video file into an ffmpeg decoder for decoding to obtain multiple video frames; A division unit, used for inputting a mosaic area to be processed in each of the video frames, and dividing the mosaic area to obtain a plurality of mosaic blocks; A calculation unit, used to determine the pixel format of each of the video frames, and calculate the index position of each pixel in each mosaic block according to the pixel format; The unification unit is used to unify all the pixels in each mosaic block according to the index position and a preset replacement rule.

9. A computer device, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for realizing local mosaic based on ffmpeg video frame as described in any one of claims 1 to 7 is realized.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for realizing local mosaic based on ffmpeg video frames according to any one of claims 1 to 7 is implemented.