GIF generation method, electronic equipment, readable storage medium and chip
By performing frame extraction processing on video or photos, only the part of the image frame is processed, the image frame after the frame extraction is generated and GIFs are generated, which solves the problems of large data volume, slow processing speed and high power consumption in the prior art, and achieves more efficient GIF generation and better user experience.
Patent Information
- Application Number
- CN202311130803.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-31
- Publication Date
- 2025-03-07
AI Technical Summary
The prior art needs to process all photos of each image frame or multiple photos in the video when generating GIFs, resulting in large amount of data, slow processing speed, high power consumption, and affecting the user experience.
By performing frame extraction processing on video or photo, only part of the image frame is processed, image frames after the frame extraction are generated, and GIFs are generated based on these image frames.
Reduces the amount of data processed, improves the processing speed and performance of electronic devices, reduces power consumption, improves user experience, and reduces stored data.
Smart Images

Figure CN119583883A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of images, and in particular to a GIF generation method, an electronic device, a readable storage medium and a chip. Background Art
[0002] With the development and popularization of electronic devices such as mobile phones and tablet computers, more and more users use instant messaging software installed on electronic devices to communicate. In a scenario where users use instant messaging software to communicate, users can make videos or photos into graphics interchange format (GIF) images, and express their chat content vividly by sending GIFs. At the same time, sending GIFs can also increase the fun of user communication.
[0003] Usually, users need to input videos or photos into a GIF encoder for processing to generate a GIF. This way of generating GIF requires the electronic device to process each image frame in the video or all photos of multiple photos. Therefore, the amount of data that the electronic device needs to process is large. When the electronic device processes a large amount of data, the processing speed of the electronic device will be reduced, thereby reducing the performance of the electronic product. At the same time, when the electronic device processes a large amount of data, the power consumption of the electronic device will increase, affecting the user experience. Summary of the invention
[0004] The present application provides a GIF generation method, an electronic device, a readable storage medium and a chip, which can improve the performance of electronic products, reduce the power consumption of electronic devices, and thus improve the user experience.
[0005] In a first aspect, a GIF generation method is provided, the method comprising: an electronic device displays a first interface, the first interface includes at least one video and / or at least one photo (i.e., at least one image material) selected by a user, detecting an operation (i.e., a first operation) selected by the user on the first interface to generate a GIF from at least one video and / or at least one photo, in response to the first operation, the electronic device can perform frame extraction processing on all or part of the image frames (i.e., at least part of N image frames) included in at least one video and / or at least one photo to obtain image frames after frame extraction processing (i.e., M image frames); then, a GIF is generated based on the M image frames, and finally the GIF can be displayed in a gallery interface (i.e., a second interface).
[0006] In an embodiment of the present application, the electronic device may perform frame extraction processing on at least part of the N image frames included in at least one image material to obtain M image frames; then generate a GIF based on the M image frames. Compared with a solution in which all image frames (such as N image frames) in at least one image material need to be processed before generating a GIF, the present application only needs to process the M image frames obtained after the frame extraction processing when generating a GIF, and the amount of data to be processed is small. When processing a small amount of data, the processing speed of the electronic device is increased, thereby improving the performance of the electronic device. At the same time, when the electronic device processes a small amount of data, the power consumption of the electronic device is reduced, thereby improving the user experience.
[0007] Furthermore, when storing the generated GIF, the embodiment of the present application does not need to store the data of all image frames in at least one image material, but only needs to store the data of image frames (M image frames) after frame extraction of at least one image material, thereby reducing the stored data.
[0008] In combination with the first aspect, in some implementations of the first aspect, the electronic device performs frame extraction processing on all or part of the image frames (that is, at least part of the N image frames) included in at least one video and / or at least one photo to obtain the image frames after frame extraction processing (that is, M image frames) may be implemented as follows:
[0009] The electronic device determines the total number of all image frames included in at least one video and / or at least one photo, and performs frame extraction processing on all or part of the image frames in at least one video and / or at least one photo based on the total number of image frames, so that the number of image frames obtained after the frame extraction processing is less than the total number of frames.
[0010] In an embodiment of the present application, before performing frame extraction processing on all or part of the image frames (i.e., at least part of N image frames) in at least one video and / or at least one photo, the total number of all image frames in the at least one video and / or at least one photo can be determined, and frame extraction processing can be performed based on the total number of frames, so that the number of image frames obtained after the frame extraction processing can be less than the total number of frames. In this way, it can be ensured that the number of M image frames obtained after the frame extraction processing is less than the number of all image frames (i.e., N image frames) in the at least one video and / or at least one photo.
[0011] In combination with the first aspect, in certain implementations of the first aspect, the electronic device performs frame extraction processing on all or part of the image frames in at least one video and / or at least one photo based on the total number of all image frames, so that the number of image frames obtained after the frame extraction processing is less than the total number of frames. One implementation method may be:
[0012] The electronic device extracts all or part of the image frames in at least one video and / or at least one photo at a preset frame interval based on the total number of all image frames to obtain M image frames.
[0013] In an embodiment of the present application, the electronic device can perform frame extraction processing on all or part of the image frames in at least one video and / or at least one photo at a preset frame interval, and can accurately obtain M image frames. Moreover, when the frame extraction processing is performed at the preset frame interval, the frame extraction processing is performed based on the total number of all image frames, and it can be ensured that the number of M image frames is less than the total number of all image frames.
[0014] In combination with the first aspect, in certain implementations of the first aspect, the electronic device performs frame extraction processing on all or part of the image frames in at least one video and / or at least one photo based on the total number of all image frames, so that the number of image frames obtained after the frame extraction processing is less than the total number of frames. Another implementation method may be:
[0015] The electronic device randomly extracts all or part of the image frames in at least one video and / or at least one photo based on the total number of all image frames to obtain M image frames.
[0016] In an embodiment of the present application, an electronic device performs frame sampling processing on all or part of the image frames in at least one video and / or at least one photo in a random frame sampling manner, which can improve the diversity of image frames obtained by the frame sampling processing. Moreover, when the frame sampling processing is performed in a random frame sampling manner, the frame sampling processing is performed based on the total number of all image frames, which can ensure that the number of M image frames is less than the total number of all image frames.
[0017] In combination with the first aspect, in some implementations of the first aspect, when the type of the image material includes a video, the electronic device may determine the total number of frames included in at least one video by:
[0018] The frame rate of each video segment in at least one video segment and the playing time of each video segment are obtained; and the total number of N image frames is determined according to the frame rate of each video segment and the playing time of each video segment.
[0019] In the embodiment of the present application, when the type of image material includes video, the electronic device can accurately determine the total number of N image frames according to the frequency of each video segment and the playback duration of each video segment.
[0020] In combination with the first aspect, in some implementations of the first aspect, when the type of the image material includes a video and a photo, the electronic device determines the total number of frames included in at least one video and at least one photo in an implementation manner that:
[0021] Obtain the frame rate of each video segment, the playing time of each video segment, and the number of each photo in at least one video segment and at least one photo;
[0022] The total number of N image frames is determined according to the frame rate of each video segment, the playback time of each video segment and the number of each photo.
[0023] In an embodiment of the present application, when the types of image materials include videos and photos, the electronic device can accurately determine the total number of N image frames based on the frame rate of each video segment, the playback duration of each video segment, and the number of each photo.
[0024] In combination with the first aspect, in some implementations of the first aspect, when the type of the image material includes a photo, the electronic device may determine the total number of frames included in the multiple photos in the following manner:
[0025] The number of each photo in the plurality of photos is obtained; and the total number of N image frames is determined according to the number of each photo.
[0026] In the embodiment of the present application, when the type of image material includes photos, the electronic device can accurately determine the total number of N image frames based on the number of each photo.
[0027] In combination with the first aspect, in some implementations of the first aspect, the electronic device, in response to a user's first operation on at least one video and / or at least one photo, performs frame extraction processing on at least part of N image frames included in the at least one video and / or at least one photo to obtain M image frames. The implementation method may be:
[0028] In response to a first operation of the user on at least one video and / or at least one photo, editing the at least one video and / or at least one photo to obtain N rendered image frames, where the editing includes one or more of adding a filter, cropping, adding text, adding transition information, and adding subtitles;
[0029] A frame extraction process is performed on at least a portion of the N rendered image frames to obtain M image frames.
[0030] In an embodiment of the present application, before performing frame extraction to generate a GIF, the electronic device may edit at least one video and / or at least one photo to obtain N frames of rendered image frames, thereby performing frame extraction and GIF generation on the N frames of rendered image frames to obtain a GIF. Since the rendered image frames are image frames obtained through one or more editing processes including adding filter processing, cropping processing, adding text processing, adding transition information processing, and adding subtitles processing, the display effect of the GIF can be improved based on the GIF generated based on the rendered image frames.
[0031] In combination with the first aspect, in some implementations of the first aspect, in response to a first operation of a user on at least one video and / or at least one photo, after performing frame extraction processing on at least part of N image frames included in the at least one video and / or at least one photo to obtain M image frames, the method further includes:
[0032] Performing editing processing on the M image frames to obtain M rendered image frames, the editing processing including one or more of adding filter processing, cropping processing, adding text processing, adding transition information processing, and adding subtitle processing; and;
[0033] Generate GIF based on M frames, including:
[0034] Generate a GIF based on the M frames of rendered image frames.
[0035] In the embodiment of the present application, since the electronic device performs editing processing on M image frames obtained through frame extraction processing to obtain M rendered image frames, compared with the editing method in which the electronic device performs editing processing on at least one video and / or at least one photo to obtain N rendered image frames, the number of image frames to be edited can be reduced. Since the number of image frames to be edited is reduced, the speed of the editing processing of the electronic device can be increased, thereby improving the performance of the electronic device. At the same time, when the electronic device edits fewer image frames, the power consumption of the electronic device can be reduced.
[0036] Moreover, since the image frames rendered by the M frames are image frames obtained through one or more editing processes including adding filter processing, cropping processing, adding text processing, adding transition information processing and adding subtitles processing, generating GIF based on the image frames rendered by the M frames can improve the display effect of the GIF.
[0037] In a second aspect, an electronic device is provided, and the electronic device is used to execute the method provided in the first aspect. Specifically, the electronic device may include a processing unit for executing any possible implementation manner of the first aspect.
[0038] In a third aspect, an electronic device is provided, comprising: one or more processors; one or more memories; the one or more memories storing one or more computer programs, the one or more computer programs comprising instructions, which, when executed by the one or more processors, enable the electronic device to execute a method in any possible implementation of the first aspect.
[0039] In a fourth aspect, a computer-readable storage medium is provided, comprising computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the method described in the first aspect.
[0040] In a fifth aspect, a chip is provided, comprising a memory for storing instructions; and a processor for calling and executing instructions from the memory, so that an electronic device equipped with the chip executes the method described in the first aspect above. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 It is a structural diagram of an electronic device 100 provided in an embodiment of the present application.
[0042] Figure 2 Schematic diagram of the software system of the electronic device 100 according to an embodiment of the present application.
[0043] Figure 3 It is a set of graphical user interfaces provided by the embodiments of the present application.
[0044] Figure 4 It is a set of graphical user interfaces provided by the embodiments of the present application.
[0045] Figure 5 This is another set of graphical user interfaces provided by an embodiment of the present application.
[0046] Figure 6 It is a schematic flowchart of editing image materials and generating GIF provided in an embodiment of the present application.
[0047] Figure 7 This is a timing diagram of an electronic device performing environment initialization provided in an embodiment of the present application.
[0048] Figure 8 This is a data flow diagram of an electronic device generating a GIF provided in an embodiment of the present application.
[0049] Fig. 9 This is a timing diagram of an electronic device generating a GIF provided in an embodiment of the present application.
[0050] Fig.10 It is a schematic flowchart of a method for generating GIF provided in an embodiment of the present application.
[0051] Fig.11 This is an example diagram of an M-frame image frame provided in an embodiment of the present application.
[0052] Fig.12 It is an exemplary block diagram of an electronic device provided in an embodiment of the present application.
[0053] Fig.13It is a schematic structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0054] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "plurality" or "multiple" refers to two or more than two.
[0055] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this embodiment, unless otherwise specified, "plurality" means two or more.
[0056] The GIF generation method provided in the embodiment of the present application is applied to electronic devices. The electronic device may also be referred to as a terminal, a user equipment (UE), a mobile station (MS), a mobile terminal (MT), etc. The electronic device may be an electronic device (mobile phone), a smart TV, a wearable device, a tablet computer (Pad), a computer with wireless transceiver function, a virtual reality (VR) electronic device, an augmented reality (AR) electronic device, a wireless terminal in industrial control, a wireless terminal in self-driving, a wireless terminal in remote medical surgery, a wireless terminal in smart grid, a wireless terminal in transportation safety, a wireless terminal in smart city, a wireless terminal in smart home, etc. The embodiment of the present application does not limit the specific technology and specific device form adopted by the electronic device.
[0057] Figure 11 is a schematic diagram of the structure of an electronic device 100 (taking a mobile phone as an example) provided in an embodiment of the present application. The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, an antenna 1, an antenna 2, a mobile communication module 140, a wireless communication module 150, an audio module 160, a sensor module 170, a camera 181, a display screen 182, etc. The sensor module 170 may include a pressure sensor 170A, a gyroscope sensor 170B, etc.
[0058] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0059] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0060] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0061] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0062] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0063] Exemplarily, the MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 182 and the camera 181. The MIPI interface includes a camera serial interface (CSI), a display serial interface (DSI), etc. In some embodiments, the processor 110 and the camera 181 communicate via the CSI interface to implement the shooting function of the electronic device 100. The processor 110 and the display screen 182 communicate via the DSI interface to implement the display function of the electronic device 100.
[0064] The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 with the camera 181, the display 182, the wireless communication module 150, the audio module 160, the sensor module 170, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.
[0065] The USB interface 130 is an interface that complies with the USB standard specification, and specifically can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transfer data between the electronic device 100 and a peripheral device. It can also be used to connect headphones to play audio through the headphones. The interface can also be used to connect other electronic devices, such as AR devices, etc.
[0066] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0067] In the embodiment of the present application, the processor 110 may process the video and / or photo selected by the user to generate a GIF. It is understandable.
[0068] In some embodiments, the processor 110 can also edit the video and / or photos selected by the user (for example, adding filters, cropping, adding text, adding transition information, adding subtitles, etc. to the video and / or photos) to obtain rendered videos and / or photos, and then process the rendered videos and / or photos to generate GIFs.
[0069] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 140, the wireless communication module 150, the modem processor and the baseband processor.
[0070] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0071] The mobile communication module 140 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 100. The mobile communication module 140 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 140 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 140 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 140 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 140 can be set in the same device as at least some of the modules of the processor 110.
[0072] The modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to a speaker, a receiver, etc.), or displays an image or video through a display screen 182. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 140 or other functional modules.
[0073] The wireless communication module 150 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 150 can be one or more devices integrating at least one communication processing module. The wireless communication module 150 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 150 can also receive the signal to be sent from the processor 110, modulate the frequency of the signal, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0074] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 140, and the antenna 2 is coupled to the wireless communication module 150, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).
[0075] The electronic device 100 implements the display function through a GPU, a display screen 182, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 182 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0076] In an embodiment of the present application, the GPU can edit the video and / or photo selected by the user to obtain rendered video and / or photo.
[0077] The display screen 182 is used to display images, videos, etc. The display screen 182 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light emitting diode or an active-matrix organic light emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 182, where N is a positive integer greater than 1.
[0078] The electronic device 100 can realize the shooting function through ISP, camera 181, video codec, GPU, display screen 182 and application processor.
[0079] ISP is used to process the data fed back by camera 181. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to ISP for processing and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, ISP can be set in camera 181.
[0080] The camera 181 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 181, where N is a positive integer greater than 1.
[0081] The digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the electronic device 100 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.
[0082] Video codecs are used to compress or decompress digital videos. The electronic device 100 may support one or more video codecs. Thus, the electronic device 100 may play or record videos in a variety of coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0083] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.
[0084] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.
[0085] In an embodiment of the present application, the editing materials (such as text information, subtitle information, etc.) required for editing videos and / or photos can be stored in an external storage card.
[0086] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0087] In this embodiment of the present application, the rendered video and / or photo may be stored in the internal memory 121 .
[0088] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 160 and the application processor.
[0089] The audio module 160 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 160 can also be used to encode and decode audio signals. In some embodiments, the audio module 160 can be arranged in the processor 110, or some functional modules of the audio module 160 can be arranged in the processor 110.
[0090] The pressure sensor 170A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 170A can be set on the display screen 182. There are many types of pressure sensors 170A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. The capacitive pressure sensor can be a parallel plate including at least two conductive materials. When a force acts on the pressure sensor 170A, the capacitance between the electrodes changes. The electronic device 100 determines the intensity of the pressure according to the change in capacitance. When a touch operation acts on the display screen 182, the electronic device 100 detects the touch operation intensity according to the pressure sensor 170A. The electronic device 100 can also calculate the touch position according to the detection signal of the pressure sensor 170A. In some embodiments, touch operations acting on the same touch position but with different touch operation intensities can correspond to different operation instructions. For example: when a touch operation with a touch operation intensity less than the first pressure threshold acts on the short message application icon, an instruction to view the short message is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold acts on the short message application icon, an instruction to create a new short message is executed.
[0091] The gyro sensor 170B can be used to determine the motion posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., x, y, and z axes) can be determined by the gyro sensor 170B. The gyro sensor 170B can be used for anti-shake shooting. For example, when the shutter is pressed, the gyro sensor 170B detects the angle of the electronic device 100 shaking, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to offset the shaking of the electronic device 100 through reverse movement to achieve anti-shake. The gyro sensor 170B can also be used for navigation and somatosensory game scenes.
[0092] The hardware structure of the electronic device 100 is introduced here. It can be understood that: Figure 1The components included in the hardware structure shown do not constitute a specific limitation on the electronic device 100. The electronic device 100 may have more or fewer components than those shown in the figure, may combine two or more components, or may have different component configurations. The various components shown in the figure may be implemented in hardware, software, or a combination of hardware and software including one or more signal processing and / or application specific integrated circuits.
[0093] The electronic device provided in the embodiments of the present application may be a user equipment (UE), for example, a mobile terminal (such as a mobile phone), a tablet computer, a desktop computer, a laptop computer, a handheld computer, a netbook, a personal digital assistant (PDA), and the like.
[0094] In addition, an operating system is running on the above components, such as the iOS operating system developed by Apple, the Android open source operating system developed by Google, and the Windows operating system developed by Microsoft. Application programs can be installed and run on the operating system.
[0095] The operating system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software system of the electronic device 100.
[0096] Figure 2 1 is a schematic diagram of the software system of the electronic device 100 of the embodiment of the present application. The software system includes several layers, each layer has a clear role and division of labor, and the layers communicate with each other through software interfaces. In some embodiments, the software system is divided into an application layer, an application framework layer, a system library, and a hardware layer from top to bottom.
[0097] The application layer may include a series of application packages, such as camera, gallery, calendar, map, navigation, etc. When these application packages are running, they can access various service modules provided by the application framework layer through the application programming interface (API) and execute corresponding services.
[0098] In the embodiment of the present application, the camera is used to respond to user operations to take photos, videos, slow-motion photos, panoramic photos, etc. After these image materials are captured by the camera, or after the user triggers the electronic device to take a screenshot, or after the user triggers the electronic device to record the screen, or after the electronic device downloads the image materials from other devices, the electronic device can save these image materials in the gallery.
[0099] In the embodiment of the present application, the gallery is used to process the image material selected by the user to generate a GIF in response to the user's operation.
[0100] In some embodiments, the gallery is also used to edit the image material selected by the user in response to the user's operation (for example, adding filters, cropping, adding text, adding transition information, adding subtitles, etc. to the image material), obtain rendered image material, and then process the rendered image material to generate a GIF.
[0101] The application framework layer, referred to as the framework layer, provides an application programming interface (API) and programming framework for the application layer's applications. The application framework layer includes some predefined functions.
[0102] The application framework layer may include a window manager, content provider, view system, resource manager, etc.
[0103] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.
[0104] Content providers are used to store and retrieve data and make it accessible to applications. These data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0105] The view system includes visual controls, such as controls for displaying text and controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.
[0106] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0107] In the embodiments of the present application, Figure 2 As shown, the application framework layer also includes a media framework, which provides multiple tools for editing video and audio. Among them, the above tools include MediaCodec. MediaCodec is a class provided by Android for encoding and decoding audio and video. It includes encoders, decoders, GIF encoders, and Surface type caches.
[0108] The encoder provided by MediaCodec can convert image materials of one format input to the encoder into another format through compression technology, while the decoder performs the reverse process of encoding and can convert image materials of one format input to the decoder into another format through decompression technology.
[0109] For example, assuming that the decoded image material is a video in 10-bit YUV format (YUV is a color format for video sampling), after receiving the video, the decoder can deframe the video, thereby splitting the encapsulated video into frames of 10-bit YUV format image data. Then, the encoder can re-encode the split 10-bit YUV format image data, and then re-encapsulate the split 10-bit YUV format image data into a 10-bit YUV format video.
[0110] MediaCodec can also apply for a memory of type Surface (hereinafter referred to as Surface). Surface is used to cache image material data. For example, after the electronic device 100 edits the image material selected by the user in response to the user's operation and obtains the rendered image material, the electronic device 100 can input the above image material into the Surface cache. Then, the application can obtain the rendered image material from the above Surface for storage or display, etc.
[0111] A GIF encoder is a program for generating GIF files. The GIF encoder in the embodiment of the present application is used to process rendered image materials to generate GIF.
[0112] The GIF encoder can also apply for a memory of type Surface (hereinafter referred to as Surface). Surface is used to cache image material data. For example, after the electronic device 100 edits the image material selected by the user in response to the user's operation and obtains the rendered image material, the electronic device 100 can input the above image material into the Surface cache. Then, the GIF encoder can obtain the rendered image material from the above Surface and generate a GIF based on the rendered image material.
[0113] In the embodiment of the present application, the application framework layer also includes a Java Native Interface (JNI). JNI can be used to set the color format of the image material data supported by Surface. Surface has a default color format for the video data supported by Surface. Generally, Surface supports receiving video data in 8-bit format. In the embodiment of the present application, Surface can also be used to cache video data in 10-bit format.
[0114] Android Runtime includes core libraries and virtual machines. Android Runtime is responsible for scheduling and management of the Android system.
[0115] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.
[0116] The application layer and the application framework layer run in a virtual machine, which executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0117] The system library can include multiple functional modules. For example: surface manager, media library, 3D graphics processing library (for example: OpenGL ES), 2D graphics engine (for example: SGL), etc. The surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications; the media library supports playback and recording of multiple commonly used audio and video formats, as well as static image files, etc. The media library can support multiple audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.; the 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing, etc. The 2D graphics engine is a drawing engine for 2D drawing; the Open Graphics Library (OpenGL) provides multiple image rendering functions that can be used to draw simple graphics to complex 3D scenes.
[0118] In an embodiment of the present application, the OpenGL provided by the system library can be used to support the gallery application to perform image editing operations, such as adding filters, cropping, adding text, adding transition information, adding subtitles, etc. to image materials as introduced in the aforementioned embodiments.
[0119] The hardware layer includes memory and a graphics processing unit (GPU). The memory can be used to temporarily store the computing data in the central processing unit (CPU) and the data exchanged with the external memory such as the hard disk. The GPU is a processor that performs image and graphics related computing work. In an embodiment of the present application, the electronic device 100 runs a program to edit and process the image material selected by the user, and the storage space required to obtain the rendered image material can be provided by the memory, including Surface, data conveyor belt bufferqueue, etc. The process of the electronic device 100 using OpenGL to edit the image material and process the image material to generate GIF can be completed by the GPU.
[0120] Understandably, Figure 2 The layers in the software system shown and the components contained in each layer do not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer layers than shown in the figure, and each layer may include more or fewer components. For example, the software system may also include a hardware abstraction layer, a kernel layer, etc.
[0121] Among them, the hardware abstraction layer is a package of the Linux kernel driver, providing an interface to the upper layer. It hides the hardware interface details of a specific platform and provides a virtual hardware platform for the operating system, making it hardware-independent and portable on multiple platforms. The kernel layer is the layer between hardware and software. The kernel layer contains at least display drivers, camera drivers, audio drivers, and sensor drivers.
[0122] It is understandable that in order to implement the GIF generation method in the embodiment of the present application, the electronic device includes hardware and / or software modules corresponding to the execution of each function. In combination with the algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in combination with the embodiments.
[0123] It should be noted that although the embodiments of the present application are described using the Android system as an example, its basic principles are also applicable to electronic devices based on operating systems such as iOS or Windows.
[0124] The following is a brief introduction to the technical problems solved by this application and the inventive concept of this application.
[0125] With the development and popularization of electronic devices such as mobile phones and tablet computers, more and more users use instant messaging software installed on electronic devices to communicate. In a scenario where users use instant messaging software to communicate, users can make videos or photos into graphics interchange format (GIF) images, and express their chat content vividly by sending GIFs. At the same time, sending GIFs can also increase the fun of user communication.
[0126] Usually, users need to input videos or photos into a GIF encoder for processing to generate a GIF. This way of generating GIF requires the electronic device to process each image frame in the video or all photos of multiple photos. Therefore, the amount of data that the electronic device needs to process is large. When the electronic device processes a large amount of data, the processing speed of the electronic device will be reduced, thereby reducing the performance of the electronic product. At the same time, when the electronic device processes a large amount of data, the power consumption of the electronic device will increase, affecting the user experience.
[0127] In order to avoid reducing the performance of electronic products and increasing the power consumption of electronic devices when electronic devices generate GIFs, an embodiment of the present application provides a GIF generation method. When the electronic device generates a GIF, the video or photo can be framed, and the image frames obtained after the frame extraction process are processed to generate a GIF. In the scheme for generating GIFs in the present application, since the electronic device can process the image frames obtained after the frame extraction process to generate a GIF, the electronic device needs to process a smaller amount of data. When the electronic device processes a smaller amount of data, the processing speed of the electronic device will be increased, thereby improving the performance of the electronic device. At the same time, when the electronic device processes a smaller amount of data, the power consumption of the electronic device will be reduced, thereby improving the user experience.
[0128] For the convenience of description, the embodiments of the present application may collectively refer to videos or photos input into a GIF encoder for processing as image materials.
[0129] The following describes the GIF generation method provided by the embodiment of the present application in conjunction with specific application scenarios.
[0130] the following Figure 3 and Figure 4 It is a set of graphical user interfaces (GUI) provided in the embodiments of the present application.
[0131] In one application scenario, for example, a user uses an electronic device to pre-shoot multiple image materials, and the electronic device stores the multiple image materials in a gallery. Figure 3As shown in (a) of FIG. 1 , an icon of a gallery is displayed on the desktop of the electronic device. When the user wants to edit the image material and generate a GIF based on the image material, the user can click the icon of the gallery on the desktop of the electronic device. In response to the user's click operation on the icon, the electronic device displays the following Figure 3 The user interface shown in (b) in FIG. 1 provides a "free creation" option, such as Figure 3 As shown in (c) of FIG. 1 , the user can click on the “free creation” option. In response to the user clicking on the “free creation” option, the electronic device displays the following Figure 3 The user interface shown in (d) in FIG. 1 may include a plurality of image materials taken recently, such as a plurality of image materials taken on October 1, 2020. Figure 3 As shown in (e) of FIG. 1 , the user can click on any one of the multiple image materials. In response to the user's click operation on the any one of the image materials, the electronic device displays the following Figure 3 The user interface shown in (f) in FIG. 1 includes all the materials in the gallery. In this way, the user can Figure 3 In the user interface shown in (f) in FIG. 1 , select the image material to be edited, for example, Figure 3 As shown in (f) in FIG. 8 , it is assumed that the user selects 3 image materials. Figure 3 The user interface shown in (f) also includes a confirmation option, such as Figure 3 As shown in (f) in the figure, check the option to confirm.
[0132] like Figure 4 As shown in (a) of FIG. 1 , after selecting the image material to be edited, the user can click a confirmation option, such as clicking a check mark. In response to the user's click operation on the check mark option, the electronic device displays the following Figure 4 The user interface shown in (b) in FIG. 1 includes numerous editing options, such as a “clip” option, a “filter” option, a “music” option, a “text” option, a “special effect” option, a “picture-in-picture” option, etc. It should be understood that Figure 4 The editing options shown in (b) do not constitute a specific limitation on the editing options. In other embodiments of the present application, the editing options may also include a "material package" option, a "background" option, an "adjustment" option, etc.
[0133] When the user wants to edit the image material to be edited, he can do Figure 4 The user can click on the "special effects" option to add special effects to the image material, and the user can click on the "text" option to add text to the image material.
[0134] When the user clicks the Edit option, Figure 4 The edited image material is displayed in the preview box shown in (b) in FIG. 8 . The edited image material can also be called rendered image material.
[0135] exist Figure 4 After the rendered image material is displayed in the preview box shown in (b) in the figure, the user can click Figure 4 The "720P" option shown in (b) of FIG. It should be understood that in other embodiments, the "720P" option can also be replaced by a "1080P" option, a "480P" option, etc., and the embodiment of the present application is illustrated by using the "720P" option.
[0136] In other embodiments, the user clicks Figure 4 After checking the box shown in (a) Figure 4 In the user interface shown in (b), no editing options are clicked, and no editing operations are performed on the image material. Instead, the "720P" option is directly clicked to generate a GIF based on the image material.
[0137] In response to the user clicking the "720P" option, the electronic device displays Figure 4 The user interface shown in (c) in the figure includes an option for the user to select a file format, such as a "video" option, a "GIF" option, etc. The user clicks the "video" option to output the format of the rendered image material to a video format. Common video formats include mp4, flv, f4v, webm, etc. The user clicks the "GIF" option to output the format of the rendered image material to a GIF format. The user interface also includes an option for the user to select video parameters or GIF parameters. For example, the video parameters or GIF parameters include resolution, frame rate, etc. The resolution options may include, for example, a "480P" option, a "720P" option, a "1080P" option, a "2K / 4K" option, etc. The resolution is also called pixel resolution, which refers to the number of pixels that can be displayed on the display. The frame rate options may include, for example, a "24" option, a "25" option, a "30" option, a "50" option, and a "60" option, etc. The frame rate refers to the number of image frames transmitted per second. Figure 4 The resolution and frame rate shown in (c) do not constitute a specific limitation on the video or GIF parameters. In other embodiments of the present application, the video or GIF parameters may also include bit rate, etc.
[0138] See also Figure 4 In the user interface shown in (d), if the user wants to generate a GIF based on the rendered image material, the user can click the "GIF" option, and the user can also select the GIF parameters, for example, the resolution of the generated GIF selected by the user is 720P, and the frame rate of the generated GIF selected is 25.
[0139] See also Figure 4 In the user interface shown in (f) of FIG. 1 , after the user selects the GIF parameters, the user can click the "Export" option. In response to the user clicking the "Export" option, the electronic device displays Figure 4 The user interface shown in (e) in FIG. 1 shows the export progress, for example, the export progress is 45%. When the export progress is 100%, the electronic device can export the GIF and store the GIF in the gallery, so that the user can send the GIF to other users through the gallery to vividly express their chat content. At the same time, sending GIF can also increase the fun of user communication.
[0140] Figure 5 This is another set of GUIs provided by an embodiment of the present application.
[0141] In another application scenario, a user uses an electronic device to pre-shoot multiple image materials, and the electronic device stores the multiple image materials in a gallery. In this way, the user can select an image material in the gallery, so that the electronic device generates a GIF based on the image material.
[0142] For example, Figure 5 As shown in (a) of FIG. 1 , after entering the user interface of the gallery, the user interface includes multiple image materials taken recently. The user can click on any one of the multiple image materials, such as the first image material. In response to the user's click operation on the any one material, the electronic device displays the following Figure 5 The user interface shown in (b) in FIG. 1 includes all image materials in the gallery. In this way, the user can Figure 5 In the user interface shown in (b) of FIG. 1 , select the image material to be edited, for example, Figure 5 As shown in (b) in FIG. 8 , it is assumed that the user has selected three image materials to be edited. Figure 5 The user interface shown in (b) further includes a "Create" option. When the user wants to edit the image material to be edited, the user can click the "Create" option. In response to the user clicking the "Create" option, the electronic device displays the following information: Figure 5 The user interface shown in (c) includes a "free creation" option, and the user can choose to click the "free creation" option to edit the image material to be edited.
[0143] After the user clicks the "free creation" option, the electronic device responds to the user clicking the "free creation" option and displays a user interface that can refer to Figure 4 In this example, the user can click Figure 4(b) shows a number of editing options to edit the image material to be edited. After editing, click Figure 4 The "720P" option shown in (b) of the figure can also be directly clicked by the user. Figure 4 The electronic device responds to the user clicking the "720P" option and displays the following Figure 4 In the user interface shown in (c), the user can click on the "GIF" option and select GIF parameters, such as Figure 4 In the user interface shown in (d), the user can click the "Export" option after selecting GIF parameters, for example Figure 4 In the user interface shown in (e) in FIG. 1 , after the user clicks the “Export” option, the export progress may be displayed in the user interface, for example Figure 4 When the export progress is 100%, the electronic device can export the GIF and store the GIF in the gallery, so that the user can send the GIF to other users through the gallery to vividly express their chat content. At the same time, sending GIF can also increase the fun of user communication.
[0144] Figure 6 2 is a schematic flow chart of a method 200 for editing image materials and generating GIF by an electronic device provided in an embodiment of the present application. Figure 6 and Figures 3 to 5 The user interface shown introduces in detail the editing process and the process of generating GIF in the embodiment of the present application.
[0145] like Figure 6 The method 200 includes: S201 and S202.
[0146] The method 200 may be executed by an electronic device, or by a processor or chip in the electronic device, and the present application embodiment does not impose any limitation thereto. For ease of description, the method 200 is described in detail by taking an electronic device as an example.
[0147] S201. The electronic device detects that a user clicks on “free creation”, and in response to the user clicking on “free creation”, displays a user interface for editing image materials.
[0148] In one scenario, for example, refer to Figure 3 The user interface shown in Figure 3 In the user interface of the gallery shown in (c) in FIG. 1 , click the “Free Creation” option, and Figure 3In the user interface shown in (f) of FIG. 1 , the user selects the image material to be edited. After the user selects the image material to be edited, the electronic device can determine the detailed information of the image material to be edited, and the detailed information includes the frame rate, playback time, etc. of the image material. Then the user Figure 3 In the user interface shown in (f), the “check mark” option is clicked. In response to the user clicking the “check mark” option, the electronic device can detect the user's operation of editing the image material.
[0149] In another scenario, for example, refer to Figure 5 The user interface shown in Figure 5 In the user interface of the gallery shown in (b) of FIG. 1 , the user selects the image material to be edited. After the user selects the image material to be edited, the electronic device can determine the detailed information of the image material to be edited, and the detailed information includes the frame rate, playback time, etc. of the image material. Then the user Figure 5 In the user interface shown in (b) in FIG. Figure 5 In the user interface shown in (c), the “Free Creation” option is clicked. In response to the user clicking the “Free Creation” option, the electronic device can detect the user's operation of editing the image material.
[0150] After the electronic device detects the user's operation of editing the image material, the electronic device 100 may display a user interface for editing the image material. Figure 4 Middle (b) to Figure 4 The user interface shown in (f) in FIG.
[0151] S202. After the electronic device detects an editing operation initiated by the user in the user interface for editing image material, it also detects an operation of generating GIF initiated by the user. In response to the operation of generating GIF initiated by the user, the image material to be edited is edited to obtain rendered image material, and a GIF is generated based on the rendered image material.
[0152] For example, the electronic device displays Figure 4 When the user interface shown in (b) is displayed, the user can initiate an editing operation in the user interface. For example, the user can click the "Special Effects" option to add special effects to the image material, and the user can click the "Text" option to add text to the image material, etc.
[0153] After the user has completed all editing operations, the electronic device can display Figure 4 When the user interface shown in (b) is displayed, click the "720P" option of the user interface, and then the electronic device displays Figure 4 Click the "GIF" option in the user interface shown in (d) in the figure, select GIF parameters in the user interface, and then Figure 4 In the user interface shown in (e), the electronic device edits the image material to be edited in response to the user clicking the "Export" option, and obtains the rendered image material. For example: in response to the user clicking the "Special Effects" option for editing, special effects are added to the image material to be edited, and the image material after the special effects are added is obtained. For another example: in response to the user clicking the "Text" option for editing, text is added to the image material to be edited, and the image material after the text is added is obtained.
[0154] It should be understood that the editing operation initiated by the user in the user interface for editing image materials is an optional operation. In some embodiments, the user does not initiate any editing operation in the user interface for editing image materials, and can directly initiate the operation of generating a GIF. Figure 4 When the user interface shown in (b) in FIG. 1 is displayed, the user can directly click the "720P" option in the user interface, and then the electronic device displays Figure 4 Click the "GIF" option in the user interface shown in (d) in the figure, select GIF parameters in the user interface, and then Figure 4 In the user interface shown in (e), the “Export” option is clicked, and the electronic device generates a GIF based on the image material to be edited in response to the user clicking the “Export” option.
[0155] In the embodiment of the present application, the edited image material, for example, the image material after adding special effects or the image material after adding text, may be referred to as rendered image material.
[0156] In an embodiment of the present application, after obtaining the rendered image material, the electronic device may further perform frame extraction processing on the rendered image material, and compress the image material obtained after the frame extraction processing to generate a GIF.
[0157] In other embodiments, the electronic device may also directly perform frame extraction processing on the image material, and compress the image material after the frame extraction processing to generate a GIF.
[0158] The specific implementation method of generating GIF will be described in the following embodiments and will not be described in detail here.
[0159] In the embodiment of the present application, when generating a GIF, the image material can be first subjected to frame extraction processing, and then the GIF can be generated based on the image material after the frame extraction processing. Since the electronic device can process the image material obtained after the frame extraction processing to generate the GIF, the electronic device needs to process a smaller amount of data. When the electronic device processes a smaller amount of data, the processing speed of the electronic device will be increased, thereby improving the performance of the electronic device. At the same time, when the electronic device processes a smaller amount of data, the power consumption of the electronic device will be reduced, thereby improving the user experience.
[0160] Furthermore, the scheme for generating GIF provided by the present application can reduce the storage data compared with the scheme of processing all the image frames in the image material to generate GIF. For example, the usual scheme is to process each image frame in a video with 25 image frames to generate GIF, and the storage data of the generated GIF is 25 megabytes (M). The scheme provided by the present application will perform frame extraction processing on the video with 25 image frames. For example, there are 10 image frames left in the video after the frame extraction processing. Then, the storage data of the generated GIF after processing these 10 image frames is 10M. Since the storage data of the GIF generated by the present application is 10M, while the storage data of the GIF generated by the usual scheme is 25M, the present application can reduce the storage data.
[0161] exist Figures 3 to 5 In the illustrated scenario of editing image materials and generating GIF, after detecting the user's editing operation and the user-initiated operation of generating GIF in S202, the electronic device can perform the following processing: first, initialize the editing environment; second, edit the image materials to generate rendered image materials; and third, generate GIF based on the image materials. Among them, editing the image materials to generate rendered image materials is optional.
[0162] The following first introduces the process of initializing the editing environment.
[0163] The editing environment initialization includes: creating the tools required for the editing process and applying for the storage space required for the editing process. In the embodiment of the present application, the above tools include a decoder for decoding the data format of the image material, a rendering tool OpenGL for rendering the image material, and a GIF encoder for generating a GIF based on the rendered image material. The above storage space includes the Surface provided by the memory, the data conveyor (BufferQueue), etc., and the video memory provided by the GPU.
[0164] For details, please refer to the editing environment initialization process. Figure 7 . Figure 7 This is a timing diagram of an electronic device performing environment initialization provided in an embodiment of the present application.
[0165] S301. The application layer sends a request to MediaCodec to create a GIF encoder.
[0166] In an embodiment of the present application, after the application layer detects an operation of generating a GIF initiated by a user, in response to the operation, the application layer sends a request to MediaCodec to create a GIF encoder.
[0167] For example, the electronic device may detect that the user clicks Figure 4 The "GIF" option shown in (d) and detecting that the user clicks on Figure 4 After the "Export" option is shown in (e), in response to the user clicking the "Export" option, the application layer sends a request to MediaCodec to create a GIF encoder.
[0168] S302. MediaCodec creates a GIF encoder in response to the request.
[0169] S303. After creating the GIF encoder, MediaCodec returns confirmation information indicating that the GIF encoder has been successfully created to the application layer.
[0170] S304: After receiving the confirmation information, the application layer sends a request to create a Surface to the GIF encoder.
[0171] S305 , the GIF encoder applies for a Surface from the memory in response to the request.
[0172] It should be understood that Surface is an object with a specific data structure. Generally, Surface refers to a memory space used to carry image frames to be encoded. In response to the request to create Surface, the GIF encoder sends a request to apply for Surface to the memory, and the memory can allocate a memory space for the GIF encoder, namely the above-mentioned Surface.
[0173] S306. After receiving the request from the GIF encoder for applying for a Surface, the memory allocates a section of memory space to the GIF encoder as a Surface for use by the GIF encoder.
[0174] It should be understood that the memory can provide multiple Surfaces, and each Surface carries an identity (ID) indicating the Surface. For any Surface, the ID of the Surface corresponds one-to-one to the address of the Surface. For example, the ID of Surface-01 is 01, and the address of the Surface is 0011-0100. When the ID of a Surface is identified as 01, the electronic device 100 can determine that the above Surface is Surface-01, and can also determine that the address of the above Surface is 0011-0100; conversely, when the address used by a Surface is identified as 0011-0100, the electronic device 100 can determine that the Surface is Surface-01.
[0175] S307. The memory returns a parameter indicating the Surface to the GIF encoder, where the parameter indicating the Surface includes the address of the Surface and / or the ID of the Surface.
[0176] S308. The GIF encoder returns confirmation information indicating successful creation of the Surface and parameters indicating the Surface to the application layer.
[0177] It should be understood that after the GIF encoder returns confirmation information and parameters indicating the Surface to the application layer, the application layer can obtain the address of the Surface applied for by the GIF encoder and / or the ID of the Surface.
[0178] S309: After the GIF encoder creates the Surface, the application layer may notify OpenGL to initialize.
[0179] In one scenario, the notification carries the ID of the Surface applied for above, and at this time, OpenGL needs to continue to execute S310 and S311.
[0180] In another scenario, the notification carries the address of the Surface applied for above, or carries the address of the Surface applied for above and the ID of the Surface. Then, OpenGL does not need to execute S310 and S311, and can directly execute S312.
[0181] S310. OpenGL sends a request to the application layer to query the address of the Surface corresponding to the Surface ID according to the Surface ID carried in the notification.
[0182] S311. The application layer responds to the request, queries the address of the Surface corresponding to the Surface ID, and returns the address of the Surface to OpenGL.
[0183] It should be understood that OpenGL can be used to support the gallery application to perform image editing operations, such as adding filters, cropping, adding text, adding transition information, adding subtitles, etc. to the image material as described in the above embodiments. After OpenGL edits the image material, the edited image material can be stored in the address of the Surface.
[0184] S312. After receiving the above initialization notification, OpenGL requests a video memory from the GPU.
[0185] It should be understood that the video memory of the embodiment of the present application can be used to cache the video to be edited. The video memory can store textures (texture) or frame buffer objects (Frame Buffer Object) in OpenGL.
[0186] S313, when the GPU successfully applies for the video memory, it returns the application success information and the video memory address to OpenGL.
[0187] S314. OpenGL returns confirmation information to the application layer indicating that the OpenGL initialization is complete.
[0188] S315. The application layer sends a request to MediaCodec to create a decoder.
[0189] For example, the application layer may detect that the user clicks Figure 4 After the "Export" option is shown in (e), in response to the user clicking the "Export" option, a request to create a decoder is sent to MediaCodec at the same time, before, or after S301 sends a request to MediaCodec to create a GIF decoder.
[0190] S316. MediaCodec creates a decoder in response to the request.
[0191] S317: The decoder applies for a memory space from the memory.
[0192] It should be understood that the memory space requested by the decoder from the memory may also be referred to as a data conveyor belt (BufferQueue).
[0193] S318. The memory allocates a section of memory space for the decoder as a BufferQueue for use by the decoder.
[0194] It should be understood that the BufferQueue in the embodiment of the present application can be used to cache image materials to be decoded, and can transmit the decoded image materials to the application layer.
[0195] S319. The memory returns the BufferQueue address to the decoder.
[0196] S320: The decoder returns confirmation information indicating successful creation of the decoder to the application layer.
[0197] It should be understood that the embodiment of the present application does not limit the order of creating a decoder, creating an encoder, and notifying OpenGL of initialization.
[0198] The above describes the process of initializing the editing environment. The following describes the process of editing the image material, generating the rendered image material, and generating a GIF based on the rendered image material.
[0199] Please refer to Figure 8 , Figure 8 This is a data flow diagram of an electronic device generating a GIF provided in an embodiment of the present application. Figure 8 The software architecture that incorporates the electronics details the data flow that generates the GIF. Figure 8 The circles and numbers inside the circles are used to represent steps in the data flow.
[0200] Step 1: The application layer sends the image material to be edited to the decoder.
[0201] It should be understood that the image material to be edited is a packaged image material. Before editing the packaged image material, the packaged image material needs to be decoded into image frames one by one, so as to facilitate the subsequent rendering of the image frames and realize the editing specified by the user.
[0202] Step 2: The decoder decodes the image material to be edited into image frames one by one to obtain an image frame sequence.
[0203] Step 3: The decoder sends a sequence of image frames to OpenGL.
[0204] Step 4: OpenGL converts the color encoding format of the image frame sequence into RGB format and performs normalization processing to obtain an image frame sequence in floating-point (float) RGB format.
[0205] It should be understood that since OpenGL only supports processing (such as calculation operations) of image frames in RGB format, step 4 needs to convert the image frames in the original color encoding format (such as YUV format) into RGB format when receiving the image frame sequence sent by the decoder.
[0206] Step 5: OpenGL writes the floating-point RGB format image frame sequence into the video memory previously requested in the GPU.
[0207] It should be understood that in the process of OpenGL processing image frames, the GPU's video memory is used to carry the processed image frame sequence, and OpenGL is mainly used to send calculation logic to OpenGL to guide the GPU to perform image calculations on the processed image frame sequence carried in the video memory. Therefore, after obtaining the image frame sequence to be edited in floatRGB format in step 4, OpenGL will store the above image frame sequence to be edited in the GPU. Specifically, Figure 7 In the initialization process shown, referring to S312, OpenGL pre-applies for a video memory from the GPU during initialization. At this time, OpenGL can write the image frame sequence to be edited in the floatRGB format into the pre-applied video memory, that is, write into the video memory.
[0208] Step 6: After OpenGL writing is completed, OpenGL returns a message to the application layer indicating that writing is completed.
[0209] Step 7: The application layer sends the recorded user editing operation to OpenGL.
[0210] In some embodiments, for example, in S202, when a user initiates an editing operation in the user interface, the application layer records the user's valid editing operation. After the application layer receives a message indicating that writing is complete, the recorded valid editing operation can be sent to OpenGL. Exemplarily, the valid editing operation includes the user clicking on the "special effects" option, the user clicking on the "text" option, etc., which is not limited in the embodiments of the present application.
[0211] After the application layer sends the recorded valid editing operations to OpenGL, steps 8 and 9 can be performed.
[0212] In other embodiments, when a user initiates an editing operation in the user interface, the application layer records the user's invalid editing operation. After the application layer receives a message indicating that writing is complete, the recorded invalid editing operation can be sent to OpenGL. Exemplarily, the invalid editing operation includes the user canceling the operation of clicking the "special effects" option, canceling the operation of clicking the "text" option, etc., which is not limited in the embodiments of the present application.
[0213] After the application layer sends the recorded valid editing operation to OpenGL, there is no need to execute step 8 and step 9, and step 10 and subsequent steps can be directly executed.
[0214] Step 8: After OpenGL receives the editing operation sent by the application layer, OpenGL determines the calculation logic corresponding to the editing operation according to the editing operation, and sends the calculation logic to the GPU.
[0215] It should be understood that OpenGL has preset calculation logic corresponding to different editing operations. For example, the calculation logic corresponding to the operation of clicking the "Special Effects" option can add special effects to the image frame, and the calculation logic corresponding to the operation of clicking the "Text" option can add text to the image frame.
[0216] After OpenGL receives the editing operation sent by the application layer, OpenGL can determine the calculation logic corresponding to the sent editing operation in the preset editing operations.
[0217] Step 9: After receiving the calculation logic sent by OpenGL, the GPU executes the calculation logic in sequence to obtain the rendered image material.
[0218] For example, the GPU receives two calculation logics, one is the calculation logic corresponding to the operation of the user clicking the "special effects" option, and the other is the calculation logic corresponding to the operation of the user clicking the "text" option. Then the GPU can add filters and text to the image frame based on these calculation logics to obtain the image frame after adding filters and text.
[0219] It should be noted that the process of adding filters and text to the image frame in the embodiment of the present application can also be referred to as the process of rendering the image frame. Before rendering, the data format of the image frame to be edited is floatRGB, and the data format of the rendered image frame is also floatRGB.
[0220] In the embodiment of the present application, in order to subsequently output the rendered image frame in the original color encoding format (e.g., YUV format), after obtaining the rendered image frame in the floatRGB format, OpenGL needs to convert the color encoding format of the rendered image frame, for example, converting the RGB format into the YUV format.
[0221] By performing the above processing on each image frame in the image frame sequence, the rendered image material can be obtained.
[0222] Step 10: GPU returns information indicating the completion of processing to OpenGL, and returns the video memory address storing the rendered image material to OpenGL.
[0223] In an embodiment of the present application, after the application layer sends the recorded valid editing operation to OpenGL in step 7, the GPU in step 10 can return information to OpenGL to indicate that the processing is complete, and return to OpenGL the video memory address where the above-mentioned rendered image material is stored.
[0224] In other embodiments, after the application layer sends the recorded invalid editing operation to OpenGL in step 7, step 10 may directly return the video memory address of the stored image material to be edited to OpenGL.
[0225] Step 11: OpenGL returns information indicating the completion of the processing and the video memory address of the rendered image material to the application layer.
[0226] It should be understood that after the application layer receives the above-mentioned returned information, the application layer can obtain the rendered image material from the above-mentioned video memory address, and then write the rendered image material into the Surface applied for by the GIF encoder, so that the GIF encoder can process the rendered image material and generate GIF.
[0227] In other embodiments, after the application layer receives the above-mentioned returned information, it can also obtain the image material to be edited from the above-mentioned video memory address, and then write the image material to be edited into the Surface applied for by the GIF encoder, so that the GIF encoder can process the image material to be edited and generate GIF.
[0228] For details on how to write to Surface, please refer to the following steps.
[0229] Step 12: The application layer calls JNI, which includes two parameters: video memory address and Surface address.
[0230] It should be understood that the memory address can indicate which storage space of the GPU the JNI should obtain the image material from; the surface address indicates which storage space of the memory the JNI should store the obtained image material into. For example, the APP can pass the memory address A1 and the surface address A2 to the JNI. The memory address A1 can be Figure 7 In the initialization process shown, referring to S312, OpenGL pre-applies to the GPU for the address of a video memory. The above Surface address A2 is Figure 7 The address of the Surface applied for by the GIF encoder.
[0231] Step 13, JNI sends a request for a graphics buffer to the memory. In response to the request, the memory allocates a graphics buffer to the JNI. The memory returns the address of the graphics buffer to the JNI. The JNI uses the graphics buffer to receive the rendered image material output by the GPU.
[0232] In other embodiments, the JNI may also utilize the graphics buffer to receive the image material to be edited output by the GPU.
[0233] Step 14: JNI sends the video memory address and the address of the graphics buffer to OpenGL, and OpenGL reads the rendered image material from the GPU storage space indicated by the video memory address through a read function.
[0234] It should be understood that the read function may be readpixel. In other embodiments, OpenGL reads the image material to be edited from the GPU storage space indicated by the video memory address through the read function.
[0235] Step 15: OpenGL writes the read rendered image material into the graphics buffer indicated by the address of the graphics buffer.
[0236] In other embodiments, OpenGL may also write the read image material to be edited into the graphics buffer indicated by the address of the graphics buffer.
[0237] Step 16, JNI inputs the rendered image material cached in the graphics buffer into the Surface indicated by the Surface address.
[0238] In the embodiment of the present application, JNI inputs the rendered image material or the image material to be edited cached in the graphics buffer into the Surface indicated by the Surface address in order to enable the GIF encoder to encode the image material cached in the sufface to generate a GIF.
[0239] In some embodiments, JNI may not apply for a graphics buffer, but directly input the read rendered image material or the image material to be edited into the Surface.
[0240] Step 17: After the rendered image material is carried in the Surface, the GIF encoder performs frame extraction on the rendered image material to obtain the rendered image material after frame extraction, and the GIF encoder generates a GIF based on the rendered image material after frame extraction.
[0241] It should be understood that the implementation process of the GIF encoder performing frame extraction processing on the rendered image material may be:
[0242] The GIF encoder can obtain the description information of the image material to be edited from the application layer, determine the total number of frames of the image material to be edited according to the description information of the image material to be edited, perform frame extraction processing on the rendered image material according to the total number of frames to obtain the rendered image material after frame extraction, process the rendered image material after frame extraction, and generate GIF.
[0243] In one implementation, when the image material to be edited includes at least one video segment, the description information obtained by the GIF encoder from the application layer includes the frame rate of each video segment in the at least one video segment and the playback time of each video segment, and the total number of frames of the image material to be edited is determined according to the frame rate of each video segment in the at least one video segment and the playback time of each video segment. For example: the image material to be edited includes 2 videos, namely the first video segment and the second video segment, and the description information obtained by the GIF encoder from the application layer includes the frame rate of the first video segment, such as 30 frames / S, the playback time of the first video segment, such as 2S, the frame rate of the second video segment, such as 40 frames / S, and the playback time of the second video segment, such as 3S. The total number of frames of the image material to be edited can be determined as: 30 frames / S×2S+40 frames / S×3S=180 frames.
[0244] In one implementation, the image material to be edited includes at least one video segment and at least one photo, and the description information obtained by the GIF encoder from the application layer includes the frame rate of each video segment in the at least one video segment, the playback time of each video segment, and the number of at least one photo. The total number of frames of the image material to be edited is determined according to the frame rate of each video segment in the at least one video segment, the playback time of each video segment, and the number of at least one photo. For example, the image material to be edited includes 2 videos and 3 photos, and the 2 videos are the first video segment and the second video segment, respectively. The description information obtained by the GIF encoder from the application layer includes the frame rate of the first video segment, such as 30 frames / S, the playback time of the first video segment, such as 2S, the frame rate of the second video segment, such as 40 frames / S, the playback time of the second video segment, such as 3S, and the number of the three photos, such as 3 photos. The total number of frames of the image material to be edited can be determined as: 30 frames / S×2S+40 frames / S×3S+3=183 frames.
[0245] In one implementation, the image material to be edited includes multiple photos, and the description information obtained by the GIF encoder from the application layer includes the number of the multiple photos. For example, the obtained description information includes the number of 3 photos, and the total number of frames of the image material to be edited is determined to be 3 frames.
[0246] In an embodiment of the present application, the rendered image material is subjected to frame extraction processing according to the total number of frames, and the rendered image material after frame extraction can be obtained as follows: based on the total number of frames, the rendered image material is randomly extracted, and the number of frames of the rendered image material after frame extraction is less than the total number of frames. For example, the total number of frames is 10 frames. After the first frame of the 10 frames is used as the first frame of the rendered image material after extraction, the fourth frame of the 10 frames is extracted at an interval of 2 frames as the second frame of the rendered image material after extraction, and then the sixth frame of the 10 frames is extracted at an interval of 1 frame as the third frame of the rendered image material after extraction, and then the tenth frame of the 10 frames is extracted at an interval of 3 frames as the fourth frame of the rendered image material after extraction. In this way, the rendered image material after frame extraction has a total of 4 frames. For another example: the 4th, 5th, 6th, and 7th frames can be directly extracted as the rendered image material after frame extraction.
[0247] In other embodiments, the rendered image material is subjected to frame extraction processing according to the total number of frames, and the rendered image material after frame extraction can be: based on the total number of frames, the rendered image material is subjected to frame extraction processing at a preset frame interval to obtain the rendered image material after frame extraction. For example, the total number of frames is 10 frames, and the preset frame interval is 1 frame, then the rendered image material after frame extraction is respectively the 1st frame, the 3rd frame, the 5th frame, the 7th frame and the 9th frame of the 10 image frames. For another example, the total number of frames is 10 frames, and the preset frame interval is 2 frames, then the rendered image material after frame extraction is respectively the 1st frame, the 4th frame, the 7th frame and the 10th frame of the 10 image frames.
[0248] In an embodiment of the present application, the GIF encoder can compress the rendered image material after the frame extraction to generate a GIF. For example, the GIF encoder compresses the rendered image material after the frame extraction through a lossless compression algorithm to generate a GIF. The lossless compression algorithm can be a Lempel Ziv Welch Encoding (LZW) string table compression algorithm.
[0249] In other embodiments, step 17 may also be: after the image material to be edited is carried in the Surface, the GIF encoder performs frame extraction on the image material to be edited to obtain the image material to be edited after frame extraction, and the GIF encoder generates a GIF based on the image material to be edited after frame extraction.
[0250] It should be understood that the GIF encoder performs frame extraction processing on the image material to be edited to obtain the image material to be edited after frame extraction, and the implementation method of the GIF encoder generating GIF based on the image material to be edited after frame extraction is the same as the GIF encoder performs frame extraction processing on the rendered image material to obtain the rendered image material after frame extraction, and the implementation method of the GIF encoder generating GIF based on the rendered image material after frame extraction, which will not be repeated here.
[0251] Step 18: The GIF encoder sends the GIF to the application layer, and the application layer displays or saves the GIF.
[0252] It should be understood that the GIF encoder sends the GIF to the application layer, and the gallery application in the application layer can display or save the GIF.
[0253] Please refer to Fig. 9 , Fig. 9 This is a timing diagram of an electronic device generating a GIF provided in an embodiment of the present application. Fig. 9 Steps in . Fig. 9 The data interaction between the modules in (steps 1 to 18) and Figure 8 Steps 1 to 18 in the above correspond to each other and will not be repeated here.
[0254] Please refer to Fig.10 , Fig.10 4 is a schematic flow chart of a method 400 for generating a GIF provided in an embodiment of the present application. The method 400 may be executed by an electronic device, or by a processor or chip in the electronic device, and the embodiment of the present application does not make any limitation. For ease of description, the method 400 is described in detail by taking an electronic device as an example.
[0255] S401. An electronic device displays a first interface including at least one image material, where the image material includes a video and / or a photo.
[0256] It should be understood that the first interface refers to the user interface of the gallery. For example, the first interface can be Figure 4 The at least one image material included in the first interface refers to an image material selected by the user from all image materials stored in the gallery. For example, the at least one image material may be Figure 4 (a) shows three image materials selected by the user in the user interface.
[0257] In the embodiment of the present application, the image material may be a video, a photo, or a combination of a video and a photo. For example, at least one image material may be at least one video, multiple photos, or a combination of at least one video and at least one photo.
[0258] S402. In response to a first operation of a user on at least one image material, the electronic device extracts at least part of N image frames included in the at least one image material to obtain M image frames, where N is an integer greater than 1, M is an integer greater than or equal to 1, and M is less than N.
[0259] It should be understood that the first operation refers to the operation of the user generating a GIF. For example, the first operation may be that the user clicks Figure 4 The “Export” option in the user interface shown in (e).
[0260] It should also be understood that N image frames are image frames generated after at least one image material is decoded. Figure 2 The decoder shown in FIG. 1 generates image frames one by one after decoding.
[0261] The embodiment of the present application can perform frame extraction processing on all image frames of N image frames to obtain M image frames. For example, Fig.11 is a video image of M frames provided in an embodiment of the present application, such as Fig.11 As shown in (a), N image frames are 10 frames, namely the 1st, 2nd, 3rd, 4th, 5th, 6th, 7th, 8th, 9th and 10th frames. All 10 image frames are extracted, for example, the 1st, 3rd, 5th, 7th and 9th frames are extracted to obtain 5 image frames. In this example, these 5 image frames are called M image frames.
[0262] The embodiment of the present application can also perform frame extraction processing on some image frames of N image frames to obtain M image frames. For example, Fig.11 As shown in (b), N image frames are 10 frames, and 5 frames (for example, the first 5 frames) of the 10 image frames are subjected to frame extraction processing to obtain 3 image frames. This example calls the sum of these 3 image frames and the remaining 5 image frames that have not been subjected to frame extraction processing, that is, 8 image frames, M image frames.
[0263] S403: The electronic device generates a GIF based on the M image frames.
[0264] In the embodiment of the present application, the electronic device can compress M frames of image material using a lossless compression algorithm to generate a GIF. For example, the lossless compression algorithm can be a Lempel Ziv Welch Encoding (LZW) string table compression algorithm.
[0265] S404: The electronic device displays a second interface including a GIF.
[0266] It should be understood that the second interface refers to the user interface of the gallery. For example, the second interface can be Figure 3 The user interface shown in (d) may also be Figure 5 The user interface shown in (a) in FIG. The user can view the GIF in the second interface, and can also send the GIF to other users for communication through instant messaging software.
[0267] In an embodiment of the present application, the electronic device may perform frame extraction processing on all or part of the image frames (i.e., at least part of the image frames of N frames) included in at least one video and / or at least one photo (i.e., at least one image material) to obtain image frames after frame extraction processing (i.e., M frames of image frames); then, a GIF is generated based on the M frames of image frames. Compared with a solution in which a GIF is usually generated based on all the image frames in at least one image material, the present application only needs to process the image frames after frame extraction processing when generating a GIF, and the amount of data to be processed is relatively small. When processing a small amount of data, the processing speed of the electronic device is increased, thereby improving the performance of the electronic device. At the same time, when the electronic device processes a small amount of data, the power consumption of the electronic device is reduced, thereby improving the user experience.
[0268] Furthermore, when storing the generated GIF, the embodiment of the present application does not need to store the data of all image frames in at least one image material, but only needs to store the data of image frames (M image frames) after frame extraction of at least one image material, thereby reducing the stored data.
[0269] In some embodiments, the electronic device performs frame extraction processing on at least part of N image frames included in at least one image material to obtain M image frames, including:
[0270] The electronic device determines the total number of N image frames included in at least one image material, and performs frame extraction processing on at least part of the N image frames based on the total number of frames to obtain M image frames.
[0271] In order to ensure that the number of M image frames obtained after frame extraction is less than the number of N image frames, in an embodiment of the present application, the electronic device can determine the total number of all image frames in at least one video and / or at least one photo before performing frame extraction on all or part of the image frames in at least one video and / or at least one photo (i.e., at least part of the N image frames), and perform frame extraction based on the total number of frames, so that the number of image frames obtained after the frame extraction can be less than the total number of frames. In this way, it can be ensured that the number of M image frames obtained after the frame extraction is less than the number of all image frames (i.e., N image frames) in at least one video and / or at least one photo.
[0272] The following first introduces the implementation process of the electronic device determining the total number of N image frames:
[0273] In one scenario, at least one image material includes only video, and the electronic device determines the total number of N image frames included in the at least one image material by: the electronic device obtains the frame rate of each video segment in the at least one image material and the playback duration of each video segment; and determines the total number of N image frames according to the frame rate of each video segment and the playback duration of each video segment.
[0274] Exemplary, reference Figure 2 In the software system of the electronic device shown, at least one image material can be two videos selected by the user in the gallery in the application layer. The GIF encoder can extract at least part of the image frames of the two videos to obtain M image frames. At the same time, the GIF encoder can also determine the total number of N image frames included in the two videos. When determining the total number of frames, the GIF encoder can obtain description information of the two videos from the application layer, and the description information includes the frame rate of each video in the two videos and the playback time of each video. For example, the two videos are the first video and the second video, respectively. The description information obtained by the GIF encoder from the application layer includes the frame rate of the first video, such as 30 frames / S, and the playback time of the first video, such as 2S, the frame rate of the second video, such as 40 frames / S, and the playback time of the second video, such as 3S. Then the total number of N image frames determined by the GIF encoder can be: 30 frames / S×2S+40 frames / S×3S=180 frames.
[0275] In the embodiment of the present application, the electronic device can accurately determine the total number of N image frames according to the frequency of each video segment and the playback duration of each video segment.
[0276] In another scenario, at least one image material includes videos and photos, and the electronic device determines the total number of N image frames included in the at least one image material by: the electronic device obtains the frame rate of each video segment, the playback duration of each video segment, and the number of each photo in the at least one image material; and determines the total number of N image frames according to the frame rate of each video segment, the playback duration of each video segment, and the number of each photo.
[0277] For example, refer again to Figure 2In the software system of the electronic device shown, at least one image material can be two videos and three photos selected by the user in the gallery in the application layer. When the GIF encoder determines the total number of frames of the at least one image material, the GIF encoder can obtain description information of the two videos and the three photos from the application layer, and the description information includes the frame rate of each of the two videos and the playback time of each video, as well as the number of the three photos. For example, the description information obtained by the GIF encoder from the application layer includes the frame rate of the first video, such as 30 frames / S, the playback time of the first video, such as 2S, the frame rate of the second video, such as 40 frames / S, the playback time of the second video, such as 3S, and the number of the three photos, such as 3 photos. Then, the total number of N image frames determined by the GIF encoder can be: 30 frames / S×2S+40 frames / S×3S+3=183 frames.
[0278] In the embodiment of the present application, the electronic device can accurately determine the total number of N image frames based on the frame rate of each video segment, the playback duration of each video segment, and the number of each photo.
[0279] In another scenario, at least one image material includes photos, and the electronic device determines the total number of N image frames included in the at least one image material by: the electronic device obtains the number of each photo in the at least one image material; and determines the total number of N image frames based on the number of each photo.
[0280] For example, refer again to Figure 2 In the software system of the electronic device shown, at least one image material can be three photos selected by a user in a gallery in an application layer. When the GIF encoder determines the total number of frames of the at least one image material, the GIF encoder can obtain description information of the three photos from the application layer. The description information includes the number of the three photos. Then the total number of N image frames determined by the GIF encoder is 3 frames.
[0281] In the embodiment of the present application, the electronic device can determine the total number of N image frames according to the number of each photo, and accurately determine the total number of N image frames.
[0282] The following describes an implementation process in which an electronic device performs frame extraction processing on at least part of N image frames based on the total number of frames to obtain M image frames:
[0283] In one scenario, the electronic device may perform frame extraction processing on at least part of N image frames at a preset frame interval based on the total number of frames to obtain M image frames.
[0284] It should be understood that the preset frame interval can be 1 frame, 2 frames, etc., and the embodiments of the present application are not limited to this.
[0285] For example, the total number of frames is 10 frames, and the preset frame interval is 1 frame. Then, the implementation process of extracting frames for all image frames in the 10 image frames with a frame interval of 1 frame can be: after taking the first frame of the 10 frames as the first frame of the extracted M image frames, extract the third frame of the 10 frames as the second frame of the extracted M image frames after an interval of 1 frame, then extract the fifth frame of the 10 frames as the third frame of the extracted M image frames after an interval of 1 frame, then extract the seventh frame of the 10 frames as the fourth frame of the extracted M image frames after an interval of 1 frame, and then extract the ninth frame of the 10 frames as the fifth frame of the extracted M image frames after an interval of 1 frame. In this way, there are a total of 5 frames in the M image frames, namely the 1st, 3rd, 5th, 7th, and 9th frames of the 10 frames.
[0286] For another example, the total number of frames is 20 frames, and the preset frame interval is 1 frame. Then, the implementation process of performing frame extraction processing on some image frames of the 20 frames (for example, the first 10 frames of the 20 frames) with a frame interval of 1 frame can be: after taking the first frame of the first 10 frames as the first frame of the extracted M frames, extract the third frame of the first 10 frames as the second frame of the extracted M frames, then extract the fifth frame of the first 10 frames as the third frame of the extracted M frames, then extract the seventh frame of the first 10 frames as the fourth frame of the extracted M frames, then extract the ninth frame of the first 10 frames as the fifth frame of the extracted M frames, so that there are 15 frames in total, namely the 1st, 3rd, 5th, 7th, 9th frames of the first 10 frames and the last 10 frames.
[0287] In an embodiment of the present application, the electronic device can perform frame extraction processing on all or part of the image frames in at least one video and / or at least one photo at a preset frame interval, and can accurately obtain M image frames. Moreover, when the frame extraction processing is performed at the preset frame interval, the frame extraction processing is performed based on the total number of all image frames, and it can be ensured that the number of M image frames is less than the total number of all image frames.
[0288] In another scenario, the electronic device may randomly extract at least part of the N image frames based on the total number of frames to obtain M image frames.
[0289] For example, if the total number of frames is 10, then the implementation process of randomly extracting all the image frames in the 10 image frames can be: after taking the first frame of the 10 frames as the first frame of the extracted M image frames, extract the fourth frame of the 10 frames as the second frame of the extracted M image frames after 2 frames, then extract the sixth frame of the 10 frames as the third frame of the extracted M image frames after 1 frame, then extract the tenth frame of the 10 frames as the fourth frame of the extracted M image frames after 3 frames, so that the M frame image material after frame extraction has 4 frames, which are the first, fourth, sixth and tenth frames of the 10 frames. The electronic device can also directly extract the fourth, fifth, sixth and seventh frames of the 10 frames as the M image frames. It can be seen from this example that when all image frames of N frames are randomly sampled, the image frames can be sampled with an interval of at least one frame to obtain M frames, or several consecutive frames of the N frames can be used as M frames, which can improve the diversity of the obtained M frames.
[0290] For another example, if the total number of frames is 10, then the implementation process of randomly extracting some image frames in the 20 frames (for example, the first 10 frames in the 20 frames) can be: after taking the first frame in the first 10 frames as the first frame in the extracted M frames, extract the fourth frame in the first 10 frames as the second frame in the extracted M frames, then extract the sixth frame in the first 10 frames as the third frame in the extracted M frames, then extract the tenth frame in the first 10 frames as the fourth frame in the extracted M frames, so that the M frame image material after the extraction has 14 frames, which are the first, fourth, sixth, tenth and last ten frames in the first 10 frames. The electronic device can also directly extract the fourth, fifth, sixth and seventh frames in the first 10 frames, and then use the fourth, fifth, sixth, seventh and last ten frames as the M frames. It can be seen from this example that when sampling some image frames of N image frames in a random sampling manner, the sampling can be performed with an interval of at least one frame to obtain M image frames, or several consecutive frames of some image frames in the N image frames can be used as M image frames, which can improve the diversity of the obtained M image frames.
[0291] In an embodiment of the present application, an electronic device performs frame sampling processing on all or part of the image frames in at least one video and / or at least one photo in a random frame sampling manner, which can improve the diversity of image frames obtained by the frame sampling processing. Moreover, when the frame sampling processing is performed in a random frame sampling manner, the frame sampling processing is performed based on the total number of all image frames, which can ensure that the number of M image frames is less than the total number of all image frames.
[0292] In some embodiments, in order to improve the display effect of the generated GIF, at least one image material selected by the user may be rendered before the GIF is generated to obtain a rendered image material, and the GIF is generated by the rendered image material. Therefore, S402 in the method 400 may also be:
[0293] In response to a first operation of a user on at least one image material, the electronic device edits the at least one image material to obtain N rendered image frames, wherein the editing process includes one or more of adding filter processing, cropping processing, adding text processing, adding transition information processing, and adding subtitle processing; and extracting frames of at least part of the rendered image frames of the N rendered image frames to obtain M image frames.
[0294] In this embodiment, the first operation includes an editing operation and an operation of generating a GIF. For example, the operation of generating a GIF by a user may be that the user clicks Figure 4 The "Export" option in the user interface shown in (e) of FIG. The editing operation can be performed by the user clicking Figure 4 Operation of one or more of the numerous editing options shown in (b).
[0295] The meaning of at least one image material has been stated in the above embodiments and will not be repeated here.
[0296] In the embodiment of the present application, the implementation process of editing at least one image material to obtain N frames of rendered image frames can be referred to Figure 8 and Fig. 9 The illustrated embodiments will not be described in detail here.
[0297] In the embodiment of the present application, the implementation process of extracting at least part of the N rendered image frames to obtain M image frames is the same as the implementation process of extracting at least part of the N rendered image frames to obtain M image frames recorded in S402, and will not be repeated here.
[0298] In an embodiment of the present application, before performing frame extraction to generate a GIF, the electronic device may edit at least one video and / or at least one photo to obtain N frames of rendered image frames, thereby performing frame extraction and GIF generation on the N frames of rendered image frames to obtain a GIF. Since the rendered image frames are image frames obtained through one or more editing processes including adding filter processing, cropping processing, adding text processing, adding transition information processing, and adding subtitles processing, the display effect of the GIF can be improved based on the GIF generated based on the rendered image frames.
[0299] In the above embodiment, the electronic device first performs the editing process and then performs the frame extraction process. In some embodiments, the electronic device may also first perform the frame extraction process and then perform the editing process. Therefore, after S402 of the method 400, the method further includes:
[0300] The electronic device performs editing processing on the M image frames to obtain M rendered image frames, wherein the editing processing includes one or more of adding filter processing, cropping processing, adding text processing, adding transition information processing, and adding subtitle processing.
[0301] It should be understood that the electronic device can perform frame extraction processing on at least part of the N image frames through S402 to obtain M image frames, and then perform editing processing on the M image frames to obtain M rendered image frames. The implementation process of the editing processing can refer to Figure 8 and Fig. 9 The illustrated embodiments will not be described in detail here.
[0302] In some embodiments, after obtaining the M frames of rendered image frames, the electronic device may generate a GIF based on the M frames of rendered image frames.
[0303] It should be understood that the implementation process of generating a GIF based on the M-frame rendered image frames is the same as the implementation process of generating a GIF based on the M-frame image frames, which will not be repeated here.
[0304] In the embodiment of the present application, since the electronic device performs editing processing on M image frames obtained through frame extraction processing to obtain M rendered image frames, compared with the editing method in which the electronic device performs editing processing on at least one video and / or at least one photo to obtain N rendered image frames, the number of image frames to be edited can be reduced. Since the number of image frames to be edited is reduced, the speed of the editing processing of the electronic device can be increased, thereby improving the performance of the electronic device. At the same time, when the electronic device edits fewer image frames, the power consumption of the electronic device can be reduced.
[0305] Moreover, since the image frames rendered by the M frames are image frames obtained through one or more editing processes including adding filter processing, cropping processing, adding text processing, adding transition information processing and adding subtitles processing, generating GIF based on the image frames rendered by the M frames can improve the display effect of the GIF.
[0306] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0307] The electronic device provided by the embodiments of the present application is described in detail below with reference to the accompanying drawings.
[0308] Fig.12 is an exemplary block diagram of an electronic device 500 provided in an embodiment of the present application. The electronic device 500 includes a processing unit 51, and the processing unit 51 is used to perform the following operations:
[0309] A first interface is displayed, including at least one image material, the image material including video and / or photo; in response to a first operation of a user on at least one image material, at least part of N image frames included in the at least one image material are subjected to frame extraction processing to obtain M image frames, where N is an integer greater than 1, M is an integer greater than or equal to 1, M is less than N, and the N image frames are image frames generated after the at least one image material is decoded; a GIF is generated based on the M image frames; a second interface is displayed, including a GIF.
[0310] It should be understood that the processing unit 51 can be used to execute each step performed by the electronic device in the method 400. For specific descriptions, please refer to the relevant descriptions above and will not be repeated here.
[0311] In addition, the processing unit 51 can also be used to execute the method 200 or Figure 7 or Fig. 9 For the detailed description of each step executed by the electronic device, please refer to the relevant description above and will not be repeated here.
[0312] It should be understood that the electronic device 500 is embodied in the form of a functional unit. The term "unit" herein may refer to an application specific integrated circuit (ASIC), an electronic circuit, a processor (e.g., a shared processor, a dedicated processor, or a group processor, etc.) and a memory for executing one or more software or firmware programs, a combined logic circuit, and / or other suitable components that support the described functions.
[0313] In the embodiments of the present application, Fig.12 The electronic device in the embodiment may also be a chip or a chip system, for example, a system on chip (SoC).
[0314] Fig.13 6 is a schematic structural diagram of an electronic device 600 provided in an embodiment of the present application. The electronic device 600 is used to execute the corresponding steps and / or processes in the above method embodiment.
[0315] The electronic device 600 includes a processor 601, a transceiver 602, and a memory 603. The processor 601, the transceiver 602, and the memory 603 communicate with each other through an internal connection path, and the processor 601 can implement the functions of the processing unit 51 in various possible implementations of the electronic device 500. The memory 603 is used to store instructions, and the processor 601 is used to execute the instructions stored in the memory 603, or in other words, the processor 601 can call these stored instructions to implement the functions of the processing unit 51 in the electronic device 500.
[0316] Optionally, the memory 603 may include a read-only memory and a random access memory, and provide instructions and data to the processor. A portion of the memory may also include a non-volatile random access memory. For example, the memory may also store information about the device type. The processor 601 may be used to execute instructions stored in the memory, and when the processor 601 executes instructions stored in the memory, the processor 601 is used to execute the various steps and / or processes of the above-mentioned method embodiment corresponding to the electronic device.
[0317] The processor 601 is configured to perform the following steps:
[0318] A first interface is displayed, including at least one image material, the image material including video and / or photo; in response to a first operation of a user on at least one image material, at least part of N image frames included in the at least one image material are subjected to frame extraction processing to obtain M image frames, where N is an integer greater than 1, M is an integer greater than or equal to 1, M is less than N, and the N image frames are image frames generated after the at least one image material is decoded; a GIF is generated based on the M image frames; a second interface is displayed, including a GIF.
[0319] It should be understood that the processor 601 can be used to execute each step performed by the electronic device in the method 400. For specific descriptions, please refer to the relevant descriptions above and will not be repeated here.
[0320] In addition, the processor 601 may also be used to execute the method 200 or Figure 7 or Fig. 9 For the detailed description of each step executed by the electronic device, please refer to the relevant description above and will not be repeated here.
[0321] It should be understood that in the embodiments of the present application, the processor of the above-mentioned device may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0322] In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in a processor or an instruction in the form of software. The steps of the method disclosed in conjunction with the embodiment of the present application can be directly embodied as a hardware processor for execution, or a combination of hardware and software units in a processor for execution. The software unit can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor executes the instructions in the memory, and completes the steps of the above method in conjunction with its hardware. To avoid repetition, it is not described in detail here.
[0323] The embodiment of the present application provides a computer program product, when the computer program product is run on an electronic device, the electronic device executes the technical solution in the above embodiment. Its implementation principle and technical effect are similar to those of the above method-related embodiments, and will not be repeated here.
[0324] The embodiment of the present application provides a readable storage medium, the readable storage medium contains instructions, when the instructions are executed in an electronic device, the electronic device executes the technical solution of the above embodiment. The implementation principle and technical effect are similar, and will not be repeated here.
[0325] The embodiment of the present application provides a chip, the chip is used to execute instructions, when the chip is running, the technical solution in the above embodiment is executed. The implementation principle and technical effect are similar, and will not be repeated here.
[0326] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a high-density digital video disc (DVD)), or a semiconductor medium (eg, a solid state disk (SSD)).
[0327] It should be understood that the "embodiment" mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, the various embodiments in the entire specification do not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application.
[0328] In this application, elements expressed in the singular are intended to mean "one or more" rather than "one and only one", unless otherwise specified. In this application, "at least one" is intended to mean "one or more", and "more than one" is intended to mean "two or more", unless otherwise specified.
[0329] In this document, the term "at least one of..." or "at least one of..." means all or any combination of the listed items. For example, "at least one of A, B, and C" may mean: A exists alone, B exists alone, C exists alone, A and B exist at the same time, B and C exist at the same time, and A, B, and C exist at the same time, where A may be singular or plural, B may be singular or plural, and C may be singular or plural.
[0330] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0331] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0332] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0333] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0334] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0335] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage media include: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM), random access memories (RAM), magnetic disks or optical disks.
[0336] The same or similar parts between the various embodiments in this application can refer to each other. In the various embodiments in this application, and the various implementation methods / implementation methods / implementation methods in each embodiment, if there is no special explanation and logical conflict, the terms and / or descriptions between different embodiments and the various implementation methods / implementation methods / implementation methods in each embodiment are consistent and can be referenced to each other. The technical features in different embodiments and the various implementation methods / implementation methods / implementation methods in each embodiment can be combined to form new embodiments, implementation methods, implementation methods, or implementation methods according to their inherent logical relationships. The above-described implementation methods of this application do not constitute a limitation on the scope of protection of this application.
[0337] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims. In short, the above is only a preferred embodiment of the technical solution of the present application, and is not used to limit the protection scope of the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.
Claims
1. A GIF generation method, characterized in that: include: Displaying a first interface, including at least one image material, wherein the image material includes a video and / or a photo; In response to a first operation of the user on the at least one image material, performing frame extraction processing on at least part of N image frames included in the at least one image material to obtain M image frames, where N is an integer greater than 1, M is an integer greater than or equal to 1, and M is less than N, and the N image frames are image frames generated after the at least one image material is decoded; Generate a GIF based on the M image frames; The second interface is displayed, including the GIF.
2. The method according to claim 1, characterized in that The step of performing frame extraction processing on at least part of the N image frames included in the at least one image material to obtain M image frames includes: Determining a total number of the N image frames included in the at least one image material; Based on the total number of frames, at least part of the N image frames are subjected to frame extraction processing to obtain the M image frames.
3. The method according to claim 2, characterized in that The step of performing frame extraction processing on at least part of the N image frames based on the total number of frames to obtain the M image frames includes: Based on the total number of frames, at least part of the N image frames are subjected to frame extraction processing at a preset frame interval to obtain the M image frames.
4. The method according to claim 2, characterized in that: The step of performing frame extraction processing on at least part of the N image frames based on the total number of frames to obtain the M image frames includes: At least part of the N image frames are randomly sampled based on the total number of frames to obtain the M image frames.
5. The method according to any one of claims 2 to 4, characterized in that: The image material includes a video; and determining the total number of the N image frames included in the at least one image material includes: Obtaining a frame rate of each video segment in the at least one image material and a playback duration of each video segment; The total number of the N image frames is determined according to the frame rates of the respective video segments and the playing durations of the respective video segments.
6. The method according to any one of claims 2 to 4, characterized in that: The image material includes a video and a photo; and the determining the total number of the N image frames included in the at least one image material includes: Obtaining the frame rate of each video segment in the at least one image material, the playing time of each video segment, and the number of each photo; The total number of the N image frames is determined according to the frame rate of each video segment, the playing time of each video segment and the number of each photo.
7. The method according to any one of claims 2 to 4, characterized in that: The image material includes a photo; and determining the total number of the N image frames included in the at least one image material includes: Obtaining the number of each photo in the at least one image material; The total number of the N image frames is determined according to the number of the photos.
8. The method according to any one of claims 1 to 7, characterized in that: In response to the first operation of the user on the at least one image material, performing frame extraction processing on at least part of the N image frames included in the at least one image material to obtain M image frames, including: In response to the first operation of the user on the at least one image material, editing the at least one image material to obtain N rendered image frames, wherein the editing process includes one or more of adding a filter process, a cropping process, adding a text process, adding a transition information process, and adding a subtitle process; A frame extraction process is performed on at least a portion of the N rendered image frames to obtain M image frames.
9. The method according to any one of claims 1 to 7, characterized in that: After performing frame extraction processing on at least part of the N image frames included in the at least one image material in response to the user's first operation on the at least one image material to obtain M image frames, the method further includes: Performing editing processing on the M image frames to obtain M rendered image frames, wherein the editing processing includes one or more of adding filter processing, cropping processing, adding text processing, adding transition information processing, and adding subtitle processing; and; The generating of GIF based on the M image frames comprises: A GIF is generated based on the rendered image frames of the M frames.
10. An electronic device, characterized in that: include: one or more processors; one or more memories; The one or more memories store one or more computer programs, and the one or more computer programs include instructions, which, when executed by the one or more processors, enable the electronic device to perform the method as claimed in any one of claims 1 to 9.
11. A computer-readable storage medium, characterized in that: The method comprises computer instructions, which, when executed on an electronic device, cause the electronic device to execute the method as claimed in any one of claims 1 to 9.
12. A chip, characterized in that: The chip comprises: A memory for storing instructions; A processor, configured to call and execute the instructions from the memory, so that an electronic device equipped with the chip executes the method as claimed in any one of claims 1 to 9.