WO2024153191A1 - 视频生成方法、装置、电子设备及介质 - Google Patents
视频生成方法、装置、电子设备及介质 Download PDFInfo
- Publication number
- WO2024153191A1 WO2024153191A1 PCT/CN2024/073038 CN2024073038W WO2024153191A1 WO 2024153191 A1 WO2024153191 A1 WO 2024153191A1 CN 2024073038 W CN2024073038 W CN 2024073038W WO 2024153191 A1 WO2024153191 A1 WO 2024153191A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- video
- video data
- encoding
- electronic device
- time
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/20—Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
- H04N21/23—Processing of content or additional data; Elementary server operations; Server middleware
- H04N21/231—Content storage operation, e.g. caching movies for short term storage, replicating data over plural servers, prioritizing data for deletion
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/20—Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
- H04N21/23—Processing of content or additional data; Elementary server operations; Server middleware
- H04N21/234—Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs
- H04N21/23424—Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving splicing one content stream with another content stream, e.g. for inserting or substituting an advertisement
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/20—Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
- H04N21/23—Processing of content or additional data; Elementary server operations; Server middleware
- H04N21/234—Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs
- H04N21/2343—Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements
- H04N21/234309—Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements by transcoding between formats or standards, e.g. from MPEG-2 to MPEG-4 or from Quicktime to Realvideo
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/40—Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
- H04N21/43—Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
- H04N21/433—Content storage operation, e.g. storage operation in response to a pause request, caching operations
- H04N21/4334—Recording operations
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/40—Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
- H04N21/43—Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
- H04N21/44—Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs
- H04N21/44016—Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving splicing one content stream with another content stream, e.g. for substituting a video clip
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/40—Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
- H04N21/43—Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
- H04N21/44—Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs
- H04N21/4402—Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display
- H04N21/440218—Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display by transcoding between formats or standards, e.g. from MPEG-2 to MPEG-4
Definitions
- the present application belongs to the field of video technology, and specifically relates to a video generation method, device, electronic equipment and medium.
- the user can use the video special effects application to add special effects to a video clip in the original video. Specifically, the user needs to first find the location of the video clip in the video special effects application, then capture the clip, perform special effects processing on the captured video clip, and finally insert it into the original video, so that the electronic device can generate a video containing the video clip with special playback effects.
- the purpose of the embodiments of the present application is to provide a video generation method, device, electronic device and medium, which can solve the problem that the process of users using electronic devices to generate special effects videos that meet their needs is cumbersome and time-consuming.
- an embodiment of the present application provides a video generation method, the method comprising: receiving a first input from a user during a video recording process; in response to the first input, obtaining N first video data, and performing video encoding on the N first video data in a first encoding direction to obtain a first video fragment, where N is a positive integer; generating a target video based on the first video fragment and the second video fragment, the second video fragment comprising: a video fragment obtained by performing video encoding on M second video data in a second encoding direction; wherein the first encoding direction and the second encoding direction are different, and M is a positive integer.
- an embodiment of the present application provides a video generating device, which includes: a receiving module, an acquisition module, an encoding module and a generating module.
- the receiving module is used to receive a first input from a user during the process of recording a video.
- the acquisition module is used to obtain N first video data in response to the first input received by the receiving module.
- the encoding module is used to perform video encoding on the N first video data acquired by the acquisition module in a first encoding direction to obtain a first video segment, where N is a positive integer.
- the generating module is used to generate a target video based on the first video segment and the second video segment encoded by the encoding module, and the second video segment includes: a video segment obtained by video encoding the M second video data in a second encoding direction.
- the first encoding The code direction is different from the second code direction, and M is a positive integer.
- an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the method described in the first aspect are implemented.
- an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
- an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect.
- an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the first aspect.
- the electronic device can obtain N first video data according to the first input of the user during the video recording process, and perform video encoding on the obtained N first video data according to the first encoding direction to obtain a first video clip, where N is a positive integer; then generate a target video according to the first video clip and the second video clip (the second video clip includes: a video clip obtained by video encoding M second video data according to the second encoding direction).
- the first encoding direction and the second encoding direction are different, and M is a positive integer.
- the electronic device can obtain N first video data according to the first input of the user during the video recording process, and perform video encoding on the N first video data according to the first encoding direction to obtain a first video clip, and perform video encoding on the M second video data according to the second encoding direction to obtain a second video clip, and finally generate a target video according to the first video clip and the second video clip, and since the video encoding directions of the first video clip and the second video clip are opposite, the target video obtained after the shooting is directly a video including a video clip with an opposite playback effect, without the user having to use a video special effect application to perform complex post-processing on the shot video, thereby simplifying the process of the user using the electronic device to generate a special effect video that meets the needs, saving time.
- FIG1 is a schematic diagram of a flow chart of a video generation method according to an embodiment of the present application.
- FIG2 is a schematic diagram of a display interface of an electronic device provided in an embodiment of the present application.
- FIG3 is a second flow chart of a video generation method provided in an embodiment of the present application.
- FIG4 is a schematic diagram of a reverse encoding process provided by an embodiment of the present application.
- FIG5 is a third flow chart of the video generation method provided in an embodiment of the present application.
- FIG6 is a fourth flow chart of the video generation method provided in an embodiment of the present application.
- FIG7 is a fifth flow chart of a video generation method provided in an embodiment of the present application.
- FIG8 is a schematic diagram of the structure of a video generating device provided in an embodiment of the present application.
- FIG9 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
- FIG. 10 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application.
- first, second, etc. in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first”, “second”, etc. are generally of one type, and the number of objects is not limited.
- the first object can be one or more.
- “and/or” in the specification and claims represents at least one of the connected objects, and the character “/" generally indicates that the objects associated with each other are in an "or” relationship.
- the video generation method provided in the embodiment of the present application can be applied to a scenario in which a user uses an electronic device to generate a video that can be played in reverse order.
- a user uses an electronic device to generate a video that can be played in reverse order
- a user uses an electronic device to shoot a video of a sunrise at sea.
- the sun slowly rises from the sea level and slowly illuminates the entire sky.
- the user needs to play the video in reverse order to enhance the fun of the video playback. For example, when the sun encounters a cloud during the rising process, the user wants to change the sun in the video from rising from the bottom to falling from the top to enhance the fun of the video playback.
- the user can only wait until the entire video is shot, use the video special effects application to first find the video clip that wants to be played in reverse order, then intercept the clip, and reverse the intercepted video clip, and finally insert it into the original video.
- the user needs to use a third-party application to generate the entire process of the reverse video, and the operation is complicated and inefficient.
- a user uses an electronic device to shoot a video of a sunrise at sea, when the sun in the video slowly rises from the sea level, it encounters a cloud. If the user wants to change the sun in the video from rising from the bottom to falling from the top to enhance the fun of the video playback, the user only needs to click the reverse switch on the target control in the electronic device to mark a video clip shot later in reverse order. When the user clicks the forward switch on the target control, the user can mark a video clip shot later in forward order. During the shooting process, the user can select the video clip that needs to be processed in reverse order at any time.
- the electronic device reverses all the video clips marked in reverse order, and splices them with the video clips marked in forward order, directly generating a video that includes forward and reverse playback, without the need for the user to use a third-party application to perform complex post-processing on the shot video. Therefore, it simplifies the way in which users use electronic devices to generate reverse videos that meet their needs, and improves the efficiency of generating reverse videos.
- the execution subject of the video generation method provided in the embodiment of the present application may be a video generation device.
- the video generation device may be an electronic device, or a functional module in the electronic device.
- the technical solution provided in the embodiment of the present application will be described below by taking an electronic device as an example.
- Step 101 The electronic device receives a first input from a user during video recording.
- the electronic device when a user wants to use an electronic device to record a scene, the electronic device can be triggered to open an application with a video recording function, and a first mark in the interface of the application is selected and input (for example, clicked and inputted) and then aimed at the scene to be photographed. Then the user can select and input (for example, clicked and inputted) a second mark in the interface of the application so that the electronic device can start recording a video of the scene.
- the above-mentioned first identifier is used to select whether to trigger the electronic device to enter the forward recording mode or the reverse recording mode; the above-mentioned second identifier is used to select whether to trigger the electronic device to start recording the video.
- forward recording mode can be understood as: when the video recorded in the forward recording mode is played back after the recording is completed, the pictures in the video are played back in forward order according to the chronological order
- reverse recording mode can be understood as: when the video recorded in the reverse recording mode is played back after the recording is completed, the pictures in the video are played back in reverse order according to the chronological order.
- the first identifier may be an icon of a combination of mutually exclusive switches, which includes a forward sequence switch and a reverse sequence switch.
- a forward sequence switch When the user selects the reverse sequence switch, the forward sequence switch is automatically grayed out and turned off, and the reverse sequence switch is highlighted and turned on; when the user selects the forward sequence switch, the reverse sequence switch is automatically grayed out and turned off, and the forward sequence switch is highlighted and turned on.
- the above-mentioned second identifier can be an icon of a shutter switch.
- the shutter switch When the user chooses to turn on the shutter switch, the shutter switch is highlighted and the electronic device starts recording video; when the user chooses to turn off the shutter switch, the shutter switch is grayed out and the electronic device stops recording video.
- the first input is used to switch the video recording mode of the electronic device, and can be used to switch the electronic device from a forward recording mode to a reverse recording mode, or can be used to switch the electronic device from a reverse recording mode to a forward recording mode.
- the above-mentioned first input includes but is not limited to: the user's touch input of the first identifier through a touch device such as a finger or a stylus, or a specific gesture input by the user, or other feasible input, which can be determined according to actual use requirements and is not limited in the embodiment of the present invention.
- the specific gesture in the embodiment of the present application can be any one of a single-click gesture, a sliding gesture, a dragging gesture, a pressure recognition gesture, a long press gesture, an area change gesture, a double-press gesture, and a double-click gesture;
- the click input in the embodiment of the present application can be a single-click input, a double-click input, or any number of click inputs, etc., and can also be a long press input or a short press input.
- the first input may specifically be: during the process of recording a video, the user clicks on a positive sequence switch in the combined mutually exclusive switch.
- the first input may also specifically be: during the process of recording a video, the user clicks on a reverse switch in the combined mutually exclusive switch.
- the user after the user triggers the electronic device to start an application with a video recording function, the user clicks the positive sequence switch 2 in the combination of mutually exclusive switches 1 in the interface of the application, and then focuses on the scene to be photographed. Click the shutter switch 3 in the application interface to trigger the electronic device to start recording the video of the scene in the forward recording mode.
- the reverse switch 4 in the combined mutually exclusive switch 1 (i.e., the first input)
- the forward switch 2 is automatically grayed out and turned off, and the reverse switch 4 is turned on, thereby triggering the electronic device to switch from the current forward recording mode to the reverse recording mode.
- the user clicks the reverse switch in the combination of mutually exclusive switches in the interface of the application, aligns the scene to be photographed, and then clicks the shutter switch in the interface of the application to trigger the electronic device to start recording the video of the scene in the reverse recording mode.
- the reverse switch is automatically grayed out and turned off, and the forward switch is highlighted and turned on, thereby triggering the electronic device to switch from the current reverse recording mode to the forward recording mode.
- the user after the user triggers the electronic device to start an application with a video recording function, the user aims at the scene to be photographed, and then clicks the shutter switch in the interface of the application to trigger the electronic device to start recording the video of the scene in the reverse recording mode by default.
- the forward switch in the combined mutually exclusive switch i.e., the first input
- the reverse switch is automatically grayed out and turned off, and the forward switch is highlighted and turned on, thereby triggering the electronic device to switch from the current reverse recording mode to the forward recording mode.
- Step 102 The electronic device obtains N first video data in response to a first input, and performs video encoding on the N first video data according to a first encoding direction to obtain a first video segment.
- N is a positive integer.
- the above-mentioned N first video data can be N image data corresponding to N image frames in a video recorded when the electronic device is in a reverse sequence recording mode, or can be N image data corresponding to N image frames in a video recorded when the electronic device is in a forward sequence recording mode.
- the N first video data are the N image data corresponding to the N image frames in the video recorded by the electronic device in the reverse recording mode; if the electronic device is in the reverse recording mode before the user selects and inputs the first identifier (that is, before the user switches the recording mode of the electronic device), and after the user selects and inputs the first identifier (that is, the electronic device is switched from the current forward recording mode to the reverse recording mode), the N first video data are the N image data corresponding to the N image frames in the video recorded by the electronic device in the forward recording mode;
- the above-mentioned first encoding direction is the encoding direction when encoding N first video data.
- the first encoding direction is reverse sequence encoding;
- the first encoding direction is forward sequence encoding.
- the camera module of an electronic device when the camera module of an electronic device records a scene, it will produce visual After the electronic device receives the raw data of the recorded video, it needs to encode the data before it can be saved in the corresponding video format and the video file can be saved.
- the process of video recording is also the process of real-time encoding of these raw data.
- the current mainstream video encoding formats include H.264, H.265, MPEG-4, MPEG-2, WMA-HD and VC-1.
- the video image of a time period is generally regarded as being spliced from P image frames.
- the image data received by the electronic device within one second is the image data of 30 image frames.
- the encoding direction when video encoding is performed on the image data of the 30 image frames is: the 1st frame, the 2nd frame, the 3rd frame... until the 30th frame;
- the encoding direction when video encoding is performed on the image data of the 30 image frames is: the 30th frame, the 29th frame, the 28th frame... until the 1st frame.
- the electronic device may encode the N first video data in any one of the following ways: transform coding, motion estimation and motion compensation coding, entropy coding, etc.
- the N first video data are N image data corresponding to N image frames in a video recorded by the electronic device in a reverse recording mode
- the electronic device encodes the N first video data in a first encoding direction
- the image of the obtained first video clip when played is played in reverse order.
- the N first video data are N image data corresponding to N image frames in a video recorded by the electronic device in a forward sequence recording mode
- the electronic device encodes the N first video data in a first encoding direction
- the image of the obtained first video clip during playback is played in forward sequence.
- Step 103 The electronic device generates a target video according to the first video segment and the second video segment.
- the second video segment includes: a video segment obtained by performing video encoding on M second video data according to a second encoding direction.
- the first encoding direction and the second encoding direction are different, and M is a positive integer.
- the M second video data are: video data acquired in a time before the N first video data during the video recording process.
- the electronic device during the video recording process, after the user selects and inputs the first identifier, that is, after the recording mode of the electronic device is switched from the forward recording mode (or reverse recording mode) to the reverse recording mode (or forward recording mode), the electronic device will end the recording of the previous video (i.e., the second video clip) and save the second video clip.
- the second video clip includes M second video data.
- the electronic device encodes the N first video data in the first video clip according to the first encoding direction, and encodes the M second video data in the second video clip according to the second encoding direction, and then splices the encoded first video segment and second video segment to generate a target video.
- the user can slide up on the video recording interface to make the electronic device display a "file management" window on the video recording interface, and then the user can input a target file in the "file management" window to make the target file appear in the window.
- the second video clip can be added to the video splicing list, and then the user uses the electronic device to record a video in the forward recording mode (or reverse recording mode) to obtain the first video clip, and the N first video data in the first video clip are encoded according to the first encoding direction and then spliced with the second video clip to generate the target video.
- the generated target video includes both video segments that can be played in forward order and video segments that can be played in reverse order.
- the N first video data can be marked before being encoded, which is specifically described below.
- the video generation method provided in the embodiment of the present application may also include the following step 201.
- Step 201 The electronic device adds a first mark to N first video data.
- the first mark is used to indicate that the encoding direction corresponding to the N first video data is the first encoding direction.
- the electronic device during the process of recording a video, if the electronic device is in a forward recording mode (or a reverse recording mode) before the user selects and inputs the first identifier (i.e., before the user switches the recording mode of the electronic device), after the user selects and inputs the first identifier, that is, after the electronic device is switched from the current forward recording mode (or reverse recording mode) to the reverse recording mode (or forward recording mode), the electronic device will end recording the current second video clip and save it, then create a new first file, and add a first mark to the first file.
- the first file is a video file storing N first video data, and the first mark is used to indicate that the encoding direction of the video data in the video file is a reverse encoding direction (or a forward encoding direction).
- the first mark may be instruction information, and the instruction information is used to instruct the electronic device to encode the video data in the video file marked by the first mark according to the first encoding direction.
- the forward recording process is not affected, that is, the recording screen after switching the recording mode can still be a normal forward recording, but an instruction information will be written to create a new video file.
- the electronic device may perform reverse encoding on the N first video data written into the first file, and after the video recording ends and the reverse encoding is completed, when the first video in the exported first file is played on any player, the video image is played in reverse order.
- the electronic device can first receive N first video data, and save the Nth first video data as the starting video data, and then write the N-1th first video data after the Nth first video data, and then write the N-2th first video data after the N-1th first video data, and so on, until the first first video data is written after the second first video data, and then encode the N first video data arranged in reverse order to obtain N first video data encoded in reverse order.
- the first row of video data is 5 first video data inputted, assuming that the image indicated by the first first video data is letter A, the image indicated by the second first video data is letters A and B, the image indicated by the third first video data is letters A, B and C, the image indicated by the fourth first video data is letters A, B, C and D, and the image indicated by the fifth first video data is letters A, B, C, D and E.
- the reverse coded data in the second row represents the reverse coded data of each corresponding video data, that is, the fifth first video data (that is, the last video data) is first saved as the starting video data, and then the fourth first video data is written after the fifth first video data, and then the third first video data is written after the fourth first video data, and so on, until the first first video data is written after the second first video data, and then the five first video data arranged in reverse order are encoded, and the five first video data encoded in reverse order are the coded data of the first video segment.
- the animation effect it presents is a picture in which the five letters "ABCDE-ABCD-ABC-AB-A" are displayed one by one in a decreasing manner.
- the electronic device during the video recording process, before the user selects and inputs the first identifier (i.e., before the user switches the recording mode of the electronic device), the electronic device is in the reverse recording mode, and after the user selects and inputs the first identifier (i.e., the electronic device switches from the current reverse recording mode to the forward recording mode), the electronic device will end the recording of the second video clip, create a new first file, and add a first mark to the first file.
- the first file is a video file for storing N first video data, and the first mark is used to indicate that the corresponding encoding direction is the forward encoding direction.
- the electronic device before the electronic device encodes the N first video data, it can first add a first mark to the N first video data to indicate that the encoding direction corresponding to the N first video data is the first encoding direction, so that the electronic device can better identify the encoding direction of the video data and improve the accuracy of the electronic device in encoding the video data.
- the video generation method provided in the embodiment of the present application may further include the following step 301 .
- Step 301 The electronic device adds a second mark to M second video data.
- the second mark is used to identify that the encoding direction corresponding to the M second video data is the second encoding direction.
- the electronic device at the beginning of recording a video, if the user selects and inputs the first identifier, the electronic device is in a forward recording mode (or a reverse recording mode), the electronic device creates a second file, and then adds a second mark to the second file, and the M second video data in the video recording process are stored in the second file.
- the second file is a video file for storing the M second video data, and the second mark is used to indicate that the encoding direction of the video data in the video file is a forward encoding direction (or a reverse encoding direction).
- the electronic device before the electronic device obtains the N first video data, it can first obtain the M second video data and add the second mark to the M second video data to indicate the code corresponding to the M second video data.
- the direction is the second encoding direction, so that the electronic device can better identify the encoding direction of the video data, thereby improving the accuracy of the electronic device in encoding the video data.
- the electronic device can obtain N first video data according to the first input of the user during the video recording process, and perform video encoding on the obtained N first video data according to the first encoding direction to obtain a first video clip, where N is a positive integer; then generate a target video according to the first video clip and the second video clip (the second video clip includes: a video clip obtained by performing video encoding on M second video data according to the second encoding direction).
- the first encoding direction and the second encoding direction are different, and M is a positive integer.
- the electronic device can obtain N first video data according to the first input of the user during the video recording process, and perform video encoding on the N first video data according to the first encoding direction to obtain a first video clip, and perform video encoding on the M second video data according to the second encoding direction to obtain a second video clip, and finally generate a target video according to the first video clip and the second video clip, and since the video encoding directions of the first video clip and the second video clip are opposite, the target video obtained after the shooting is directly a video including a video clip with an opposite playback effect, without the user having to use a video special effect application to perform complex post-processing on the shot video, thereby simplifying the process of the user using the electronic device to generate a special effect video that meets the needs, saving time.
- step 102 in combination with FIG. 1 , as shown in FIG. 6 , “obtaining N first video data” in the above step 102 can be specifically implemented by the following step 102a.
- Step 102a The electronic device determines the video data collected in the first time period as N first video data.
- the starting time of the above-mentioned first time period is: the input time of the first input; the ending time of the above-mentioned first time period is: the time after the first preset time length from the starting time of the first time period.
- the above-mentioned first preset duration may be a duration pre-set by the user in a target template
- the target template may be a time template that the user selects and calls in the electronic device before video recording and that can timer switch the video recording mode.
- the target template includes X first instructions and Y second instructions, the first instruction is used to instruct the electronic device to remain in a forward recording mode or a reverse recording mode within a preset time length, X is a positive integer; the second instruction is used to instruct the electronic device to remain in a reverse recording mode or a forward recording mode within a preset time length, Y is a positive integer.
- X and Y can be the same or different; the video recording mode after the electronic device executes the first instruction is opposite to the video recording mode after executing the second instruction.
- video recording mode can be understood as: whether the video recording mode of the electronic device is a forward recording mode or a reverse recording mode.
- the video recording mode after the electronic device executes the first instruction is a forward recording mode
- the video recording mode after the electronic device executes the second instruction is a reverse recording mode
- the video recording mode after the electronic device executes the first instruction is a reverse recording mode
- the video recording mode after the electronic device executes the second instruction is a forward recording mode
- the time template may be: 10 seconds in forward order + 10 seconds in reverse order, that is, the time template includes 1 first instruction and 1 second instruction.
- the first instruction instructs the electronic device to keep the video in the first 10 seconds after the video starts recording.
- the second switching instruction instructs the electronic device to remain in the reverse recording mode within the second 10 seconds after the video recording starts.
- the time template may be: 5S in reverse order + 10S in forward order + 10S in reverse order, that is, the time template includes 2 first instructions and 1 second instruction.
- the first first instruction instructs the electronic device to remain in the reverse order recording mode within 5S after the video starts recording
- the first second instruction instructs the electronic device to remain in the forward order recording mode within 6S to 15S after the video starts recording
- the second first instruction instructs the electronic device to remain in the reverse order recording mode within 16S to 25S after the video starts recording.
- the input time of the first input may be the time when the electronic device receives the second instruction.
- the starting time of the first time period is: the starting time when the electronic device is in the forward recording mode
- the end time of the first time period is: the moment when the time when the electronic device is in the forward recording mode meets the preset time length corresponding to the second instruction
- the starting time of the first time period is: the starting time when the electronic device is in the reverse recording mode
- the end time of the first time period is: the moment when the time when the electronic device is in the reverse recording mode exceeds the preset time length corresponding to the second instruction.
- the time template is: 10S in reverse order + 10S in forward order + 10S in reverse order
- the electronic device after the electronic device starts recording the video and remains in reverse order recording mode for 10S, it receives a second switching instruction instructing the electronic device to switch from reverse order recording mode to forward order recording mode
- the starting moment of the first time period is: the 11th second after the electronic device starts recording the video
- the ending moment of the first time period is: the moment after the electronic device starts recording the video (that is, the moment after the electronic device has been in forward order recording mode for more than 10S).
- the N video data collected by the electronic device from the 11th to the 20th second that is, the first time period
- the first time period that is, within 10S in forward order recording mode
- the time template is: 5S in forward order + 5S in reverse order + 5S in forward order
- the electronic device after the electronic device starts recording the video and remains in the forward recording mode for 5S, it receives a second switching instruction instructing the electronic device to switch from the forward recording mode to the reverse recording mode
- the starting time of the first time period is: the 6th second after the electronic device starts recording the video
- the ending time of the first time period is: the moment after the electronic device starts recording the video (that is, the moment after the electronic device has been in the reverse recording mode for more than 5S).
- the above-mentioned target template can be a time template pre-stored in the electronic device or a user-defined time template.
- the switching order of the forward recording mode and the reverse recording mode in the time template and the preset time in each recording mode can be set arbitrarily and are not limited here.
- the electronic device can collect video data in the time period from the input time of the first input to the first preset duration, and determine the collected video data as N first video data, so that the user can use the electronic device to obtain various video content that meets the needs.
- the above-mentioned second video segment also includes: a video segment obtained by video encoding Q third video data according to the second encoding direction, Q is a positive integer.
- the video generation method provided in the embodiment of the present application may also include the following step 401.
- Step 401 The electronic device determines the video data collected in the second time period as Q third video data.
- the starting time of the above-mentioned second time period is: the ending time of the first time period; the ending time of the above-mentioned second time period is: the time after the second preset time length from the starting time of the second time period.
- the starting moment of the second time period is the moment after the first preset time period from when the electronic device is in the forward recording mode (or reverse recording mode) after executing the second instruction.
- the second preset duration may be a duration preset by the user in the first instruction received again by the electronic device or preset in the target template.
- the time template is: reverse 10S+forward 10S+reverse 10S
- the electronic device after the electronic device starts recording the video, it is in reverse recording mode for 10S according to the first first instruction, and then it is in forward recording mode for 10S according to the second instruction, and then the electronic device receives the second first instruction, instructing the electronic device to switch from forward recording mode to reverse recording mode
- the starting time of the second time period is: the 21st second after the electronic device starts recording the video (i.e., the moment when the second first instruction is received)
- the end time of the second time period is: after the 30th second after the electronic device starts recording the video (i.e., the moment after the electronic device is in reverse recording mode for more than 10S).
- the time template is: 5S in forward sequence + 10S in reverse sequence + 10S in forward sequence
- the electronic device after the electronic device starts recording the video, it is in forward recording mode for 5S according to the first first instruction, and then in reverse recording mode for 10S according to the second instruction, and then the electronic device receives the second first instruction, instructing the electronic device to switch from reverse recording mode to forward recording mode
- the starting time of the second time period is: the 16th second after the electronic device starts recording the video (i.e., the moment when the second first instruction is received)
- the end time of the second time period is: after the 25th second after the electronic device starts recording the video (i.e., the moment after the electronic device is in forward recording mode for more than 10S).
- the Q video data collected by the electronic device from the 16th second to the 25th second are determined as Q third video data.
- the electronic device After the electronic device obtains the Q third video data, it performs video encoding on the Q third video data in a forward encoding manner to obtain a second video clip.
- the electronic device after the electronic device obtains X video files containing second video data and Y video files containing first video data according to the X first instructions and Y second instructions in the target template, it performs video encoding on all the first video data according to the first encoding direction to obtain Y first video clips, and performs video encoding on all the second video data according to the first encoding direction to obtain Y first video clips.
- Video encoding is performed according to the second encoding direction to obtain X second video segments, and finally the Y first video segments and the X second video segments are sorted and spliced according to the acquisition time of the video files to obtain the target video.
- the electronic device can also collect the third video data in the second time period after the first time period, and perform video encoding on the collected third video data according to the second encoding direction to obtain a second video segment, so that the user can use the electronic device to obtain any number of first video segments and second video segments as needed.
- the method provided in the embodiment of the present application can be executed by a video generating device.
- a video generating device executing a video generating method is taken as an example to illustrate the video generating device provided in the embodiment of the present application.
- FIG8 shows a video generating device 60 involved in the above embodiment, and the video generating device 60 includes: a receiving module 61, an acquisition module 62, an encoding module 63 and a generating module 64.
- the receiving module 61 is used to receive a first input from a user during video recording.
- the acquisition module 62 is used to obtain N first video data in response to the first input received by the receiving module.
- the encoding module 63 is used to perform video encoding on the N first video data acquired by the acquisition module according to the first encoding direction to obtain a first video segment, where N is a positive integer.
- the generating module 64 is used to generate a target video according to the first video segment and the second video segment encoded by the encoding module, and the second video segment includes: a video segment obtained by video encoding M second video data according to the second encoding direction.
- the first encoding direction and the second encoding direction are different, and M is a positive integer.
- the video generation device 60 further includes: a determination module.
- the determination module is used to determine the video data collected in the first time period as N first video data.
- the start time of the first time period is: the input time of the first input
- the end time of the first time period is: the time after the first preset time length from the start time of the first time period.
- the second video segment further includes: a video segment obtained by video encoding Q third video data according to the second encoding direction, where Q is a positive integer.
- the determination module is also used to determine the video data collected in the second time period as Q third video data.
- the start time of the second time period is: the end time of the first time period
- the end time of the second time period is: the time after the second preset time length from the start time of the second time period.
- the video generating device 60 further includes: an adding module, wherein the adding module is used to add a first mark to the N first video data, wherein the first mark is used to indicate that the encoding direction corresponding to the N first video data is the first encoding direction.
- the video generating device 60 further includes: an adding module, wherein the adding module is used to add a second mark to the M second video data, wherein the second mark is used to indicate that the encoding direction corresponding to the M second video data is the second encoding direction.
- the video generating device provided in the embodiment of the present application can obtain N first video data according to the first input of the user during the video recording process, and encode the N first video data according to the first encoding direction.
- Video encoding is performed to obtain a first video clip
- video encoding is performed on M second video data according to a second encoding direction to obtain a second video clip
- a target video is generated according to the first video clip and the second video clip. Since the video encoding directions of the first video clip and the second video clip are opposite, the target video obtained after shooting is directly a video including the video clip with the opposite playback effect, and the user does not need to use a video special effects application to perform complicated post-processing on the shot video. Therefore, the process of using a video generating device to generate a special effects video that meets the needs is simplified, saving time.
- the video generating device in the embodiment of the present application can be an electronic device or a component in the electronic device, such as an integrated circuit or a chip.
- the electronic device can be a terminal or other devices other than a terminal.
- the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile internet device (mobile internet device, MID), an augmented reality (augmented reality, AR)/virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc.
- It can also be a server, a network attached storage (network attached storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., and the embodiment of the present application is not specifically limited.
- network attached storage network attached storage, NAS
- personal computer personal computer, PC
- television television
- teller machine a self-service machine
- the video generation device in the embodiment of the present application may be a device having an operating system.
- the operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
- the video generation device provided in the embodiment of the present application can implement each process implemented by the method embodiments of Figures 1 to 7. To avoid repetition, they will not be described here.
- the embodiment of the present application also provides an electronic device 80, including a processor 81 and a memory 82, and the memory 82 stores a program or instruction that can be executed on the processor 81.
- the program or instruction is executed by the processor 81, the various process steps of the above-mentioned method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
- the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.
- FIG. 10 is a schematic diagram of the hardware structure of an electronic device implementing an embodiment of the present application.
- the electronic device 100 includes but is not limited to components such as a radio frequency unit 1001, a network module 1002, an audio output unit 1003, an input unit 1004, a sensor 1005, a display unit 1006, a user input unit 1007, an interface unit 1008, a memory 1009, and a processor 110.
- the electronic device 100 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 110 through a power management system, so that the power management system can manage charging, discharging, and power consumption.
- a power source such as a battery
- the electronic device structure shown in FIG10 does not constitute a limitation on the electronic device, and the electronic device may include more or fewer components than shown, or combine certain components, or arrange components differently, which will not be described in detail here.
- the processor 110 is specifically configured to receive a first input from a user during video recording; An input is used to obtain N first video data, and video encoding is performed on the N first video data according to a first encoding direction to obtain a first video segment, where N is a positive integer; a target video is generated according to the first video segment and the second video segment, and the second video segment includes: a video segment obtained by video encoding M second video data according to a second encoding direction; wherein the first encoding direction and the second encoding direction are different, and M is a positive integer.
- the electronic device provided by the embodiment of the present application can obtain N first video data according to the user's first input during the process of recording a video, and perform video encoding on the N first video data according to a first encoding direction to obtain a first video clip, and perform video encoding on M second video data according to a second encoding direction to obtain a second video clip, and finally generate a target video according to the first video clip and the second video clip. Since the video encoding directions of the first video clip and the second video clip are opposite, the target video obtained after shooting is directly a video including the video clip with the opposite playback effect, and the user does not need to use a video special effects application to perform complicated post-processing on the shot video. Therefore, the process of users using electronic devices to generate special effects videos that meet their needs is simplified, saving time.
- the processor 110 is specifically used to determine the video data collected in the first time period as N first video data; wherein the starting moment of the first time period is: the input moment of the first input; the end moment of the first time period is: the moment after the first preset time length from the starting moment of the first time period.
- the electronic device can collect video data in the time period from the input time of the first input to the first preset duration, and determine the collected video data as N first video data, so that the user can use the electronic device to obtain various video content that meets the needs.
- the processor 110 is specifically used to determine the video data collected in the second time period as Q third video data; wherein the starting moment of the second time period is: the end moment of the first time period; the end moment of the second time period is: the moment after the second preset time length from the starting moment of the second time period.
- the electronic device can collect video data in the time period from the input time of the first input to the first preset duration, and determine the collected video data as N first video data, so that the user can use the electronic device to obtain various video content that meets the needs.
- the processor 110 is specifically configured to add a first mark to the N first video data, where the first mark is used to indicate that the encoding direction corresponding to the N first video data is the first encoding direction.
- the electronic device before the electronic device encodes the N first video data, it can first add a first mark to the N first video data to indicate that the encoding direction corresponding to the N first video data is the first encoding direction, so that the electronic device can better identify the encoding direction of the video data and improve the accuracy of the electronic device in encoding the video data.
- the processor 110 is specifically configured to add a second mark to the M second video data, where the second mark is used to indicate that the encoding direction corresponding to the M second video data is the second encoding direction.
- the electronic device before the electronic device obtains the N first video data, it can first obtain the M second video data and add the second mark to the M second video data to indicate the code corresponding to the M second video data.
- the direction is the second encoding direction, so that the electronic device can better identify the encoding direction of the video data, thereby improving the accuracy of the electronic device in encoding the video data.
- the input unit 1004 may include a graphics processing unit (GPU) 1041 and a microphone 1042, and the graphics processor 1041 processes the image data of the static picture or video obtained by the image capture device (such as a camera) in the video capture mode or the image capture mode.
- the display unit 1006 may include a display panel 1061, and the display panel 1061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc.
- the user input unit 1007 includes a touch panel 1071 and at least one of other input devices 1072.
- the touch panel 1071 is also called a touch screen.
- the touch panel 1071 may include two parts: a touch detection device and a touch controller.
- Other input devices 1072 may include, but are not limited to, a physical keyboard, function keys (such as a volume control key, a switch key, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.
- the memory 1009 can be used to store software programs and various data.
- the memory 1009 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc.
- the memory 1009 may include a volatile memory or a non-volatile memory, or the memory 1009 may include both volatile and non-volatile memories.
- the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory.
- the volatile memory may be a random access memory (RAM), a static RAM (SRAM), a dynamic RAM (DRAM), a synchronous DRAM (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct RAM bus random access memory (DRRAM).
- the memory 1009 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
- the processor 110 may include one or more processing units; optionally, the processor 110 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 110.
- the technical solution of the present application can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM/RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
- a storage medium such as ROM/RAM, a disk, or an optical disk
- a terminal which can be a mobile phone, a computer, a server, or a network device, etc.
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Business, Economics & Management (AREA)
- Marketing (AREA)
- Television Signal Processing For Recording (AREA)
Abstract
本申请公开了一种视频生成方法、装置、电子设备及介质,属于视频技术领域。其中,该视频生成方法包括:在录制视频的过程中,接收用户的第一输入;响应于第一输入,获取N个第一视频数据,并按照第一编码方向对该N个第一视频数据进行视频编码,得到第一视频片段,N为正整数;根据第一视频片段和第二视频片段,生成目标视频,该第二视频片段包括:按照第二编码方向对M个第二视频数据进行视频编码得到的视频片段;其中,第一编码方向和第二编码方向不同,M为正整数。
Description
相关申请的交叉引用
本申请主张在2023年01月19日在中国提交的中国专利申请号202310076842.4的优先权,其全部内容通过引用包含于此。
本申请属于视频技术领域,具体涉及一种视频生成方法、装置、电子设备及介质。
通常,用户想要得到一段具有特殊播放效果的视频时,可以使用视频特效应用对原视频中的某一个视频片段添加特效,具体地,用户需要先在视频特效应用中找到该视频片段的位置,然后对该片段进行截取,并对截取的视频片段进行特效处理,最后再插入到原视频中,以使得电子设备可以生成包含有特殊播放效果的视频片段的视频。
但是,生成包含有特殊播放效果的视频片段的视频,需要在视频特效应用中进行繁琐的操作,整个过程复杂且费时。
因此,导致用户使用电子设备生成满足需求的特效视频的过程繁琐且费时。
发明内容
本申请实施例的目的是提供一种视频生成方法、装置、电子设备及介质,能够解决用户使用电子设备生成满足需求的特效视频的过程繁琐且费时的问题。
第一方面,本申请实施例提供了一种视频生成方法,该方法包括:在录制视频的过程中,接收用户的第一输入;响应于第一输入,获取N个第一视频数据,并按照第一编码方向对该N个第一视频数据进行视频编码,得到第一视频片段,N为正整数;根据第一视频片段和第二视频片段,生成目标视频,该第二视频片段包括:按照第二编码方向对M个第二视频数据进行视频编码得到的视频片段;其中,第一编码方向和第二编码方向不同,M为正整数。
第二方面,本申请实施例提供了一种视频生成装置,该视频生成装置包括:接收模块、获取模块、编码模块以及生成模块。其中,接收模块,用于在录制视频的过程中,接收用户的第一输入。获取模块,用于响应于接收模块接收的第一输入,获取N个第一视频数据。编码模块,用于并按照第一编码方向对获取模块获取的N个第一视频数据进行视频编码,得到第一视频片段,N为正整数。生成模块,用于根据编码模块编码得到的第一视频片段和第二视频片段,生成目标视频,该第二视频片段包括:按照第二编码方向对M个第二视频数据进行视频编码得到的视频片段。其中,第一编
码方向和第二编码方向不同,M为正整数。
第三方面,本申请实施例提供了一种电子设备,该电子设备包括处理器和存储器,所述存储器存储可在所述处理器上运行的程序或指令,所述程序或指令被所述处理器执行时实现如第一方面所述的方法的步骤。
第四方面,本申请实施例提供了一种可读存储介质,所述可读存储介质上存储程序或指令,所述程序或指令被处理器执行时实现如第一方面所述的方法的步骤。
第五方面,本申请实施例提供了一种芯片,所述芯片包括处理器和通信接口,所述通信接口和所述处理器耦合,所述处理器用于运行程序或指令,实现如第一方面所述的方法。
第六方面,本申请实施例提供一种计算机程序产品,该程序产品被存储在存储介质中,该程序产品被至少一个处理器执行以实现如第一方面所述的方法。
在本申请实施例中,电子设备可以在录制视频的过程中,根据用户的第一输入,获取N个第一视频数据,并按照第一编码方向对获取的N个第一视频数据进行视频编码,得到第一视频片段,N为正整数;然后根据第一视频片段和第二视频片段(第二视频片段包括:按照第二编码方向对M个第二视频数据进行视频编码得到的视频片段),生成目标视频。其中,第一编码方向和第二编码方向不同,M为正整数。由于电子设备在录制视频的过程中就可以根据用户的第一输入获取N个第一视频数据,并按照第一编码方向对N个第一视频数据进行视频编码,得到第一视频片段,且按照第二编码方向对M个第二视频数据进行视频编码,得到第二视频片段,最后根据第一视频片段和第二视频片段,生成目标视频,又由于第一视频片段和第二视频片段的视频编码方向是相反的,因而拍摄结束后得到的目标视频直接就是包括播放效果相反的视频片段的视频,而无需用户使用视频特效应用对拍摄的视频进行复杂的后期处理,因此简化了用户使用电子设备生成满足需求的特效视频的过程,节约了时间。
图1是本申请实施例提供的视频生成方法的流程示意图之一;
图2是本申请实施例提供的电子设备的显示界面示意图;
图3是本申请实施例提供的视频生成方法的流程示意图之二;
图4是本申请实施例提供的倒序编码过程的示意图;
图5是本申请实施例提供的视频生成方法的流程示意图之三;
图6是本申请实施例提供的视频生成方法的流程示意图之四;
图7是本申请实施例提供的视频生成方法的流程示意图之五;
图8是本申请实施例提供的视频生成装置的结构示意图;
图9是本申请实施例提供的电子设备的结构示意图;
图10是本申请实施例提供的电子设备的硬件结构示意图。
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员获得的所有其他实施例,都属于本申请保护的范围。
本申请的说明书和权利要求书中的术语“第一”、“第二”等是用于区别类似的对象,而不用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便本申请的实施例能够以除了在这里图示或描述的那些以外的顺序实施,且“第一”、“第二”等所区分的对象通常为一类,并不限定对象的个数,例如第一对象可以是一个,也可以是多个。此外,说明书以及权利要求中“和/或”表示所连接对象的至少其中之一,字符“/”,一般表示前后关联对象是一种“或”的关系。
下面结合附图,通过具体的实施例及其应用场景对本申请实施例提供的视频生成方法、装置、电子设备及介质进行详细地说明。
本申请实施例提供的视频生成方法可以应用于用户使用电子设备生成可以倒序播放的视频的场景。
针对用户使用电子设备生成可以倒序播放的视频的场景,假设用户使用电子设备在拍摄一段海上日出的视频,该视频中太阳从海平面缓缓升起,慢慢地照亮了整个天空,然而,在某些特殊的场景下,用户需要对视频进行倒序播放以增强视频播放的趣味性,例如,当太阳升起的过程中碰到了一片云朵,用户想要将视频中的太阳由从下至上升起改为自上而下降落,以增强该视频播放的趣味性。在现实情况下,用户只能等整个视频拍摄完成后,利用视频特效应用先找到想要进行倒序播放的视频片段,然后对该片段进行截取,并对截取的视频片段进行倒序处理,最后再插入到原视频中。但是,生成倒序视频的整个处理过程用户需要借助第三方应用,并且操作复杂,效率较低。
而在本申请实施例中,用户使用电子设备拍摄一段海上日出的视频过程中,当视频中太阳从海平面缓缓升起时碰到了一片云朵,若此时用户想要将视频中的太阳由从下至上升起改为自上而下降落,以增强该视频播放的趣味性,则用户只需要点击电子设备中的目标控件上的倒序开关,就可以对之后拍摄的一个视频片段进行倒序标记,当用户点击目标控件上的正序开关后,又可以对之后拍摄的一个视频片段进行正序标记,拍摄过程中用户可以随时对需要倒序处理的视频片段进行选择,最后视频拍摄完成后,电子设备对所有倒序标记的视频片段进行倒序处理,并和正序标记的视频片段进行拼接处理,直接生成包括正序播放和倒序播放的视频,而无需用户使用第三方应用对拍摄的视频进行复杂的后期处理,因此简化了用户使用电子设备生成满足需求的倒序视频的方式,提高了生成倒序视频的效率。
本申请实施例提供的视频生成方法的执行主体可以为视频生成装置。其中,视频生成装置可以为电子设备,或该电子设备中的功能模块。以下将以电子设备为例对本申请实施例提供的技术方案进行说明。
图1示出了本申请实施例提供的一种视频生成方法的流程图。如图1所示,本申请实施例提供的一种视频生成方法可以包括下述的步骤101至步骤103。
步骤101、电子设备在录制视频的过程中,接收用户的第一输入。
可选地,本申请实施例中,在用户想要使用电子设备对某个场景进行录制时,可以触发电子设备开启具有视频录制功能的应用,并对该应用的界面中的第一标识进行选择输入(例如点击输入)后对准要拍摄的场景,然后用户可以对该应用的界面中的第二标识进行选择输入(例如点击输入),以使得电子设备可开始录制该场景的视频。
其中,上述第一标识用于选择触发电子设备进入正序录制模式还是倒序录制模式;上述第二标识用于选择触发电子设备开始录制视频。
需要说明的是,上述“正序录制模式”可以理解为:在该正序录制模式下录制的视频在录制结束后进行播放时,视频中的画面是按照时间先后的顺序进行正序播放的;上述“倒序录制模式”可以理解为:在该倒序录制模式下录制的视频在录制结束后进行播放时,视频中的画面是按照时间先后的顺序进行倒序播放的。
可选地,本申请实施例中,上述第一标识可以为组合互斥开关的图标,该组合互斥开关包括正序开关和倒序开关。其中,当用户选择倒序开关后,则正序开关自动置灰并关闭,倒序开关高亮并开启;当用户选择正序开关后,则倒序开关自动置灰并关闭,正序开关高亮并开启。
可选地,本申请实施例中,上述第二标识可以为快门开关的图标,当用户选择开启快门开关后,快门开关高亮,并且电子设备开始录制视频;当用户选择关闭快门开关后,快门开关置灰,并且电子设备停止录制视频。
可选地,本申请实施例中,上述第一输入用于切换电子设备的视频录制模式,可以用于将电子设备由正序录制模式切换为倒序录制模式,也可以用于将电子设备由倒序录制模式切换为正序录制模式。
可选地,本申请实施例中,上述第一输入包括但不限于:用户通过手指或者手写笔等触控装置对第一标识的触控输入,或者为用户输入的特定手势,或者为其他可行性输入,具体的可以根据实际使用需求确定,本发明实施例不作限定。本申请实施例中的特定手势可以为单击手势、滑动手势、拖动手势、压力识别手势、长按手势、面积变化手势、双按手势、双击手势中的任意一种;本申请实施例中的点击输入可以为单击输入、双击输入或任意次数的点击输入等,还可以为长按输入或短按输入。
例如,上述第一输入具体可以为:在录制视频的过程中,用户对组合互斥开关中的正序开关进行点击的输入。
例如,上述第一输入具体还可以为:在录制视频的过程中,用户对组合互斥开关中的倒序开关进行点击的输入。
在一种示例中,如图2所示,用户触发电子设备开启具有视频录制功能的应用后,对该应用的界面中的组合互斥开关1中的正序开关2进行点击后,对准要拍摄的场景,然后
点击该应用界面中的快门开关3,以触发电子设备在正序录制模式下开始录制该场景的视频。在录制视频的过程中,用户对组合互斥开关1中的倒序开关4进行点击后(即第一输入),正序开关2自动置灰并关闭,倒序开关4开启,从而触发电子设备由当前的正序录制模式切换为倒序录制模式。
在另一种示例中,用户触发电子设备开启具有视频录制功能的应用后,对该应用的界面中的组合互斥开关中的倒序开关进行点击后,对准要拍摄的场景,然后点击该应用的界面中的快门开关,以触发电子设备在倒序录制模式下开始录制该场景的视频。在录制视频的过程中,用户对组合互斥开关中的正序开关进行点击后(即第一输入),倒序开关自动置灰并关闭,正序开关高亮并开启,从而触发电子设备由当前的倒序录制模式切换为正序录制模式。
在再一种示例中,用户触发电子设备开启具有视频录制功能的应用后,对准要拍摄的场景,然后点击该应用的界面中的快门开关,以触发电子设备默认在倒序录制模式下开始录制该场景的视频。在录制视频的过程中,用户对组合互斥开关中的正序开关进行点击后(即第一输入),倒序开关自动置灰并关闭,正序开关高亮并开启,从而触发电子设备由当前的倒序录制模式切换为正序录制模式。
步骤102、电子设备响应于第一输入,获取N个第一视频数据,并按照第一编码方向对N个第一视频数据进行视频编码,得到第一视频片段。
本申请实施例中,N为正整数。
可选地,本申请实施例中,上述N个第一视频数据可以为电子设备处于倒序录制模式下录制的视频中的N个图像帧对应的N个图像数据,也可以为电子设备处于正序录制模式下录制的视频中的N个图像帧对应的N个图像数据。
可以理解,在录制视频的过程中,若用户对第一标识进行选择输入之前(即用户切换电子设备的录制模式之前),电子设备处于正序录制模式,当用户对第一标识进行选择输入后(即将电子设备由当前的正序录制模式切换为倒序录制模式),则N个第一视频数据为电子设备处于倒序录制模式下录制的视频中的N个图像帧对应的N个图像数据;若用户对第一标识进行选择输入之前(即用户切换电子设备的录制模式之前),电子设备处于倒序录制模式,当用户对第一标识进行选择输入后(即将电子设备由当前的倒序录制模式切换为正序录制模式),则N个第一视频数据为电子设备处于正序录制模式下录制的视频中的N个图像帧对应的N个图像数据。
可选地,本申请实施例中,上述第一编码方向为对N个第一视频数据进行编码时的编码方向,当N个第一视频数据为电子设备处于倒序录制模式下录制的视频中的N个图像帧对应的N个图像数据,则第一编码方向为倒序编码;当N个第一视频数据为电子设备处于正序录制模式下录制的视频中的N个图像帧对应的N个图像数据,则第一编码方向为正序编码。
需要说明的是,电子设备的摄像模组在对某个场景进行视频录制的过程中,会产生视
频的原始数据,电子设备接收到录制视频的原始数据后,需对之进行数据编码后,才可保存为相应的视频格式,并进行视频文件的保存。也就是说,视频录制的过程也是对这些原始数据进行实时编码的过程。一般而言,目前主流的视频编码格式包括H.264、H.265、MPEG-4、MPEG-2、WMA-HD以及VC-1等,在视频录制的过程中,对录制视频的原始数据进行编码时,一般都是将一个时间段的视频图像看作是由P个图像帧进行拼接得来的。假设,视频拍摄时的帧率为30帧/每秒(Frames Per Second,FPS),则一秒内电子设备接收到的图像数据就是30张图像帧的图像数据。如果该30张图像帧为正序录制模式下得到的图像帧,则对该30张图像帧的图像数据进行视频编码时的编码方向为:第1帧、第2帧、第3帧……直至第30帧;如果该30张图像帧为倒序录制模式下得到的图像帧,则对该30张图像帧的图像数据进行视频编码时的编码方向为:第30帧、第29帧、第28帧……直至第1帧。
可选地,本申请实施例中,电子设备对N个第一视频数据进行编码的方式可以为以下任意一项:变换编码、运动估计和运动补偿编码、熵编码等。
可选地,本申请实施例中,当N个第一视频数据为电子设备处于倒序录制模式下录制的视频中的N个图像帧对应的N个图像数据,则电子设备按照第一编码方向对该N个第一视频数据进行编码后,得到的第一视频片段在播放时的图像为倒序播放。
可选地,本申请实施例中,当N个第一视频数据为电子设备处于正序录制模式下录制的视频中的N个图像帧对应的N个图像数据,则电子设备按照第一编码方向对该N个第一视频数据进行编码后,得到的第一视频片段在播放时的图像为正序播放。
步骤103、电子设备根据第一视频片段和第二视频片段,生成目标视频。
本申请实施例中,上述第二视频片段包括:按照第二编码方向对M个第二视频数据进行视频编码得到的视频片段。
本申请实施例中,上述第一编码方向和第二编码方向不同,M为正整数。
可选地,本申请实施例中,上述M个第二视频数据为:在录制视频的过程中,获取的时间位于N个第一视频数据之前的视频数据。可选地,在本申请实施例的一种可能的实现方式中,在录制视频的过程中,当用户对第一标识进行选择输入后,即将电子设备的录制模式由正序录制模式(或倒序录制模式)切换为倒序录制模式(或正序录制模式)后,电子设备会结束前一段视频(即第二视频片段)的录制,并保存该第二视频片段。其中,该第二视频片段包括M个第二视频数据。进一步可选地,本申请实施例中,电子设备对第一视频片段中的N个第一视频数据按照第一编码方向进行编码,并对第二视频片段中的M个第二视频数据按照第二编码方向进行编码,然后对编码后的第一视频段和第二视频段进行拼接处理,生成目标视频。
可选地,在本申请实施例的另一种可能的实现方式中,在录制视频的过程中,用户可以在视频录制界面进行上滑输入,以使得电子设备可以在视频录制界面上显示“文件管理”窗口,然后用户可以对该“文件管理”窗口中的目标文件进行输入,以使得该目标文件中
的第二视频片段可以加入视频拼接列表,然后用户使用电子设备在正序录制模式(或倒序录制模式)下录制一段视频后,得到第一视频片段,对第一视频片段中的N个第一视频数据按照第一编码方向进行编码后与第二视频片段进行拼接处理,生成目标视频。
可以理解,生成的目标视频既包括可以正序播放的视频段又包括可以倒序播放的视频段。为了使电子设备更好地识别哪些视频数据需要进行正序编码,哪些视频数据需要进行倒序编码,可以在对N个第一视频数据进行视频编码之前,对N个第一视频数据添加标记,以下具体进行说明。
可选地,本申请实施例中,结合图1,如图3所示,在上述步骤102中的“按照第一编码方向对N个第一视频数据进行视频编码,得到第一视频片段”之前,本申请实施例提供的视频生成方法还可以包括下述的步骤201。
步骤201、电子设备对N个第一视频数据添加第一标记。
本申请实施例中,上述第一标记用于标示N个第一视频数据对应的编码方向为第一编码方向。
可选地,本申请实施例中,在录制视频的过程中,若用户对第一标识进行选择输入之前(即用户切换电子设备的录制模式之前),电子设备处于正序录制模式(或倒序录制模式),当用户对第一标识进行选择输入后,即将电子设备由当前的正序录制模式(或倒序录制模式)切换为倒序录制模式(或正序录制模式)后,电子设备会结束录制当前的一个第二视频片段并保存,然后新建一个第一文件,且对该第一文件添加第一标记。其中,第一文件为存储N个第一视频数据的视频文件,第一标记用于标示视频文件内的视频数据的编码方向为倒序编码方向(或正序编码方向)。
可选地,本申请实施例中,第一标记可以为一个指令信息,该指令信息用于指示电子设备对第一标记标示的视频文件中的视频数据按照第一编码方向进行编码。
需要说明的是,用户在将电子设备由当前的正序录制模式切换为倒序录制模式后不影响正序录制的过程,即切换录制模式后的录制画面仍然可以是正常的正序录制,只不过会对建新的视频文件写入一个指令信息。
可选地,本申请实施例中,若N个第一视频数据为电子设备切换为倒序录制模式后获取的视频数据,则在倒序录制模式下的视频录制过程中,电子设备可以对写入第一文件内的N个第一视频数据进行倒序编码,并在视频录制结束,待倒序编码完成后,导出的第一文件中的第一视频在任意播放器播放时,视频图像都是倒序播放。
具体地,电子设备可以先接收N个第一视频数据,并保存第N个第一视频数据,作为起始视频数据,再将第N-1个第一视频数据写入到第N个第一视频数据之后,然后将第N-2个第一视频数据写入到第N-1个第一视频数据之后,以此类推,直至第1个第一视频数据写入到第2个第一视频数据之后,进而对倒序排列后的N个第一视频数据进行编码,得到的倒序编码的N个第一视频数据。
下面结合具体例子对上述过程进行详细说明。以第一文件包括5(N=5)个第一视频
数据为例,如图4所示,第一排的视频数据为输入的5个第一视频数据,假设第1个第一视频数据指示的图像是字母A,第2个第一视频数据指示的图像是字母A、B,第3个第一视频数据指示的图像是字母A、B、C,第4个第一视频数据指示的图像是字母A、B、C、D,第5个第一视频数据指示的图像是字母A、B、C、D、E。第二排的倒序编码数据表示的是相应的每个视频数据的倒序编码数据,即先保存第5个第一视频数据(即最后一个视频数据),作为起始视频数据,再将第4个第一视频数据写入到第5个第一视频数据之后,然后将第3个第一视频数据写入到第4个第一视频数据之后,以此类推,直至第1个第一视频数据写入到第2个第一视频数据之后,进而对倒序排列后的5个第一视频数据进行编码,得到的倒序编码的5个第一视频数据即得到第一视频段的编码数据。视频播放设备对该编码数据进行解码播放时,其呈现出的动画效果就是“ABCDE-ABCD-ABC-AB-A”五个字母逐个减少显示的画面。
可选地,本申请实施例中,在录制视频的过程中,若用户对第一标识进行选择输入之前(即用户切换电子设备的录制模式之前),电子设备处于倒序录制模式,当用户对第一标识进行选择输入后(即将电子设备由当前的倒序录制模式切换为正序录制模式),电子设备会结束对第二视频片段的录制,并新建一个第一文件,且对该第一文件添加第一标记。其中,第一文件为用于存储N个第一视频数据的视频文件,第一标记用于标示对应的编码方向为正序编码方向。
需要说明的是,电子设备对视频数据进行正序编码的过程说明可以参考现有的编码技术,在此不予赘述。
如此可知,由于电子设备对N个第一视频数据进行视频编码之前,可以先对该N个第一视频数据添加第一标记,以标示该N个第一视频数据对应的编码方向为第一编码方向,从而使电子设备更好地识别视频数据的编码方向,提高了电子设备对视频数据进行编码的准确性。
可选地,本申请实施例中,结合图1,如图5所示,在上述步骤102之前,本申请实施例提供的视频生成方法还可以包括下述的步骤301。
步骤301、电子设备对M个第二视频数据添加第二标记。
本申请实施例中,上述第二标记用于标识M个第二视频数据对应的编码方向为第二编码方向。
可选地,本申请实施例中,在录制视频开始,若用户对第一标识进行选择输入后,电子设备处于正序录制模式(或倒序录制模式),电子设备新建一个第二文件,然后对该第二文件添加第二标记,视频录制过程中的M个第二视频数据会存储到该第二文件内。其中,第二文件为用于存储M个第二视频数据的视频文件,第二标记用于标示视频文件内的视频数据的编码方向为正序编码方向(或倒序编码方向)。
如此可知,由于电子设备在获取N个第一视频数据之前,可以先获取M个第二视频数据,并对该M个第二视频数据添加第二标记,以标示该M个第二视频数据对应的编码
方向为第二编码方向,从而使电子设备更好地识别视频数据的编码方向,提高了电子设备对视频数据进行编码的准确性。
本申请实施例提供的视频生成方法,电子设备可以在录制视频的过程中,根据用户的第一输入获取N个第一视频数据,并按照第一编码方向对获取的N个第一视频数据进行视频编码,得到第一视频片段,N为正整数;然后根据第一视频片段和第二视频片段(第二视频片段包括:按照第二编码方向对M个第二视频数据进行视频编码得到的视频片段),生成目标视频。其中,第一编码方向和第二编码方向不同,M为正整数。由于电子设备在录制视频的过程中就可以根据用户的第一输入获取N个第一视频数据,并按照第一编码方向对N个第一视频数据进行视频编码,得到第一视频片段,且按照第二编码方向对M个第二视频数据进行视频编码,得到第二视频片段,最后根据第一视频片段和第二视频片段,生成目标视频,又由于第一视频片段和第二视频片段的视频编码方向是相反的,因而拍摄结束后得到的目标视频直接就是包括播放效果相反的视频片段的视频,而无需用户使用视频特效应用对拍摄的视频进行复杂的后期处理,因此简化了用户使用电子设备生成满足需求的特效视频的过程,节约了时间。
以下具体说明电子设备获取N个第一视频数据的过程。
可选地,本申请实施例中,结合图1,如图6所示,在上述步骤102中的“获取N个第一视频数据”具体可以通过下述的步骤102a来实现。
步骤102a、电子设备将第一时间段内采集的视频数据,确定为N个第一视频数据。
本申请实施例中,上述第一时间段的起始时刻为:第一输入的输入时刻;上述第一时间段的结束时刻为:第一时间段的起始时刻起的第一预设时长之后的时刻。
可选地,本申请实施例中,上述第一预设时长可以为用户在目标模板中预先设置的一个时长,该目标模板可以为视频录制前,用户在电子设备中选择并调用的可以定时切换视频录制模式的时间模板。
进一步可选地,本申请实施例中,上述目标模板包括X个第一指令和Y个第二指令,该第一指令用于指示电子设备在一个预设时长内保持处于正序录制模式或者倒序录制模式,X为正整数;该第二指令用于指示电子设备在一个预设时长内保持处于倒序录制模式或者正序录制模式,Y为正整数。其中,X和Y可以相同,也可以不同;电子设备执行第一指令后的视频录制模式和执行第二指令后的视频录制模式相反。
需要说明的是,上述“视频录制模式”可以理解为:电子设备处于的视频录制模式为正序录制模式还是倒序录制模式。
可以理解,若电子设备执行第一指令后的视频录制模式为正序录制模式,则电子设备执行第二指令后的视频录制模式为倒序录制模式;若电子设备执行第一指令后的视频录制模式为倒序录制模式,则电子设备执行第二指令后的视频录制模式为正序录制模式。
在一种示例中,时间模板可以为:正序10S+倒序10S,即该时间模板包括1个第一指令和1个第二指令。其中,第一指令指示电子设备在视频开始录制的第一个10S内保持处
于正序录制模式,第二切换指令指示电子设备在视频开始录制的第二个10S内保持处于倒序录制模式。
在另一种示例中,时间模板可以为:倒序5S+正序10S+倒序10S,即该时间模板包括2个第一指令和1个第二指令。其中,第1个第一指令指示电子设备在视频开始录制的5S内保持处于倒序录制模式,第1个第二指令指示电子设备在视频开始录制的第6S至15S内保持处于正序录制模式,第2个第一指令指示电子设备在视频开始录制的第16S至25S内保持处于倒序录制模式。
可选地,本申请实施例中,上述第一输入的输入时刻可以为电子设备接收到第二指令的时刻。
可以理解,当该第二指令指示电子设备由倒序录制模式切换为正序录制模式时,则第一时间段的起始时刻为:电子设备处于正序录制模式的开始时刻,第一时间段的结束时刻为:电子设备处于正序录制模式的时间满足该第二指令对应的预设时长之后的时刻;当该第二指令指示电子设备由正序录制模式切换为倒序录制模式时,则第一时间段的起始时刻为:电子设备处于倒序录制模式的开始时刻,第一时间段的结束时刻为:电子设备处于倒序录制模式的时间高超过该第二指令对应的预设时长之后的时刻。
在一种示例中,假设时间模板为:倒序10S+正序10S+倒序10S,电子设备开始录制视频后处于倒序录制模式保持10S后,接收到第二切换指令指示电子设备由倒序录制模式切换为正序录制模式,则第一时间段的起始时刻为:电子设备开始录制视频后的第11S,第一时间段的结束时刻为:电子设备开始录制视频的第20S之后的时刻(即电子设备处于正序录制模式的时间超过10S之后的时刻)。可以理解,电子设备在第11S到第20S(即第一时间段)内,即处于正序录制模式的10S内采集的N个视频数据,确定为N个第一视频数据。
在另一种示例中,假设时间模板为:正序5S+倒序5S+正序5S,电子设备开始录制视频后处于正序录制模式保持5S后,接收到第二切换指令指示电子设备由正序录制模式切换为倒序录制模式,则第一时间段的起始时刻为:电子设备开始录制视频后的第6S,第一时间段的结束时刻为:电子设备开始录制视频的第10S之后的时刻(即电子设备处于倒序录制模式的时间超过5S之后的时刻)。可以理解,电子设备在第6S到第10S(即第一时间段)内,即处于倒序录制模式的5S内采集的N个视频数据,确定为N个第一视频数据。
需要说明的是,上述目标模板可以为电子设备预存的时间模板也可以为用户自定义的时间模板,时间模板中的正序录制模式和倒序录制模式的切换顺序以及各个录制模式下的预设时间可以任意设置,在此不作限定。
如此可知,由于用户在设置第一输入的输入时刻和第一预设时长之后,电子设备可以在第一输入的输入时刻开始到第一预设时长之内的时间段中采集视频数据,并将采集到的视频数据确定为N个第一视频数据,从而用户可以使用电子设备得到各种满足需求的视频内容。
当然,用户有时需要使用电子设备录制包括正序视频段和倒序视频段混合的视频,以下针对这种情况进行具体说明。
可选地,本申请实施例中,上述第二视频片段还包括:按照第二编码方向对Q个第三视频数据进行视频编码得到的视频片段,Q为正整数,结合图6,如图7所示,在上述步骤102a之后,本申请实施例提供的视频生成方法还可以包括下述的步骤401。
步骤401、电子设备将第二时间段内采集的视频数据,确定为Q个第三视频数据。
本申请实施例中,上述第二时间段的起始时刻为:第一时间段的结束时刻;上述第二时间段的结束时刻为:第二时间段的起始时刻起的第二预设时长之后的时刻。
可选地,本申请实施例中,上述第二时间段的起始时刻为:电子设备执行第二指令后处于正序录制模式(或倒序录制模式)起的第一预设时长之后的时刻。
可以理解,第二时间段的起始时刻为:电子设备执行完一个第二指令后再次接收到第一指令的时刻。
可选地,本申请实施例中,上述第二预设时长可以为电子设备再次接收到的第一指令中用户预先设置或者目标模板中预置的一个时长。
在一种示例中,假设时间模板为:倒序10S+正序10S+倒序10S,电子设备开始录制视频后根据第1个第一指令处于倒序录制模式保持10S后,根据第二指令又处于正序录制模式保持10S,然后电子设备又接收到第2个第一指令,指示电子设备由正序录制模式切换为倒序录制模式,则第二时间段的起始时刻为:电子设备开始录制视频的第21S(即接收到第2个第一指令的时刻),第二时间段的结束时刻为:电子设备开始录制视频后的第30S之后(即电子设备处于倒序录制模式的时间超过10S之后的时刻)。可以理解,电子设备在第21S到第30S(即第二时间段)内,即处于倒序录制模式的10S内采集的Q个视频数据,确定为Q个第三视频数据。电子设备得到Q个第三视频数据后,按照倒序编码的方式对Q个第三视频数据进行视频编码得到一个第二视频片段。
在另一种示例中,假设时间模板为:正序5S+倒序10S+正序10S,电子设备开始录制视频后根据第1个第一指令处于正序录制模式保持5S后,根据第二指令又处于倒序录制模式保持10S,然后电子设备又接收到第2个第一指令,指示电子设备由倒序录制模式切换为正序录制模式,则第二时间段的起始时刻为:电子设备开始录制视频的第16S(即接收到第2个第一指令的时刻),第二时间段的结束时刻为:电子设备开始录制视频后的第25S之后(即电子设备处于正序录制模式的时间超过10S之后的时刻)。可以理解,电子设备在第16S到第25S(即第二时间段)内,即处于正序录制模式的10S内采集的Q个视频数据,确定为Q个第三视频数据。电子设备得到Q个第三视频数据后,按照正序编码的方式对Q个第三视频数据进行视频编码得到一个第二视频片段。
本申请实施例中,电子设备根据目标模板中的X个第一指令和Y个第二指令,得到X个包含第二视频数据的视频文件和Y个包含第一视频数据的视频文件后,对所有的第一视频数据按照第一编码方向进行视频编码,得到Y个第一视频片段,对所有的第二视频数据
按照第二编码方向进行视频编码,得到X个第二视频片段,最后按照视频文件的获取时间,对Y个第一视频片段和X个第二视频片段进行排序和拼接处理,得到目标视频。
如此可知,由于电子设备在第一时间段内采集第一视频数据后,还可以在第一时间段之后的第二时间段内采集第三视频数据,并对采集的第三视频数据按照第二编码方向进行视频编码得到一个第二视频片段,从而用户可以使用电子设备得到需要的任意数量的第一视频片段和第二视频片段。
本申请实施例提供的方法,执行主体可以为视频生成装置。本申请实施例中是以视频生成装置执行视频生成方法为例,说明本申请实施例提供的视频生成装置。
图8示出了上述实施例中所涉及的一种视频生成装置60,该视频生成装置60包括:接收模块61、获取模块62、编码模块63以及生成模块64。其中,接收模块61,用于在录制视频的过程中,接收用户的第一输入。获取模块62,用于响应于接收模块接收的第一输入,获取N个第一视频数据。编码模块63,用于并按照第一编码方向对获取模块获取的N个第一视频数据进行视频编码,得到第一视频片段,N为正整数。生成模块64,用于根据编码模块编码得到的第一视频片段和第二视频片段,生成目标视频,该第二视频片段包括:按照第二编码方向对M个第二视频数据进行视频编码得到的视频片段。其中,第一编码方向和第二编码方向不同,M为正整数。
在一种可能的实现方式中,上述M个第二视频数据为:在录制视频的过程中,获取的时间位于N个第一视频数据之前的视频数据。
在一种可能的实现方式中,上述视频生成装置60还包括:确定模块。其中,确定模块,用于将第一时间段内采集的视频数据,确定为N个第一视频数据。其中,第一时间段的起始时刻为:第一输入的输入时刻,第一时间段的结束时刻为:第一时间段的起始时刻起的第一预设时长之后的时刻。
在一种可能的实现方式中,上述第二视频片段还包括:按照第二编码方向对Q个第三视频数据进行视频编码得到的视频片段,Q为正整数。上述确定模块还用于将第二时间段内采集的视频数据,确定为Q个第三视频数据。其中,第二时间段的起始时刻为:第一时间段的结束时刻,第二时间段的结束时刻为:第二时间段的起始时刻起的第二预设时长之后的时刻。
在一种可能的实现方式中,上述视频生成装置60还包括:添加模块。其中,添加模块,用于对N个第一视频数据添加第一标记,该第一标记用于标示N个第一视频数据对应的编码方向为第一编码方向。
在一种可能的实现方式中,上述视频生成装置60还包括:添加模块。其中,添加模块,用于对M个第二视频数据添加第二标记,该第二标记用于标示M个第二视频数据对应的编码方向为第二编码方向。
本申请实施例提供的视频生成装置,由于视频生成装置在录制视频的过程中就可以根据用户的第一输入获取N个第一视频数据,并按照第一编码方向对N个第一视频数据进行
视频编码,得到第一视频片段,且按照第二编码方向对M个第二视频数据进行视频编码,得到第二视频片段,最后根据第一视频片段和第二视频片段,生成目标视频,又由于第一视频片段和第二视频片段的视频编码方向是相反的,因而拍摄结束后得到的目标视频直接就是包括播放效果相反的视频片段的视频,而无需用户使用视频特效应用对拍摄的视频进行复杂的后期处理,因此简化了用户使用视频生成装置生成满足需求的特效视频的过程,节约了时间。
本申请实施例中的视频生成装置可以是电子设备,也可以是电子设备中的部件,例如集成电路或芯片。该电子设备可以是终端,也可以为除终端之外的其他设备。示例性的,电子设备可以为手机、平板电脑、笔记本电脑、掌上电脑、车载电子设备、移动上网装置(mobile internet device,MID)、增强现实(augmented reality,AR)/虚拟现实(virtual reality,VR)设备、机器人、可穿戴设备、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本或者个人数字助理(personal digital assistant,PDA)等,还可以为服务器、网络附属存储器(network attached storage,NAS)、个人计算机(personal computer,PC)、电视机(television,TV)、柜员机或者自助机等,本申请实施例不作具体限定。
本申请实施例中的视频生成装置可以为具有操作系统的装置。该操作系统可以为安卓(Android)操作系统,可以为iOS操作系统,还可以为其他可能的操作系统,本申请实施例不作具体限定。
本申请实施例提供的视频生成装置能够实现图1至图7的方法实施例实现的各个过程,为避免重复,这里不再赘述。
可选地,本申请实施例中,如图9所示,本申请实施例还提供一种电子设备80,包括处理器81和存储器82,存储器82上存储有可在所述处理器81上运行的程序或指令,该程序或指令被处理器81执行时实现上述方法实施例的各个过程步骤,且能达到相同的技术效果,为避免重复,这里不再赘述。
需要说明的是,本申请实施例中的电子设备包括上述的移动电子设备和非移动电子设备。
图10为实现本申请实施例的一种电子设备的硬件结构示意图。
该电子设备100包括但不限于:射频单元1001、网络模块1002、音频输出单元1003、输入单元1004、传感器1005、显示单元1006、用户输入单元1007、接口单元1008、存储器1009、以及处理器110等部件。
本领域技术人员可以理解,电子设备100还可以包括给各个部件供电的电源(比如电池),电源可以通过电源管理系统与处理器110逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。图10中示出的电子设备结构并不构成对电子设备的限定,电子设备可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置,在此不再赘述。
其中,处理器110,具体用于在录制视频的过程中,接收用户的第一输入;响应于第
一输入,获取N个第一视频数据,并按照第一编码方向对该N个第一视频数据进行视频编码,得到第一视频片段,N为正整数;根据第一视频片段和第二视频片段,生成目标视频,该第二视频片段包括:按照第二编码方向对M个第二视频数据进行视频编码得到的视频片段;其中,第一编码方向和第二编码方向不同,M为正整数。
本申请实施例提供的电子设备,由于电子设备在录制视频的过程中就可以根据用户的第一输入获取N个第一视频数据,并按照第一编码方向对N个第一视频数据进行视频编码,得到第一视频片段,且按照第二编码方向对M个第二视频数据进行视频编码,得到第二视频片段,最后根据第一视频片段和第二视频片段,生成目标视频,又由于第一视频片段和第二视频片段的视频编码方向是相反的,因而拍摄结束后得到的目标视频直接就是包括播放效果相反的视频片段的视频,而无需用户使用视频特效应用对拍摄的视频进行复杂的后期处理,因此简化了用户使用电子设备生成满足需求的特效视频的过程,节约了时间。
可选地,本申请实施例中,处理器110,具体用于将第一时间段内采集的视频数据,确定为N个第一视频数据;其中,第一时间段的起始时刻为:第一输入的输入时刻;第一时间段的结束时刻为:第一时间段的起始时刻起的第一预设时长之后的时刻。
如此可知,由于用户在设置第一输入的输入时刻和第一预设时长之后,电子设备可以在第一输入的输入时刻开始到第一预设时长之内的时间段中采集视频数据,并将采集到的视频数据确定为N个第一视频数据,从而用户可以使用电子设备得到各种满足需求的视频内容。
可选地,本申请实施例中,处理器110,具体用于将第二时间段内采集的视频数据,确定为Q个第三视频数据;其中,第二时间段的起始时刻为:第一时间段的结束时刻;第二时间段的结束时刻为:第二时间段的起始时刻起的第二预设时长之后的时刻。
如此可知,由于用户在设置第一输入的输入时刻和第一预设时长之后,电子设备可以在第一输入的输入时刻开始到第一预设时长之内的时间段中采集视频数据,并将采集到的视频数据确定为N个第一视频数据,从而用户可以使用电子设备得到各种满足需求的视频内容。
可选地,本申请实施例中,处理器110,具体用于对N个第一视频数据添加第一标记,该第一标记用于标示N个第一视频数据对应的编码方向为第一编码方向。
如此可知,由于电子设备对N个第一视频数据进行视频编码之前,可以先对该N个第一视频数据添加第一标记,以标示该N个第一视频数据对应的编码方向为第一编码方向,从而使电子设备更好地识别视频数据的编码方向,提高了电子设备对视频数据进行编码的准确性。
可选地,本申请实施例中,处理器110,具体用于对M个第二视频数据添加第二标记,该第二标记用于标示M个第二视频数据对应的编码方向为第二编码方向。
如此可知,由于电子设备在获取N个第一视频数据之前,可以先获取M个第二视频数据,并对该M个第二视频数据添加第二标记,以标示该M个第二视频数据对应的编码
方向为第二编码方向,从而使电子设备更好地识别视频数据的编码方向,提高了电子设备对视频数据进行编码的准确性。
应理解的是,本申请实施例中,输入单元1004可以包括图形处理器(graphics processing unit,GPU)1041和麦克风1042,图形处理器1041对在视频捕获模式或图像捕获模式中由图像捕获装置(如摄像头)获得的静态图片或视频的图像数据进行处理。显示单元1006可包括显示面板1061,可以采用液晶显示器、有机发光二极管等形式来配置显示面板1061。用户输入单元1007包括触控面板1071以及其他输入设备1072中的至少一种。触控面板1071,也称为触摸屏。触控面板1071可包括触摸检测装置和触摸控制器两个部分。其他输入设备1072可以包括但不限于物理键盘、功能键(比如音量控制按键、开关按键等)、轨迹球、鼠标、操作杆,在此不再赘述。
存储器1009可用于存储软件程序以及各种数据。存储器1009可主要包括存储程序或指令的第一存储区和存储数据的第二存储区,其中,第一存储区可存储操作系统、至少一个功能所需的应用程序或指令(比如声音播放功能、图像播放功能等)等。此外,存储器1009可以包括易失性存储器或非易失性存储器,或者,存储器1009可以包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(read-only memory,ROM)、可编程只读存储器(programmable ROM,PROM)、可擦除可编程只读存储器(erasable PROM,EPROM)、电可擦除可编程只读存储器(electrically EPROM,EEPROM)或闪存。易失性存储器可以是随机存取存储器(random access memory,RAM),静态随机存取存储器(static RAM,SRAM)、动态随机存取存储器(dynamic RAM,DRAM)、同步动态随机存取存储器(synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(double data rate SDRAM,DDRSDRAM)、增强型同步动态随机存取存储器(enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(synch link DRAM,SLDRAM)和直接内存总线随机存取存储器(direct rambus RAM,DRRAM)。本申请实施例中的存储器1009包括但不限于这些和任意其它适合类型的存储器。
处理器110可包括一个或多个处理单元;可选的,处理器110集成应用处理器和调制解调处理器,其中,应用处理器主要处理涉及操作系统、用户界面和应用程序等的操作,调制解调处理器主要处理无线通信信号,如基带处理器。可以理解的是,上述调制解调处理器也可以不集成到处理器110中。
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。此外,需要指出的是,本申请实施方式中的方法和装置的范围不限按示出或讨论的顺序来执行功能,还可包括根据所涉及的功能按基本同时的方式或按相反的顺序来执行功能,例如,可以按不同于
所描述的次序来执行所描述的方法,并且还可以添加、省去、或组合各种步骤。另外,参照某些示例所描述的特征可在其他示例中被组合。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以计算机软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端(可以是手机,计算机,服务器,或者网络设备等)执行本申请各个实施例所述的方法。
上面结合附图对本申请的实施例进行了描述,但是本申请并不局限于上述的具体实施方式,上述的具体实施方式仅仅是示意性的,而不是限制性的,本领域的普通技术人员在本申请的启示下,在不脱离本申请宗旨和权利要求所保护的范围情况下,还可做出很多形式,均属于本申请的保护之内。
Claims (14)
- 一种视频生成方法,所述方法包括:在录制视频的过程中,接收用户的第一输入;响应于所述第一输入,获取N个第一视频数据,并按照第一编码方向对所述N个第一视频数据进行视频编码,得到第一视频片段,N为正整数;根据所述第一视频片段和第二视频片段,生成目标视频,所述第二视频片段包括:按照第二编码方向对M个第二视频数据进行视频编码得到的视频片段;其中,所述第一编码方向和所述第二编码方向不同,M为正整数。
- 根据权利要求1所述的方法,其中,所述M个第二视频数据为:在录制视频的过程中,获取的时间位于所述N个第一视频数据之前的视频数据。
- 根据权利要求1所述的方法,其中,所述获取N个第一视频数据,包括:将第一时间段内采集的视频数据,确定为所述N个第一视频数据;其中,所述第一时间段的起始时刻为:所述第一输入的输入时刻,所述第一时间段的结束时刻为:所述第一时间段的起始时刻起的第一预设时长之后的时刻。
- 根据权利要求3所述的方法,其中,所述第二视频片段还包括:按照所述第二编码方向对Q个第三视频数据进行视频编码得到的视频片段;Q为正整数;在所述获取N个第一视频数据之后,所述方法还包括:将第二时间段内采集的视频数据,确定为所述Q个第三视频数据;其中,所述第二时间段的起始时刻为:所述第一时间段的结束时刻;所述第二时间段的结束时刻为:所述第二时间段的起始时刻起的第二预设时长之后的时刻。
- 根据权利要求1所述的方法,其中,在所述按照第一编码方向对所述N个第一视频数据进行视频编码,得到第一视频片段之前,所述方法还包括:对所述N个第一视频数据添加第一标记,所述第一标记用于标示所述N个第一视频数据对应的编码方向为所述第一编码方向。
- 根据权利要求1所述的方法,其中,在所述获取N个第一视频数据之前,所述方法还包括:对所述M个第二视频数据添加第二标记,所述第二标记用于标示所述M个第二视频数据对应的编码方向为所述第二编码方向。
- 一种视频生成装置,所述视频生成装置包括:接收模块、获取模块、编码模块以及生成模块;所述接收模块,用于在录制视频的过程中,接收用户的第一输入;所述获取模块,用于响应于所述接收模块接收的第一输入,获取N个第一视频数据;所述编码模块,用于按照第一编码方向对所述获取模块获取的N个第一视频数据进行视频编码,得到第一视频片段,N为正整数;所述生成模块,用于根据所述编码模块编码得到的第一视频片段和第二视频片段,生成目标视频,所述第二视频片段包括:按照第二编码方向对M个第二视频数据进行视频编码得到的视频片段;其中,所述第一编码方向和所述第二编码方向不同,M为正整数。
- 根据权利要求7所述的视频生成装置,其中,所述视频生成装置还包括:确定模块;所述确定模块,用于将第一时间段内采集的视频数据,确定为所述N个第一视频数据;其中,所述第一时间段的起始时刻为:所述第一输入的输入时刻;所述第一时间段的结束时刻为:所述第一时间段的起始时刻起的第一预设时长之后的时刻。
- 根据权利要求7所述的视频生成装置,其中,所述视频生成装置还包括:添加模块;所述添加模块,用于对所述N个第一视频数据添加第一标记,所述第一标记用于标示所述N个第一视频数据对应的编码方向为所述第一编码方向。
- 一种电子设备,包括处理器和存储器,所述存储器存储可在所述处理器上运行的程序或指令,所述程序或指令被所述处理器执行时实现如权利要求1至6中任一项所述的视频生成方法的步骤。
- 一种可读存储介质,所述可读存储介质上存储程序或指令,所述程序或指令被处理器执行时实现如权利要求1至6中任一项所述的视频生成方法的步骤。
- 一种电子设备,包括处理器、存储器及存储在所述存储器上并可在所述处理器上运行的程序或指令,所述程序或指令被所述处理器执行时实现如权利要求1至6中任一项所述的视频生成方法的步骤。
- 一种计算机程序产品,所述程序产品被至少一个处理器执行以实现如权利要求1至6中任一项所述的视频生成方法。
- 一种用户设备UE,包括所述UE被配置成用于执行如权利要求1至6中任一项所述的视频生成方法。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202310076842.4A CN116095358A (zh) | 2023-01-19 | 2023-01-19 | 视频生成方法、装置、电子设备及介质 |
| CN202310076842.4 | 2023-01-19 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2024153191A1 true WO2024153191A1 (zh) | 2024-07-25 |
Family
ID=86213709
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2024/073038 Ceased WO2024153191A1 (zh) | 2023-01-19 | 2024-01-18 | 视频生成方法、装置、电子设备及介质 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN116095358A (zh) |
| WO (1) | WO2024153191A1 (zh) |
Families Citing this family (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN116095358A (zh) * | 2023-01-19 | 2023-05-09 | 维沃移动通信有限公司 | 视频生成方法、装置、电子设备及介质 |
| CN116527980A (zh) * | 2023-05-23 | 2023-08-01 | 北京字跳网络技术有限公司 | 动画播放方法、装置、介质以及电子设备 |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107547814A (zh) * | 2017-09-28 | 2018-01-05 | 维沃移动通信有限公司 | 一种视频录制方法、移动终端 |
| WO2018062591A1 (ko) * | 2016-09-30 | 2018-04-05 | 라인 가부시키가이샤 | 컨텐츠 제공 방법 및 시스템 |
| CN107948571A (zh) * | 2017-12-27 | 2018-04-20 | 努比亚技术有限公司 | 视频录制的方法、装置及计算机可读存储介质 |
| CN111464864A (zh) * | 2020-04-02 | 2020-07-28 | Oppo广东移动通信有限公司 | 倒序视频获取方法、装置、电子设备以及存储介质 |
| CN114845157A (zh) * | 2021-01-30 | 2022-08-02 | 华为技术有限公司 | 一种视频处理方法及电子设备 |
| CN116095358A (zh) * | 2023-01-19 | 2023-05-09 | 维沃移动通信有限公司 | 视频生成方法、装置、电子设备及介质 |
Family Cites Families (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| KR20070049504A (ko) * | 2005-11-08 | 2007-05-11 | 엘지전자 주식회사 | 디지털 콘텐츠 재생 장치 및 그의 역방향 콘텐츠 저장 및재생방법 |
| CN108184161B (zh) * | 2017-12-26 | 2021-01-01 | 努比亚技术有限公司 | 一种视频播放方法、移动终端及计算机可读存储介质 |
-
2023
- 2023-01-19 CN CN202310076842.4A patent/CN116095358A/zh active Pending
-
2024
- 2024-01-18 WO PCT/CN2024/073038 patent/WO2024153191A1/zh not_active Ceased
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2018062591A1 (ko) * | 2016-09-30 | 2018-04-05 | 라인 가부시키가이샤 | 컨텐츠 제공 방법 및 시스템 |
| CN107547814A (zh) * | 2017-09-28 | 2018-01-05 | 维沃移动通信有限公司 | 一种视频录制方法、移动终端 |
| CN107948571A (zh) * | 2017-12-27 | 2018-04-20 | 努比亚技术有限公司 | 视频录制的方法、装置及计算机可读存储介质 |
| CN111464864A (zh) * | 2020-04-02 | 2020-07-28 | Oppo广东移动通信有限公司 | 倒序视频获取方法、装置、电子设备以及存储介质 |
| CN114845157A (zh) * | 2021-01-30 | 2022-08-02 | 华为技术有限公司 | 一种视频处理方法及电子设备 |
| CN116095358A (zh) * | 2023-01-19 | 2023-05-09 | 维沃移动通信有限公司 | 视频生成方法、装置、电子设备及介质 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN116095358A (zh) | 2023-05-09 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN108616696B (zh) | 一种视频拍摄方法、装置、终端设备及存储介质 | |
| CN108900771B (zh) | 一种视频处理方法、装置、终端设备及存储介质 | |
| CN112714253B (zh) | 视频录制方法、装置、电子设备和可读存储介质 | |
| CN112672061B (zh) | 视频拍摄方法、装置、电子设备及介质 | |
| CN112887802A (zh) | 视频访问方法及装置 | |
| WO2024153191A1 (zh) | 视频生成方法、装置、电子设备及介质 | |
| CN113852756B (zh) | 图像获取方法、装置、设备和存储介质 | |
| CN112954199A (zh) | 视频录制方法及装置 | |
| CN113918522A (zh) | 一种文件生成方法、装置及电子设备 | |
| WO2023030270A1 (zh) | 音视频处理方法、装置和电子设备 | |
| CN114282022B (zh) | 多媒体编辑方法、装置、电子设备及存储介质 | |
| CN112887618A (zh) | 视频拍摄方法及其装置 | |
| WO2024104113A1 (zh) | 截屏方法、截屏装置、电子设备及可读存储介质 | |
| CN112711368B (zh) | 操作指导方法、装置及电子设备 | |
| WO2025077527A1 (zh) | 媒体内容的生成方法、装置、电子设备和可读存储介质 | |
| CN112367487A (zh) | 视频录制方法和电子设备 | |
| CN112307252A (zh) | 文件处理方法、装置及电子设备 | |
| CN115174812B (zh) | 视频生成方法、视频生成装置及电子设备 | |
| WO2025036376A1 (zh) | 视频预览方法、视频预览装置和电子设备 | |
| CN113778300B (zh) | 截屏方法及装置 | |
| CN114025237B (zh) | 视频生成方法、装置和电子设备 | |
| CN112130738B (zh) | 截图处理方法、装置、电子设备及存储介质 | |
| CN116755597A (zh) | 截图文件控制方法、装置、电子设备及存储介质 | |
| CN114500852A (zh) | 拍摄方法、拍摄装置、电子设备和可读存储介质 | |
| CN114245017A (zh) | 一种拍摄方法、装置及电子设备 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 24744361 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 24744361 Country of ref document: EP Kind code of ref document: A1 |