Method and device for automatically synthesizing picture materials based on FFmpeg

By building a picture library and using FFmpeg for batch processing, matching pictures based on the keyword list and automatically synthesizing picture materials that meet preset specification parameters, the problem of low efficiency in manual image processing is solved and efficient and accurate picture material synthesis is achieved.

CN119807463APending Publication Date: 2025-04-11GUANGZHOU QISHENG INFORMATION TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411870892.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-18
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

In the prior art, users need to manually process pictures, resulting in low processing efficiency and poor accuracy, especially when processing large batches of different types of pictures.

Method used

By building a picture library and batch processing using FFmpeg, match the pictures according to the keyword list, and automatically synthesize picture materials that meet preset target specification parameters.

Benefits of technology

It realizes efficient and accurate picture material synthesis, saving a lot of time and labor costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119807463A_ABST
    Figure CN119807463A_ABST
Patent Text Reader

Abstract

The invention discloses a method and device for automatically synthesizing picture materials based on FFmpeg, and the method comprises the steps: constructing a picture library, and marking the ID, specification parameter information and key attribute features of an original picture in the picture library; constructing and importing a keyword list, setting a search word according to the keyword list, searching in the picture library, and obtaining and storing an original picture consistent with the search word; according to the specification parameter information of the original picture and preset target specification parameter information, synthesizing the obtained original picture to obtain a target picture material; and performing quality inspection on the target picture material, and storing the target picture material passing the quality inspection. Through the method, the pictures can be processed into the picture materials with the preset target specification parameters in batches, and automatic process processing is realized, so that the picture materials are synthesized efficiently and accurately.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular to a method and device for automatically synthesizing picture materials based on FFmpeg. Background Art

[0002] At present, when processing pictures, users can usually only manually process the pictures to synthesize the desired target picture materials, such as manually cropping the pictures, adding watermarks, adding text, etc. Manual processing is not only time-consuming and laborious, but also inefficient in processing pictures, especially when large quantities of pictures of different types need to be processed, the efficiency and accuracy of manual processing will be greatly reduced. Therefore, the present invention proposes a method, which can match the corresponding pictures according to the keyword list, and then use FFmpeg to batch process the pictures into picture materials with preset target specification parameters, and realize efficient and accurate synthesis of picture materials through automated process processing. Summary of the invention

[0003] The main purpose of the present invention is to disclose a method and device for automatically synthesizing picture materials based on FFmpeg, which can batch process pictures into picture materials with preset target specification parameters, realize automated process processing, and thus efficiently and accurately synthesize picture materials, saving a lot of time and labor costs.

[0004] In the first aspect, a method for automatically synthesizing image materials based on FFmpeg is provided.

[0005] A method for automatically synthesizing picture materials based on FFmpeg according to the present invention includes:

[0006] Constructing a picture library, marking the ID, specification parameter information and key attribute characteristics of the original pictures in the picture library; wherein the key attribute characteristics are population, part, disease and final keyword;

[0007] Construct and import a keyword list, set search terms according to the keyword list, search in the picture library, obtain and store original pictures consistent with the search terms; wherein the content of the keyword list includes number, batch number, part, disease, applicable population and final keyword; the content of the search terms is population, part and final keyword;

[0008] Synthesizing the acquired original picture according to the specification parameter information of the original picture and the preset target specification parameter information to obtain the target picture material;

[0009] Performing a quality check on the target image material and storing the target image material that passes the quality check, including: verifying according to the preset target specification parameter information.

[0010] Preferably, the searching in the picture library further comprises: if there is no original picture consistent with the search term in the picture library, automatically searching for original pictures similar to the search term and sorting them, and then selecting the original picture with the highest similarity.

[0011] Preferably, the obtaining and storing of original pictures consistent with the search term further includes: when there are multiple original pictures consistent with the search term in the picture library, randomly obtaining one of the original pictures, and recording the ID of the original picture that has been obtained in the picture library, so that the original picture with the recorded ID will no longer be matched during the next search.

[0012] Preferably, the synthesis includes one or more of adding watermarks, scaling, cropping, adding text, adding picture borders, and adding transparent rounded corners.

[0013] Preferably, the adding of text comprises: adding a transparent canvas, then adding text, calculating the pixel width of the text, and if the pixel width of the text exceeds a preset safety value, wrapping the added text, wherein the preset safety value is the blank width of the border of the transparent canvas.

[0014] Preferably, the verification according to the preset target specification parameter information also includes: obtaining the current specification parameter information of the target image material, comparing it with the preset target specification parameter information, and determining whether they are consistent; wherein the preset target specification parameters and the current specification parameter information include one or more of color gamut, size, and format.

[0015] In a second aspect, a device for automatically synthesizing image materials based on FFmpeg is provided.

[0016] A device for automatically synthesizing picture materials based on FFmpeg according to the present invention comprises:

[0017] The picture management module is used to build a picture library and mark the ID, specification parameter information and key attribute characteristics of the original pictures in the picture library; wherein the key attribute characteristics are population, part, disease and final keyword;

[0018] A matching module is used to construct and import a keyword list, set search terms according to the keyword list, search in the image library, and obtain and store original images consistent with the search terms; wherein the content of the keyword list includes number, batch number, part, disease, applicable population and final keyword; the content of the search term is population, part and final keyword;

[0019] A synthesis module, used to synthesize the acquired original picture according to the specification parameter information of the original picture and the preset target specification parameter information to obtain the target picture material;

[0020] The quality inspection module is used to perform a quality inspection on the target image material and store the target image material that passes the quality inspection, including: verifying according to the preset target specification parameter information.

[0021] Preferably, the matching module is further used for: if there is no original picture consistent with the search term in the picture library, automatically searching for and sorting original pictures similar to the search term, and then selecting the original picture with the highest similarity.

[0022] Preferably, the matching module is also used for: when there are multiple original pictures consistent with the search term in the picture library, randomly obtaining one of the original pictures, and recording the ID of the original picture that has been obtained in the picture library, and no longer matching the original picture with the recorded ID during the next search.

[0023] Preferably, the quality inspection module is also used to: obtain the current specification parameter information of the target image material, compare it with the preset target specification parameter information, and determine whether they are consistent; wherein the preset target specification parameters and the current specification parameter information include one or more of color gamut, size, and format. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 This is a flow chart of a method for automatically synthesizing picture materials based on FFmpeg according to an embodiment of the present invention;

[0025] Figure 2 It is a schematic diagram of the structure of a device for automatically synthesizing picture materials based on FFmpeg according to an embodiment of the present invention. DETAILED DESCRIPTION

[0026] In order to make the objectives, technical solutions and advantages of the embodiments of the present invention more clearly understood, the spirit of the contents disclosed by the present invention will be clearly explained with the accompanying drawings and detailed descriptions below. After understanding the embodiments of the contents of the present invention, any technician in the relevant technical field can change and modify the techniques taught by the contents of the present invention without departing from the spirit and scope of the contents of the present invention.

[0027] Figure 1 A flowchart of an implementation method of a method for automatically synthesizing picture materials based on FFmpeg provided by an embodiment of the present invention is shown as follows: Figure 1 As shown, the method includes:

[0028] S1, constructing a picture library, marking the ID, specification parameter information and key attribute characteristics of the original pictures in the picture library; wherein the key attribute characteristics are population, body part, disease and final keyword.

[0029] In this embodiment, the original pictures in the picture library can be added according to needs. By labeling the original pictures in the picture library, for example, what part, what disease, applicable population and other dimensions, the key attribute characteristics of each original picture may be the same, so it is necessary to mark the ID of each original picture.

[0030] S2, construct and import a keyword list, set search terms according to the keyword list, search in the image library, obtain and store original images consistent with the search terms; wherein the content of the keyword list includes number, batch number, part, disease, applicable population and final keyword; the content of the search term is population, part, and final keyword.

[0031] In this embodiment, the groups of people in the keyword list can be set to different identity characteristics such as children, the elderly, men, and women, the parts can be set to the soles of the feet, the back of the hands, the back and other physiological parts of the human body, and the names of diseases can be set according to the types of diseases in the history of human medicine, such as plantar fasciitis, plantar fasciitis, foot trauma, etc. The final keywords correspond to the diseases, reflecting the diseases, conditions, treatment methods, etc. For example, if the disease is foot trauma, the final keywords can be set to rest, cold compress, foot edema or foot trauma. The contents of the above keyword lists can be added and defined according to the needs. When setting the search terms, you need to set them according to the contents of the keyword list. For example, the search terms are: "children and soles and foot edema". After setting the search terms, search and search are performed in the picture library according to the search terms. During the search and search process, the search terms are segmented and matched with the marked pictures in the picture library through Elasticsearch. The following two situations may occur during the search: First, there is no matching original picture in the picture library, that is, when there is no original picture that matches the search term in the picture library, the original picture similar to the search term is automatically searched, and these pictures are sorted according to the similarity, and finally the original picture with the highest similarity is selected. Second, there are multiple original pictures with the same search term in the picture library. When there are multiple original pictures that match the search term in the picture library, one of the original pictures is randomly obtained, and the ID of the original picture that has been obtained is recorded in the picture library. The original picture with the ID that has been recorded will no longer be matched during the next search.

[0032] S3, synthesizing the acquired original picture according to the specification parameter information of the original picture and the preset target specification parameter information to obtain the target picture material.

[0033] After obtaining the desired original image, the original image is synthesized by executing FFmpeg commands, including adding watermarks, scaling, cropping, adding text, adding image borders, adding transparent rounded corners, etc. For example, use ffmpeg's crop filter to crop the image, use the scale filter to reduce or enlarge the image, use the alphamerge filter to add transparent rounded corners, and use the overlay filter to add an outer border of the image. When adding text, first use the pad filter to add a transparent canvas, use the overlay filter to place the image on the transparent canvas, and use the drawtext filter to add text. When adding text, the font may be too long, so you need to calculate the pixel width of the added text. If the pixel width of the text exceeds the preset safety value, you need to wrap the text. The preset safety value can be set by yourself, which is generally the width of the blank border of the transparent canvas.

[0034] In this embodiment, when the pixel width of the added text exceeds the preset width, the text is added in a line break. When the line break occurs, the specific operation is as follows:

[0035] 1. Use the drawtext filter to draw "text that does not exceed the preset width"

[0036] 2. Calculate the y-axis coordinate of the text that needs to be wrapped relative to the transparent canvas. This part requires reserved line spacing.

[0037] 3. Use the drawtext filter to draw text that exceeds the preset width and needs to wrap.

[0038] In the implementation process, the input parameters of the drawtext filter include the x, y coordinates of the text, font size, font style, etc. Here, the xy coordinates are the coordinate axes established relative to the transparent canvas.

[0039] S4, performing a quality check on the target image material, and storing the target image material that passes the quality check, including: verifying according to the preset target specification parameter information.

[0040] In this embodiment, the parameter information of the image is obtained through the ffprobe tool, including the current parameter information of the target image material and the preset target specification parameter information. The parameter information includes color gamut, size, format, etc. The image is verified based on the parameter information, and the verified image is saved.

[0041] In the entire process of the method for automatically synthesizing picture materials in the technical solution, asynchronous programming can be implemented through threads. For example, matching pictures and synthesizing pictures can perform multiple tasks at the same time. Using the producer and consumer model, the number of producers and consumers can be dynamically adjusted according to the system load to optimize resources. The non-blocking method used in Reactor is used to handle concurrency, which can reduce the complexity of the code. According to the type of GPU read by the program, an encoder that supports hardware acceleration is automatically selected to achieve greater throughput and faster synthesis speed.

[0042] According to an embodiment of the present invention, a device for automatically synthesizing picture materials based on FFmpeg is also provided. Figure 2 is with Figure 1 The corresponding device uses the corresponding functional unit to perform the corresponding method steps, such as Figure 2 As shown, the device comprises:

[0043] The picture management module 201 is used to construct a picture library and mark the ID, specification parameter information and key attribute characteristics of the original pictures in the picture library; wherein the key attribute characteristics are population, body part, disease and final keyword.

[0044] The matching module 202 is used to construct and import a keyword list, set search terms according to the keyword list, search in the image library, obtain and store original images consistent with the search terms; wherein the content of the keyword list includes number, batch number, part, disease, applicable population and final keyword; the content of the search term is population, part, and final keyword.

[0045] The matching module 202 is also used to automatically search for and sort original pictures similar to the search word if there is no original picture consistent with the search word in the picture library, and then select the original picture with the highest similarity. When there are multiple original pictures consistent with the search word in the picture library, one of the original pictures is randomly obtained, and the ID of the original picture that has been obtained is recorded in the picture library, and the original picture whose ID has been recorded is no longer matched in the next search.

[0046] The synthesis module 203 is used to synthesize the acquired original picture according to the specification parameter information of the original picture and the preset target specification parameter information to obtain the target picture material.

[0047] The quality inspection module 204 is used to perform a quality inspection on the target image material and store the target image material that passes the quality inspection, including: verifying according to the preset target specification parameter information.

[0048] The quality inspection module 204 is also used to obtain the current specification parameter information of the target image material, and compare it with the preset target specification parameter information to determine whether they are consistent; wherein the preset target specification parameters and the current specification parameter information include one or more of color gamut, size, and format.

[0049] In summary, with the help of the above-mentioned implementation methods provided by the present invention, a method and device for automatically synthesizing picture materials based on FFmpeg are disclosed, which can batch process pictures into picture materials with preset target specification parameters, realize automated process processing, and thus efficiently and accurately synthesize picture materials, saving a lot of time and labor costs.

[0050] So far, the technical solutions of the present invention have been described in conjunction with the embodiments shown in the accompanying drawings, but it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.

[0051] The above descriptions are only several specific embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for automatically synthesizing picture materials based on FFmpeg, characterized in that: The method comprises: Constructing a picture library, marking the ID, specification parameter information and key attribute characteristics of the original pictures in the picture library; wherein the key attribute characteristics are population, part, disease and final keyword; Construct and import a keyword list, set search terms according to the keyword list, search in the picture library, obtain and store original pictures consistent with the search terms; wherein the content of the keyword list includes number, batch number, part, disease, applicable population and final keyword; the content of the search terms is population, part and final keyword; Synthesizing the acquired original picture according to the specification parameter information of the original picture and the preset target specification parameter information to obtain the target picture material; Performing a quality check on the target image material and storing the target image material that passes the quality check, including: verifying according to the preset target specification parameter information.

2. The method for automatically synthesizing picture materials based on FFmpeg according to claim 1, characterized in that: The searching in the picture library further includes: if there is no original picture consistent with the search term in the picture library, automatically searching for original pictures similar to the search term and sorting them, and then selecting the original picture with the highest similarity.

3. The method for automatically synthesizing picture materials based on FFmpeg according to claim 1, characterized in that: The method of obtaining and storing the original pictures that are consistent with the search term also includes: when there are multiple original pictures that are consistent with the search term in the picture library, randomly obtaining one of the original pictures, and recording the ID of the original picture that has been obtained in the picture library, so that the original picture with the recorded ID will no longer be matched during the next search.

4. The method for automatically synthesizing picture materials based on FFmpeg according to claim 1, characterized in that: The synthesis includes one or more of adding watermarks, scaling, cropping, adding text, adding picture borders, and adding transparent rounded corners.

5. The method for automatically synthesizing picture materials based on FFmpeg according to claim 4, characterized in that: The adding of text includes: adding a transparent canvas, then adding text, calculating the pixel width of the text, and if the pixel width of the text exceeds a preset safety value, wrapping the added text, wherein the preset safety value is the blank width of the border of the transparent canvas.

6. The method for automatically synthesizing picture materials based on FFmpeg according to claim 1, characterized in that: The verification according to the preset target specification parameter information also includes: obtaining current specification parameter information of the target image material, comparing it with the preset target specification parameter information, and determining whether they are consistent; wherein the preset target specification parameters and the current specification parameter information include one or more of color gamut, size, and format.

7. A device for automatically synthesizing picture materials based on FFmpeg, characterized in that: include: The picture management module is used to build a picture library and mark the ID, specification parameter information and key attribute characteristics of the original pictures in the picture library; wherein the key attribute characteristics are population, part, disease and final keyword; A matching module is used to construct and import a keyword list, set search terms according to the keyword list, search in the image library, and obtain and store original images consistent with the search terms; wherein the content of the keyword list includes number, batch number, part, disease, applicable population and final keyword; the content of the search term is population, part and final keyword; A synthesis module, used to synthesize the acquired original picture according to the specification parameter information of the original picture and the preset target specification parameter information to obtain the target picture material; The quality inspection module is used to perform a quality inspection on the target image material and store the target image material that passes the quality inspection, including: verifying according to the preset target specification parameter information.

8. The device for automatically synthesizing picture materials based on FFmpeg according to claim 7, characterized in that: The matching module is also used to: if there is no original picture consistent with the search term in the picture library, automatically search for and sort original pictures similar to the search term, and then select the original picture with the highest similarity.

9. The device for automatically synthesizing picture materials based on FFmpeg according to claim 7, characterized in that: The matching module is also used to: when there are multiple original pictures consistent with the search term in the picture library, randomly obtain one of the original pictures, and record the ID of the original picture that has been obtained in the picture library, and no longer match the original picture with the recorded ID during the next search.

10. The device for automatically synthesizing picture materials based on FFmpeg according to claim 7, characterized in that: The quality inspection module is also used to: obtain the current specification parameter information of the target image material, compare it with the preset target specification parameter information, and determine whether they are consistent; wherein the preset target specification parameters and the current specification parameter information include one or more of color gamut, size, and format.