Dynamic picture generation method and device, equipment and storage medium
By preprocessing the video, calling the color image and image encoding interface to generate the color image and then encoding it, the problem of time-consuming dynamic image generation is solved, and efficient generation of high-quality dynamic images is achieved to adapt to different storage devices.
Patent Information
- Application Number
- CN202410309542.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-18
- Publication Date
- 2025-09-19
AI Technical Summary
Existing dynamic image generation methods take a long time while ensuring image quality and are unable to efficiently generate high-quality dynamic images.
By preprocessing the video to be processed, calling the color image generation interface and image encoding interface, generating a color image and encoding the video processing image, omitting the video decoding and encoding steps, and using a multi-threading mechanism to improve generation efficiency.
Without affecting the quality of dynamic images, the generation steps are reduced, the generation efficiency of dynamic images is improved, the system is adapted to electronic devices with different storage capacities, and generation failure is avoided.
Smart Images

Figure CN120676204A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of computer technology, and in particular to a method, apparatus, device, and storage medium for generating a dynamic image. Background Art
[0002] A dynamic image is an image that produces a certain dynamic effect when a set of specific static images switches at a specified frequency.
[0003] In video editing scenarios, there is a need to convert video materials into dynamic images. High-quality dynamic images require a long time to generate, and existing generation methods mainly solve the problem of time-consuming generation by reducing the image quality of dynamic images. Summary of the Invention
[0004] Embodiments of the present invention provide a method, apparatus, device, and storage medium for generating a dynamic image, so as to improve the generation efficiency of the dynamic image without affecting the image quality of the dynamic image.
[0005] In a first aspect, an embodiment of the present invention provides a method for generating a dynamic image, the method comprising:
[0006] In response to detecting the image generation instruction, performing video preprocessing on the to-be-processed video corresponding to the image generation instruction to obtain at least one frame of video processing image; wherein the video preprocessing includes at least decoding processing;
[0007] Generate a toned image based on the at least one frame of the video processing image by calling a toned image generation interface; wherein the toned image is used to extract color features of the video processing image;
[0008] By calling an image encoding interface, encoding the at least one frame of video processing image is performed according to the color-adjusted image to obtain at least one frame of video encoding image;
[0009] A dynamic picture corresponding to the video to be processed is generated according to the color-adjusted image and the at least one frame of video encoding image.
[0010] In a second aspect, an embodiment of the present invention further provides a device for generating a dynamic image, the device comprising:
[0011] a video processing image determination module, configured to, in response to detecting an image generation instruction, perform video preprocessing on the video to be processed corresponding to the image generation instruction to obtain at least one frame of video processing image; wherein the video preprocessing includes at least decoding processing;
[0012] A toned image generation module, configured to generate a toned image based on the at least one frame of the video processing image by calling a toned image generation interface; wherein the toned image is used to extract color features of the video processing image;
[0013] a video processing image encoding module, configured to perform encoding processing on the at least one frame of the video processing image according to the toning image by calling an image encoding interface, to obtain at least one frame of video encoding image;
[0014] A dynamic picture generation module is used to generate a dynamic picture corresponding to the video to be processed based on the color-adjusted image and the at least one frame of video encoding image.
[0015] In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising:
[0016] at least one processor; and
[0017] a memory communicatively connected to the at least one processor; wherein,
[0018] The memory stores a computer program that can be executed by the at least one processor. The computer program is executed by the at least one processor so that the at least one processor can execute the method for generating a dynamic picture described in any embodiment of the present invention.
[0019] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method for generating a dynamic image described in any embodiment of the present invention when executed.
[0020] The technical solution of the embodiment of the present invention performs video preprocessing on the video to be processed corresponding to the image generation instruction to obtain at least one frame of video processing image, calls the color image generation interface and the image encoding interface, and respectively realizes generating a color image according to each video processing image and encoding processing of each video processing image according to the color image to obtain at least one frame of video encoding image. The weakly coupled generation process implemented by the interface call omits the execution step of video encoding of the video processing image in the traditional generation method, the execution step of video decoding in the color image generation process, and the execution step of video decoding in the encoding image process. While ensuring the picture quality of the dynamic picture, the generation efficiency of the dynamic picture is improved by reducing the execution steps of the dynamic picture generation method. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The above and other features, advantages, and aspects of the various embodiments of the present invention will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that the originals and elements are not necessarily drawn to scale.
[0022] Figure 1 A flowchart of a method for generating a dynamic image provided by one embodiment of the present invention;
[0023] Figure 2 A schematic diagram of a toned image provided by one embodiment of the present invention;
[0024] Figure 3 A flowchart of another method for generating a dynamic image provided by one embodiment of the present invention;
[0025] Figure 4 A flowchart of a specific example of a method for generating a dynamic image provided by one embodiment of the present invention;
[0026] Figure 5 A schematic structural diagram of a device for generating a dynamic image provided by one embodiment of the present invention;
[0027] Figure 6 The present invention provides a schematic structural diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0028] Embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be construed as limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present invention. It should be understood that the drawings and embodiments of the present invention are for illustrative purposes only and are not intended to limit the scope of protection of the present invention.
[0029] It should be understood that the various steps described in the method embodiments of the present invention may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present invention is not limited in this respect.
[0030] As used herein, the term "including" and its variations are open-ended, i.e., "including but not limited to." The term "based on" means "based, at least in part, on." The term "one embodiment" means "at least one embodiment," the term "another embodiment" means "at least one additional embodiment," and the term "some embodiments" means "at least some embodiments." Other terms are defined in the following description.
[0031] It should be noted that the concepts of "first" and "second" mentioned in the present invention are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0032] It should be noted that the modifications of "one" and "multiple" mentioned in the present invention are illustrative rather than restrictive. Those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0033] The names of the messages or information exchanged between multiple devices in the embodiments of the present invention are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0034] It is understandable that before using the technical solutions disclosed in the embodiments of the present invention, the type, scope of use, usage scenarios, etc. of the personal information involved in the present invention should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0035] For example, in response to a user's active request, a prompt message is sent to the user to clearly inform the user that the operation requested will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the electronic device, application, server, storage medium, or other software or hardware that performs the operation of the technical solution of the present invention based on the prompt message.
[0036] As an optional but non-limiting implementation, in response to receiving a user's active request, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. Furthermore, the pop-up window may also contain a selection control for the user to select "agree" or "disagree" to provide personal information to the electronic device.
[0037] It is understandable that the above notification and user authorization process is merely illustrative and does not limit the implementation of the present invention. Other methods that comply with relevant laws and regulations may also be applied to the implementation of the present invention.
[0038] Figure 1 This is a flow chart of a method for generating a dynamic image provided by an embodiment of the present invention. This embodiment is applicable to the case of converting a video file into a dynamic image. The method can be executed by a dynamic image generating device. The dynamic image generating device can be implemented in the form of hardware and / or software. The dynamic image generating device can be configured in an electronic device, typically, in a mobile terminal or a cloud server. Figure 1 As shown, the method includes:
[0039] S110 . In response to detecting an image generation instruction, perform video preprocessing on the to-be-processed video corresponding to the image generation instruction to obtain at least one frame of video processing image.
[0040] Specifically, the image generation instruction represents a control instruction for converting a video file into a dynamic image. In an optional embodiment, the method further includes: generating the image generation instruction in response to detecting a trigger operation of an image generation control displayed in the video editing interface; or generating the image generation instruction in response to detecting an image generation signal.
[0041] For example, the control type of the image generation control can be a button control, specifically a command button or a radio button, and the signal type of the image generation signal can be a sound signal or a gesture signal, etc. There is no limitation on the control type of the image generation control and the signal type of the image generation signal here, and the specific settings can be customized according to actual needs.
[0042] In this embodiment, the video preprocessing includes at least decoding processing. Specifically, the decoding processing is used to restore the original video data contained in the video to be processed.
[0043] In an optional embodiment, performing video preprocessing on the video to be processed corresponding to the picture generation instruction to obtain at least one frame of video processing image includes: decoding the video to be processed corresponding to the picture generation instruction to obtain at least one frame of video processing image.
[0044] In another optional embodiment, the video to be processed corresponding to the picture generation instruction is subjected to video preprocessing to obtain at least one frame of video processing image, including: decoding the video to be processed corresponding to the picture generation instruction to obtain a decoded video; performing preset processing on the decoded video to obtain at least one frame of video processing image; wherein the preset processing includes at least one of resolution processing, frame rate processing and scaling processing.
[0045] Specifically, resolution processing is used to reduce the resolution of each video frame in the decoded video, frame rate processing is used to reduce the corresponding frame rate of the decoded video, where frame rate refers to the frequency at which bitmap images, measured in units of frames, appear continuously on the display, and scaling processing is used to reduce the image size of each video frame in the decoded video. Exemplarily, scaling processing can be implemented using a Lanczos filter. The resolution, frame rate, and scaling method used in the preset processing are not limited here. The resolution and frame rate used in the preset processing only need to be smaller than the resolution and frame rate of the video frames in the decoded video. Specific parameter values can be customized according to actual needs.
[0046] The benefit of setting preset processing is that, while ensuring that the image quality requirements of dynamic pictures are met, the image data volume of the video processing image is reduced, thereby further improving the efficiency of generating dynamic pictures.
[0047] S120 , generating a toned image by calling a toned image generation interface and processing the image according to the at least one frame of video.
[0048] Specifically, the color image generation interface is used to represent the reference type provided by the video processing tool to define the generation protocol of the color image. The color image is used to extract the color characteristics of the video processing image and can be used to represent a color set containing a preset number, such as a preset number of 128 colors or 256 colors. Figure 2 A schematic diagram of a color-adjusted image provided by an embodiment of the present invention, specifically, Figure 2 The toned image shown contains 256 colors.
[0049] Exemplarily, the statistical modes (stats_mode) of the color-adjusted image defined by the color-adjusted image generation interface include full mode, diff mode and single mode, wherein the full mode and diff mode are used to generate a global color-adjusted image, the single mode is used to generate a separate color-adjusted image for each frame of video processing image, and in the full mode, the color values in all video processing images are used for color distribution statistics, and in the diff mode, only the color values in the next frame of video processing image that are different from those in the previous frame of video processing image are considered. Therefore, the full mode is more suitable for video processing images with little color change, and the diff mode is more suitable for video processing images with large color change.
[0050] S130 , by calling an image encoding interface, encoding the at least one frame of the video-processed image according to the toning image to obtain at least one frame of the video-encoded image.
[0051] Specifically, the image coding interface is used to represent the reference type provided by the video processing tool to define the image coding protocol that depends on the color-graded image. The video processing tool to which the image coding interface belongs can be the same as or different from the video processing tool to which the color-graded image generation interface belongs.
[0052] In an optional embodiment, the at least one frame of video processing image is encoded according to the color-adjusted image to obtain at least one frame of video encoding image, including: for each pixel point in the video processing image, searching the color-adjusted image for the closest color corresponding to the pixel color of the current pixel point, and replacing the pixel color of the current pixel point in the video processing image with the index value of the closest color relative to the color-adjusted image to obtain a video encoding image.
[0053] In another optional embodiment, the encoding algorithm used by the image encoding interface is a dithering algorithm. Exemplarily, the dithering algorithms defined by the image encoding interface include the Bayer algorithm, the Heckbert algorithm, the Floyd-Steinberg algorithm, the Sierra2 algorithm, and the Sierra2_4a algorithm. Among them, the Bayer algorithm is an ordered dithering algorithm, and the other algorithms are error expansion dithering algorithms.
[0054] When the video processing image contains a lot of color information, directly encoding the video processing image using the toned image may result in loss of color details, as the maximum number of colors in the toned image is 256. The benefit of setting a dithering algorithm is that it can disperse the color error between the closest color in the toned image and the pixel color of the current pixel to the pixels adjacent to the current pixel, allowing the toned image to simulate a wider color space. The video encoding image retains the color information of the video processing image as much as possible, further ensuring the image quality of the dynamic picture.
[0055] In an optional embodiment, by calling an image encoding interface, the at least one frame of video processing image is respectively encoded according to the color-adjusted image to obtain at least one frame of video encoding image, including: using a serial mechanism, calling the image encoding interface according to the at least one frame of video processing image; by calling the image encoding interface, encoding the current video processing image according to the color-adjusted image to obtain a video encoding image; returning to execute the step of using a serial mechanism, calling the image encoding interface according to the at least one frame of video processing image, until the current video processing image is the last frame of video processing image.
[0056] S140: Generate a dynamic picture corresponding to the video to be processed according to the toned image and the at least one frame of video encoding image.
[0057] Specifically, based on the color-adjusted image and the at least one frame of video-encoded image, a dynamic picture corresponding to the video to be processed is generated, including: adding the color-adjusted image to the color-adjusted image data block of the dynamic picture, and adding the at least one frame of video-encoded image to the image data block of the dynamic picture to obtain the dynamic picture corresponding to the video to be processed.
[0058] Exemplarily, the image formats of dynamic images include but are not limited to GIF (Graphics Interchange Format), APNG (Animated Portable Network Graphics, bitmap animation extension of PNG) and WebP, etc. There is no limitation on the image format of dynamic images here, and the specific settings can be defined according to actual needs.
[0059] In an optional embodiment, the method further includes: exporting the dynamic image using a default export method; or exporting the dynamic image according to the export method in the image generation instruction. Exemplarily, the default export method or the export method in the image generation instruction includes but is not limited to saving to a preset storage space, sending to a video editing client, sending to a designated application client, or generating a link for a dynamic image, etc. For example, the preset storage space can be a cache space, memory space, or disk space, etc. The specific export method of the dynamic image is not limited here, and can be customized according to actual needs.
[0060] The technical solution of this embodiment performs video preprocessing on the video to be processed corresponding to the image generation instruction to obtain at least one frame of video processing image, calls the color image generation interface and the image encoding interface, and respectively realizes generation of color images according to each video processing image and encoding processing of each video processing image according to the color image to obtain at least one frame of video encoding image. The weakly coupled generation process implemented by the interface call omits the execution steps of video encoding of the video processing image in the traditional generation method, the execution steps of video decoding in the color image generation process, and the execution steps of video decoding in the encoding image process. While ensuring the picture quality of the dynamic picture, the generation efficiency of the dynamic picture is improved by reducing the execution steps of the dynamic picture generation method.
[0061] Figure 3 This is a flow chart of another method for generating dynamic images provided by an embodiment of the present invention. This embodiment further refines the above embodiment's "by calling the image encoding interface, encoding the at least one frame of video processing image according to the color image, to obtain at least one frame of video encoding image". Figure 3 As shown, the method includes:
[0062] S210 : In response to detecting an image generation instruction, perform video preprocessing on the to-be-processed video corresponding to the image generation instruction to obtain at least one frame of video processing image.
[0063] S210 in this embodiment is the same as that in the above embodiment. Figure 1 The steps in S110 shown are the same or similar and will not be described in detail in this embodiment.
[0064] On the basis of the above embodiment, optionally, after performing video preprocessing on the video to be processed corresponding to the picture generation instruction to obtain at least one frame of video processing image, the method also includes: determining the space occupancy based on the image attribute parameters corresponding to the at least one frame of video processing image; if the space occupancy is less than or equal to the remaining space usage of the cache space, storing the at least one frame of video processing image in the cache space; if the space occupancy is greater than the remaining space usage of the cache space and less than or equal to the remaining space usage of the memory space, storing the at least one frame of video processing image in the memory space; if the space occupancy is greater than the remaining space usage of the memory space, storing the at least one frame of video processing image in the disk space.
[0065] Specifically, image attribute parameters include the image height, image width, frame rate, and video duration corresponding to the video processing image. Assuming that a pixel occupies 1.5 bits, the space occupied satisfies the formula: image height * image width * 1.5 * frame rate * video duration / (1024 * 1024).
[0066] Since the space occupied by video processing images will be large, setting a space occupancy judgment step not only ensures that the video processing images can be stored normally, but also makes the video processing images stored in a storage space with a higher read and write rate as much as possible, thereby improving the subsequent reading efficiency of video processing images, and further improving the efficiency of generating dynamic pictures.
[0067] In an optional embodiment, the method further includes: if the space occupied is greater than the remaining space usage of the disk space, encoding the at least one frame of video processing image to obtain an encoded video, and storing the encoded video; before generating a color image based on the at least one frame of video processing image by calling a color image generation interface, and before encoding the at least one frame of video processing image according to the color image by calling an image encoding interface to obtain at least one frame of video encoded image, the method further includes: decoding the encoded video by calling a video decoding interface to obtain at least one frame of video processing image.
[0068] Specifically, if the space occupied is greater than the remaining space usage of the disk space, it means that the space occupied by the video-processed image is large and the video-processed image cannot be stored.
[0069] Specifically, the encoding process may be used to compress the at least one frame of the video-processed image, converting the video-processed image into a video file in a video format, wherein the space occupied by the encoded video is significantly smaller than the space occupied by the video-processed image. Exemplarily, the encoding process may employ a hard-coding algorithm, which has a higher encoding speed than a soft-coding algorithm, thereby further improving the efficiency of generating dynamic images.
[0070] Exemplarily, the storage method of the encoded video can refer to the storage method of the video processing image. The storage method of the encoded video is not limited here and can be customized according to actual needs.
[0071] Specifically, the video decoding interface is used to represent the reference type provided by the video processing tool to define the video decoding protocol. The video processing tool to which the video decoding interface belongs may be the same as or different from the video processing tool to which the color image generation interface and / or image encoding interface belongs.
[0072] In another optional embodiment, the method further includes: if the space occupied is greater than the remaining space usage of the disk space, encoding the at least one frame of video processing image to obtain an encoded video, and storing the encoded video; generating a color-adjusted image based on the encoded video by calling a color-adjusted image command line utility; generating a dynamic picture corresponding to the video to be processed based on the color-adjusted image and the encoded video by calling an encoding command line utility.
[0073] Specifically, the color-adjusted image command line utility is an implementation method for interacting with video processing tools to generate color-adjusted images. Exemplarily, the video filter used by the color-adjusted image command line utility is the palettegen filter, wherein the palettegen filter provides filter parameters such as max_colors (maximum number of colors), reserve_transparent (reserve transparent color), transparency_color (transparent color), and stats_mode (statistical mode) to set the properties of the color-adjusted image. For example, max_colors is used to specify the number of colors used in the color-adjusted image, reserve_transparent is used to set whether to reserve transparent color, transparency_color is used to specify which color is reserved for transparent color, and stats_mode includes full mode, diff mode, and single mode.
[0074] Specifically, the encoding command line utility is an implementation method for interacting with video processing tools to perform dynamic image generation tasks. Exemplarily, the video filter used by the encoding command line utility is the paletteuse filter, wherein the paletteuse filter provides filter parameters such as dither (dithering algorithm), bayer_scale (dithering range), diff_mode (dithering mode) and new to set the properties of the dynamic image. For example, dither includes the bayer algorithm, heckbert algorithm, floyd_steinberg algorithm, sierra2 algorithm and sierra2_4a algorithm, the value range of bayer_scale is 0-5, the smaller the value, the longer the search time, and the better the effect, diff_mode includes none and rectangle (matrix), and new is set to on to indicate that each frame of video processing image uses a new color image when output.
[0075] Since the space occupied by the video processing image may exceed the storage capacity of the storage space, the video processing image may not be able to be stored, resulting in the failure of dynamic image generation. Setting the judgment steps of the space occupied and the remaining space usage of the disk space can avoid the failure of dynamic image generation, improve the completeness of the dynamic image generation process, and thus improve the adaptability between the dynamic image generation method and electronic devices with different storage capacities.
[0076] S220 , generating a toned image by calling a toned image generation interface and processing the image according to the at least one frame of video.
[0077] S220 in this embodiment is the same as that in the above embodiment. Figure 1 The S120 shown corresponds to the same or similar steps, and will not be described in detail in this embodiment.
[0078] S230: Using a multi-thread mechanism, processing an image according to the at least one frame of video, and calling an image encoding interface.
[0079] Specifically, at least two threads are reserved for calling the image encoding interface, and the specific number of reserved threads can be customized according to actual needs.
[0080] Specifically, determine whether there is an idle thread and there is an unencoded video processing image. If so, use the idle thread, use the unencoded video processing image as the video processing image of the idle thread, and call the image encoding interface; if there is no idle thread but there is an unencoded video processing image, return to the step of determining whether there is an idle thread and there is an unencoded video processing image; if there is an idle thread but there is no unencoded video processing image or there is no idle thread and there is no unencoded video processing image, wait for all threads to end.
[0081] S240 , encoding the video processing image corresponding to the current thread according to the toning image by calling an image encoding interface to obtain a video encoding image.
[0082] Specifically, the "image coding interface" in this embodiment is the same as that in the above embodiment. Figure 1 The “image coding interface” in S130 shown is the same or similar to that in the embodiment, and will not be described in detail here.
[0083] S250: Generate a dynamic picture corresponding to the video to be processed according to the toned image and the at least one frame of video encoding image.
[0084] In an alternative embodiment, S250 is different from the above embodiment. Figure 1 The S140 shown corresponds to the same or similar steps, and will not be described in detail in this embodiment.
[0085] In another optional embodiment, generating a dynamic picture corresponding to the video to be processed based on the color-adjusted image and the at least one frame of video encoding image includes: sequentially adding the video encoding images corresponding to at least two threads to the producer-consumer queue; and generating a dynamic picture corresponding to the video to be processed based on the video encoding images in the producer-consumer queue.
[0086] Specifically, the order in which the video coded images are added to the producer consumer queue follows the display order of the video coded images.
[0087] Since the processing time of different threads may be different, the consumption order of video coded images may be easily confused. By setting the order and adding them to the producer-consumer queue, the display confusion of dynamic images can be avoided. Among them, the producer-consumer queue makes it possible for the video coded images generated by multiple threads to not wait for consumption, and the dynamic image generation process does not have to wait for the generation of video coded images, thereby realizing the decoupling of the production and consumption of video coded images, thereby further improving the generation efficiency of dynamic images.
[0088] Figure 4This is a flowchart of a specific example of a method for generating a dynamic image provided by an embodiment of the present invention. Specifically, the video to be processed is decoded and preset in sequence to obtain a video processing image, and the video processing image is stored in a cache space. According to the video processing image read from the cache space, a color image generation interface is called to generate a color image, and a multi-threaded mechanism is adopted ( Figure 4 According to the video processing image read from the cache space, the image encoding interface is called to generate a video encoding image, and the video encoding images obtained by multiple threads are sequentially added to the producer consumer queue, and the video encoding images read from the producer consumer queue are used to generate a GIF corresponding to the video to be processed.
[0089] Traditional generation methods mainly adopt the implementation method of command line utilities, which are highly coupled and define a serial mechanism to implement image encoding. The technical solution of this embodiment overcomes the high coupling of traditional generation methods by implementing the interface call. By adopting a multi-threaded mechanism, the image encoding interface is called according to each video processing image. By calling the image encoding interface, the video processing image corresponding to the current thread is encoded according to the color image to obtain a video encoded image, which solves the problem of long time-consuming serial image encoding, thereby further improving the generation efficiency of dynamic pictures.
[0090] The following is an embodiment of a device for generating dynamic images provided by an embodiment of the present invention. This device and the method for generating dynamic images of the above-mentioned embodiment belong to the same inventive concept. For details not fully described in the embodiment of the device for generating dynamic images, please refer to the content of the method for generating dynamic images in the above-mentioned embodiment.
[0091] Figure 5 This is a schematic diagram of a structure of a dynamic picture generation device provided by an embodiment of the present invention. Figure 5 As shown, the apparatus includes: a video processing image determination module 310 , a color-adjusted image generation module 320 , a video processing image encoding module 330 and a dynamic picture generation module 340 .
[0092] The video processing image determination module 310 is configured to, in response to detecting an image generation instruction, perform video preprocessing on the video to be processed corresponding to the image generation instruction to obtain at least one frame of video processing image; wherein the video preprocessing includes at least decoding processing;
[0093] A toned image generation module 320 is configured to generate a toned image based on the at least one frame of video processing image by calling a toned image generation interface;
[0094] The video processing image encoding module 330 is configured to encode the at least one frame of the video processing image according to the toning image by calling an image encoding interface to obtain at least one frame of video encoding image;
[0095] The dynamic image generation module 340 is configured to generate a dynamic image corresponding to the video to be processed based on the toned image and the at least one frame of video encoding image.
[0096] The technical solution of this embodiment performs video preprocessing on the video to be processed corresponding to the image generation instruction to obtain at least one frame of video processing image, calls the color image generation interface and the image encoding interface, and respectively realizes generation of color images according to each video processing image and encoding processing of each video processing image according to the color image to obtain at least one frame of video encoding image. The weakly coupled generation process implemented by the interface call omits the execution steps of video encoding of the video processing image in the traditional generation method, the execution steps of video decoding in the color image generation process, and the execution steps of video decoding in the encoding image process. While ensuring the picture quality of the dynamic picture, the generation efficiency of the dynamic picture is improved by reducing the execution steps of the dynamic picture generation method.
[0097] In an optional embodiment, the video processing image determination module 310 is specifically configured to:
[0098] Decoding the video to be processed corresponding to the picture generation instruction to obtain a decoded video;
[0099] The decoded video is subjected to preset processing to obtain at least one frame of video processing image; wherein the preset processing includes at least one of resolution processing, frame rate processing and scaling processing.
[0100] In an optional embodiment, the video processing image encoding module 330 is specifically configured to:
[0101] Using a multi-thread mechanism, processing an image according to the at least one frame of video, and calling an image encoding interface;
[0102] By calling the image encoding interface, encoding processing is performed on the video processing image corresponding to the current thread according to the color-adjusted image to obtain a video encoding image.
[0103] In an optional embodiment, the dynamic image generation module 340 is specifically configured to:
[0104] Add the video encoding images corresponding to at least two threads in sequence to the producer-consumer queue;
[0105] Generate a dynamic picture corresponding to the video to be processed based on the video encoding image in the producer consumer queue.
[0106] In an optional embodiment, the device further comprises:
[0107] a video processing image storage module, configured to, after performing video preprocessing on the to-be-processed video corresponding to the picture generation instruction to obtain at least one frame of video processing image, determine the space occupancy based on image attribute parameters corresponding to the at least one frame of video processing image;
[0108] If the space occupied is less than or equal to the remaining space usage of the cache space, storing the at least one frame of video-processed image in the cache space;
[0109] If the space occupied is greater than the remaining space usage of the cache space and less than or equal to the remaining space usage of the memory space, storing the at least one frame of video-processed image in the memory space;
[0110] If the space occupied is greater than the remaining space usage of the memory space, the at least one frame of video-processed image is stored in the disk space.
[0111] In an optional embodiment, the device further comprises:
[0112] a video processing image encoding module, configured to encode the at least one frame of the video processing image to obtain an encoded video if the space occupied is greater than the remaining space of the disk space, and store the encoded video;
[0113] A video processing image decoding module is used to decode the encoded video by calling a video decoding interface to obtain at least one frame of video processing image before generating a color-adjusted image based on the at least one frame of video processing image by calling a color-adjusted image generation interface, and before encoding the at least one frame of video processing image according to the color-adjusted image by calling an image encoding interface to obtain at least one frame of video encoded image.
[0114] In an optional embodiment, the encoding algorithm adopted by the image encoding interface is a dithering algorithm.
[0115] The dynamic picture generation device provided by the embodiment of the present invention can execute the dynamic picture generation method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0116] Reference below Figure 6, which shows a schematic structural diagram of an electronic device (e.g., a terminal device or a server) 400 suitable for implementing an embodiment of the present invention. The terminal device in the embodiment of the present invention may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 6 The electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present invention.
[0117] like Figure 6 As shown, the electronic device 400 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 401, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 402 or a program loaded from a storage device 406 into a random access memory (RAM) 403. Various programs and data required for the operation of the electronic device 400 are also stored in the RAM 403. The processing device 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0118] Typically, the following devices may be connected to the I / O interface 405: an input device 406 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 407 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 406 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 409. The communication device 409 may allow the electronic device 400 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 The electronic device 400 is shown with various devices, but it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed instead.
[0119] In particular, according to an embodiment of the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program comprising program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication device 409, or installed from the storage device 406, or installed from the ROM 402. When the computer program is executed by the processing device 401, the above-mentioned functions defined in the method of the embodiment of the present invention are performed.
[0120] It should be noted that the computer-readable medium described above in the present invention may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection having one or more conductors, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device, or component. In the present invention, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.
[0121] In some embodiments, the client and server can communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0122] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0123] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: obtains at least two Internet Protocol addresses; sends a node evaluation request including the at least two Internet Protocol addresses to a node evaluation device, wherein the node evaluation device selects an Internet Protocol address from the at least two Internet Protocol addresses and returns it; receives the Internet Protocol address returned by the node evaluation device; wherein the obtained Internet Protocol address indicates an edge node in a content distribution network.
[0124] Alternatively, the computer-readable medium carries one or more programs, which, when executed by the electronic device, causes the electronic device to: receive a node evaluation request including at least two Internet Protocol addresses; select an Internet Protocol address from the at least two Internet Protocol addresses; and return the selected Internet Protocol address; wherein the received Internet Protocol address indicates an edge node in a content distribution network.
[0125] Computer program code for performing the operations of the present invention may be written in one or more programming languages, or a combination thereof, including, but not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0126] The flow charts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0127] The units involved in the embodiments of the present invention may be implemented in software or hardware. In some cases, the name of a unit does not limit the unit itself. For example, the first acquisition unit may also be described as a "unit for acquiring at least two Internet Protocol addresses."
[0128] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.
[0129] In the context of the present invention, machine-readable medium can be a tangible medium that can contain or store a program for use with an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. Machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. More specific examples of machine-readable storage media can include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0130] According to one or more embodiments of the present invention, Example 1 provides a method for generating a dynamic image, including:
[0131] In response to detecting the image generation instruction, performing video preprocessing on the to-be-processed video corresponding to the image generation instruction to obtain at least one frame of video processing image; wherein the video preprocessing includes at least decoding processing;
[0132] Generate a toned image by calling a toned image generation interface and processing the image according to the at least one frame of video;
[0133] By calling an image encoding interface, encoding the at least one frame of video processing image is performed according to the color-adjusted image to obtain at least one frame of video encoding image;
[0134] A dynamic picture corresponding to the video to be processed is generated according to the color-adjusted image and the at least one frame of video encoding image.
[0135] According to one or more embodiments of the present invention, Example 2, according to the method of Example 1, performing video preprocessing on the to-be-processed video corresponding to the image generation instruction to obtain at least one frame of video processed image, includes:
[0136] Decoding the video to be processed corresponding to the picture generation instruction to obtain a decoded video;
[0137] The decoded video is subjected to preset processing to obtain at least one frame of video processing image; wherein the preset processing includes at least one of resolution processing, frame rate processing and scaling processing.
[0138] According to one or more embodiments of the present invention, Example 3 is the method according to Example 1 or Example 2,
[0139] The step of encoding the at least one frame of the video-processed image according to the toning image by calling the image encoding interface to obtain at least one frame of the video-encoded image includes:
[0140] Using a multi-thread mechanism, processing an image according to the at least one frame of video, and calling an image encoding interface;
[0141] By calling the image encoding interface, encoding processing is performed on the video processing image corresponding to the current thread according to the color-adjusted image to obtain a video encoding image.
[0142] According to one or more embodiments of the present invention, Example 4 is based on the method of Example 3,
[0143] The step of generating a dynamic picture corresponding to the video to be processed according to the toned image and the at least one frame of video encoding image includes:
[0144] Add the video encoding images corresponding to at least two threads in sequence to the producer-consumer queue;
[0145] Generate a dynamic picture corresponding to the video to be processed based on the video encoding image in the producer consumer queue.
[0146] According to one or more embodiments of the present invention, Example 5, according to the method of Example 1 or Example 2, further comprises: performing video preprocessing on the to-be-processed video corresponding to the image generation instruction to obtain at least one frame of video processed image.
[0147] determining a space occupancy amount according to image attribute parameters corresponding to the at least one frame of video processing image;
[0148] If the space occupied is less than or equal to the remaining space usage of the cache space, storing the at least one frame of video-processed image in the cache space;
[0149] If the space occupied is greater than the remaining space usage of the cache space and less than or equal to the remaining space usage of the memory space, storing the at least one frame of video-processed image in the memory space;
[0150] If the space occupied is greater than the remaining space usage of the memory space, the at least one frame of video-processed image is stored in the disk space.
[0151] According to one or more embodiments of the present invention, Example 6 is the method according to Example 5, further comprising:
[0152] If the space occupied is greater than the remaining space usage of the disk space, encoding the at least one frame of the video-processed image to obtain an encoded video, and storing the encoded video;
[0153] Before generating a toned image based on the at least one frame of video processing image by calling a toned image generation interface, and before encoding the at least one frame of video processing image based on the toned image by calling an image encoding interface to obtain at least one frame of video encoding image, the method further includes:
[0154] By calling a video decoding interface, the encoded video is decoded to obtain at least one frame of video processing image.
[0155] According to one or more embodiments of the present invention, Example 7 describes the method according to Example 1, wherein the encoding algorithm adopted by the image encoding interface is a dithering algorithm.
[0156] According to one or more embodiments of the present invention, Example 8 provides a device for generating a dynamic image, including:
[0157] a video processing image determination module, configured to, in response to detecting an image generation instruction, perform video preprocessing on the video to be processed corresponding to the image generation instruction to obtain at least one frame of video processing image; wherein the video preprocessing includes at least decoding processing;
[0158] A toned image generation module, configured to generate a toned image based on the at least one frame of the video processing image by calling a toned image generation interface; wherein the toned image is used to extract color features of the video processing image;
[0159] a video processing image encoding module, configured to perform encoding processing on the at least one frame of the video processing image according to the toning image by calling an image encoding interface, to obtain at least one frame of video encoding image;
[0160] A dynamic picture generation module is used to generate a dynamic picture corresponding to the video to be processed based on the color-adjusted image and the at least one frame of video encoding image.
[0161] According to one or more embodiments of the present invention, Example 9 provides an electronic device, including:
[0162] at least one processor; and
[0163] a memory communicatively connected to the at least one processor; wherein,
[0164] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to perform the method for generating a dynamic picture described in any one of Examples 1-7.
[0165] According to one or more embodiments of the present invention, Example 10 provides a computer-readable storage medium storing computer instructions, which are used to enable a processor to implement the method for generating a dynamic picture described in any one of Examples 1-7 when executed.
[0166] The above description is merely a preferred embodiment of the present invention and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of disclosure involved in the present invention is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, but also includes other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the above-mentioned disclosed concepts. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in the present invention.
[0167] In addition, although adopting specific order to describe each operation, this should not be interpreted as requiring these operations to be executed in the specific order shown or in sequential order.Under certain environment, multitasking and parallel processing may be advantageous.Similarly, although comprising some specific implementation details in the above discussion, these should not be interpreted as limiting the scope of the present invention.Some features described in the context of independent embodiment can also be implemented in single embodiment in combination.On the contrary, the various features described in the context of independent embodiment also can be implemented in multiple embodiments individually or in the mode of any suitable subcombination.
[0168] Although the subject matter has been described in language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.
Claims
1. A method for generating a dynamic picture, characterized in that: include: In response to detecting the image generation instruction, performing video preprocessing on the to-be-processed video corresponding to the image generation instruction to obtain at least one frame of video processing image; wherein the video preprocessing includes at least decoding processing; Generate a toned image based on the at least one frame of the video processing image by calling a toned image generation interface; wherein the toned image is used to extract color features of the video processing image; By calling an image encoding interface, encoding the at least one frame of video processing image is performed according to the color-adjusted image to obtain at least one frame of video encoding image; A dynamic picture corresponding to the video to be processed is generated according to the color-adjusted image and the at least one frame of video encoding image.
2. The method according to claim 1, characterized in that The performing video preprocessing on the to-be-processed video corresponding to the picture generation instruction to obtain at least one frame of video processing image includes: Decoding the video to be processed corresponding to the picture generation instruction to obtain a decoded video; The decoded video is subjected to preset processing to obtain at least one frame of video processing image; wherein the preset processing includes at least one of resolution processing, frame rate processing and scaling processing.
3. The method according to claim 1 or 2, characterized in that The step of encoding the at least one frame of the video-processed image according to the toning image by calling the image encoding interface to obtain at least one frame of the video-encoded image includes: Using a multi-thread mechanism, processing an image according to the at least one frame of video, and calling an image encoding interface; By calling the image encoding interface, encoding processing is performed on the video processing image corresponding to the current thread according to the color-adjusted image to obtain a video encoding image.
4. The method according to claim 3, characterized in that The step of generating a dynamic picture corresponding to the video to be processed according to the toned image and the at least one frame of video encoding image includes: Add the video encoding images corresponding to at least two threads in sequence to the producer-consumer queue; Generate a dynamic picture corresponding to the video to be processed based on the video encoding image in the producer consumer queue.
5. The method according to claim 1 or 2, characterized in that After performing video preprocessing on the video to be processed corresponding to the image generation instruction to obtain at least one frame of video processing image, the method further includes: determining a space occupancy amount according to image attribute parameters corresponding to the at least one frame of video processing image; If the space occupied is less than or equal to the remaining space usage of the cache space, storing the at least one frame of video-processed image in the cache space; If the space occupied is greater than the remaining space usage of the cache space and less than or equal to the remaining space usage of the memory space, storing the at least one frame of video-processed image in the memory space; If the space occupied is greater than the remaining space usage of the memory space, the at least one frame of video-processed image is stored in the disk space.
6. The method according to claim 5, characterized in that The method further comprises: If the space occupied is greater than the remaining space usage of the disk space, encoding the at least one frame of the video-processed image to obtain an encoded video, and storing the encoded video; Before generating a toned image based on the at least one frame of video processing image by calling a toned image generation interface, and before encoding the at least one frame of video processing image based on the toned image by calling an image encoding interface to obtain at least one frame of video encoding image, the method further includes: By calling a video decoding interface, the encoded video is decoded to obtain at least one frame of video processing image.
7. The method according to claim 1, characterized in that The encoding algorithm adopted by the image encoding interface is a dithering algorithm.
8. A device for generating a dynamic picture, characterized in that: include: a video processing image determination module, configured to, in response to detecting an image generation instruction, perform video preprocessing on the video to be processed corresponding to the image generation instruction to obtain at least one frame of video processing image; wherein the video preprocessing includes at least decoding processing; A toned image generation module, configured to generate a toned image based on the at least one frame of the video-processed image by calling a toned image generation interface; wherein the toned image is used to extract color features of the video-processed image; a video processing image encoding module, configured to perform encoding processing on the at least one frame of the video processing image according to the toning image by calling an image encoding interface, to obtain at least one frame of video encoding image; A dynamic picture generation module is used to generate a dynamic picture corresponding to the video to be processed based on the color-adjusted image and the at least one frame of video encoding image.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor. The computer program is executed by the at least one processor so that the at least one processor can execute the method for generating a dynamic picture according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method for generating a dynamic picture according to any one of claims 1 to 7 when executed.