Shooting method and electronic equipment

By keeping the encoder in the electronic device continuously encoding and providing encoding to multiple mixers, the problem of the electronic device being unable to continuously capture dynamic images is solved, realizing efficient continuous shooting of dynamic images, improving user experience and saving resources.

CN119052628APending Publication Date: 2024-11-29HONOR DEVICE CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202310623035.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-05-29
Publication Date
2024-11-29

Smart Images

  • Figure CN119052628A_ABST
    Figure CN119052628A_ABST
Patent Text Reader

Abstract

A shooting method and an electronic device, the method being applied to the electronic device, the method comprising: in response to a first operation acting on a shooting control, starting a first video encoder; encoding the first video frame through a first video encoder; in the process of encoding the first video frame by the first video encoder, in response to a second operation acting on the shooting control, encoding a second video frame by the first video encoder; generating a first dynamic image, wherein the first dynamic image corresponds to the first video frame; generating a second dynamic image, wherein the second dynamic image corresponds to the second video frame; and controlling the first video encoder to stop encoding. The embodiment of the invention is used for realizing continuous shooting of dynamic images, improving the coding efficiency and saving processing and storage resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of terminal technology, and in particular to a shooting method and electronic equipment. Background Art

[0002] When an electronic device is taking photos, the user can click to take photos multiple times in a row, and the electronic device can take multiple frames of images continuously. The electronic device takes dynamic images (referred to as "gifs"), and each gif taken includes a short period of video. Therefore, if the user takes photos multiple times in a short period of time, and the electronic device receives a new shooting request while the previous shooting request is being processed, the electronic device cannot respond to the new shooting request and cannot achieve continuous shooting of dynamic images. The above will result in the electronic device being unable to take multiple gifs in a short period of time like taking photos, and the user's shooting experience is poor. Summary of the invention

[0003] The embodiments of the present application provide a shooting method and an electronic device for realizing a dynamic image continuous shooting function in a short period of time, improving encoding efficiency, and saving processing resources.

[0004] In a first aspect, an embodiment of the present application provides a shooting method, which is applied to an electronic device, comprising: starting a first video encoder in response to a first operation applied to a shooting control; encoding a first video frame through the first video encoder; during the process of encoding the first video frame by the first video encoder, encoding a second video frame through the first video encoder in response to a second operation applied to the shooting control; generating a first dynamic image, the first dynamic image corresponding to the first video frame; generating a second dynamic image, the second dynamic image corresponding to the second video frame; and controlling the first video encoder to stop encoding.

[0005] Among them, the first video frame and the second video frame are both images to be encoded. The first video frame and the second video frame may include multiple frames of images to be encoded. The images to be encoded in the first video frame and the second video frame are not repeated. The first dynamic image includes all the images to be encoded in the first video frame, and the first dynamic image also includes part of the second video frame. The second dynamic image includes all the second video frames, and the second dynamic image may also include part of the first video frame. That is, it can be understood that the images to be encoded used to generate the first dynamic image and the second dynamic image may be partially repeated. The first operation reference Figure 1C The relevant description of S801 is omitted here. Figure 1F The first video encoder may refer to Figure 6A to Figure 6D ,as well as Figures 8A to 8DThe first video encoder can obtain the first video frame and the second video frame from the first video cache queue.

[0006] In an embodiment of the present application, when multiple requests for shooting dynamic images are received continuously, the electronic device can keep a group of encoders from stopping encoding, provide encoding to multiple mixers, and stop encoding after the videos of all dynamic images are synthesized. This can enable a scene in which users can shoot dynamic images continuously, thereby improving the user's shooting experience.

[0007] In a possible implementation, after controlling the first video encoder to stop encoding, the method further includes: in response to a third operation acting on the shooting control, starting the second video encoder; encoding the third video frame through the second video encoder; generating a third dynamic image, the third dynamic image corresponding to the third video frame; after generating the third dynamic image, controlling the second video encoder to stop encoding; in response to a fourth operation acting on the shooting control, starting the third video encoder; encoding the fourth video frame through the third video encoder; generating a fourth dynamic image, the fourth dynamic image corresponding to the fourth video frame. In this way, the electronic device can also realize the process of dynamic image shooting in a single shot of the user.

[0008] The third video frame and the fourth video frame are also images to be encoded. The third video frame and the fourth video frame may include multiple frames of images to be encoded. The first video frame, the second video frame, the third video frame and the fourth video frame do not have the same image frame. The third video encoder and the fourth video encoder refer to different video encoders started by the electronic device at different time periods.

[0009] In a possible implementation, before the electronic device controls the first video encoder to stop encoding, the method further includes: in response to the first operation, adding a first shooting task to the task list; in response to the second operation, adding a second shooting task to the task list; in the case of generating the first dynamic image: clearing the first shooting task, and in the case of tasks in the task list, controlling the first encoder to continue encoding; in the case of generating the second dynamic image: clearing the second shooting task, and in the case of no tasks in the task list, controlling the first video encoder to stop encoding. In this way, the stop of the encoder needs to be determined by the task status in the task list, ensuring that there is a shooting request, encoding is not stopped, and the encoded image is submitted to the mixer, so that the continuous shooting process of the dynamic image can be realized.

[0010] The task list can be found in Fig. 9A and Fig. 9BThe situation of the above, and the description of the related steps S649, S877 and S880 are not repeated. Generating the first dynamic image may refer to the process of receiving the first video mixing completion notification in S876. Similarly, generating the second dynamic image may refer to the process of receiving the second video mixing completion notification in S879.

[0011] In a possible implementation, before the electronic device controls the second video encoder to stop encoding, the method further includes: in response to the third operation, adding a third shooting task to the task list; in the case of generating the third dynamic image, clearing the third shooting task; in the case of no task in the task list, controlling the third video encoder to stop encoding. In this way, the stop of the encoder needs to be determined by the task status in the task list, ensuring that there is a shooting request, encoding is not stopped, and the encoded image is submitted to the mixer, so that the continuous shooting process of the dynamic image can be realized.

[0012] The above description may refer to S649, and generating the third dynamic image may refer to the process of receiving the first video mixing completion notification in S648.

[0013] In a possible implementation, after the electronic device generates the first dynamic image, the method further includes: in response to an operation on starting the gallery, displaying a second user interface; the second user interface includes a first thumbnail of a first static image of the first dynamic image; in response to an operation on the first thumbnail, displaying a third user interface, the third user interface includes the first static image; in response to an operation on the first static image, the electronic device plays the first dynamic image. In this way, the electronic device completes shooting, and the user can click to play the dynamic image.

[0014] The operation of starting the gallery can be referred to Figure 1H For the description of the second user interface, please refer to Fig. 1I or Figure 1J , the second user interface can refer to Figure 1E The description of (a) in FIG. 1 is omitted here.

[0015] In a possible implementation, the first dynamic image includes the first static image and a first video, the first video includes M frames of static images, and M is an integer greater than 1.

[0016] There is a corresponding relationship between the M static image frames and the video frames included in the first dynamic image.

[0017] In a possible implementation, the method further includes: in response to the first operation, starting a first audio encoder; encoding a first audio frame through the first audio encoder, and the first dynamic image corresponds to the first audio frame; in the process of encoding the first audio frame by the first audio encoder, in response to the second operation, encoding a second audio frame through the first audio encoder, and the second dynamic image corresponds to the second audio frame. In this way, the audio encoder, upon receiving a new shooting request, continues to encode, ensuring that multiple shots are completed through one encoding, ensuring multiple continuous shooting, and improving user experience.

[0018] The first audio frame and the second audio frame are both audio to be encoded. The first audio frame and the second audio frame may include multiple frames of audio to be encoded. The audio in the first audio frame and the second audio frame are not repeated. The first dynamic image includes all the audio in the first audio frame and part of the audio in the second audio frame. The second dynamic image includes all the audio in the second audio frame and part of the audio in the first audio frame.

[0019] In a possible implementation, the generating of the first dynamic image includes: mixing the first coded video frame and the first audio code video frame by a first mixer to generate the first dynamic image, the first coded video frame is obtained after the first video encoder encodes the first video frame, and the first coded audio frame is obtained after the first audio encoder encodes the first audio frame; the generating of the second dynamic image includes: mixing the second coded video frame and the second audio code video frame by a second mixer to generate the second dynamic image, the second coded video frame is obtained after the first video encoder encodes the second video frame, and the second coded audio frame is obtained after the second audio encoder encodes the second audio frame. In this way, the electronic device can start two mixers and consume the encoding results of one encoder, while realizing the continuous shooting of dynamic images, reducing the number of encoder startups, improving processing efficiency, saving processing resources, and thus preventing the jamming caused by the continuous shooting of dynamic images.

[0020] The first coded video frame and the second coded video frame may both include multiple frames of coded images. There may be partially repeated coded images in the first coded video frame and the second coded video frame.

[0021] In a possible implementation, after the electronic device generates the first dynamic image and the second dynamic image, the method further includes: controlling the first video encoder to stop encoding, and controlling the first audio encoder to stop encoding. In this way, after the two dynamic images taken continuously are obtained, the electronic device can determine to end encoding, ensuring that the encoding can be provided to the two mixers at the same time, thereby ensuring the feasibility of continuous shooting.

[0022] In a possible implementation, the method further includes: in response to an operation for starting the camera, acquiring the first video frame through the camera; storing the first video frame in a first video cache queue; after the first video encoder encodes the first video frame to obtain the first encoded video frame, storing the first encoded video frame in a second video cache queue. In this way, the problem of one-time mixed consumption can be solved through the second video cache queue, and input data can also be provided for the mixer that is started later, ensuring the feasibility of one-way encoding and multi-way mixing. Similarly, it also breaks the original problem boundary, improves encoding efficiency, saves processing resources and storage resources, ensures program security, and reduces problems such as jamming.

[0023] In a possible implementation, the method further includes: in response to an operation for starting the camera, acquiring the first audio frame through a microphone; storing the first audio frame in a first audio cache queue; and after the first audio encoder encodes the first audio frame to obtain the first encoded audio frame, storing the first encoded audio frame in a second audio cache queue. In this way, the problem of one-time mixed consumption can be solved through the second video cache queue, and input data can also be provided for the mixer that is started later, ensuring the feasibility of one-way encoding and multi-way mixing. Similarly, it also breaks the original problem boundaries, improves encoding efficiency, saves processing resources and storage resources, ensures program security, and reduces problems such as freezes.

[0024] In a possible implementation, the method further includes: in response to an operation on the dynamic mode control, creating the first video cache queue, creating the second video cache queue, creating the first audio cache queue, and creating the second audio cache queue. In this way, during the streaming process, the electronic device can queue the data before and after encoding to ensure that the mixer can obtain the encoded image a period of time before shooting.

[0025] In a possible implementation, the first video cache queue is stored in the hardware abstraction layer HAL of the electronic device, and the second video cache queue, the first audio cache queue, and the second audio cache queue are stored in the application layer of the electronic device. In this way, due to the limitation of application memory, the YUV image is cached in the HAL, which reduces the pressure of the application layer, and the YUV image quality is better, ensuring better encoding effect and better dynamic image effect.

[0026] In a possible implementation, the method further includes: determining the first time by a first mixer based on the shooting time of the first operation and the specific video duration; mixing the i-th frame of coded image into the first dynamic image by the first mixer when the first time difference between the timestamp of the i-th frame of coded image and the timestamp of the first frame of coded image is less than or equal to the first time, the i-th frame of coded image is a coded video frame in the second video cache queue; and controlling the first mixer to end mixing when the first time difference between the timestamp of the i-th frame of coded image and the timestamp of the first frame of coded image is greater than the first time. In this way, the mixer can determine when mixing ends to ensure the validity of the mixed video.

[0027] The shooting time of the first operation may be Y. For the first time, reference may be made to the relevant descriptions of S625 and S825, which will not be described in detail.

[0028] In a possible implementation, the method further includes: determining a second time based on the shooting time and the specific video duration by the first mixer; and selecting a frame of coded video with a timestamp closest to the second time from the second video cache queue by the first mixer as the first frame of coded image. In this way, the duration of the animated image that can be produced by the electronic device is sufficient, ensuring the shooting effect.

[0029] The shooting time of the first operation may be Y, and the second time may refer to the related description of S625 and S825, which will not be described in detail. The first frame of the coded image is the first frame of the coded image mixed by the mixer 1 .

[0030] In one possible implementation, the method further includes: creating the first video encoder and the first audio encoder in response to an operation on the dynamic mode control.

[0031] In a possible implementation, the method further includes: in response to an operation for exiting the camera, releasing the first video encoder and the first audio encoder.

[0032] In a possible implementation, the method further includes: in response to an operation for starting the camera, displaying a first user interface, the first user interface displaying an image acquired by the camera, the first user interface including a dynamic mode control in a closed state; in response to an operation for starting the camera, the dynamic mode control is switched to an open state. Figure 1A , the first user interface, and the user can refer to Figure 1B , dynamic mode controls are Figure 1B Dynamic mode switch 111 in. Dynamic mode control is switched to the on state. Figure 1C.

[0033] In a second aspect, an embodiment of the present application provides an electronic device, including: a touch screen, a camera, one or more processors, and one or more memories; the one or more processors are coupled to the touch screen, the camera, and the one or more memories, and the one or more memories are used to store computer program codes, and the computer program codes include computer instructions. When the one or more processors execute the computer instructions, the electronic device executes:

[0034] In response to a first operation applied to a shooting control, a first video encoder is started; a first video frame is encoded by the first video encoder; during the process of encoding the first video frame by the first video encoder, in response to a second operation applied to the shooting control, a second video frame is encoded by the first video encoder; a first dynamic image is generated, the first dynamic image corresponds to the first video frame; a second dynamic image is generated, the second dynamic image corresponds to the second video frame; and the first video encoder is controlled to stop encoding.

[0035] Among them, the first video frame and the second video frame are both images to be encoded. The first video frame and the second video frame may include multiple frames of images to be encoded. The images to be encoded in the first video frame and the second video frame are not repeated. The first dynamic image includes all the images to be encoded in the first video frame, and the first dynamic image also includes part of the second video frame. The second dynamic image includes all the second video frames, and the second dynamic image may also include part of the first video frame. That is, it can be understood that the images to be encoded used to generate the first dynamic image and the second dynamic image may be partially repeated. The first operation reference Figure 1C The relevant description of S801 is omitted here. Figure 1F The first video encoder may refer to Figure 6A to Figure 6D ,as well as Figures 8A to 8D The video encoder in .

[0036] In an embodiment of the present application, when multiple requests for shooting dynamic images are received continuously, the electronic device can keep a group of encoders from stopping encoding, provide encoding to multiple mixers, and stop encoding after the videos of all dynamic images are synthesized. This can enable a scene in which users can shoot dynamic images continuously, thereby improving the user's shooting experience.

[0037] In a possible implementation, after controlling the first video encoder to stop encoding, the electronic device further performs: in response to a third operation acting on the shooting control, starting the second video encoder; encoding the third video frame through the second video encoder; generating a third dynamic image, the third dynamic image corresponding to the third video frame; after generating the third dynamic image, controlling the second video encoder to stop encoding; in response to a fourth operation acting on the shooting control, starting the third video encoder; encoding the fourth video frame through the third video encoder; generating a fourth dynamic image, the fourth dynamic image corresponding to the fourth video frame. In this way, the electronic device can also realize the process of dynamic image shooting in a single shot of the user.

[0038] The third video frame and the fourth video frame are also images to be encoded. The third video frame and the fourth video frame may include multiple frames of images to be encoded. The first video frame, the second video frame, the third video frame and the fourth video frame do not have the same image frame.

[0039] In a possible implementation, before the electronic device controls the first video encoder to stop encoding, the electronic device also performs: in response to the first operation, adding the first shooting task to the task list; in response to the second operation, adding the second shooting task to the task list; in the case of generating the first dynamic image: clearing the first shooting task, and in the case of tasks in the task list, controlling the first encoder to continue encoding; in the case of generating the second dynamic image: clearing the second shooting task, and in the case of no tasks in the task list, controlling the first video encoder to stop encoding. In this way, the stop of the encoder needs to be determined by the task status in the task list, ensuring that there is a shooting request, encoding is not stopped, and the encoded image is submitted to the mixer, so that the continuous shooting process of the dynamic image can be realized.

[0040] The task list can be found in Fig. 9A and Fig. 9B The situation of the above, and the description of the related steps S649, S877 and S880 are not repeated. Generating the first dynamic image may refer to the process of receiving the first video mixing completion notification in S876. Similarly, generating the second dynamic image may refer to the process of receiving the second video mixing completion notification in S879.

[0041] In a possible implementation, before the electronic device controls the second video encoder to stop encoding, the electronic device further performs: in response to the third operation, adding a third shooting task to the task list; in the case of generating the third dynamic image, clearing the third shooting task; in the case of no task in the task list, controlling the third video encoder to stop encoding. In this way, the stop of the encoder needs to be determined by the task status in the task list, ensuring that there is a shooting request, encoding is not stopped, and the encoded image is submitted to the mixer, so that the continuous shooting process of the dynamic image can be realized.

[0042] The above description may refer to S649, and generating the third dynamic image may refer to the process of receiving the first video mixing completion notification in S648.

[0043] In a possible implementation, after the electronic device generates the first dynamic image, the electronic device further performs: in response to an operation on starting the gallery, displaying a second user interface; the second user interface includes a first thumbnail of a first static image of the first dynamic image; in response to an operation on the first thumbnail, displaying a third user interface, the third user interface includes the first static image; in response to an operation on the first static image, the electronic device plays the first dynamic image. In this way, the electronic device completes shooting, and the user can click to play the dynamic image.

[0044] The operation of starting the gallery can be referred to Figure 1H For the description of the second user interface, please refer to Fig. 1I or Figure 1J , the second user interface can refer to Figure 1E The description of (a) in FIG. 1 is omitted here.

[0045] In a possible implementation, the first dynamic image includes the first static image and a first video, the first video includes M frames of static images, and M is an integer greater than 1.

[0046] There is a corresponding relationship between the M static image frames and the video frames included in the first dynamic image.

[0047] In a possible implementation, the electronic device further performs: in response to the first operation, starting the first audio encoder; encoding the first audio frame through the first audio encoder, and the first dynamic image corresponds to the first audio frame; in the process of encoding the first audio frame by the first audio encoder, in response to the second operation, encoding the second audio frame through the first audio encoder, and the second dynamic image corresponds to the second audio frame. In this way, the audio encoder continues encoding upon receiving a new shooting request, ensuring that multiple shooting controls are encoded all the way, ensuring multiple continuous shooting, and improving user experience.

[0048] The first audio frame and the second audio frame are both audio to be encoded. The first audio frame and the second audio frame may include multiple frames of audio to be encoded. The audio in the first audio frame and the second audio frame are not repeated. The first dynamic image includes all the audio in the first audio frame and part of the audio in the second audio frame. The second dynamic image includes all the audio in the second audio frame and part of the audio in the first audio frame.

[0049] In a possible implementation, the generating of the first dynamic image is specifically performed as follows: the first coded video frame and the first audio code video frame are mixed by the first mixer to generate the first dynamic image, the first coded video frame is obtained after the first video encoder encodes the first video frame, and the first coded audio frame is obtained after the first audio encoder encodes the first audio frame; the generating of the second dynamic image is specifically performed as follows: the second coded video frame and the second audio code video frame are mixed by the second mixer to generate the second dynamic image, the second coded video frame is obtained after the first video encoder encodes the second video frame, and the second coded audio frame is obtained after the second audio encoder encodes the second audio frame. In this way, the electronic device can start two mixers and consume the encoding results of one encoder, while realizing the continuous shooting of dynamic images, reducing the number of encoder startups, improving processing efficiency, saving processing resources, and thus preventing the jamming caused by the continuous shooting of dynamic images.

[0050] The first coded video frame and the second coded video frame may both include multiple frames of coded images. There may be partially repeated coded images in the first coded video frame and the second coded video frame.

[0051] In a possible implementation, after the electronic device generates the first dynamic image and the second dynamic image, the electronic device further executes: controlling the first video encoder to stop encoding, and controlling the first audio encoder to stop encoding. In this way, after the two dynamic images taken continuously are obtained, the electronic device can determine to end encoding, ensuring that the encoding can be provided to the two mixers at the same time, thereby ensuring the feasibility of continuous shooting.

[0052] In a possible implementation, the electronic device further performs: in response to an operation for starting the camera, acquiring the first video frame through the camera; storing the first video frame in a first video cache queue; after the first video encoder encodes the first video frame to obtain the first encoded video frame, the first encoded video frame is stored in a second video cache queue. In this way, the problem of one-time mixed consumption can be solved through the second video cache queue, and input data can also be provided for the mixer that is started later, ensuring the feasibility of one-way encoding and multi-way mixing. Similarly, it also breaks the original problem boundary, improves encoding efficiency, saves processing resources and storage resources, ensures program security, and reduces problems such as jamming.

[0053] In a possible implementation, the electronic device further performs: in response to an operation for starting the camera, acquiring the first audio frame through a microphone; storing the first audio frame in a first audio cache queue; and after the first audio encoder encodes the first audio frame to obtain the first encoded audio frame, storing the first encoded audio frame in a second audio cache queue. In this way, the problem of one-time mixed consumption can be solved through the second video cache queue, and input data can also be provided for the mixer that is started later, ensuring the feasibility of one-way encoding and multi-way mixing. Similarly, it also breaks the original problem boundaries, improves encoding efficiency, saves processing resources and storage resources, ensures program security, and reduces problems such as freezes.

[0054] In a possible implementation, the electronic device further executes: in response to the operation on the dynamic mode control, creating the first video cache queue, creating the second video cache queue, creating the first audio cache queue, and creating the second audio cache queue. In this way, during the process of streaming, the electronic device can queue the data before and after encoding to ensure that the mixer can obtain the encoded image a period of time before shooting.

[0055] In a possible implementation, the first video cache queue is stored in the hardware abstraction layer HAL of the electronic device, and the second video cache queue, the first audio cache queue, and the second audio cache queue are stored in the application layer of the electronic device. In this way, due to the limitation of application memory, the YUV image is cached in the HAL, which reduces the pressure of the application layer, and the YUV image quality is better, ensuring better encoding effect and better dynamic image effect.

[0056] In a possible implementation, the electronic device further performs: determining the first time based on the shooting time of the first operation and the specific video duration through the first mixer; mixing the i-th frame of coded image into the first dynamic image through the first mixer when the first time difference between the timestamp of the i-th frame of coded image and the timestamp of the first frame of coded image is less than or equal to the first time, the i-th frame of coded image is a coded video frame in the second video cache queue; and controlling the first mixer to end mixing when the first time difference between the timestamp of the i-th frame of coded image and the timestamp of the first frame of coded image is greater than the first time. In this way, the mixer can determine when mixing ends to ensure the validity of the mixed video.

[0057] The shooting time of the first operation may be Y. For the first time, reference may be made to the relevant descriptions of S625 and S825, which will not be described in detail.

[0058] In a possible implementation, the electronic device further executes: controlling the first mixer to determine a second time based on the shooting time and the specific video duration; and selecting, by the first mixer, a coded video frame whose timestamp is closest to the second time from the second video cache queue as the first coded image. In this way, the duration of the animated image that can be produced by the electronic device is sufficient, thereby ensuring the shooting effect.

[0059] The shooting time of the first operation may be Y, and the second time may refer to the related description of S625 and S825, which will not be described in detail. The first frame of the coded image is the first frame of the coded image mixed by the mixer 1 .

[0060] In a possible implementation, the electronic device further executes: in response to an operation acting on the dynamic mode control, creating the first video encoder and the first audio encoder.

[0061] In a possible implementation, the electronic device further executes: in response to an operation for exiting the camera, releasing the first video encoder and the first audio encoder.

[0062] In a possible implementation, the electronic device further performs: in response to an operation to start the camera, displaying a first user interface, wherein the first user interface displays an image acquired by the camera, the first user interface including a dynamic mode control in a closed state; in response to an operation to the dynamic mode control, the dynamic mode control switches to an open state.

[0063] The operation of starting the camera can be referred to Figure 1A , the first user interface, and the user can refer to Figure 1B , dynamic mode controls are Figure 1BDynamic mode switch 111 in. Dynamic mode control is switched to the on state. Figure 1C .

[0064] In a third aspect, an embodiment of the present application provides a chip system, which is applied to an electronic device, and the chip system includes one or more processors, which are used to call computer instructions to enable the electronic device to execute the shooting method described in the first aspect or any possible implementation method of the first aspect.

[0065] In a fourth aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when executed on an electronic device, enables the electronic device to execute the shooting method as described in the first aspect or any possible implementation of the first aspect.

[0066] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, comprising instructions, which, when executed on an electronic device, enable the electronic device to execute the shooting method as described in the first aspect or any possible implementation of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0067] Figure 1A to Figure 1J is a schematic diagram of a group of shooting scenes in dynamic mode provided in an embodiment of the present application;

[0068] Figure 2A to Figure 2D It is a schematic diagram of the data structure of a group of photos and videos in a continuous shooting scenario provided by an embodiment of the present application;

[0069] Figure 3 It is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;

[0070] Figure 4A It is a schematic diagram of the software and hardware structure of an electronic device provided in an embodiment of the present application;

[0071] Figure 4B It is a schematic diagram of the software and hardware structure of another electronic device provided in an embodiment of the present application;

[0072] Figure 5 It is a flowchart of a method for processing video data in a dynamic mode provided by an embodiment of the present application;

[0073] Figure 6A to Figure 6C It is a schematic diagram of a method flow of video processing in a dynamic mode provided by an embodiment of the present application;

[0074] Fig.6D It is a flowchart of a method for stopping video encoding provided by an embodiment of the present application;

[0075] Fig. 7Ais a schematic diagram of a format structure of a first file provided in an embodiment of the present application;

[0076] Figure 7B This is a schematic diagram provided in an embodiment of the present application, which is a schematic diagram of the packaging time of audio data and video data of video data;

[0077] Figure 8A to Figure 8C is a flowchart of another method for processing video data in a dynamic mode provided by an embodiment of the present application;

[0078] Fig.8D It is a flowchart of another method for stopping video encoding provided by an embodiment of the present application;

[0079] Fig. 9A and Fig. 9B It is a schematic diagram of a group of task queue changes provided by an embodiment of the present application;

[0080] Fig.10 It is a schematic diagram of hybrid coding of video in a dynamic image provided by an embodiment of the present application;

[0081] Figures 11A to 11E This is a schematic diagram of image frame production and consumption of a group of second video cache queues provided in an embodiment of the present application;

[0082] Fig. 12A This is a flowchart of a method for exiting shooting provided in an embodiment of the present application;

[0083] Fig. 12B It is a flowchart of another method for exiting shooting provided in an embodiment of the present application. DETAILED DESCRIPTION

[0084] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to be used as limitations to the present application. As used in the specification and appended claims of the present application, the singular expressions "one", "a kind of", "said", "above", "the" and "this" are intended to also include plural expressions, unless there is a clear indication to the contrary in the context. It should also be understood that the term "and / or" used in the present application refers to and includes any or all possible combinations of one or more listed items.

[0085] In one embodiment provided in the present application, a terminal device such as a mobile phone or a tablet computer with shooting and image processing functions (referred to as an electronic device, and the electronic device will be used to refer to the above terminal device in the following unified manner) can be in a shooting scene, and the user can shoot dynamic images, that is, photos with dynamic effects. The dynamic image (video data in a short time) can include videos and images in a short time. The electronic device can also save dynamic images, and the user can select images from dynamic multi-frame images. Among them, the video included in the dynamic image is a mixture of images captured by the camera and audio captured by the microphone.

[0086] A dynamic image refers to an image with dynamic effects. The dynamic effect can be reflected in the switching display of multiple static images according to preset rules, that is, video playback can produce dynamic effects; a static image is an image with a static picture. In an embodiment of the present application, a dynamic image may include a static image (i.e., a cover image) and a video (such as an MP4 file). Exemplarily, when an electronic device displays a dynamic image, it can display the cover of the dynamic image when no user operation is received, and display the video corresponding to the dynamic image when receiving a user operation (such as a long press operation). Among them, the cover image can be called a cover frame. Exemplarily, the cover image can have the same content as a frame of an image in a video, but a different resolution.

[0087] In the embodiments of the present application, the electronic device may not be limited to mobile phones and tablet computers. The electronic device may also be a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, and a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) device, a virtual reality (VR) device, an artificial intelligence (AI) device, a wearable device, a vehicle-mounted device, a smart home device and / or a smart city device. The embodiments of the present application do not impose any special restrictions on the specific type of the terminal.

[0088] The following introduces the application scenarios involved in the embodiments of the present application.

[0089] In daily life, people often use electronic devices such as smartphones and tablet computers to take photos. Figure 1A to Figure 1J This application exemplarily discloses a schematic diagram of a dynamic image shooting scene. The following describes the process of performing dynamic shooting in the preview state when the electronic device enters the dynamic mode.

[0090] Figure 1AThe user interface diagram of the electronic device is shown as an example. The user turns on his electronic device, so that the display screen of the electronic device displays the desktop of the electronic device, that is, the user interface 100. Figure 1A As shown, the user interface 100 may include at least one application icon (e.g., weather, calendar, mail, settings, app store, notes, gallery, phone, short message, browser, and camera (camera control 101), etc.). The positions of the application icons and the corresponding application names may be adjusted according to the user's preferences, which is not limited in this application.

[0091] It should be noted that Figure 1A The interface diagram of the electronic device shown is an exemplary display of an embodiment of the present application. The interface diagram of the electronic device may also be in other styles, and the present application does not limit this.

[0092] exist Figure 1A In the example, the user can click the camera control 101 in the user interface 100, and after the electronic device receives the operation acting on the camera control 101, it can display Figure 1B User interface 110 is shown. Figure 1B This is a shooting preview interface exemplarily shown in the embodiment of the present application. Figure 1B As shown, the user uses the electronic device to take a photo, that is, the electronic device is currently in the photo taking mode. In the user interface 110, the electronic device can display Figure 1B The specific controls or switches are described below:

[0093] The shooting mode menu 112 may include options for multiple camera modes such as portrait 1121, video 1122, photo 1123, night scene 1124, and more 1125. Different camera modes can achieve different shooting functions. The camera mode pointed to by the "triangle" in the shooting mode menu 112 is used to indicate the initial or user-selected camera mode, such as Figure 1B As shown, the “triangle” points to “photograph”, indicating that the current camera is in photo-taking mode.

[0094] The gallery 113 is used for users to view the pictures and videos they have taken.

[0095] The shooting control 114 is used to respond to the user's operation to enable the electronic device to shoot an image or record a video.

[0096] The camera switching control 115 is used to switch the camera for collecting images between the front camera and the rear camera.

[0097] The shooting function switch 116 may include a beauty switch 1161, an AI mode switch 1162, a flash switch 1163, a filter switch 1164, and a setting control 1165. Among them:

[0098] The beauty switch 1161 is used to turn on or off the beauty function.

[0099] The AI ​​mode switch 1162 is used to turn on or off the automatic recognition mode function.

[0100] The flash switch 1163 is used to turn on or off the flash.

[0101] The filter switch 1164 is used to turn the filter on or off.

[0102] The setting control 1165 is used to set various parameters when acquiring images.

[0103] In addition, the user interface 110 may also display a dynamic mode switch 111 for turning the dynamic mode on or off. When the dynamic mode is on, the user can take a dynamic picture by clicking the shooting control 114.

[0104] After the user opens the camera and enters the shooting preview interface, the dynamic mode can be turned on or off.

[0105] Optionally, the camera is turned on, the dynamic mode is off, and the user clicks to turn on the dynamic mode. Figure 1A In the user interface 100, the user clicks the camera control 101, and in response to the operation of opening the camera, the electronic device displays Figure 1B In the user interface 110 , the dynamic mode switch 111 is in an off state, and the user can click the dynamic mode switch 111 . In response to the operation of turning on the dynamic mode of the electronic device, the electronic device can display the user interface 120 . Figure 1C is a schematic diagram of a user interface for starting shooting in dynamic mode disclosed in an embodiment of the present application. Figure 1C As shown, in the user interface 120, the user can click the shooting control electronic device to shoot a dynamic image. Among them, the dynamic mode switch 121 is in the on state.

[0106] Optionally, open the camera with dynamic mode turned on. Figure 1A In the user interface 100, the user clicks the camera control 101, and in response to the operation of opening the camera, the electronic device displays Figure 1C In the user interface 120 , the dynamic mode switch 111 is in an on state, and the user can click the shooting control 114 to allow the electronic device to shoot dynamic images.

[0107] The user can click to view the dynamic images saved in the gallery. For example, if the user has taken a dynamic image, such as Figure 1DAs shown, in the user interface 130, the user can click on the gallery control. In response to the operation of opening the gallery, the electronic device can display the most recent animated image. Figure 1E As shown in (a), the electronic device in the user interface 140 can display a recently taken dynamic image, and when the user long presses the preview area 141, the electronic device can play the dynamic image. The user can process the current dynamic image, and the user interface 140 can display a dynamic image processing function 142. The dynamic image processing function 142 may include sharing, collecting, editing, deleting and more. The user interface 140 may also include an identifier 143A and a parameter 143B. The identifier 143A can be used to indicate that the image displayed on the current interface is a dynamic image; the parameter 143B can be used to display information such as the shooting parameters of the image displayed on the current interface. The above is only one way of viewing dynamic images. Users can also open the gallery on the desktop for viewing, and this application is not limited to this.

[0108] It should be noted that the above-mentioned dynamic mode switch pattern and position display are exemplary descriptions and are not limited in this application. Figure 1E The display interface of the electronic device for shooting animated images in (a) is also an exemplary display, and this application does not limit this.

[0109] Display on electronic devices Figure 1E In the case of (a), the electronic device can click the parameter 134B control, and in response to the above click operation, the electronic device can display the detailed parameter information of the picture. Figure 1E As shown in (b), the user interface 145 is newly provided with an information box 1451 compared with the user interface 140, and the information box 1451 is used to display the parameters of the HDR image (preview area 141). The name of the above image is IMG_20230527_111422, the resolution of the image displayed in the preview area 141 is 3072×4097, the data size of the image displayed in the preview area 141 is 13.53MB, and the storage path of the file of the above image is internal storage / DCIM / Camera / IMG_20230501_111422.jpg. The information in the above information box indicates that the above image is a jpg format image.

[0110] Display on electronic devices Figure 1E In the case of (a), the electronic device may click the edit control 142a, and in response to the operation of clicking the edit control 142a, the electronic device may display the image encoding interface. Figure 1EAs shown in (c) in the figure, in the user interface 146 (image encoding interface), the user can edit the above-mentioned moving picture. The user interface 146 may include a return control 1461, a picture display window 1462, a set as cover control 1463, a save as photo control 1464, a video image frame preview window 1465 and an image editing bar 1466. Among them, the video image frame preview window 1465 may include thumbnails of multiple consecutive frames of images in the video of the moving image. Among them, the picture display window 1462 displays the image corresponding to the thumbnail 1465a. Thumbnail 1465a may correspond to the cover frame of the current moving image. The image editing bar 1466 may include functions such as moving photos, cropping, graffiti and filters. In the user interface 146, the moving photo is in an open state, and the user can slide the video image frame preview window 1465 left and right to select a frame, and the image displayed in the picture display window 1462 will also change accordingly.

[0111] In the case where the user continuously shoots multiple dynamic images, the user clicks the shooting control 114 once and then clicks the shooting control again within a short period of time, and the electronic device cannot respond to the latter shooting operation to obtain dynamic images. At this time, if the gallery is opened, the electronic device only saves the dynamic image shot last time.

[0112] For example, Figure 1C As shown, after the user clicks the shooting control 114 for the first time, he immediately clicks it for the second time to shoot (assuming that the time difference between the first shooting and the second shooting is 0.7s.). Figure 1F As shown, in the user interface 150, the user clicks the capture control 114 for the second time. The electronic device has not yet processed the dynamic image captured by the first click. Therefore, when the electronic device is processing the dynamic image captured by the first click, it receives the second click. The electronic device does not have time to process the second dynamic image, and thus cannot capture the second dynamic image. The electronic device can display a preview screen that cannot respond. Figure 1G As shown, in response to the second click shooting operation, the electronic device cannot process the animated image shot by the second click, and the user interface 160 can display a loading buffer icon on the preview screen.

[0113] In the above process, since the electronic device cannot respond to the second click-to-shoot request, the electronic device cannot obtain two dynamic images. Figure 1H As shown, after the above two shots (no subsequent shots), in the user interface 170, the user can click the gallery control 171 ( Figure 1H For a detailed description, please refer to Figure 1A In response to the above operation of opening the gallery, the electronic device may display a user interface 180. Fig. 1IAs shown, in the gallery, the electronic device stores 100 photos and 10 videos, including the dynamic image 181 obtained by clicking the shooting control for the first time. The dynamic image of clicking the shooting control for the second time is not obtained (stored) in the gallery. In this way, the electronic device cannot respond to the user's second shooting operation to generate a dynamic image, resulting in a poor experience for the user to shoot dynamic images.

[0114] In view of the above situation that the dynamic image cannot be continuously captured, in the embodiment of the present application, Figure 1C and Figure 1F In the two shots in the video, the electronic device will not display the loading buffer icon for the second click, but will display the normal preview screen (such as Figure 1F ). After the above two shots, the electronic device can also open the gallery. Figure 1J As shown, the user interface 190 includes two dynamic images: dynamic image 191A and dynamic image 191B. The dynamic image 191A is obtained by the first click shooting, and the dynamic image 191B is obtained by the second click shooting. In this way, the electronic device can respond to the user's second continuous shooting to obtain a dynamic image, thereby improving the user's dynamic image shooting experience.

[0115] In the above two shooting processes, the second shooting is after the first shooting. In the preview screen, the ball slides down the slope over time. Therefore, the ball in the animated image 191A is located higher on the slope than the ball in the animated image 191B.

[0116] Electronic devices can enable users to shoot dynamic images with a single click. Figure 2A As shown, after the user clicks to shoot a dynamic image, in response to the user's click to shoot 1 operation (such as Figure 1C As shown), the electronic device may need to generate the video in the dynamic image. That is, the electronic device starts the video encoder, audio encoder and mixer. Among them, the video encoder, audio encoder and mixer can be started successively in response to the click to shoot 1 operation, and may not be started at the same time. The video encoder and audio encoder encode the image and audio respectively. The mixer mixes the encoded image and audio to obtain the video in the dynamic image. When the video is obtained, the video encoder, audio encoder and mixer can be stopped. For the case of a single click to shoot a dynamic image, the video encoder and audio encoder are only used for encoding processing of one video, so the encoding process can be realized. For the case of discontinuous multiple clicks to shoot a dynamic image, such as Figure 2A As shown, a first group of encoders (audio encoder 1 and video encoder 1) and a mixer 1 are created, and the electronic device can respond to the user clicking to shoot 1 ( Figure 1C), start this set of encoders (audio encoder 1 and video encoder 1) and this mixer, and after acquiring a dynamic image, stop audio encoder 1, video encoder 1 and mixer 1 and release them. Then the user can click ( Figure 1C ), in response to clicking shooting 2, the electronic device creates audio encoder 2, video encoder 2, mixer 2, and starts. After acquiring the second dynamic image, the audio encoder 2, video encoder 2, and mixer 2 can be stopped and released.

[0117] Of course, before starting the encoder, the electronic device can create the encoder, and after stopping the encoder, the electronic device can clear (release) the encoder.

[0118] When the user takes photos, since the image is acquired at a certain point in time (the time interval for acquiring images is extremely short), the user can perform continuous shooting operations, that is, continuously click the shooting control in a short period of time, and the electronic device can correspondingly acquire multiple frames of images. However, according to the continuous shooting method that the user is accustomed to, in the above dynamic (shooting) mode, the user cannot achieve continuous shooting by continuously clicking the shooting control.

[0119] like Figure 2B As shown, the user clicks to shoot for the first time (such as Figure 1C ), in response to the first click-to-shoot operation, the electronic device can start the video encoder, audio encoder and mixer to perform the encoding and mixing process. During the encoding and mixing process, the user clicks to shoot for the second time (such as Figure 1F ), in response to the second click to shoot operation, the electronic device should start the video encoder, audio encoder and mixer. For example, the video encoder and audio encoder need to perform encoding processing within 1.5s after the first click to shoot. 0.7s after the first click to shoot, the second click to shoot is received. At this time, the electronic device has not yet completed the processing of the first click to shoot, and has no time to process the second click to shoot. Specifically, the encoding of one video corresponds to a group of encoders. The encoding of the next video (the video that needs to be encoded for the first click to shoot) can only be started when the encoding of the previous video (the video that needs to be encoded for the first click to shoot) is stopped. Figure 2B In the case of the above, this set of encoders is in the process of running and cannot respond to the second click to start encoding request. Figure 2B As shown in the image in , since the second click to shoot cannot respond, the electronic device can shoot the preview interface to show the loading pattern (such as Figure 1G ), and electronic devices cannot obtain the animated images taken this time.

[0120] Figure 2BIn the encoding mixing process, the video encoder obtains the image to be encoded from the video cache queue 1 for encoding, the audio encoder obtains the audio to be encoded from the audio cache queue 1 for encoding, and the mixer obtains the encoded image and audio directly for mixing. In the mixing process, the mixer's input image is obtained from the output of the encoder, that is, when one frame of data is encoded, the mixer obtains one frame of data for mixing. The above process means that a group of encoders only provide encoding results to one mixer at the same time, that is, a group of encoders and a mixer are bound as a set.

[0121] In order to solve the above problems, Figure 2C In the scenario of continuously shooting dynamic images, the electronic device receives a shooting request and starts a group of encoders and a mixer. Figure 2B In the above process, the electronic device needs to start multiple sets of encoders and mixers (2, 3 or even more) in the same period, which is a great test for the processing resources of the electronic device and is prone to device freeze. Furthermore, Figure 2C In the example, the electronic device also has four cache queues, namely, video cache queue 1, audio cache queue 1, video cache queue 2, and video cache queue 2. This requires a large amount of storage resources of the electronic device at the same time. The tight storage resources will also cause the electronic device to freeze and respond slowly.

[0122] For resource scheduling and program security considerations, the Android system has a limit on the number of encoders in the business, and general electronic devices can only start one set of encoders. Therefore, the above solutions cannot solve the problem of dynamic video continuous shooting.

[0123] In view of the above problems, a shooting method is proposed in an embodiment of the present application. After the dynamic mode is started, when the user clicks to shoot a moving picture for the first time, the audio encoder, video encoder and mixer 1 are started. The audio encoder performs audio encoding, the video encoder performs image encoding, and mixer 1 mixes the encoded audio and the encoded image. During the above encoding and mixing process, the user clicks to shoot a moving picture for the second time, the electronic device starts mixer 2, and mixes the encoded data of the audio encoder and the video encoder. Mixers 1 and 2 can reuse part of the encoding results for mixing. After mixer 1 completes the mixing, since the encoding mixing of the second click to shoot is not completed, the audio encoder and video encoder continue to encode until mixer 2 completes the mixing, and the audio encoder, video encoder and mixer 2 can be stopped.

[0124] like Figure 2DAs shown, when the user clicks the shooting control for the first time, in response to the operation of the first click to shoot, the electronic device can start the video encoder, the audio encoder and the mixer 1. The electronic device can start encoding and mixing to generate a first video. While the video encoder and the audio encoder are encoding, the user clicks the shooting control for the second time. In response to the operation of the second click to shoot, the electronic device can start the mixer 2 to start mixing the encoding results of the video encoder and the audio encoder being encoded. When the video mixing of the animated image shot by the first click is completed, the mixer 1 stops, but the encoder does not stop, that is, the video encoder and the audio encoder continue to encode. When the video mixing of the second click to shoot is completed, the mixer 2 is stopped. If the electronic device does not receive the third click to shoot during the encoding process, it can be determined that all video mixing tasks requested by the shooting are completed, and the video encoder and the audio encoder are stopped. If the third click to shoot is received, the video encoder and the audio encoder continue to encode, and the process is the same as the second click to shoot, which will not be repeated.

[0125] In the above implementation, when multiple requests for shooting dynamic images are received continuously, the electronic device can keep a group of encoders from stopping encoding, provide encoding to multiple mixers, and stop encoding after the videos of all dynamic images are synthesized, thereby enabling the user to shoot dynamic images continuously and improving the user's shooting experience.

[0126] Furthermore, the generation of dynamic images requires the use of multiple frames of images acquired within a continuous period of time before and after the user clicks to shoot. Figure 2C In the case where a group of encoders provide encoded data to only one mixer, for example, Figure 2C Video encoder 1 obtains data encoding from video cache queue 1, and audio encoder 1 cache queue obtains data encoding from audio cache queue 1, and immediately sends the editing results to mixer 1 for consumption and mixing. After mixer 1 consumes, this frame of encoded data will not be stored any more. This consumption process is one-time, which makes it impossible to use multiple mixers at the same time to use the encoding results of the same group of encoders. For example, when the user clicks to shoot for the first time, the corresponding mixer 1 consumes the encoding result of the first frame and clears the encoding result data of the first frame. When the user clicks to shoot for the second time, the corresponding mixer 2 also needs to use the encoding result of the first frame, but since the data has been cleared, it cannot be used. Therefore, it is impossible for a group of encoders to provide encoding data to multiple mixers. Figure 2DAs shown, in an embodiment of the present application, the electronic device needs to add two cache queues: a second video cache queue and a second audio cache queue for storage. The encoding results of the video encoder and the audio encoder are stored by the second video cache queue and the second audio cache queue, respectively. The second video cache queue and the second audio cache queue store the encoded data within a time period. In this way, each mixer can distinguish the data that needs to be mixed from the second video cache queue and the second audio cache queue according to the time of the shooting request, thereby releasing the binding relationship between the mixer and a group of encoders. Therefore, it is possible to reduce the number of encoder startups and the processing process, save processing resources, and ensure the security of program operation.

[0127] It should be noted that the above Figure 2A to Figure 2D The encoder and mixer in the above-mentioned process can only be started at the same time, or they can be started successively after clicking to shoot. The encoder and mixer respond to the same shooting request, and the specific order of starting is not limited in this application. Of course, for the case where the encoder and mixer are stopped at the same time, there may also be a certain time sequence in the actual program execution process, which is also not limited. In the above process, when the animated picture is shot continuously, a new shooting request is received during the encoding process, and the electronic device can start another mixer. At this time, the two encoders can reuse the encoding results of the same group of encoders (as the input of the mixer). In this way, two videos can be mixed separately. After the mixing of the video shot by the previous click is completed, the mixer 1 can be stopped, and the encoder does not stop. After that, the encoding data of this group of encoders is consumed by the mixer 2 until the mixing is completed. In the case of mixing completion, if all click shooting tasks are completed (no new click shooting), the encoding is terminated and the encoder is stopped. In this way, it can be ensured that the encoder stops encoding only after the video mixing of all animated pictures is completed, ensuring the reliability of the encoder start and stop, providing reliable encoding results for the continuous shooting animated pictures, and ensuring the feasibility of the continuous shooting of animated pictures. Furthermore, it can also reduce the number of encoders started, reduce the occurrence of freezes in electronic devices, and ensure the security of resources and programs.

[0128] In addition, when shooting dynamic images continuously, the image only needs to be encoded once, and the video of each dynamic image is mixed separately to obtain the dynamic image of each shooting, ensuring the feasibility of the solution of shooting multiple dynamic images continuously. At the same time, it can also reduce the number of encoding times, improve execution efficiency, and save processing resources.

[0129] The following is an introduction to the device involved in the embodiments of the present application.

[0130] Figure 3 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application.

[0131] The electronic device may include a processor 310, an external memory interface 320, an internal memory 321, a Universal Serial Bus (USB) interface 330, a charging management module 340, a power management module 341, a battery 342, an antenna 1, an antenna 2, a mobile communication module 350, a wireless communication module 360, an audio module 370, a microphone 370C, a sensor module 380, a camera 393, and a display screen 394. The sensor module 380 may include a touch sensor 380K.

[0132] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer components than shown in the figure, or combine certain components, or split certain 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.

[0133] The processor 310 may include one or more processing units, for example: the processor 310 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 processor (NPU), etc. Among them, different processing units can be independent devices or integrated in one or more processors. Among them, the controller can be the nerve center and command center of the electronic device. The controller can generate an operation control signal according to the instruction opcode and the timing signal to complete the control of fetching and executing instructions. A memory can also be set in the processor 310 for storing instructions and data.

[0134] In the embodiment provided in the present application, the electronic device may execute the shooting method through the processor 310.

[0135] The internal memory 321 may be used to store computer executable program codes, which include instructions. The processor 310 executes the instructions stored in the internal memory 321 to perform various functional applications and data processing of the electronic device.

[0136] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Mobile communication module 350 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied in electronic devices. Wireless communication module 360 ​​can provide solutions for wireless communications 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 technology (IR), etc. applied in electronic devices.

[0137] The electronic device implements the display function through a GPU, a display screen 394, and an application processor. The GPU is a microprocessor for image processing, connecting the display screen 394 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 310 may include one or more GPUs that execute program instructions to generate or change display information.

[0138] The display screen 394 is used to display images, videos, etc. The display screen 394 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), Mini LED, Micro LED, Micro-OLED, quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device may include 1 or N display screens 394, where N is a positive integer greater than 1.

[0139] The electronic device can realize the acquisition function through an ISP, a camera 393, a video codec, a GPU, a display screen 394, and an application processor.

[0140] The ISP is used to process the data fed back by the camera 393. 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 the ISP for processing and converts it into an image or video visible to the naked eye. The ISP can also perform algorithm optimization on the noise, brightness, and color of the image. The ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, the ISP can be set in the camera 393.

[0141] The camera 393 is used to capture static 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 transmits the electrical signal to the ISP to be converted into a digital image or video signal. The ISP outputs the digital image or video signal to the DSP for processing. The DSP converts the digital image or video signal into an image or video signal in a standard RGB, YUV or other format. In some embodiments, the electronic device may include multiple cameras 393.

[0142] Video codecs are used to compress or decompress digital videos. Electronic devices can support one or more video codecs. In this way, electronic devices can play or record videos in multiple encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

[0143] The touch sensor 380K is also called a "touch panel". The touch sensor 380K can be set on the display screen 394, and the touch sensor 380K and the display screen 394 form a touch screen, also called a "touch screen". The touch sensor 380K is used to detect touch operations acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 394. In other embodiments, the touch sensor 380K can also be set on the surface of the electronic device, which is different from the position of the display screen 394.

[0144] It should be noted that Figure 3 The functions of other modules not mentioned in the electronic device shown can be referred to the relevant technical documents, and this application will not elaborate on them.

[0145] Figure 4A A schematic diagram of the software and hardware structure of an electronic device provided in an embodiment of the present application.

[0146] like Figure 4A As shown, the software framework of the electronic device involved in the present application may include an application layer, an application framework layer (framework, FWK), a system library, an Android runtime, a hardware abstraction layer (HAL) and a kernel layer (kernel).

[0147] The application layer may include a series of application packages, such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and other applications (also referred to as applications, some of which are not shown). The camera application may be used to obtain images and videos.

[0148] like Figure 4A As shown, the camera application may include a dynamic camera module, a static camera module, a video management module, an audio management module, an encoding control module, a data cache module, a mixing module and a storage module.

[0149] The modes of the camera may include, but are not limited to, dynamic mode, photo mode, video mode, portrait mode, night scene mode, etc. Among them, the mode may include a dynamic mode, in which the user can shoot dynamic images, and the dynamic images include audio and multiple frames of images. Both the dynamic photo module and the static photo module can be used to monitor user operations and determine the mode of the camera. The dynamic photo module can control encoding and mixing in the dynamic mode, and generate videos in the dynamic image; the static photo module can obtain images in the dynamic image in the dynamic mode, such as the cover frame in the dynamic image.

[0150] The video management module is used to manage video data. For example, the video data configuration information is sent. The video management module can include an area for caching video data. For example, Video-surface. Video-surface can be stored in the video acquisition module in the camera HAL to provide it to the video encoding module. The video management module can also configure the FWK path for dynamic image encoding, i.e., post camera.

[0151] The encoding control module may include a video encoding module and an audio encoding module. The video encoding module may control the video encoder to encode the image to be encoded. The audio encoding module may control the audio encoder to encode the audio to be encoded in the audio buffer module.

[0152] The data cache module includes an audio queue module and a video queue module, and the data cache module can cache the data encoded by the encoding control module. Among them, the audio queue module can cache the encoded audio output by the audio encoding module, and the video queue module can cache the encoded image output by the video encoding module.

[0153] The mixing module is used to encapsulate the coded image and the coded audio into video data, that is, encapsulate the coded audio data cached by the audio queue module and the coded video data cached by the video queue module to obtain the video. In the process of mixing to obtain a dynamic image, at the same time, the mixing module may include N mixers, where N is a positive integer. Fig. 6A and Figure 6B Where N is 1; Figure 8A to Figure 8C Where N is 2. Each mixer can be used to mix a video to obtain a dynamic image.

[0154] The storage module is used to store the dynamic image after the mixer mixes, that is, to store the video, image and related description information in the dynamic image. The storage module can control the memory to store.

[0155] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.

[0156] like Figure 4A As shown, the application framework layer may include camera FWK (framework layer), media FMK (framework layer), audio FWK (framework layer) and post camera. Camera FWK can provide API interface for application (e.g., camera application) to call, and then receive requests from the application, while maintaining the business logic of the request flowing internally, and finally send the request to the camera service (Camera Service) for processing by calling the camera AIDL cross-process interface, and then wait for the return of the camera service (Camera Service) result, and then send the final result to the camera application. Among them, AIDL is the full name of Android Interface Definition Language in English, and its Chinese meaning is Android Interface Definition Language. Similarly, media FWK can call the corresponding application (e.g., camera application) through API interface, and then receive requests from the application (e.g., camera application), pass the application request downward, and then pass it back to the application. Audio FWK can provide API interface for application to call, and the application can transmit audio or issue instructions (issue instructions to audio HAL) through audio FWK, etc.

[0157] The post camera can also provide an interface for the application to call. In dynamic mode, the video management module can configure the post camera. The post camera can be used as a new data channel to call the camera application, receive encoding requests from the dynamic shooting module and the video management module, and fill the video cache data in the camera HAL into the Video-surface through the post camera to pass it to the camera application. The video encoding module consumes the data to be encoded on the Video-surface, thereby forming a data channel. It can be understood that the application framework layer can also include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, etc. Its specific meaning can be referred to the relevant technical documents, which will not be explained in detail here.

[0158] The runtime is responsible for the scheduling and management of the system. The runtime includes the core library and the virtual machine. The core library contains two parts: one part is the function that the programming language (for example, Java language) needs to call, and the other part is the core library of the system.

[0159] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the programming files (e.g., 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.

[0160] The system library may include multiple functional modules, such as: Surface Manager, Media Libraries, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.

[0161] The surface manager is used to manage the display subsystem and provides the fusion of two-dimensional (2D) and three-dimensional (3D) layers for multiple applications.

[0162] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

[0163] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis and layer processing, etc.

[0164] A 2D graphics engine is a drawing engine for 2D drawings.

[0165] The hardware abstraction layer (HAL) is an interface layer located between the operating system kernel and the upper-level software, and its purpose is to abstract the hardware. The hardware abstraction layer is an abstract interface driven by the device kernel, which is used to implement the application programming interface that provides access to the underlying device to the higher-level Java API framework. HAL contains multiple library modules, such as camera HAL, audio HAL, display, Bluetooth, etc. Each of these library modules implements an interface for a specific type of hardware component. It can be understood that the camera HAL can provide an interface for the camera FWK and post camera to access hardware components such as the camera, and the camera HAL can include a video acquisition module and a video cache module. The video acquisition module is used to configure the video stream and manage the raw video data obtained from the camera. The video cache module can be used to store the processed raw image data obtained by the video acquisition module from the camera. The audio HAL can provide an interface for the audio FWK to access hardware components such as the microphone.

[0166] Assuming that the video cache module is in the application layer, the application cache has memory limitations, the cached YUV image data (image to be encoded) has a large amount of data, and the application layer can only compress the image, which will lead to poor video effects and pixel differences of dynamic images. In the embodiment of the present application, the camera HAL distributes and caches the image data, which can reduce the storage and processing burden of the application layer camera, improve the processing efficiency and running speed of the camera application, and can also use sufficient cache space to process the cached image to ensure the effect of the dynamic image.

[0167] The kernel layer is the foundation of the Android operating system, and the final functions of the Android operating system are completed through the kernel layer. The kernel layer at least includes display drivers, camera drivers, and audio drivers.

[0168] The hardware layer may include displays, microphones, cameras, memory, audio encoders, and video encoders, etc. The microphone collects raw audio data, the camera collects raw image data, and the memory can store video, image, and dynamic image files. The audio encoder is the hardware that performs audio encoding, and the video encoder is the hardware that performs video encoding.

[0169] It should be noted that the application provides Figure 4A The software structure diagram of the electronic device shown is only an example.

[0170] The specific module division in different layers of the Android operating system is not limited, and the specific reference can be made to the introduction of the Android operating system software structure in conventional technology. In addition, the shooting method provided in this application can also be implemented based on other operating systems, and this application will not cite examples one by one.

[0171] based on Figure 3 and Figure 4AThe hardware and software structure of the electronic device shown, Figure 4B is a schematic diagram of the software and hardware structure of another electronic device provided in an embodiment of the present application, combined with Figure 4B The basic processing logic in a shooting method provided in an embodiment of the present application is introduced from the perspective of software and hardware collaboration.

[0172] In response to the operation of opening the camera, the dynamic camera module starts the camera application and notifies the camera to start collecting images; when the dynamic mode is started, the dynamic camera module requests to create a first video cache queue (video cache module) in the camera HAL. The microphone is started to collect audio; and the first audio cache queue (audio cache module) is created in the camera application, and audio encoding is initialized to video encoding.

[0173] Step (1): Turn on the camera and configure the video stream in dynamic mode.

[0174] The dynamic camera mode can monitor user operations (or obtain the on and off status of the current dynamic mode), thereby determining that the current camera mode is the dynamic mode and notifying the video management module. Correspondingly, the video management module can create a Video-surface and send the distribution information of the video data to the post camera. After receiving the distribution information, the post camera can store the address of the Video-surface to generate an image reporting channel. Afterwards, the post camera can send the distribution information to the camera HAL, and the camera HAL will receive a successful distribution initialization message. The camera HAL processes and caches the raw image data collected by the camera. The camera HAL notifies the dynamic camera module of the message that the raw image data has been obtained through the camera FWK, which is used to trigger audio acquisition and video data configuration.

[0175] When the user clicks the shooting control to shoot a dynamic image, the collected audio and image are encoded and mixed to generate a video, and the video and image are packaged to obtain a dynamic image.

[0176] Step (2): Data flow of audio acquisition and encoding.

[0177] The audio HAL can obtain the original audio data collected by the microphone and upload it to the audio management module for caching (the first audio cache queue) through the audio FWK. The audio encoding module encodes the audio to be encoded in the first audio cache queue to obtain the encoded audio and cache it to the audio queue module (the second audio cache queue).

[0178] Step (3): Data flow of image acquisition and encoding.

[0179] In the camera HAL, the video acquisition module can process the raw image data collected by the camera and store it in the video cache module (first video cache queue) (for example, YUV image). The video cache module can also transmit the image data to the video encoding module through the post camera. The video encoding module encodes the image to be encoded, obtains the encoded image, and caches it in the video queue module (second video cache queue).

[0180] In the process of acquiring dynamic images, the original image (or image data processed by effects) collected by the camera needs to be encoded and processed to obtain the encoded image for packaging and storage. For example, the video encoder can compress the color space (luminance chrominance chroma, YUV) data collected by the Camera module into a video stream in MPEG-4 or advanced video coding (AVC) format, and the video stream is sent to the File Muxer module to be encapsulated into a video file that can be played by the player, such as 3gpp, mp4, H.264 and AAC, etc.

[0181] Step (4): Data flow of image acquisition in dynamic images.

[0182] The static shooting mode can monitor user operations (or obtain the user's operation of clicking the shooting control to shoot dynamic images), obtain images from the camera HAL through the camera FWK, and store this frame of image in the storage module.

[0183] Step (5): Mix the encoded image and audio into a video, and store the video.

[0184] Mixer 1 and mixer 2 can obtain the encoded data from the video queue module and the audio queue module respectively, and mix them respectively. During the execution of steps (2) and (3), mixer 1 and mixer 2 can respectively mix the encoded image and audio into a video and store it in the storage module. After the video and image are stored in the storage module, the video and image can be packaged to obtain a dynamic image, and the storage is updated. Two mixers correspond to two dynamic images. The stored dynamic images can be as follows Figure 1J .

[0185] In addition, when the dynamic camera module and the static camera module start the dynamic mode, the application layer configures the camera HAL. The dynamic camera module can send the first distribution parameter information to the video acquisition module. The first distribution parameter information may include the first width width1 and the first height height1 of the image. For example, width1*height1 is 1440*1080. The video acquisition module stores the first distribution parameter information, and the configuration is completed. After the configuration is completed, in the first video cache queue, the image size stored by the video cache module is width1*height1. The static camera module sends the second distribution parameter information to the camera HAL. The second distribution parameter information may include the second width width2 and the second height height2 of the image. For example, width2*height2 is 4000*8000. The camera HAL stores the second distribution parameter information. After the configuration is completed, the camera HAL obtains the large image of the first image and the second image in the dynamic image to meet the above-mentioned second width and second height.

[0186] Figure 4B For detailed description of each module in Figure 4A The relevant description is not repeated here.

[0187] Combine the following Figure 5 to Figure 12B The specific implementation of the above embodiment is described.

[0188] Figure 5 It is a flowchart of a method for processing video data in a dynamic mode provided in an embodiment of the present application.

[0189] It is understandable that the user can click the camera application icon (the user opens the camera). Correspondingly, the dynamic camera module monitors the user operation, determines that the camera is started, and sends a camera start message to the camera. The camera start message is used to request to start the camera. After the camera receives the camera start message, it starts the camera to collect images.

[0190] 1. Obtain original image data and original audio data, and configure video data (such as Figure 5 Steps S500-S526 shown)

[0191] S500: The dynamic photographing module receives a request to start a camera application.

[0192] It is understandable that the user can trigger the electronic device to start the camera application. Correspondingly, the dynamic camera module in the electronic device can receive the request to start the camera application.

[0193] For example, Figure 1AAs shown, the user can click the camera control 101, and accordingly, the electronic device can receive a request to start the camera application. In response to the operation of starting the camera application, the electronic device can start the camera application and display Figure 1B The user interface 110 is shown. It is understandable that the user can also start the camera application by voice, gesture, etc., and the present application does not limit the specific method in which the user triggers the electronic device to start the camera application.

[0194] S501: The dynamic photographing module sends a camera start message to the camera.

[0195] Correspondingly, the camera can receive a camera start message sent by the dynamic camera module. The camera start message is used to instruct the camera to start exposure and obtain raw image data.

[0196] S502: The camera starts and collects raw image data.

[0197] It is understandable that the camera can be started after receiving the camera start message sent by the dynamic camera module. After the camera is started, the original image data can be continuously collected. Specifically, the camera can collect the original image data at a first time interval. Each frame of the original image data includes the acquisition timestamp of the frame image and the frame image. For example, the camera is exposed once every 33ms to obtain a frame of original image.

[0198] S503: The camera sends raw image data to the video acquisition module.

[0199] It is understandable that the camera can send the collected raw image data to the camera HAL. The camera can send the raw image data to the video acquisition module. Correspondingly, the video acquisition module can receive the raw image data from the camera.

[0200] S504: The video acquisition module processes the original image data and sends the processed image data for display.

[0201] It is understood that when the camera application is in preview mode, the camera HAL (video acquisition module) can process the raw image data and send the processed image to the display screen for display. It is understood that the preview mode mentioned here can include a photo mode, a dynamic mode, etc.

[0202] S505: The dynamic camera module obtains a request to start the dynamic mode.

[0203] Optionally, when the camera starts the camera application, the dynamic mode is in the off state, and the user can trigger the dynamic mode to start. Accordingly, the dynamic camera module can receive a request to start the dynamic mode. Figure 1BAs shown, the user turns on the camera and the dynamic mode is off. The user can click the dynamic mode switch 111 (operation to start the dynamic mode) to turn on the dynamic mode. It is understandable that the user can also start the dynamic mode by voice, gesture, etc. This application does not limit the specific way in which the user triggers the electronic device to start the dynamic mode.

[0204] Optionally, when the camera starts the camera application, the dynamic mode is turned on, and the dynamic photography module can obtain a request to start the dynamic mode. Figure 1C As shown, when the user turns on the camera, the dynamic mode is already turned on in the shooting preview interface, and the user does not need to trigger the dynamic mode again.

[0205] S506: The dynamic photographing module sends an image data cache request to the video acquisition module through the camera FWK.

[0206] After the dynamic camera module acquires the dynamic mode, it can send an image data cache request to the video acquisition module. Correspondingly, the video acquisition module can receive the image data cache request from the dynamic camera module. The image data cache request is used to indicate that the processed image data is cached in preparation for video encoding.

[0207] Among them, there is no restriction on the execution order between S505 to S506 and S501 to S504.

[0208] S507: The video cache module creates a first video cache queue.

[0209] After the video acquisition module receives the image data cache request from the dynamic camera module, the video cache module can create a first video cache queue. Specifically, after the video acquisition module creates the first video cache queue, the processed image is stored in the first video cache queue. It can be YUV image data. For example, the first video cache queue may include 45 frames of image data. The video cache module stores the first video cache queue. The video acquisition module can determine the cache address and data size of the first video cache queue.

[0210] S508: The video cache module stores the processed image data in the first video cache queue.

[0211] After the video cache module completes creating the first video cache queue and processes the image data, the processed image data is stored in the first video cache queue.

[0212] S509: The video acquisition module sends an image acquisition notification to the dynamic photography module through the camera FWK.

[0213] When the video acquisition module stores each frame of image data in the first video cache queue, the video acquisition module sends an image acquisition notification of this frame to the dynamic photography module through the camera FWK. Correspondingly, the dynamic photography module can receive the image acquisition notification from the video acquisition module through the camera FWK.

[0214] S510: The dynamic photographing module determines a first frame image acquisition identifier based on the first received image acquisition notification.

[0215] After executing S505 and S506, the dynamic camera module can determine the first frame image acquisition identifier based on the image acquisition notification when receiving the image acquisition notification for the first time, that is, the dynamic camera module can determine that the video cache module of the current camera HAL has started to cache image data.

[0216] S511: The dynamic photographing module sends an audio collection message to the audio collection module.

[0217] The dynamic camera module can send an audio acquisition message to the audio acquisition module. Correspondingly, the audio acquisition module can receive an audio acquisition message from the dynamic camera module. The audio acquisition message is used to instruct the audio acquisition module to start collecting raw audio data, which can be pulse code modulation (PCM) data.

[0218] S512: The audio acquisition module creates a first audio buffer queue.

[0219] After the audio acquisition module receives the audio acquisition message from the dynamic camera module, it can create an audio cache queue. Specifically, the audio acquisition module creates an audio cache mode to cache multiple frames of original audio data. The audio acquisition module can determine the cache address and data size of the first audio and video cache queue. The first audio cache queue is used to cache audio data to be encoded. For example, the first audio cache queue may include 50 frames of audio data.

[0220] S513: The audio collection module sends a microphone start message to the microphone.

[0221] After the audio acquisition module receives the audio acquisition message from the dynamic camera module, it can send a microphone start message to the microphone. Correspondingly, the microphone can receive the microphone start message from the audio acquisition module. The microphone start message is used to start the microphone to collect raw audio data. The information transmission between the audio acquisition module and the microphone needs to be carried out through the audio FWK and audio HAL. For details, refer to Figure 4A The relevant description is not repeated here.

[0222] S514: The microphone is started and collects raw audio data.

[0223] After the microphone acquires the original audio data, it can start and collect the original audio data. Specifically, the microphone can collect the original audio data at a second time interval. For example, the microphone collects the original audio data every 22 ms.

[0224] S515: The microphone sends original audio data to the audio buffer module.

[0225] After the microphone collects the original audio data, it can send the original audio data to the audio buffer module through the audio HAL and the audio FWK. Correspondingly, the audio buffer module can receive the original audio data from the microphone.

[0226] S516: The audio cache module stores the original audio data in the first audio cache queue.

[0227] After creating the first audio cache queue, the audio cache module can store the received original audio data in the first audio cache queue.

[0228] S517~S520: Encoding initialization.

[0229] S517: The dynamic photographing module sends a video encoding initialization request to the video encoding module.

[0230] Correspondingly, the video encoding module receives a video encoding initialization request from the dynamic camera module.

[0231] S518: The video encoding module performs video encoding initialization.

[0232] After executing S517, the video encoding module may initialize video encoding, that is, configure the addresses of the video encoder and the video queue module to prepare for video encoding.

[0233] S519: The dynamic photographing module sends an audio encoding initialization request to the audio encoding module.

[0234] Correspondingly, the audio encoding module receives an audio encoding initialization request from the dynamic camera module.

[0235] S520: The audio encoding module performs audio encoding initialization.

[0236] After executing S519, the audio encoding module can initialize audio encoding, that is, configure the address of the audio encoder and the audio queue module to prepare for video encoding.

[0237] The execution order of S517 to S518 and S519 to S520 is not limited.

[0238] S521-S526: Encoded data stream allocation processing.

[0239] S521: The dynamic camera module sends a stream allocation notification to the video management module.

[0240] After obtaining the request to start the dynamic mode, the dynamic camera module can send a stream allocation notification to the video management module. Correspondingly, the video management module can receive the stream allocation notification from the dynamic camera module. The stream allocation notification is used to instruct the video management module to configure the data path for image encoding.

[0241] S522: The video management module creates a Video_surface buffer area.

[0242] The Video_surface buffer is the buffer of the video encoder. The video management module can create the Video_surface buffer and determine the storage address and storage space size of the Video_surface buffer. In the process of the video management module creating Video_surface, the encoding and streaming parameter information can be determined. The encoding and streaming parameter information can be related information of the surface.

[0243] S523: The video management module sends the encoding and streaming parameter information to the post camera.

[0244] After executing S522, the video management module may send the encoding and streaming parameter information to the post camera. Correspondingly, the post camera may receive the encoding and streaming parameter information from the video management module.

[0245] The encoding stream allocation parameter information is used for the configuration of the data path during the encoding process. The encoding stream allocation parameter information may include image width width, height height, format parameter Format, usage information usage and a first number number. Among them, the image width width and height height can determine the pixel size of the image; Format can determine that the format of the surface is the encoder format, such as 24; usage information usage indicates that the image is used for encoding; the first number number indicates the number of buffers (buffer areas) applied for the surface.

[0246] S524: post camera stream initialization.

[0247] The post camera initializes the stream distribution based on the encoding stream distribution parameter information. Specifically, based on the encoding stream distribution parameter information, Video_surface can create a buffer queue, the number of buffers in the buffer queue is the first number M, for example, 4, 8, etc.; each empty buffer can be filled with a frame of image width width and height height to be encoded; Video_surface is the encoder format. The buffer queue can be used for the subsequent transmission of the encoded data from the camera HAL to the camera application.

[0248] S525: The post camera sends a message indicating that the stream allocation initialization is successful to the video acquisition module.

[0249] Correspondingly, the video acquisition module can receive the stream allocation initialization success message from the post camera. The stream allocation initialization success message is used to notify the camera HAL that the stream allocation is successful.

[0250] After the post camera is created, the video management module can be notified that the new channel for dynamic image encoding is successfully configured. As a new channel, the post camera is different from the native camera FWK, and it needs to transmit the dynamic image encoding data separately. After the video management module receives the notification of successful channel configuration, it can prepare to start video encoding.

[0251] S526: The video acquisition module sends a notification of successful channel configuration to the video management module through the post camera.

[0252] After the video acquisition module confirms that the stream allocation is successful, the video acquisition module can send a notification of successful channel configuration to the post camera. Correspondingly, the video management module can receive a notification of successful channel configuration from the video acquisition module through the post camera. At this point, the video management module can confirm that the encoding and stream allocation is completed.

[0253] In the above process, the execution order of S506, S511, S517, S519 and S521 is not limited.

[0254] At this point, the electronic device has completed the process of obtaining audio and video data and the distribution of video data. In the above process, when the dynamic mode is started, the audio and video are cached to prepare for obtaining dynamic images in advance. The video encoding process is prepared in advance.

[0255] Second, video coding hybrid of single shot dynamic images (such as Fig. 6A Steps S601-S630 shown).

[0256] Fig. 6A It is a flowchart of a method for video encoding in dynamic mode provided in an embodiment of the present application.

[0257] When the electronic device enters the camera shooting preview screen and the dynamic mode is turned on, the user can click the shooting control on the interface. Correspondingly, the dynamic shooting module monitors the user operation and determines that the electronic device needs to record the first video. The following is an explanation of the encoding and mixing process of the first video in the dynamic image when the user only shoots a dynamic image once:

[0258] S601: The dynamic photographing module receives a photographing request.

[0259] When the electronic device starts the dynamic mode, the user triggers shooting, and the dynamic shooting module receives the shooting request. Specifically, the user can click the start shooting control ( Figure 1C ), and voice control can also be used for shooting. This application does not limit the action that triggers shooting. Generating dynamic images requires obtaining videos and images. The dynamic shooting mode is used to control the generation of videos, and the static shooting mode is used to control the acquisition of images. After that, the video and image are packaged accordingly to obtain a dynamic image.

[0260] S602-S611: Start video encoding. The electronic device encodes the to-be-encoded images in the first video cache queue to obtain a second video cache queue.

[0261] S602: The dynamic camera module sends a request to start image encoding to the video encoding module.

[0262] When the dynamic camera module receives the shooting request, it can send a start image encoding request to the video encoding module. Correspondingly, the video encoding module can receive the start image encoding request from the dynamic camera module. The start image encoding request is used to instruct the video encoding module to encode the original image data (stored in the video cache module).

[0263] S603: The video encoding module starts the video encoder.

[0264] When the video encoding module receives the image encoding start request from the dynamic camera module, the video encoder can be started. Specifically, the hardware of the electronic device may include a video encoder. At this time, the video encoding module can control the video encoder to start and prepare for encoding.

[0265] S604: The video encoding module sends an image data encoding start request to the video management module.

[0266] After the video encoding module starts the video encoder, it can send an image data start encoding request to the video management module. Correspondingly, the video management module can receive an image data start encoding request from the video encoding module. The image data start encoding request is used to request the video management module to start image encoding. When the video management module receives this request, the video encoder starts encoding.

[0267] S605-S611: After the video management module starts encoding, it enters a cyclic video encoding process, encoding one frame of image each time, until the video management module obtains the image data end encoding request and stops encoding.

[0268] S605: The video management module sends an image data encoding request to the video acquisition module through the post camera.

[0269] After the video management module receives the image data from the video encoding module to start the encoding request, it can send the image data encoding request to the video acquisition module through the post camera. Correspondingly, the video acquisition module can receive the image data encoding request from the video management module through the post camera. The image data encoding request is used to request the next frame of the image to be encoded stored in the video cache module for encoding.

[0270] Among them, the post camera is used to transmit the data to be encoded in the dynamic mode.

[0271] S606: The video buffer module obtains the nth frame of the image to be encoded.

[0272] When the video acquisition module receives an image data encoding request, the video buffer module needs to obtain the nth frame of the image to be encoded. The one frame of image data stored in the video buffer module is given to the video encoding module for encoding.

[0273] It should be noted that the video cache module stores an image queue with a first number of frames (the first number can be fixed and unchanged). For example, in this queue (first-in-first-out image queue), as the camera shoots, image frames are continuously added to the end of the queue. When the encoding starts, the first frame of the image to be encoded is selected as the frame at the head of the queue. During the encoding process, the next frame of the image to be encoded is selected as the frame after the last frame of the image to be encoded in the queue. That is, when the video acquisition module (entering the cyclic video encoding) receives the image data encoding request for the first time, the video acquisition module determines the frame of the image at the head of the first video cache queue in the video cache module as the next frame of image data; when the video acquisition module does not receive the image data encoding request for the first time, the video acquisition module determines the next frame of the image data of the last determined image in the first video cache queue as the next frame of image data this time, that is, the image to be encoded is taken out in sequence. At this time, the next frame of image data obtained are all processed original image data, that is, the data cached in S508. In addition, the process of obtaining the nth frame of image to be encoded can refer to Figures 11A to 11E The related exemplary descriptions are not repeated here.

[0274] S607: The video buffer module sends the nth frame of the image to be encoded to the video encoding module through the post camera.

[0275] After the video cache module obtains the nth frame to be encoded, the nth frame to be encoded can be sent to the video encoding module through the post camera (also called the post-processing camera). Correspondingly, the video encoding module can receive the nth frame to be encoded from the video cache module through the post camera.

[0276] At this time, the nth frame of the image to be encoded includes a frame of the image to be encoded and a corresponding timestamp. The timestamp can indicate the time point when the image information of this frame is captured.

[0277] S608: The video encoding module encodes the n-th frame of the image to be encoded to obtain the n-th frame of the encoded image.

[0278] When the video encoding module receives the n-th frame of the image to be encoded from the video buffer module, the video encoding module may encode the n-th frame of the image to be encoded to obtain the n-th frame of the encoded image.

[0279] S609: The video encoding module sends a request to the video management module to continue encoding the image data.

[0280] After the video encoding module completes encoding of the nth frame of the image to be encoded, it may send a request to the video management module to continue encoding the image data.

[0281] S610: The video encoding module sends the nth frame of encoded image to the video queue module.

[0282] After executing S608, the video encoding module can send the nth frame of encoded image to the video queue module. The nth frame of encoded image includes the encoded image data and a timestamp. The timestamp uses the timestamp of the corresponding frame before encoding, that is, the timestamp of shooting the frame.

[0283] S611: The video queue module caches the encoded image data.

[0284] After receiving the n-th frame of the encoded image, the video queue module may cache the n-th frame of the encoded image in the second video cache queue of the video queue module.

[0285] In the above process, the video cache module and the video queue module can both be a data cache queue. The video cache module caches the image data before encoding (first video cache queue), and the video queue module caches the image data after encoding (second video cache queue).

[0286] The video management module executes S604, starts encoding, and executes S605; then the video management module executes S609, and can continue to execute S605 in a loop. The video management module can stop encoding and end the loop until it receives a request to stop encoding the image data.

[0287] S612-S619: Start audio encoding. The electronic device encodes the audio to be encoded in the first audio cache queue to obtain a second audio cache queue.

[0288] S612: The dynamic photographing module sends a request to start audio encoding to the audio encoding module.

[0289] When the dynamic photographing module receives the shooting request, it can send a request to start audio encoding to the audio encoding module. Correspondingly, the audio encoding module can receive the request to start audio encoding from the dynamic photographing module.

[0290] S613: The audio encoding module starts the audio encoder.

[0291] After receiving the audio encoding start request, the audio encoding module may start the audio encoder. Specifically, the hardware of the electronic device may include an audio encoder, and at this time, the audio encoding module may control the audio encoder to start and prepare for encoding.

[0292] S614: The audio encoding module sends an audio data start encoding request to the audio buffer module.

[0293] After the audio encoding module starts the audio encoder, it can send an audio and video data start encoding request to the audio management module. Correspondingly, the audio management module can receive the audio and video data start encoding request from the audio encoding module. The audio and video data start encoding request is used to request the audio management module to start audio and video encoding.

[0294] S615-S619: After the audio encoding is started, a loop audio encoding process is entered, encoding one frame of audio each time in a loop until the audio buffer module obtains the audio data end encoding request and stops encoding.

[0295] S615: The audio buffer module sends the mth frame of audio to be encoded to the audio encoding module.

[0296] After receiving the audio and video data start encoding request from the audio encoding module, the audio buffer module can send the mth frame of audio to be encoded to the audio encoding module. Correspondingly, the audio encoding module can receive the mth frame of audio to be encoded from the audio buffer module.

[0297] When the audio cache module executes S615 after executing S614, the mth frame of audio to be encoded is sent to the audio encoding module as a frame of audio data at the head of the queue in the audio cache module. When the audio cache module executes S617 after executing S615, the mth frame of audio to be encoded is sent to the audio encoding module as a frame of audio data after the last audio sent in the queue, that is, it can be taken out frame by frame in the queue order.

[0298] The mth frame of audio to be encoded includes a frame of audio and an audio timestamp. The audio timestamp is used to indicate the time point of the acquisition of this frame of audio.

[0299] S616: The audio encoding module encodes the mth frame of audio to be encoded to obtain the mth audio to be encoded.

[0300] After receiving the mth frame of audio to be encoded from the audio buffer module, the audio encoding module may encode the mth frame of audio to be encoded to obtain the mth frame of encoded audio.

[0301] S617: The audio encoding module sends a request to the audio buffer module to continue encoding the audio data.

[0302] After obtaining the next frame of encoded audio data, the audio encoding module sends a request to the audio buffer module to continue encoding the audio data. Correspondingly, the audio buffer module can receive the request to continue encoding the audio data from the audio encoding module.

[0303] S618: The audio encoding module sends the mth frame of encoded audio to the audio queue module.

[0304] After the audio encoding module obtains the mth frame of encoded audio, it can send the mth frame of encoded audio to the audio queue module. Correspondingly, the audio queue module can receive the mth frame of encoded audio from the audio encoding module.

[0305] The mth frame of coded audio may include a frame of coded audio and an audio timestamp. The audio timestamp may continue to use the audio timestamp before encoding.

[0306] S619: The audio queue module caches the encoded audio data.

[0307] The audio queue module can cache the m-th frame encoded audio in the second audio cache queue of the audio queue module.

[0308] In the above process, the audio cache module and the audio queue module can both be a data cache queue. The audio cache module caches the audio data before encoding (first audio cache queue), and the audio queue module caches the audio data after encoding (second audio cache queue).

[0309] The audio cache module executes S614, starts encoding, and executes S615; then the audio cache module executes S617, and can continue to execute S615 in a loop. The audio cache module can stop encoding and end the loop until the audio cache module receives a request to stop encoding the audio data.

[0310] Figure 6B It is a flowchart of a method for video mixing in dynamic mode provided in an embodiment of the present application.

[0311] S620-S633: Mix the encoded audio and image to obtain video data.

[0312] Audio and image are mixed to obtain video data.

[0313] S620: The dynamic photographing module sends a mixer start request to mixer 1.

[0314] When the dynamic photographing module receives the photographing request (after executing S601), it may send a mixer start request to the mixer 1. Correspondingly, the mixer 1 may receive the mixer start request from the dynamic photographing module.

[0315] The mixer start request may include a timestamp Y when the electronic device receives the capture request (in S601 ).

[0316] S621: Mixer 1 starts.

[0317] When the mixer 1 receives the mixer start request, the mixer 1 can be started to start mixing.

[0318] S622: The memory creates a first file.

[0319] After the mixer 1 is started, the memory can be controlled to create a first file. The first file is a file of a dynamic image. The file of the dynamic image can include a video and an image.

[0320] S623: Mixer 1 sends a video data start mixing request to the video queue module.

[0321] After creating the first file, the mixer 1 may send a video data start mixing request to the video queue module. Correspondingly, the video queue module may receive the video data start mixing request from the mixer 1.

[0322] S624-S626 Image mixing loop: After the video queue module executes S626, it continues to execute S624 to mix the next frame. The loop ends when it is determined in S625 that the next frame of image is not to be packaged.

[0323] S624: The video queue module sends the i-th frame of encoded image data to mixer 1.

[0324] The video queue module may send the i-th frame of coded image data to the mixer 1. Correspondingly, the mixer 1 may receive the i-th frame of coded image data from the video queue module.

[0325] The i-th frame of coded image data is the earliest coded frame of image data in the cache queue of the current video queue module (the coded frame of image at the head of the second video data queue). When the i-th frame of coded image data is consumed (mixed) by the mixer 1, the next frame of the i-th frame becomes the frame of image data at the head of the queue.

[0326] The i-th frame of coded image data may include a frame of coded image and a time stamp.

[0327] S625: The mixer 1 determines whether to encapsulate the next frame of image.

[0328] In S620, the mixer 1 obtains the timestamp Y. The electronic device can determine the starting frame of the mixing (the first frame of the coded image) from the second video cache queue based on the timestamp Y and the specific video duration (or the specific number of video frames), and start packaging; each time a frame of image is packaged in the mixer, it marks that the frame of image has been consumed by the mixer 1. Before packaging a frame of image, the electronic device determines when to package this frame of image, that is, it can determine when to end packaging, and executes S626 if packaging; if not packaging, S626 is not executed. Among them, in the second video cache queue, each frame of coded image data includes this frame of coded image and the shooting timestamp.

[0329] In a possible implementation, the mixer 1 may determine the starting frame of mixing (determine the first frame of the coded image mixed this time) from the second video cache queue based on the timestamp Y and the specific video duration, and determine whether to end the encapsulation.

[0330] First, determine the starting frame.

[0331] The mixer 1 may determine the start frame based on the specific video duration of the timestamp Y and the timestamps of each encoded image in the second video cache queue. The specific video duration may be preset, and the specific duration is not limited.

[0332] Specifically, the mixer 1 can determine the first time and the second time based on Y and the specific video length, determine which frame to start mixing based on the second time, and determine whether a frame of encoded image is mixed based on the first time, that is, whether to end mixing.

[0333] Exemplarily, the specific video duration is 3s, and the electronic device determines that the images captured within 1.5s before and after Y are mixed. The electronic device can select encoded images with timestamps that satisfy the time range of Y-1.5s (second time) to Y+1.5s (first time) from the second video cache queue and input them into the mixer 1 for mixing. At this time, the electronic device can determine the image with the closest timestamp to Y1-1.5s in the second video cache queue as the starting frame. Of course, the image with the closest timestamp preset can also be determined from the second video cache queue based on Y-1s as the starting frame. The specific method of selecting the starting frame is not limited.

[0334] Secondly, determine the end of encapsulation. Mixer 1 starts encapsulation and marks each frame of the encapsulated image to indicate that the electronic device has acquired it. When the image frame is acquired next time (acquire a frame of image immediately after the marked image in the second video cache queue), it can be acquired in sequence according to the position of the last mark. When a new (i+1th frame) image frame is acquired, determine whether the current frame to the starting frame meets the specific video duration. If it meets, encapsulation is performed; if not, it is not encapsulated and the encapsulation is ended.

[0335] Optionally, the mixer 1 can determine the timestamp of the first frame of the encapsulated encoded image (the timestamp of the starting frame) and the timestamp of the current frame encapsulated image (the timestamp of the i+1th frame), and whether the first time difference between the two meets the specific video duration. When the first time difference is greater than or equal to (greater than) the specific video duration, it is judged that the specific video duration is met, and the next frame of the image is not encapsulated (the mixing of this dynamic image is ended), and S626 is not executed. When the first time difference is less than (less than or equal to) the specific video duration, it is judged that the specific video duration is not met, and the next frame of the image continues to be encapsulated (the above mixing is not completed, and the mixing of this dynamic image continues), and S626 continues to be executed.

[0336] Exemplarily, if the time difference between the timestamp of the i+1th frame and the timestamp of the starting frame is greater than 3 seconds of the specific video duration, the specific video duration is not satisfied; otherwise, the specific video duration is satisfied. The time difference between the timestamp of the i+1th frame and the timestamp of the starting frame is 2.87 seconds, which is less than 3 seconds, and the i+1th frame is encapsulated; the time difference between the timestamp of the i+1th frame and the timestamp of the starting frame is 3.001 seconds, which is greater than 3 seconds, and the i+1th frame is not encapsulated, and the image mixing ends.

[0337] Optionally, the mixer 1 can determine whether the timestamp of the current frame encapsulated image is less than (less than or equal to) Y and the specific video length to determine the end time. If it is less than (less than or equal to) the end time, the i+1th frame is encapsulated; if it is greater than or equal to (greater than) the end time, the i+1th frame is not encapsulated and the image mixing ends.

[0338] Exemplarily, it is determined whether the timestamp of this frame of image is less than (less than or equal to) Y+1.5s (second time) (the start time is Y-1.5s, and the start frame is selected accordingly). If it is less than or equal to (less than) Y+1.5s, the i+1 frame is packaged; if it is greater than (greater than or equal to) Y+1.5s, it is determined not to package the i+1 frame, and the electronic device can determine to end image mixing.

[0339] In another possible implementation, the mixer 1 may determine the starting frame of mixing (determine the first frame of the coded image mixed this time) from the second video cache queue based on the timestamp Y and the specific video frame number, and determine whether to end the encapsulation.

[0340] The mixer 1 can obtain the encoded image based on the specific number of video frames of timestamp Y and the timestamps of each encoded image in the second video cache queue. The electronic device can select a specific number of consecutive video frames in the second video cache queue before and after the timestamp Y, and input them into the mixer 1. The specific number of video frames can be preset and not limited. After the mixer 1 starts encapsulation, it marks each frame of the encapsulated image to indicate that the electronic device has acquired it. When the image frame is acquired next time (acquire a frame of image immediately after the marked image in the second video cache queue), it can be acquired in sequence according to the position of the last mark. When a new (i+1th frame) image frame is acquired, it is determined whether the current frame to the starting frame reaches a specific number of video frames. If it is not reached or just reached, encapsulation is performed; if it exceeds the specific number of video frames, it is not encapsulated and the encapsulation is ended.

[0341] Exemplarily, the number of frames of a specific video is 40, and the electronic device can determine the 20 consecutive frames with timestamps before Y; and the 20 consecutive frames after Y1 as encoded images, and input the time difference to the minimum time difference with Y. At this time, the electronic device can determine that in the second video cache queue, before the Y timestamp, 20 frames of images are determined, and the frame with the earliest frame timestamp of these 20 frames is determined as the starting frame. In the process of sequential encapsulation, the number of frames that have been encapsulated is determined. If the number of frames is less than or equal to 40, it is determined to be encapsulated. If it is greater than 40, it is not encapsulated and the image mixing is terminated.

[0342] In S625, the start frame refers to the first frame of the coded image that starts mixing.

[0343] S626: Mixer 1 sends a request to the video queue module to continue mixing images.

[0344] When the mixer 1 determines to encapsulate the next frame of image, it can send a request for continuing image mixing to the video queue module. Correspondingly, the video queue module can receive the request for continuing image mixing from the mixer 1.

[0345] S627: Mixer 1 sends an audio data start mixing request to the audio queue module.

[0346] After creating the first file, the mixer 1 may send an audio data start mixing request to the audio queue module. Correspondingly, the audio queue module may receive the audio data start mixing request from the mixer 1.

[0347] S628-S630 Audio mixing loop: After the audio queue module executes S630, it continues to execute S628 to mix the next frame. The loop ends when it is determined in S629 that the next frame of audio is not to be encapsulated.

[0348] S628: The audio queue module sends the kth encoded audio and video data to mixer 1.

[0349] Correspondingly, the mixer 1 can receive the kth encoded audio and video data from the audio queue module.

[0350] S629: Mixer 1 determines whether to encapsulate the next frame of audio.

[0351] In S620, mixer 1 obtains timestamp Y. The electronic device can determine the starting frame of the mix (the first frame of encoded audio) from the second audio cache queue based on timestamp Y and specific audio duration (or specific number of audio frames) and start encapsulation; each time a frame of audio is encapsulated in the mixer, it marks that the frame of audio mixer 1 has been consumed. Before encapsulating a frame of audio, the electronic device determines when to encapsulate this frame of audio, that is, it can determine when to end encapsulation, and executes S630 if encapsulation is performed; if not encapsulated, S630 is not performed. Among them, in the second audio cache queue, each frame of encoded audio data includes this frame of encoded audio and the acquisition timestamp.

[0352] In a possible implementation, the mixer 1 may determine the starting frame of the mixing (determine the first frame of encoded audio mixed this time) from the second audio buffer queue based on the timestamp Y and the specific audio duration, and determine whether to end the encapsulation.

[0353] First, determine the starting frame.

[0354] The mixer 1 may determine the start frame based on the specific audio duration of the timestamp Y and the timestamps of each encoded audio in the second audio buffer queue. The specific audio duration may be preset, and the specific duration is not limited.

[0355] Exemplarily, the specific audio duration is 3s, and the electronic device determines that the audio captured within 1.5s before and 1.5s after Y is mixed. The electronic device can select encoded audio with a timestamp that satisfies the time range of Y-1.5s to Y+1.5s from the second audio cache queue and input it into mixer 1 for mixing. At this time, the electronic device can determine the audio with the closest timestamp to Y1-1.5s in the second audio cache queue as the starting frame. Of course, it is also possible to determine the audio with the closest timestamp preset as the starting frame from the second audio cache queue based on Y-1s. The selection of the starting frame can refer to Figures 11A to 11E The specific method is not limited.

[0356] Secondly, determine the end of encapsulation. Mixer 1 starts encapsulation and marks each frame of encapsulated audio to indicate that the electronic device has acquired it. When the audio frame is acquired next time (acquire a frame of audio immediately after the marked audio in the second audio cache queue), it can be acquired in sequence according to the position of the last mark. When a new (i+1th frame) audio frame is acquired, determine whether the current frame to the start frame meets the specific audio duration. If it meets, encapsulation is performed; if not, it is not encapsulated and the encapsulation is ended.

[0357] Optionally, the mixer 1 can determine the timestamp of the first frame of the encapsulated encoded audio (the timestamp of the start frame) and the timestamp of the encapsulated audio of the current frame (the timestamp of the i+1th frame), and whether the second time difference between the two meets the specific audio duration. When the first time difference is greater than or equal to (greater than) the specific audio duration, it is judged that the specific audio duration is met, and the next frame of audio is not encapsulated (the mixing of this dynamic image is ended), and S630 is not executed. When the second time difference is less than (less than or equal to) the specific audio duration, it is judged that the specific audio duration is not met, and the next frame of audio continues to be encapsulated (the above mixing is not completed, and the mixing of this dynamic image continues), and S630 continues to be executed.

[0358] Exemplarily, if the time difference between the timestamp of the i+1th frame and the timestamp of the start frame is greater than 3 seconds for the specific audio duration, the specific audio duration is not satisfied; otherwise, the specific audio duration is satisfied. The time difference between the timestamp of the i+1th frame and the timestamp of the start frame is 2.87 seconds, which is less than 3 seconds, and the i+1th frame is encapsulated; the time difference between the timestamp of the i+1th frame and the timestamp of the start frame is 3.001 seconds, which is greater than 3 seconds, and the i+1th frame is not encapsulated, and the audio mixing ends.

[0359] Optionally, mixer 1 can determine whether the timestamp of the current frame encapsulated audio is less than (less than or equal to) Y and the specific audio duration to determine the end time. If it is less than (less than or equal to) the end time, the i+1th frame is encapsulated; if it is greater than or equal to (greater than) the end time, the i+1th frame is not encapsulated and the audio mixing ends.

[0360] Exemplarily, it is determined whether the timestamp of this frame of audio is less than (less than or equal to) Y+1.5s (the start time is Y-1.5s, and the start frame is selected accordingly). If it is less than or equal to (less than) Y+1.5s, the i+1 frame is encapsulated; if it is greater than (greater than or equal to) Y+1.5s, it is determined not to encapsulate the i+1 frame, and the electronic device can determine to end audio mixing.

[0361] In another possible implementation, the mixer 1 may determine the starting frame of the mixing (determine the first frame of encoded audio of the mixing) from the second audio buffer queue based on the timestamp Y and the specific audio frame number, and determine whether to end the encapsulation.

[0362] The mixer 1 can obtain the encoded audio based on the timestamp Y, the specific number of audio frames and the timestamps of each encoded audio in the second audio cache queue. The electronic device can select a specific number of consecutive audio frames of encoded audio before and after the timestamp Y in the second audio cache queue, and input them into the mixer 1. The specific number of audio frames can be preset and not limited. After the mixer 1 starts encapsulation, it marks each frame of encapsulated audio to indicate that the electronic device has acquired it. When the audio frame is acquired next time (acquire a frame of audio immediately after the marked audio in the second audio cache queue), it can be acquired in sequence according to the position of the last mark. When a new (i+1th frame) audio frame is acquired, it is determined whether the current frame to the starting frame reaches a specific number of audio frames. If it is not reached or just reached, encapsulation is performed; if it exceeds the specific number of audio frames, it is not encapsulated and the encapsulation is ended.

[0363] Exemplarily, the specific number of audio frames is 60 frames, and the electronic device can determine the 30 consecutive frames with timestamps before Y; and the 30 consecutive frames after Y1 as encoded audio, and input the time difference to the minimum time difference with Y. At this time, the electronic device can determine that in the second audio cache queue, before the Y timestamp, 30 frames of audio are determined, and the frame of audio with the earliest timestamp of these 30 audio frames is determined as the starting frame. In the process of sequential encapsulation, the number of frames that have been encapsulated is determined. If the number of frames is less than or equal to 30, it is determined to be encapsulated. If it is greater than 30, it is not encapsulated and the audio mixing is ended.

[0364] The start frame in S629 refers to the first frame of encoded audio that starts mixing.

[0365] S630: Mixer 1 sends an audio continuing mixing request to the audio queue module.

[0366] When it is determined to encapsulate the next frame of audio, an audio continuation mixing request may be sent to the audio queue module. Correspondingly, the audio queue module may receive an audio continuation mixing request from the mixer 1.

[0367] The execution order of S624 to S626 and S628 to S630 is not limited and they are executed in parallel.

[0368] S631: The mixer 1 encapsulates the i-th frame of encoded image data and the k-th frame of encoded audio data into the first video.

[0369] When the mixer 1 obtains the i-th frame of coded image data and the k-th frame of coded audio data, the i-th frame of coded image data and the k-th frame of coded audio data can be encapsulated into the first video, where i is an integer from 1 to I, and k is an integer from 1 to K. Both I and K are integers greater than 1.

[0370] S632: Mixer 1 sends a first video mixing completion notification to the dynamic photo module.

[0371] Correspondingly, the dynamic photo module receives a notification of video mixing completion from the mixer 1. The notification of first video mixing completion may include an identifier of the first video, which indicates that the first video has been packaged and can be prepared for subsequent dynamic image splicing.

[0372] S633: The memory stores the first video in a first file.

[0373] After S631 is executed and the mixing is completed, the memory may store the first video in the first file.

[0374] There is no restriction on the execution order between S632 and S633.

[0375] Figure 6C It is a flowchart of a method for taking photos and packaging dynamic images in a dynamic mode provided in an embodiment of the present application.

[0376] When the electronic device enters the camera shooting preview screen and the dynamic mode is turned on, the user can click the shooting control on the interface and click the shooting (such as Figure 1C In the case of the first video, the static camera module and the dynamic camera module will both receive the shooting request, and the action of the dynamic camera module is performed as S601, and the action of the static camera module is performed as S634. Thereafter, before the electronic device obtains the first video, no other shooting request is received, that is, the electronic device processes the user's one shot, and stops encoding and mixing after completion. The static camera module monitors the user operation and determines that the electronic device shoots a static image (the first image). When the first video and the first image are obtained, the dynamic image can be encapsulated, which is described in detail below:

[0377] S634: The static camera module receives a shooting request.

[0378] In the above S601, when the user clicks to shoot, both the dynamic shooting mode and the static shooting mode will receive a shooting request. The details of S634 can be referred to the description of S601, which will not be repeated here.

[0379] S635: The static camera module sends an image acquisition request to the camera HAL through the camera FWK.

[0380] After executing S634, the static camera module may send an image acquisition request to the camera HAL through the camera FWK. Correspondingly, the camera HAL may receive the image acquisition request from the static camera module through the camera FWK.

[0381] S636: The video cache module obtains thumbnail data of the first image.

[0382] The camera HAL receives the image acquisition request and can immediately acquire the first image from the camera and acquire thumbnail data of the first image. The thumbnail data may include a thumbnail of the first image and a timestamp. After the user clicks to shoot, the electronic device acquires a thumbnail of the first image, which can be displayed on a screen such as Figure 1D in the gallery control shown.

[0383] S637: The camera HAL sends thumbnail data of the first image to the static camera module through the camera FWK.

[0384] After the camera HAL obtains the thumbnail data of the first image, the thumbnail data of the first image can be sent to the static camera module through the camera FWK. Correspondingly, the static camera module can receive the thumbnail data of the first image sent from the camera HAL through the camera FWK. Among them, the quality of the first image in the thumbnail data is poor, the pixels are low, and the data volume is small.

[0385] S638: The static camera module performs dynamic image marking on the first image.

[0386] In a dynamic image, including image and video data, the image needs to be captured and then combined with the video to form a dynamic image. Therefore, the dynamic image needs to be marked in advance. In addition, this mark also indicates that the current first image is a thumbnail.

[0387] S639: The memory stores thumbnail data of the first image.

[0388] After the static camera module obtains the thumbnail data of the first image, the memory stores it.

[0389] At this time, the gallery can obtain the storage record of the first image and the dynamic image tag, and has stored a thumbnail of the first image.

[0390] S640: The camera HAL processes the original image of the first image to obtain large image data.

[0391] After the camera HAL processes the large image data, the pixels of the first image become higher and the effect is better. The large image data volume of the first image is greater than the thumbnail data.

[0392] S641: The camera HAL sends the large image data of the first image to the static camera module through the camera FWK.

[0393] Correspondingly, the static camera module can receive the large image data of the first image from the camera HAL through the camera FWK.

[0394] S642: The static camera module updates the dynamic image record.

[0395] After executing S641, the static camera module may update the dynamic image record. The updated dynamic image record may represent the large image data of the currently acquired first image.

[0396] At this time, the image library can obtain the updated storage record and dynamic image tag of the first image, and has stored the large image data of the first image.

[0397] S643: The memory stores the large image data of the first image.

[0398] After the static camera module obtains the large image data of the first image, the memory stores it.

[0399] S644: The dynamic photographing module sends a first video packaging notification to the storage.

[0400] After the dynamic camera module obtains the first video mixing completion notification (execution S632), it can send the first video packaging notification to the memory. Correspondingly, the memory can receive the first video packaging notification from the dynamic camera module.

[0401] S645: The static camera module sends a large image packaging notification of the first image to the storage.

[0402] After the static camera module executes S642, it may send a large image packaging notification of the first image to the memory. Correspondingly, the memory may receive the large image packaging notification of the first image from the static camera module.

[0403] S646: The memory splices the large image data of the first image and the first video to obtain and store a first file.

[0404] In S633, the electronic device has stored the first video in the first file. Under the condition of executing S644 and S645, the memory splices the large image data of the first image and the first video, and encapsulates the first file (dynamic image) based on the description information of the dynamic image. Then, the first file is stored. After the first file is stored in the gallery, click to open the gallery (such as Figure 1H ), the gallery preview screen of the electronic device may include a dynamic image of the first file, such as Fig. 1I If the user clicks on this dynamic image, it can display Figure 1E In (a), the user can long press to play the animated image, and click the edit control 142a, and the electronic device can display multiple thumbnails in the video and a large image (cover frame) of the first image. The user long presses the first image, and the electronic device plays the animated image. The triggering of playing the animated image can be other operations; the user can also long press to not play the animated image, which is not limited in this application.

[0405] Optionally, when stitching is completed, the gallery may be notified to update the record of the first file.

[0406] like Fig. 7A Schematic diagram of the format structure of a first file disclosed in the embodiment of the present application. Fig. 7A As shown. The first file is a dynamic image file and may include three fields. The first field is the large image data of the first image (JPEG image, in S643, the large image data of the first image is stored), and the second field is the mixed video data (the first video, the first video stored in S633), for example, an mp4 file. The third field is the description field of the dynamic image (a field for description information), and the third field may include three subfields. Among them, the first subfield is the version number version, for example, the current one is v2. The second subfield includes the start time start and the duration duration, that is, the second subfield is used to record the start time start and the duration duration of the playback during the gallery preview; the third subfield is TAG, which is used to record the file length of the first video.

[0407] The video data of the first file includes audio data and image data of a packaging length. Figure 7B 1 is a schematic diagram of the packaging time of audio data and video data of a video data disclosed in an embodiment of the present application. Figure 7B As shown, it is assumed that the first encapsulation duration and the second encapsulation duration are both the duration from T1 to T2. In the video data, there are a total of K audio frames and I image frames, K and I are integers greater than 1, and the frame numbers of the audio frames can be audio frame 1, audio frame 2, audio frame 3, ..., audio frame K. The frame numbers of the image frames can be image frame 1, image frame 2, ..., image frame I. Among them, the acquisition duration interval between every two adjacent image frames is the first time interval; the acquisition duration interval between every two adjacent audio frames is the second time interval. For example, the first time interval is 33ms, the second time interval is 22ms, the encapsulation time is 180ms, K is 8, and I is 5.

[0408] 3. After the single shot is completed, stop encoding and mixing. Fig.6D (shown)

[0409] Fig.6D 1 is a flow chart of a method for stopping video encoding provided by an embodiment of the present application. The method for stopping video encoding is as follows: Figure 6A to Figure 6C The execution steps after execution, that is, the process of stopping encoding when no continue shooting control is received.

[0410] S647: When the mixer 1 determines that mixing should be stopped, it stops mixing.

[0411] Specifically, during the process of executing S625 and S629, the mixer 1 determines whether to stop mixing. If it is determined that the next frame of image and the next frame of audio will not be encapsulated, the mixer 1 determines to stop mixing and stops the mixer from processing.

[0412] S648: Mixer 1 sends a first video mixing completion notification to the dynamic photography module.

[0413] Correspondingly, the dynamic photographing module may receive a first video mixing completion notification from the mixer 1 .

[0414] When it is determined that the first video mixing is completed (S631 is completed), S648 can be executed. S648 and S632 are the same execution steps and are not described in detail.

[0415] S649: The dynamic photographing module determines that there is no video with dynamic images that has not been mixed, and determines that the encoder stops.

[0416] When the dynamic photography module receives the notification that the mixing of the first video is completed, the process of determining whether to stop encoding is as follows: when there is currently no video of a dynamic image that has not yet been mixed, the electronic device stops encoding the first video cache queue and the first audio cache queue; when there is currently a video of a dynamic image that has not yet been mixed, the electronic device continues to encode the first video cache queue and the first audio cache queue.

[0417] Specifically, the electronic device receives a shooting request and adds a shooting request task to the task list. When a video mixing completion notification is received, the task corresponding to the shooting request can be determined and cleared. Each time the electronic device obtains a mixing completion notification, it first clears the task corresponding to the shooting request and determines whether there is a shooting request task in the current task list. If there is a task being processed, it can be determined that there is an unfinished mixing of the video of the dynamic image. If there is no task (the task list is empty), it can be determined that there is an unfinished mixing of the video of the dynamic image.

[0418] In S648, the electronic device starts the task of the shooting request when and only when it receives one shooting request. After receiving the notification that the first video mixing is completed, the task of the shooting request can be cleared. The electronic device can determine that there is no unfinished mixing of the video with dynamic images, and can determine that the encoder has stopped.

[0419] S650: The dynamic photographing module sends a request to the video encoding module to stop encoding the image data.

[0420] After S648 is completed, the dynamic photographing module executes S650, that is, it can send a request to stop encoding the image data to the video encoding module. Correspondingly, the video encoding module can receive the request to stop encoding the image data from the dynamic photographing module.

[0421] S651: The video encoding module stops the video encoder.

[0422] After the video encoding module receives the request to stop encoding the image data, the video encoding module may stop the video encoder.

[0423] S652: The dynamic photographing module sends a request to stop encoding the audio data to the audio encoding module.

[0424] After S648 is completed, the dynamic photographing module executes S652, that is, it can send a request to stop encoding the audio data to the audio encoding module. Correspondingly, the audio encoding module can receive the request to stop encoding the audio data from the dynamic photographing module.

[0425] S653: The audio encoding module stops the audio encoder.

[0426] After receiving the audio data stop encoding request, the audio encoding module may stop the audio encoder.

[0427] 4. Video encoding of multiple continuous dynamic images (such as Fig. 8A and Figure 8B shown).

[0428] Figure 8A to Figure 8C This is a flow chart of another method for processing video data in a dynamic mode provided in an embodiment of the present application.

[0429] When the electronic device enters the camera shooting preview screen and the dynamic mode is turned on, the user can click the shooting control on the interface multiple times in succession. Accordingly, the dynamic shooting module monitors the user's operation of shooting dynamic images multiple times and determines that the electronic device needs to obtain multiple dynamic image videos and photos. The following describes the encoding and mixing process of multiple dynamic images when the user shoots dynamic images multiple times in succession:

[0430] During the two shooting processes, the user triggers shooting twice, and both the dynamic shooting module and the static shooting module receive two shooting requests. The dynamic shooting module starts the video encoder to start encoding when receiving the first shooting request, and receives the second shooting request without stopping the encoder. The video encoder and the audio encoder continue encoding until the video mixing corresponding to the second shooting request is completed, and then the encoding is stopped. In the above-mentioned continuous shooting dynamic video process, the two dynamic videos and audio encoding only need to perform one encoding process (one encoding), and then mix them separately to obtain the video (multiple mixing), without the need for the encoder to encode and start separately, thereby improving execution efficiency and saving encoding energy consumption. It can also solve the problem of continuous shooting of dynamic images and the inability to continuously generate videos.

[0431] Taking the case where the user clicks twice in succession to shoot a dynamic image as an example, the method flow for three or more consecutive shots is similar.

[0432] S801-S819: When a shooting request is received for the first time, the audio and video encoding process is started.

[0433] S801: The dynamic photographing module receives a first photographing request.

[0434] At this time, when the dynamic mode is turned on, the user starts to trigger shooting for the first time, and the dynamic shooting module can receive the first shooting request. Thus, the first video is obtained by triggering encoding and first mixing. For details, the first time the user clicks to shoot, please refer to S601, and Figure 1C The relevant description is not repeated here.

[0435] S802-S811: Start video encoding.

[0436] S802: The dynamic camera module sends a request to start image encoding to the video encoding module.

[0437] S803: The video encoding module starts the video encoder.

[0438] S804: The video encoding module sends an image data encoding start request to the video management module.

[0439] S805: The video management module sends an image data encoding request to the video acquisition module through the post camera.

[0440] S806: The video buffer module obtains the nth frame of the image to be encoded.

[0441] S807: The video buffer module sends the nth frame of the image to be encoded to the video encoding module through the post camera.

[0442] S808: The video encoding module encodes the n-th frame of the image to be encoded to obtain the n-th frame of the encoded image.

[0443] S809: The video encoding module sends a request to the video management module to continue encoding the image data.

[0444] S810: The video encoding module sends the nth frame of encoded image to the video queue module.

[0445] S811: The video queue module caches the nth frame of the encoded image.

[0446] S812~S819: Start audio encoding.

[0447] S812: The dynamic photographing module sends a request to start audio encoding to the audio encoding module.

[0448] S813: The audio encoding module starts the audio encoder.

[0449] S814: The audio encoding module sends an audio data start encoding request to the audio buffer module.

[0450] S815: The audio buffer module sends the mth frame of audio to be encoded to the audio encoding module.

[0451] S816: The audio encoding module encodes the m-th frame of audio to be encoded to obtain the m-th frame of encoded audio.

[0452] S817: The audio encoding module sends a request to the audio buffer module to continue encoding the audio data.

[0453] S818: The audio encoding module sends the mth frame of encoded audio to the audio queue module.

[0454] S819: The audio queue module caches the mth frame of encoded audio.

[0455] The detailed description of S801 to S819 can be found in Fig. 6A The relevant descriptions of S601 to S619 are not repeated here.

[0456] Figure 8B The invention is a method flow in which two mixers are called to mix the encoded audio and video respectively for two shots to obtain two videos.

[0457] S820-S833: When the user triggers dynamic shooting for the first time, the mixer 1 mixes the encoded audio and image to obtain a first video.

[0458] S820: The dynamic photographing module sends a mixer start request 1 to mixer 1.

[0459] The mixer start request 1 is used to request the mixer 1 to start. After the dynamic camera module executes S801, it may execute S820.

[0460] The mixer start request 1 includes the timestamp of the first shooting request, that is, the timestamp Y1 when the electronic device obtains the first shooting operation of the user.

[0461] S821: Mixer 1 starts.

[0462] S822: The storage device creates a first file.

[0463] The first file is a file of a dynamic image obtained by triggering dynamic shooting for the first time.

[0464] S823: Mixer 1 sends video data to the video queue module to start mixing request 1.

[0465] S824~S826: Image mixing cycle.

[0466] S824: The video queue module sends the i1th frame of encoded image data to mixer 1.

[0467] Wherein, i1 is an integer from 1 to I1.

[0468] S825: The mixer 1 determines whether to encapsulate the next frame of image.

[0469] In S820, the mixer 1 obtains the timestamp Y1. The electronic device can determine the starting frame of the mixing from the second video cache queue based on the timestamp Y1 and the specific video duration (or the specific number of video frames), and start encapsulation; during the encapsulation process, it can be determined when to end the encapsulation. In the second video cache queue, each frame of coded image data includes the frame of coded image and the shooting timestamp.

[0470] For the specific description of S825, reference may be made to the description of S625 and will not be repeated here.

[0471] S826: Mixer 1 sends image continuing mixing request 1 to the video queue module.

[0472] S827: Mixer 1 sends audio data to the audio queue module to start mixing request 1.

[0473] S828~S830: Audio mixing loop.

[0474] S828: The audio queue module sends the k1th encoded audio and video data to mixer 1.

[0475] Wherein, k1 is an integer from 1 to K1. I1 and K1 are both integers greater than 1.

[0476] S829: Mixer 1 determines whether to encapsulate the next frame of audio.

[0477] For the specific description of S829, please refer to the description of S629 and will not be repeated here.

[0478] S830: Mixer 1 sends audio continuing mixing request 1 to the audio queue module.

[0479] S831: The mixer 1 encapsulates the i1th frame encoded image data and the k1th frame encoded audio data into the first video.

[0480] The mixer 1 needs to encapsulate all the I1 frame encoded image data and the K1 frame encoded audio data into the first video before the mixer 1 can determine that the encapsulation of the first video is completed.

[0481] S832: Mixer 1 sends a first video mixing completion notification to the dynamic camera module.

[0482] After the first video packaging is completed, the mixer 1 may continue to execute S832 .

[0483] In the embodiment of the present application, when the dynamic photographing module receives the notification that the mixing of the first video is completed, the electronic device can obtain the first video.

[0484] S833: The memory stores the first video into a first file.

[0485] Among them, the specific description of S820~S833 can refer to the relevant description of S620~S633, which is not repeated here.

[0486] There is no restriction on the execution order between S832 and S833.

[0487] S834-S848: The user touches the dynamic shooting for the second time, and the mixer 2 mixes the encoded audio and image to obtain a second video.

[0488] S834: The dynamic photographing module receives a second photographing request.

[0489] At this time, when the dynamic mode is turned on, after the first triggering of shooting, the user triggers shooting for the second time when the encoding of the first dynamic image has not yet been completed. Figure 8B Before the dynamic camera module receives the notification that the first video mixing is completed, it receives the second shooting request, and the dynamic camera module continues to encode, that is, the video encoding module and the audio encoding module continue to encode. That is, the video encoding and audio encoding are continuously cycled until the second mixing is completed, and the encoding is stopped.

[0490] In the embodiment of the present application, after the encoding is started for the first shooting request, a second shooting request for acquiring a dynamic image is received when the encoder has not stopped. The second shooting request is located after the first shooting request in time. At this time, the execution step of S834 is before S832, that is, before the first video mixing is completed, the electronic device receives the second shooting request.

[0491] Therefore, when the audio encoder and the video encoder have not stopped, the electronic device receives a second shooting request and does not start a new audio encoder and a new video encoder for the second shooting request, but keeps the above audio encoder and the video encoder to continue encoding.

[0492] For details of S834, please refer to the relevant contents of S801 and S601, which will not be elaborated here.

[0493] S835: The dynamic photographing module sends a mixer start request 2 to mixer 2.

[0494] The mixer start request 2 includes the timestamp of the second shooting request (in S834), that is, the timestamp Y2 when the electronic device obtains the second shooting operation of the user.

[0495] The mixer start request 2 is used to request the mixer 2 to start.

[0496] S836: Mixer 2 starts.

[0497] S837: The storage device creates a second file.

[0498] The second file is a file of a dynamic image obtained by triggering dynamic shooting for the second time.

[0499] S838 to S846: The image and audio mixing process of mixer 2 may refer to S623 to S631.

[0500] S838: Mixer 2 sends video data to the video queue module to start mixing request 2.

[0501] S839: The video queue module sends the i2th frame of encoded image data to mixer 2.

[0502] Wherein, i2 is an integer from 1 to I2.

[0503] S840: The mixer 2 determines whether to encapsulate the next frame of image.

[0504] For details of S840, please refer to the related descriptions of S625 and S825, which will not be repeated here.

[0505] S841: Mixer 2 sends image continuing mixing request 2 to the video queue module.

[0506] S842: Mixer 2 sends audio data to the audio queue module to start mixing request 2.

[0507] S843: The audio queue module sends the k2th encoded audio and video data to mixer 2.

[0508] Wherein, k2 is an integer from 1 to K2. I2 and K2 are both integers greater than 1.

[0509] S844: Mixer 2 determines whether to encapsulate the next frame of audio.

[0510] For details of S844, please refer to the relevant descriptions of S629 and S829, which will not be repeated here.

[0511] S845: Mixer 2 sends audio continuing mixing request 2 to the audio queue module.

[0512] S846: The mixer 2 encapsulates the i2-th frame encoded image data and the k2-th frame encoded audio data into the second video.

[0513] The mixer 2 needs to encapsulate all the I2 frame encoded image data and the K2 frame encoded audio data into the second video before the mixer 2 can determine that the encapsulation of the second video is completed.

[0514] After the judgment of S840 and S844, the second video includes I2 frames of coded images and K2 frames of coded audio; the time difference between the first frame (1st frame) and the last frame (I2th frame) of the I2 frame coded image is less than or equal to (less than) the first packaging duration; the time difference between the first frame (1st frame) and the last frame (K2th frame) of the K2 frame coded audio is less than or equal to (less than) the second packaging duration. The time difference between the I2+1th frame coded image and the 1st frame coded image is greater than (greater than or equal to) the first packaging duration. The time difference between the K2+1th frame coded audio and the 1st frame coded audio is greater than (greater than or equal to) the second packaging duration. The I2+1th frame coded image is a frame of image that is after the I2th frame coded image in the second video cache queue; the K2+1th frame of coded audio is a frame of audio that is after the K2th frame coded audio in the second audio cache queue.

[0515] S847: Mixer 2 sends a second video mixing completion notification to the dynamic photo module.

[0516] After the second video packaging is completed, the mixer 2 may continue to execute S847.

[0517] S848: The memory stores the second video in a second file.

[0518] Among them, the specific description of S835~S848 can refer to S620~S633, and the related description of S820~S833, which will not be repeated here.

[0519] There is no restriction on the execution order between S832 and S833.

[0520] Figure 8C The invention relates to a method flow of taking photos in two dynamic shootings, and encapsulating the taken photos and the mixed videos respectively to obtain two dynamic images.

[0521] In the first click shot (such as Figure 1C In the case of clicking the second time to shoot (as shown in FIG. 1 ), both the dynamic photo module and the static photo module will receive the first shooting request, the specific action of the dynamic photo module is performed as S801, and the specific action of the static photo module is performed as S849. Figure 1F As shown), both the dynamic photo module and the static photo module will receive the second shooting request, and the specific action of the dynamic photo module is executed as S834, and the specific action of the static photo module is executed as S862.

[0522] S849-S861: The user triggers the first dynamic shooting, shoots the first image, and packages the first video and the first image to obtain a first file (the dynamic image obtained by the first shooting).

[0523] S849: The static photographing module receives a first photographing request.

[0524] When the user triggers dynamic shooting for the first time, both the dynamic shooting module and the static shooting module will receive a first shooting request. After receiving the first shooting request, the static shooting module triggers the acquisition of a first image, which is used to generate the first dynamic image.

[0525] Among them, the specific description of S849 can refer to the description of S801 and S634, which will not be repeated here.

[0526] S850: The static camera module sends an image acquisition request 1 to the camera HAL through the camera FWK.

[0527] S851: The video cache module obtains thumbnail data of the first image.

[0528] S852: The camera HAL sends thumbnail data of the first image to the static camera module through the camera FWK.

[0529] S853: The static camera module performs dynamic image marking on the first image.

[0530] S854: The memory stores thumbnail data of the first image.

[0531] At this time, the electronic device may display a thumbnail of the first image in the gallery control in the shooting preview screen, such as Figure 1D shown.

[0532] S855: The camera HAL processes the original image of the first image to obtain large image data.

[0533] S856: The camera HAL sends the large image data of the first image to the static camera module through the camera FWK.

[0534] S857: The static camera module updates the dynamic image record 1.

[0535] S858: The memory stores the large image data of the first image.

[0536] S859: The dynamic photographing module sends a first video packaging notification to the storage.

[0537] After executing S832, the dynamic photographing module may send a first video packaging notification to the storage.

[0538] S860: The static camera module sends a large-image packaging notification of the first image to the storage.

[0539] S861: The memory splices the large image data of the first image and the first video to obtain and store a first file.

[0540] In S833, the electronic device has stored the first video in the first file. After executing S859 and S860, that is, after receiving the two package notifications of the first video and the first image, the first file can be spliced. At this point, the electronic device has captured a dynamic image (the first file) and has not yet obtained the second dynamic image. Fig. 1I The image shown is a dynamic image 181.

[0541] Among them, the specific description of S849~S861 can refer to the relevant description of S634~S646, which is not repeated here.

[0542] Among them, the execution order between S849~S861 and S801~S833 is not limited. The first video can be obtained first and then the first image, or the first image can be obtained and then the first video. When the user touches the dynamic shooting for the first time, both the dynamic shooting module and the static shooting module receive the first shooting request, the static shooting module obtains the first image, and the dynamic shooting module obtains the first video. The two are almost processed in parallel and do not interfere with each other, so the execution order is not limited.

[0543] S862-S874: The user triggers a second dynamic shooting, shoots a second image, and splices the second video and the second image to obtain a second file (dynamic image obtained by the second shooting).

[0544] S862: The static photographing module receives a second photographing request.

[0545] When the user triggers dynamic shooting for the second time (such as Figure 1F As shown in FIG. 1 , both the dynamic camera module and the static camera module will receive the second shooting request (execute S834 and S862). After receiving the second shooting request, the static camera module triggers the acquisition of the second image, which is used to generate the second dynamic image. Before the encoder (video encoder and audio encoder) stops, the static camera module receives the second shooting request.

[0546] The specific description of S862 can be referred to S834 and S634 and will not be repeated here.

[0547] S863: The static camera module sends an image acquisition request 2 to the camera HAL through the camera FWK.

[0548] S864: The camera HAL obtains thumbnail data of the second image.

[0549] S865: The camera HAL sends thumbnail data of the second image to the static camera module through the camera FWK.

[0550] S866: The static camera module performs dynamic image marking on the second image.

[0551] S867: The memory stores thumbnail data of the second image.

[0552] S868: The camera HAL processes the original image of the second image to obtain large image data.

[0553] S869: The camera HAL sends the large image data of the second image to the static camera module through the camera FWK.

[0554] S870: The static camera module updates the dynamic image record 2.

[0555] S871: The memory stores the large image data of the second image.

[0556] In the embodiment of the present application, the large image data of the first image and the second image is the cover image data.

[0557] S872: The dynamic photographing module sends a second video packaging notification to the storage.

[0558] After executing S847, the dynamic photographing module receives the second video mixing completion notification and may send the second video packaging notification to the storage.

[0559] S873: The static camera module sends a large image packaging notification of the second image to the storage.

[0560] S874: The memory splices the large image data of the second image and the second video to obtain and store a second file.

[0561] In S848, the electronic device has stored the second video in the second file. After executing S872 and S873, that is, after receiving two packaging notifications of the second video and the second image, the second file can be packaged. At this point, the electronic device has captured two dynamic images (first files), and the gallery can display the following: Figure 1J The images shown are two animated images 191A and 191B.

[0562] Among them, the specific description of S862~S874 can refer to the relevant description of S634~S646 and S849~S861, which will not be repeated here.

[0563] Among them, the execution order between S862~S874 and S834~S848 is not limited. The second video can be obtained first and then the second image, or the second image can be obtained and then the second video. Similarly, when the user touches the dynamic shooting for the second time, the dynamic shooting module and the static shooting module both receive the second shooting request, the static shooting module obtains the second image, and the dynamic shooting module obtains the second video. The two are almost processed in parallel and do not interfere with each other, so the execution order is not limited.

[0564] go through Figure 8A to Figure 8C As described in the description, when a user continuously shoots dynamic images in a short period of time, the dynamic shooting mode of the electronic device needs to continue encoding when it determines that there are still video mixing tasks to be executed until all videos are mixed. When there are no mixing tasks, the encoding process will be stopped. In this way, when shooting dynamic images continuously, it is only necessary to encode the image once, and the video of each dynamic image is mixed separately, so that the dynamic image taken each time can be obtained, ensuring the feasibility of the continuous dynamic image solution. At the same time, it can also reduce the number of encoding times, improve execution efficiency, and save processing resources.

[0565] 5. After multiple continuous shooting is completed, stop encoding and mixing. Fig.8D Steps S875-S884 shown)

[0566] Fig.8D 1 is a flow chart of another method for stopping video encoding provided by an embodiment of the present application. The method for stopping video encoding is as follows: Figure 8A to Figure 8CThe execution steps after execution, that is, the process of stopping encoding when no continue shooting control is received.

[0567] In the embodiment of the present application, when the electronic device obtains the first video or the second video, it determines whether to stop encoding. Specifically, when there is no video of a dynamic image that has not yet been mixed, the electronic device stops encoding the first video cache queue and the first audio cache queue; when there is a video of a dynamic image that has not yet been mixed, the electronic device continues to encode the first video cache queue and the first audio cache queue.

[0568] S875: When it is determined that the mixer 1 needs to stop mixing, the mixer 1 is stopped.

[0569] Among them, S875 can refer to the relevant description of S647 and will not be repeated here.

[0570] S876: Mixer 1 sends a first video mixing completion notification to the dynamic photography module.

[0571] Among them, S876 and S832 are the same execution steps and are not repeated here.

[0572] S877: The dynamic camera module determines that there is a video of a dynamic image that has not been mixed, and determines that the encoder does not stop.

[0573] When the dynamic camera module receives a notification of video mixing completion, the process of determining whether to stop encoding is triggered. The process of determining whether to stop encoding is as follows: when there is no video of a dynamic image that has not yet completed mixing, the electronic device stops encoding the first video cache team and the first audio cache queue; when there is a video of a dynamic image that has not yet completed mixing, the electronic device continues to encode the first video cache team and the first audio cache queue. That is, whether there is still a mixing task being processed and no notification of video mixing completion has been received. At this time, the dynamic camera module receives two dynamic shooting messages and only receives the first notification of the completion of the first video mixing (the second notification of the completion of the video mixing has not yet been received). There is still a mixing task being processed, so it is determined not to stop encoding (continue encoding). The logic for determining whether there is a task in the above-mentioned task list can be referred to the relevant description of S649 and will not be repeated.

[0574] Fig. 9A is a schematic diagram of a task queue change disclosed in an embodiment of the present application. Specifically, Fig. 9AAs shown, the electronic device receives two shooting requests, and therefore, the task queue includes a task for the first shooting request and a task for the second shooting request. When the electronic device receives a notification that the mixing of the first video is completed, it can clear the task for the first shooting request in the task queue. The cleared task queue includes the task for the second shooting request. The electronic device can determine that the current task queue also includes a task, and can determine that there is an unfinished mixing of the video of the dynamic image. In an embodiment of the present application, the task queue is a task queue established in response to a user clicking to shoot a dynamic image. When a shooting request is received, a corresponding task is created; when the dynamic image and video mixing is completed, the corresponding task is cleared.

[0575] In the above process, before the dynamic camera module receives the first video mixing completion notification, the second shooting request is received. At this time, the electronic device has not received the second video mixing completion notification for the second shooting request, and can determine that there is a video of the dynamic image that has not been mixed, and determines that the encoder does not stop.

[0576] S878: When it is determined that the mixer 2 should stop mixing, the mixer 2 is stopped.

[0577] Among them, S878 can refer to the relevant descriptions of S647 and S875, which will not be repeated here.

[0578] S879: Mixer 2 sends a second video mixing completion notification to the dynamic camera module.

[0579] Among them, S879 and S847 are the same execution steps and are not repeated here.

[0580] S880: The dynamic photographing module determines that there is no video with dynamic images that has not been mixed, and determines that the encoder stops.

[0581] When the dynamic camera module receives the second video mixing completion notification, the process of determining whether to stop encoding is triggered. At this time, the dynamic camera module receives two dynamic shooting messages, two video mixing completion notifications, and no new shooting request is received before receiving the second video mixing completion notification. It is determined that there is no video with dynamic images that has not been mixed (all mixing tasks are completed), so it is determined to stop encoding and execute S881 and S883.

[0582] Fig. 9B is a schematic diagram of another task queue change disclosed in the embodiment of the present application. Specifically, Fig. 9BThe task of the first shooting request in the task queue shown has been cleared, and only the task of the second shooting request is included. When the electronic device receives the notification of completion of the second video mixing, it can clear the task of the second shooting request in the task queue accordingly. There is no task in the cleared task queue. The electronic device can determine that there is no task in the current task queue, and can determine that there is no unfinished mixing of the video of the dynamic image.

[0583] Optionally, before the dynamic camera module receives the second video mixing completion notification, a third shooting request is received, and the third shooting request is a user operation after the second shooting request. The dynamic camera module receives the second video mixing completion notification and determines that the video of the dynamic image of the third shooting request has not been mixed, and it can be determined that the encoder does not stop and does not execute S881 to S884, that is, the video encoder and the audio encoder continue to encode.

[0584] S881: The dynamic camera module sends a request to the video encoding module to stop encoding the image data.

[0585] S882: The video encoding module stops the video encoder.

[0586] S883: The dynamic photographing module sends a request to the audio encoding module to stop encoding the audio data.

[0587] S884: The audio encoding module stops the audio encoder.

[0588] Among them, S881~S883 can refer to the relevant description of S649~S652 above, and will not be repeated here.

[0589] In the above-mentioned continuous shooting process, the dynamic camera module determines whether to stop encoding by determining whether the mixed tasks corresponding to all shooting requests in the current task thread have been processed. Each time a mixed task completion notification is received, shooting is triggered to make the above-mentioned judgment (S877 and S880). In this way, it can be ensured that encoding can be stopped when the mixed tasks of all shooting requests are completed. When shooting dynamic images continuously, it can avoid the situation where an encoder is started for each shooting request, preventing the problem of excessive occupation of processing resources by encoding. It can also ensure multiple mixing of one encoding, simplify the encoding logic, improve the processing speed, and save processing resources.

[0590] Optionally, when the dynamic mode is activated, after continuous shooting (execution Figure 8A to Figure 8C ) cannot be detected, exit code (execution Fig.8D ), if the user clicks to capture a dynamic image again, the encoding will restart and execute Fig. 6A and Figure 6B process.

[0591] Optionally, when dynamic mode is activated, after a single shot (execution Fig. 6A and Figure 6B ), exit code (execution Fig.6D ), if the user clicks on continuous shooting, re-encode and execute Figure 8A to Figure 8C process.

[0592] Combined with the above Figures 8A to 8D The encoding mixing process of the video, Fig.10 An exemplary embodiment of the present application provides a schematic diagram of hybrid coding of video in a dynamic image.

[0593] like Fig.10 As shown, when the dynamic mode is turned on, the electronic device starts to cache the first audio cache queue and the first video cache queue. Among them, the number of image frames in the first audio cache queue and the first video cache queue can be determined. For example, the first video cache queue has 45 frames. When the first video cache queue does not reach 45 frames, as new image frames are queued, the number of frames in the first video cache queue continues to increase; when the first video cache queue reaches 45 frames, as new image frames are queued, the old image frames will be dequeued (the last frame at the end of the queue is dequeued), and 45 frames remain unchanged. Fig.10 The first video cache queue in the video buffer queue moves forward continuously as the image frames are collected, and the image frames in the first video cache queue also flow continuously. The first audio cache queue can refer to the description of the first video cache queue, which will not be repeated here.

[0594] At time T1, the user clicks to shoot once, and the electronic device receives the first shooting request and starts the video encoder, audio encoder and mixer 1. The video encoder obtains the image to be encoded from the first video cache queue, encodes it, and caches the encoded image to the second video cache queue. The audio encoder obtains the audio to be encoded from the first audio cache queue for encoding, and caches the encoded audio to the second audio cache queue. The second audio cache queue and the second video cache queue can also have a fixed number of frames. As the audio encoder outputs the encoded audio and the video encoder outputs the encoded image, the data frames of the second audio cache queue and the second video cache queue are also constantly flowing. For details, please refer to the description of the first video cache queue above, which will not be repeated. Mixer 1 starts and mixes the encoded data of the second audio cache queue and the second video cache queue.

[0595] At time T2, mixer 1 has not yet finished mixing the first video, and the video encoder and audio encoder are also in the encoding process. The user clicks to shoot again, and the electronic device receives a second shooting request and starts mixer 2. When mixer 2 is started, the encoded data of the second audio cache queue and the second video cache queue can be mixed.

[0596] At time T3, mixer 1 finishes mixing the first video and mixer 1 stops. At this time, mixer 2 has not finished mixing the second video, and the video encoder and audio encoder continue encoding. Mixer 1 can obtain the first video, and the acquisition time of the image and audio in the first video starts from the time before mixer 1 is started to the time when mixer 1 stops.

[0597] At time T4, mixer 2 completes mixing of the second video, and during the process of encoding and mixing the second video, no new shooting request is received, the mixing tasks of all shooting requests are completed, and the video encoder, audio encoder and mixer 2 are all stopped. Mixer 2 can obtain the second video, and the acquisition time of the image and audio in the second video starts from the time before mixer 2 is started to the time when mixer 2 stops.

[0598] In the above implementation, the encoder keeps encoding when there is a mixing task being processed, which can solve the problem of not being able to respond to encoding in time due to continuous shooting; the multiplexer consumes the encoding results of a group of encoders, can respond to multiple shooting requests, and mix videos separately, to ensure that the effect of dynamic image continuous shooting can be achieved, and to ensure the continuous shooting experience of users. In addition, one-way encoding and multi-way mixing can save encoding resources and improve encoding efficiency.

[0599] Figures 11A to 11E FIG. 1 is a schematic diagram of image frame production and consumption of a group of second video cache queues exemplarily shown in an embodiment of the present application. Fig.10 , which explains the specific flow of image frames during the encoding mixing process.

[0600] In an embodiment of the present application, the second video cache queue maintains a specific queue duration or a specific queue frame number. As the video encoder continues to encode, newly encoded image frames are stored in the second video cache queue, and the earliest image frames are removed from the second video cache queue, thereby ensuring a specific queue duration or a specific queue frame number.

[0601] For example, Fig.11A As shown, the second video cache queue includes a total of 45 frames, and each frame of data includes a coded image frame and a timestamp (t). For example, the coded image frame 1 corresponds to a timestamp t1, the coded image frame 2 corresponds to a timestamp t2, ..., and the coded image frame 45 corresponds to a timestamp t45, where t1, t2, ..., t45, the time is from far to near (corresponding to the earliest to the latest image frames). The video encoder encodes a new frame of coded image, frame 46 (t46). The electronic device can enqueue frame 46 (t46) and remove the coded image frame corresponding to the earliest frame t1 from the second video cache queue. As shown Fig. 11BAs shown, the second video buffer queue becomes frames 2 to 46. As the video encoder encodes a new encoded image frame 47, the second video buffer queue dequeues frame 2 and enqueues frame 47, and this process continues until the encoding ends.

[0602] At time T1, mixer 1 starts consuming the encoded images in the second video buffer queue. As Fig.11A shown, mixer 1 starts up and obtains encoded images from the second video buffer queue for mixing. The specific process can refer to the relevant descriptions in S625 and S825 and will not be elaborated here.

[0603] The process of mixer 1 and mixer 2 selecting image frames for mixing (judging whether to mix the frames in the second video buffer queue) can refer to S625, and the following will illustrate it with examples:

[0604] Exemplarily, for a specific video duration of 3s, the timestamp of the first shooting request obtained by mixer 1 is T1. Mixer 1 can determine the first time as T1 + 1.5s and the second time as T1 - 1.5s. Mixer 1 can determine the first encoded image frame (the starting image frame for mixing) to start mixing based on the second time. In the second video buffer queue, if t1 < T1 - 1.5s ≤ t2 (or t1 ≤ T1 - 1.5s < t2), it can be determined that frame 1 corresponding to t1 or frame 2 corresponding to t2 is the first encoded image frame. Mixer 1 starts from the starting image frame and sequentially obtains image frames in timestamp order.

[0605] Exemplarily, for a specific video duration of 3s, the timestamp of the first shooting request obtained by mixer 1 is T1. It can determine the timestamp of a frame based on T1 and determine the first time and the second time based on this timestamp. Among two consecutive frames, frame 44 and frame 45 in the second video buffer queue, whose timestamps satisfy t44 < T1 ≤ t45 and t45 is the closest to T1 in time, it can be determined that the first time is t45 + 1.5 and the second time is t45 - 1.5s. Of course, it can also be determined that the first time is t44 + 1.5 and the second time is t44 - 1.5s. If t1 < t45 - 1.5s ≤ t2, mixer 1 can determine that frame 1 corresponding to t1 or frame 2 corresponding to t2 is the first encoded image frame.

[0606] At time T2, mixer 2 starts consuming the encoded images in the second video buffer queue, and mixer 1 continues to consume the encoded images in the second video buffer queue. As Fig. 11C shown, mixer 1 and mixer 2 respectively obtain encoded images from the second video buffer queue for mixing. At this time, the second video buffer queue includes encoded images from frame 36 to frame 80, and frame 35 in the second video buffer queue will dequeue and frame 81 will enqueue.

[0607] Exemplarily, the timestamp of the second capture request obtained by mixer 2 is T2, and the specific video duration is 3 s. Mixer 2 can determine the first time as T2 + 1.5 s and the second time as T2 - 1.5 s. Mixer 2 can determine the starting image frame for starting mixing based on the second time. Exemplarily, in the second video buffer queue, t36 < T2 - 1.5 s ≤ t37, and it can be determined that frame 36 corresponding to t36 or frame 37 corresponding to t37 is the starting frame. Mixer 2 can start mixing from frame 36 or start mixing from frame 37, and then sequentially obtain image frames according to the timestamp order.

[0608] Exemplarily, after obtaining T2, mixer 2 can determine that the timestamp of the image frame closest to T2 in the second video buffer queue is t80, so that it can determine t80 - 1.5 as the second time, t80 + 1.5 as the first time, and determine t36 < t80 - 1.5 ≤ t37, and determine that frame 36 corresponding to t36 or frame 37 corresponding to t37 is the starting frame.

[0609] In the above process, mixer 1 continues to mix. For example, mixer 1 obtains frame 38, and based on the first time T1 + 1.5 s, determines that t38 < T1 + 1.5 s and t37 < T1 + 1.5 s, and determines to mix frame 38.

[0610] At time T3, mixer 1 stops consuming the encoded images in the second video buffer queue, and mixer 2 continues to consume the encoded images in the second video buffer queue. As Fig.11D shown, both mixer 1 and mixer 2 are consuming the encoded images in the second video buffer queue. The second video buffer queue includes the encoded images from frame 46 to frame 90. The video encoder outputs frame 91 and enqueues it, and dequeues frame 45. As Fig.11E shown, the second video buffer queue includes the encoded images from frame 47 to frame 91. Mixer 1 finishes mixing and stops consuming, and mixer 2 continues to mix. Among them, mixer 1 and mixer 2 consume some of the same encoded images, for example, frames 36 to 90.

[0611] Exemplarily, mixer 1 determines the first time as T1 + 1.5 s and judges whether to continue mixing during the mixing process based on T1 + 1.5 s. In the second video buffer queue, t90 < T1 + 1.5 s ≤ t91, and it can be determined that the mixing ends at frame 90 corresponding to t90 (the mixing includes frame 90); it can also be determined that the mixing ends at frame 91 corresponding to t91 (the mixing includes frame 91). Mixer 1 can then end the mixing.

[0612] Exemplarily, the specific video duration is 3 s, and mixer 1 determines that the first time is t45 + 1.5. In the second video buffer queue, if t89 < t45 + 1.5 s ≤ t90, it can be determined that the mixing ends at frame 89 corresponding to t89 (the mixing includes frame 89); it can also be determined that the mixing ends at frame 90 corresponding to t90 (the mixing includes frame 90). Mixer 1 can then end the mixing.

[0613] At time T4, mixer 1 stops consuming the encoded images in the second video buffer queue. At this time, both mixer 2 and the video encoder can stop.

[0614] Exemplarily, mixer 2 determines that the first time is T2 + 1.5 s, and based on T2 + 1.5 s, it determines whether to continue mixing during the mixing process. In the second video buffer queue, if t125 < T2 + 1.5 s ≤ t126, it can be determined that the mixing ends at frame 125 corresponding to t125 (the mixing includes frame 125); it can also be determined that the mixing ends at frame 126 corresponding to t126 (the mixing includes frame 126). Mixer 2 can then end the mixing (frames 125 and 126 are not shown in the figure).

[0615] Exemplarily, the specific video duration is 3 s, and mixer 1 determines that the first time is t80 + 1.5. In the second video buffer queue, if t124 < t80 + 1.5 s ≤ t125, it can be determined that the mixing ends at frame 124 corresponding to t124 (the mixing includes frame 124); it can also be determined that the mixing ends at frame 125 corresponding to t125 (the mixing includes frame 125). Mixer 2 can then end the mixing.

[0616] In the embodiments of the present application, if mixer 1 mixes frames 1 to 90 and mixer 2 mixes frames 36 to 125, the first video frames can be frames 1 to 90, and the second video frames can be frames 91 to 125.

[0617] In the above process, the consumption time of mixer 1 is from T1 to T3, and the consumption time of mixer 2 is from T2 to T4. The specific consumption processes of mixer 1 and mixer 2 can refer to the processing processes of S625, S629, S825, S829, S840, and S844, which will not be elaborated.

[0618] In addition, the processing processes of the second audio buffer queue, the audio encoder, mixer 1, and mixer 2 can refer to the above process, which will not be elaborated.

[0619] VI. Exit the camera when there is no task of shooting dynamic images. (As shown in steps S1201 - S1225) Fig. 12A shown in steps S1201 - S1225)

[0620] Fig. 12AIt is a flowchart of a method for exiting shooting provided in an embodiment of the present application. Fig. 12A The method of exiting shooting is that the electronic device executes Fig.6D After or Fig.8D What is executed afterwards is the process of exiting the camera, releasing resources, and clearing the audio and video cache queues when the mixing task has been completed and encoding has stopped and the user triggers exiting the camera.

[0621] S1201: The dynamic shooting module receives a request to close the camera application.

[0622] The electronic device receives an operation of exiting the camera application triggered by the user, the dynamic shooting module may receive a request to close the camera application, and the electronic device may exit the preview shooting screen. The operation of exiting the camera application may be a touch operation of the user, or a voice command, a finger command, etc., without limitation.

[0623] S1202: The dynamic photographing module sends a camera closing message to the camera.

[0624] After receiving the request to close the camera application, the dynamic photographing module can send a camera closing message to the camera. Correspondingly, the camera can receive the camera closing message from the dynamic photographing module.

[0625] S1203: The camera stops collecting raw image data and shuts down.

[0626] After receiving the camera shutdown message, the camera may stop collecting raw image data and shut down the camera.

[0627] S1204: The camera sends a camera closing notification to the video cache module.

[0628] After the camera is turned off, a camera turn-off notification may be sent to the video cache module. Correspondingly, the video cache module may receive the camera turn-off notification from the camera.

[0629] S1205: The dynamic shooting module sends a first video cache queue clearing request to the video cache module.

[0630] After receiving the request to close the camera application, the dynamic photographing module may send a first video cache queue clearing request to the video cache module. Correspondingly, the video cache module may receive the first video cache queue clearing request from the dynamic photographing module.

[0631] S1206: The video cache module clears the first video cache queue.

[0632] When the video cache module receives the camera shutdown notification and the first video cache queue clearing request, the first video cache queue can be cleared.

[0633] S1207: The dynamic shooting module sends a streaming resource release request to the video management module.

[0634] After receiving the request to close the camera application, the dynamic photographing module may send a request to release the allocated stream resources to the video management module. Correspondingly, the video management module may receive the request to release the allocated stream resources from the dynamic photographing module.

[0635] S1208: The video management module releases video stream configuration resources.

[0636] After receiving the stream allocation resource release request from the dynamic camera module, the video management module can release the video stream allocation resource, that is, it can clear the stored matching encoding path and other information.

[0637] S1209: The video management module sends a video stream resource release request to the post camera.

[0638] After executing S1208, the video management module may send a video stream resource release request to the post camera. Correspondingly, the post camera may receive the video stream resource release request from the video management module.

[0639] S1210: post camera releases video stream channel resources.

[0640] After executing S1209, the post camera may release the video stream channel resources, that is, release the created surface and other resources.

[0641] S1211: The post camera sends a request to the video acquisition module to stop image acquisition.

[0642] After executing S1210, the post camera may send a request to stop image acquisition to the video acquisition module. Correspondingly, the video acquisition module may receive the request to stop image acquisition from the post camera.

[0643] S1212: The video acquisition module releases image cache resources.

[0644] After executing S1211, the video acquisition module may release the image cache resources, that is, clear the stream allocation parameter information and the like.

[0645] S1213: The dynamic photographing module sends an audio collection stop request to the audio collection module.

[0646] After receiving the request to close the camera application, the dynamic photographing module may send an audio stop acquisition request to the audio acquisition module. Correspondingly, the audio acquisition module may receive the audio stop acquisition request from the dynamic photographing module.

[0647] S1214: The audio collection module sends a microphone off message to the microphone.

[0648] After executing S1213, the audio collection module may send a microphone off message to the microphone. Correspondingly, the microphone may receive the microphone off message from the audio collection module.

[0649] S1215: The microphone stops collecting raw audio data and turns off.

[0650] After executing S1214 , the microphone may stop collecting raw audio data and be turned off.

[0651] S1216: The audio acquisition module sends a first audio cache queue clearing request to the audio cache module.

[0652] After the microphone is turned off, a first audio cache queue clearing request may be sent to the audio cache module. Correspondingly, the audio cache module may receive the first audio cache queue clearing request from the audio acquisition module.

[0653] S1217: The audio cache module clears the first audio cache queue.

[0654] After executing S1216, the audio cache module may clear the first audio cache queue.

[0655] S1218: The dynamic photographing module sends a video encoder release request to the video encoding module.

[0656] After receiving the request to close the camera application, the dynamic photographing module may send a video encoder release request to the video encoding module. Correspondingly, the video encoding module may receive the video encoder release request from the dynamic photographing module.

[0657] S1219: The video encoding module releases the video encoder.

[0658] After executing S1218, the video encoding module may release the video encoder.

[0659] S1220: The video encoding module sends a second video cache queue clearing request to the video queue module.

[0660] After executing S1219, the video encoding module may send a second video cache queue clearing request to the video queue module. Correspondingly, the video queue module may receive the second video cache queue clearing request from the video encoding module.

[0661] S1221: The video queue module clears the second video cache queue.

[0662] After executing S1220, the video queue module may clear the second video cache queue.

[0663] S1222: The dynamic photographing module sends an audio encoder request to the audio encoding module.

[0664] After receiving the request to close the camera application, the dynamic photographing module may send an audio encoder request to the audio encoding module. Correspondingly, the audio encoding module may receive the audio encoder request from the dynamic photographing module.

[0665] S1223: The audio encoding module releases the audio encoder.

[0666] After executing S1222, the audio encoding module may release the audio encoder.

[0667] S1224: The audio encoding module sends a second audio cache queue clearing request to the audio queue module.

[0668] The audio encoding module may send a second audio cache queue clearing request to the audio queue module. Correspondingly, the audio queue module may receive the second audio cache queue clearing request from the audio encoding module.

[0669] S1225: The audio queue module clears the second audio cache queue.

[0670] After executing S1224, the audio queue module may clear the second audio buffer queue.

[0671] In the above execution process, the execution order of S1202, S1205, S1213, S1218 and S1222 is not sequential, and they are all processed after S1201.

[0672] At this point, all encoders, encoding channels, and data caches before and after encoding in the current dynamic image shooting are cleared, releasing processing resources and storage resources.

[0673] 7. If there is a task of shooting dynamic images, exit the camera. Fig. 12B Steps S1226-S1230 shown)

[0674] Fig. 12B It is a flowchart of another method for exiting shooting provided in an embodiment of the present application. Fig. 12B It is executing Figure 6A to Figure 6B or Figure 8A to Figure 8C The exit process during the process.

[0675] When the mixer 1 in the electronic device is mixing the first video, the user triggers the exit camera operation. At this time, the electronic device will also execute steps S1201 to S1225. Furthermore, the electronic device will also execute steps S1226 to S1230. The following is a detailed description:

[0676] S1226: Determine whether a hybrid task is currently being executed.

[0677] Optionally, after receiving the request to close the camera application, the dynamic camera module can determine whether there is a mixing task currently being executed. If the mixer 1 is currently processing the mixing task and the mixing has not been completed, S1227 is executed; otherwise, it is not executed.

[0678] S1227: The dynamic photographing module sends a mixing stop request to mixer 1.

[0679] When the dynamic photographing module receives a request to close the camera application, it can directly send a mixing stop request to the mixer 1. Correspondingly, the mixer 1 can receive the mixing stop request from the dynamic photographing module.

[0680] S1228: Mixer 1 stops.

[0681] After executing S1227, the mixer 1 stops.

[0682] At this time, the judgment logic of whether mixer 1 stops is not the stop logic triggered in S825 and S829, but when receiving the mixing stop request, mixer 1 directly stops the mixing cycle. At this time, the first video mixed by the mixer may not have reached the packaging time. For example, the packaging time is 3s. When the first video is packaged to 1.5s, mixer 1 receives the mixing stop request and stops immediately. At this time, the duration of the first video is 1.5s.

[0683] S1229: Mixer 1 sends a first video mixing completion notification to the dynamic camera module.

[0684] After executing S1228, the mixer 1 may send a first video mixing completion notification to the dynamic photographing module. Correspondingly, the dynamic photographing module may receive the first video mixing completion notification from the mixer 1.

[0685] The execution of S1229 is the same as S832 (S648), except that the triggering conditions are different. S1229 is triggered by the user exiting the camera and mixer 1 ending mixing early.

[0686] S1230: The memory stores the first video as a first file.

[0687] After executing S1228, the memory stores the first file of the first video and the packaged first video.

[0688] In the above implementation, there are two ways for the electronic device to determine the first video. One is to meet the encapsulation time, end the mixing and obtain video 1, and the other is that the user exits the camera early, ends the mixing and obtains video 2. Compared with the two, the duration of video 1 is shorter than that of video 2.

[0689] In the above mixing logic, the priority corresponding to the user operation is the highest, which can ensure that the video mixing is completed while the animated image is obtained and the user operation is coordinated.

[0690] As used in the above embodiments, the term "when..." may be interpreted to mean "if..." or "after..." or "in response to determining..." or "in response to detecting...", depending on the context. Similarly, the phrases "upon determining..." or "if (the stated condition or event) is detected" may be interpreted to mean "if determining..." or "in response to determining..." or "upon detecting (the stated condition or event)" or "in response to detecting (the stated condition or event)", depending on the context.

[0691] 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 program 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 can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can 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 can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that contains one or more available media integration. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk), etc.

[0692] Those skilled in the art can understand that to implement all or part of the processes in the above-mentioned embodiments, the processes can be completed by computer programs to instruct related hardware, and the programs can be stored in computer-readable storage media. When the programs are executed, they can include the processes of the above-mentioned method embodiments. The aforementioned storage media include: ROM or random access memory RAM, magnetic disk or optical disk and other media that can store program codes.

Claims

1. A shooting method, characterized in that: The method is applied to an electronic device, and the method comprises: In response to a first operation on a capture control, starting a first video encoder; encoding the first video frame by the first video encoder; In a process in which the first video encoder encodes the first video frame, in response to a second operation acting on the shooting control, encoding a second video frame by the first video encoder; generating a first dynamic image, wherein the first dynamic image corresponds to the first video frame; generating a second dynamic image, wherein the second dynamic image corresponds to the second video frame; The first video encoder is controlled to stop encoding.

2. The method according to claim 1, characterized in that After controlling the first video encoder to stop encoding, the method further includes: In response to a third operation on the shooting control, starting a second video encoder; encoding the third video frame by the second video encoder; generating a third dynamic image, wherein the third dynamic image corresponds to the third video frame; After generating the third dynamic image, controlling the second video encoder to stop encoding; In response to a fourth operation on the shooting control, starting a third video encoder; encoding the fourth video frame by the third video encoder; A fourth dynamic image is generated, the fourth dynamic image corresponding to the fourth video frame.

3. The method according to claim 1, characterized in that Before the electronic device controls the first video encoder to stop encoding, the method further includes: In response to the first operation, adding a first shooting task to the task list; In response to the second operation, adding a second shooting task to the task list; When generating the first dynamic image: Clear the first shooting task, When there is a task in the task list, controlling the first encoder to continue encoding; When generating the second dynamic image: Clear the second shooting task, When there is no task in the task list, the first video encoder is controlled to stop encoding.

4. The method according to claim 2, characterized in that: Before the electronic device controls the second video encoder to stop encoding, the method further includes: In response to the third operation, adding a third shooting task to the task list; When the third dynamic image is generated, clearing the third shooting task; When there is no task in the task list, the third video encoder is controlled to stop encoding.

5. The method according to claim 1, characterized in that After the electronic device generates the first dynamic image, the method further includes: In response to an operation for launching the gallery, displaying a second user interface; the second user interface includes a first thumbnail of a first static image of the first dynamic image; In response to an operation on the first thumbnail, displaying a third user interface, the third user interface including the first static image; In response to an operation performed on the first static image, the electronic device plays the first dynamic image.

6. The method according to claim 5, characterized in that The first dynamic image includes the first static image and a first video, the first video includes M frames of static images, and M is an integer greater than 1.

7. The method according to any one of claims 1 to 6, characterized in that: The method further comprises: In response to the first operation, starting a first audio encoder; encoding a first audio frame by using the first audio encoder, wherein the first dynamic image corresponds to the first audio frame; During the process of the first audio encoder encoding the first audio frame, in response to the second operation, the first audio encoder encodes a second audio frame, and the second dynamic image corresponds to the second audio frame.

8. The method according to claim 7, characterized in that The generating of the first dynamic image comprises: Mixing a first coded video frame and a first audio code video frame by a first mixer to generate the first dynamic image, wherein the first coded video frame is obtained after the first video encoder encodes the first video frame, and the first coded audio frame is obtained after the first audio encoder encodes the first audio frame; The generating of the second dynamic image comprises: The second dynamic image is generated by mixing the second encoded video frame and the second audio code video frame through a second mixer, wherein the second encoded video frame is obtained after the first video encoder encodes the second video frame, and the second encoded audio frame is obtained after the second audio encoder encodes the second audio frame.

9. The method according to claim 8, characterized in that After the electronic device generates the first dynamic image and the second dynamic image, the method further includes: Control the first video encoder to stop encoding, and control the first audio encoder to stop encoding.

10. The method according to claim 1, characterized in that The method further comprises: In response to an operation for starting the camera, acquiring the first video frame through the camera; Storing the first video frame in a first video cache queue; After encoding the first video frame to obtain the first encoded video frame, the first video encoder stores the first encoded video frame in a second video cache queue.

11. The method according to claim 7, characterized in that The method further comprises: In response to an operation for starting the camera, acquiring the first audio frame through a microphone; Storing the first audio frame in a first audio buffer queue; After encoding the first audio frame to obtain the first encoded audio frame, the first audio encoder stores the first encoded audio frame in a second audio cache queue.

12. The method according to claim 10, characterized in that The method further comprises: In response to the operation acting on the dynamic mode control, the first video cache queue is created, the second video cache queue is created, the first audio cache queue is created, and the second audio cache queue is created.

13. The method according to claim 12, characterized in that The first video cache queue is stored in a hardware abstraction layer HAL of the electronic device, and the second video cache queue, the first audio cache queue and the second audio cache queue are stored in an application layer of the electronic device.

14. The method according to claim 10, characterized in that The method further comprises: determining, by a first mixer, a first time based on a shooting time of the first operation and a specific video duration; In a case where a first time difference between a timestamp of an i-th frame of coded image and a timestamp of a first frame of coded image is less than or equal to the first time, mixing the i-th frame of coded image into the first dynamic image through the first mixer, the i-th frame of coded image being a coded video frame in the second video cache queue; When a first time difference between the time stamp of the i-th frame coded image and the time stamp of the first frame coded image is greater than the first time, the first mixer is controlled to end mixing.

15. The method according to claim 14, characterized in that The method further comprises: Determining a second time based on the shooting time and the specific video duration by the first mixer; The first mixer selects a coded video frame with a timestamp closest to the second time from the second video cache queue as the first frame coded image.

16. The method according to claim 1, characterized in that The method further comprises: In response to an operation on a dynamic mode control, the first video encoder and the first audio encoder are created.

17. The method according to claim 16, characterized in that The method further comprises: In response to an operation acting to exit the camera, the first video encoder and the first audio encoder are released.

18. The method according to claim 1, characterized in that The method further comprises: In response to an operation for activating the camera, displaying a first user interface, the first user interface displays an image acquired by the camera, the first user interface including a dynamic mode control in a closed state; In response to an operation acting on the dynamic mode control, the dynamic mode control is switched to an on state.

19. An electronic device, characterized in that: include: One or more processors and one or more memories; the one or more processors are coupled to the one or more memories, the one or more memories are used to store computer program code, the computer program code includes computer instructions, when the one or more processors execute the computer instructions, the electronic device executes the method as described in any one of claims 1-18.

20. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 18 is implemented.

Citation Information

Cited By

  • Photographing method and electronic device

    EP4645889A1

  • Photographing method and electronic device

    WO2024244604A1