Video processing method, system, terminal and computer-readable storage medium
Through decoding and frame fusion processing of video files and material files, the target video expected by users is generated, and the problems of low processing efficiency and large space occupancy in the prior art are solved, and efficient video processing is achieved.
Patent Information
- Application Number
- CN202211370113.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-03
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2042-11-03
AI Technical Summary
The prior art cannot efficiently process videos to obtain the target videos that users want, and the processing efficiency is low and the space occupies a large amount of space.
By obtaining the pre-uploaded video files and material files, the first and second video packets are decoded respectively, frame fusion and encoding are performed to generate the target video file, and video processing is performed using FFMpeg and Opengl.
It realizes efficient video processing, generates target videos that users expect, and reduces processing time and storage space.
Smart Images

Figure CN115802099B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of Internet technology, and in particular to a video processing method, system, terminal and computer-readable storage medium. Background Art
[0002] Video generally refers to various technologies that capture, record, process, store, transmit, and reproduce a series of static images using electrical signals. When continuous image changes exceed 24 frames per second, the human eye cannot distinguish single static images due to the persistence of vision; instead, the visual effect appears smooth and continuous, and this continuous image is called video. Video technology was originally developed for television systems but has now evolved into various formats to facilitate consumer video recording. Advances in networking have also enabled documentary video footage to be streamed over the internet and can be received and played on computers. Video is a different technology from film, which uses photography to capture moving images as a series of still photos. With the rise of the video industry, there are more and more types of videos, and different users have different needs for videos. Different needs require various video processing. At present, the existing video processing mainly obtains the target video that the user wants by changing the video features according to the user's needs. Video features are the physical properties of the video itself that can reflect the video content information, mainly including color features, texture features, motion features, sound and subtitles, etc. However, the computational complexity of changing video features is extremely high, resulting in low processing efficiency, and the target video occupies a large space. Therefore, how to process the video more efficiently to obtain the target video that the user wants is a problem that needs to be solved urgently.
[0003] Therefore, the existing technology still needs to be improved and developed. Summary of the Invention
[0004] The main purpose of the present invention is to provide a video processing method, system, terminal and computer-readable storage medium, aiming to solve the problem in the prior art that videos cannot be processed efficiently to obtain the target video desired by the user.
[0005] To achieve the above object, the present invention provides a video processing method, which includes the following steps:
[0006] Obtaining a pre-uploaded video file and a material file, processing the video file to obtain a first video package and a first audio package, and processing the material file to obtain a second video package;
[0007] Decoding the first video packet and the second video packet to obtain a first frame and a second frame, respectively, and fusing the first frame with the second frame to obtain a target frame;
[0008] The target frame is encoded to obtain a new video package, and the new video package and the first audio package are encoded to generate a target video file.
[0009] Optionally, the video processing method, wherein the obtaining of a pre-uploaded video file and a source material file, processing the video file to obtain a first video package and a first audio package, and processing the source material file to obtain a second video package, specifically includes:
[0010] Call FFMpeg related library functions in advance to register FFMpeg related components, and open video files and material files based on the FFMpeg related components;
[0011] Calling a search function to obtain the first audio and video package of the video file and the second audio and video package of the source file respectively;
[0012] The first audio and video packet and the second audio and video packet are decoded respectively to obtain a first video packet, a first audio packet, a second video packet, and a second audio packet, and the first audio packet is saved and the second audio packet is discarded.
[0013] Optionally, the video processing method, wherein the pre-calling of FFMpeg-related library functions to register FFMpeg-related components and the opening of video files and material files based on the FFMpeg-related components, further comprises:
[0014] Position the audio and video of the video file to a set time, and jump to the time based on a seek function to complete the head cutting;
[0015] Alternatively, the total duration of the video file is obtained, and the end time is obtained based on the total duration minus the set tail time to complete the tail cutting.
[0016] Optionally, the video processing method, wherein respectively decoding the first video packet and the second video packet to obtain a first frame and a second frame, and fusing the first frame with the second frame to obtain a target frame, specifically includes:
[0017] Calling a read function to read out the first video packet and the second video packet respectively;
[0018] Sending the first video packet and the second video packet to a decoder for decoding respectively to obtain a first frame of the first video packet and a second frame of the second video packet;
[0019] The first frame and the second frame are frame-fused based on OpenGL to obtain a target frame.
[0020] Optionally, the video processing method, wherein respectively decoding the first video packet and the second video packet to obtain a first frame and a second frame, and fusing the first frame and the second frame to obtain a target frame, further includes:
[0021] Calling a read function to read the first video packet and the second video packet respectively, and setting the pts value of the filter frame;
[0022] Sending the first video packet and the second video packet to a decoder for decoding, obtaining a first frame of the first video packet and a second frame of the second video packet, and determining whether a pts value of the first frame is equal to a pts value of the filtered frame;
[0023] If it is not equal to the pts value of the filtered frame, performing frame fusion on the first frame and the second frame based on OpenGL to obtain a target frame;
[0024] If it is equal to the pts value of the filtered frame, the first frame is filtered and the first video packet is decoded to obtain the next frame.
[0025] Optionally, the video processing method, wherein the step of performing frame fusion on the first frame and the second frame based on OpenGL, further comprises:
[0026] A transparency group is preset, and the transparency of the second-first frame is adjusted to a target transparency in the transparency group, wherein the transparency group includes 90% transparency, 95% transparency, and 98% transparency.
[0027] Optionally, the video processing method, wherein the step of performing frame fusion on the first frame and the second frame based on OpenGL to obtain a target frame, further comprises:
[0028] A horizontal inversion parameter is preset, and an Opengl fragment shader is modified based on the horizontal inversion parameter to horizontally invert the target frame image to obtain a horizontal inverted frame image.
[0029] Optionally, in the video processing method, the video processing system includes:
[0030] a data processing module, configured to obtain a pre-uploaded video file and a material file, process the video file to obtain a first video package and a first audio package, and process the material file to obtain a second video package;
[0031] A data fusion module is configured to decode the first video packet and the second video packet to obtain a first frame and a second frame, and fuse the first frame with the second frame to obtain a target frame;
[0032] The video generation module is configured to encode the target frame to obtain a new video package, and encode the new video package and the first audio package to generate a target video file.
[0033] In addition, to achieve the above-mentioned purpose, the present invention also provides a terminal, wherein the terminal includes: a memory, a processor, and a video processing program stored in the memory and runnable on the processor, and when the video processing program is executed by the processor, the steps of the video processing method described above are implemented.
[0034] In addition, to achieve the above-mentioned purpose, the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a video processing program, and when the video processing program is executed by a processor, the steps of the video processing method described above are implemented.
[0035] The present invention obtains a pre-uploaded video file and a material file, processes the video file to obtain a first video package and a first audio package, and processes the material file to obtain a second video package; decodes the first video package and the second video package to obtain a first frame and a second frame, respectively, and fuses the first frame with the second frame to obtain a target frame; encodes the target frame to obtain a new video package, and encodes the new video package with the first audio package to generate a target video file. The present invention decodes the video file to be uploaded and the material video, fuses the decoded videos with frames, and sets the transparency of the material video to be invisible after fusion, finally obtaining the target video desired by the user, thereby achieving a more efficient processing effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 is a flow chart of a preferred embodiment of the video processing method of the present invention;
[0037] Figure 2 is a flow chart of step S10 in a preferred embodiment of the video processing method of the present invention;
[0038] Figure 3It is the FFmpeg decoding flow chart of the video processing method in the present invention;
[0039] Figure 4 is a flow chart of step S20 in a preferred embodiment of the video processing method of the present invention;
[0040] Figure 5 This is an overall flow chart of a preferred embodiment of the video processing method of the present invention;
[0041] Figure 6 It is a flow chart of the video processing method of cutting the video header or tail in the present invention;
[0042] Figure 7 This is a random frame extraction flow chart of the video processing method of the present invention;
[0043] Figure 8 It is a flow chart of the horizontal inversion of fused frames of the video processing method of the present invention;
[0044] Figure 9 It is a schematic diagram of the principle of a preferred embodiment of the video processing system of the present invention;
[0045] Figure 10 Schematic diagram of the operating environment of a preferred embodiment of the terminal of the present invention. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solutions and advantages of the present invention more clear and distinct, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0047] It should be noted that if the embodiments of the present invention involve directional indications (such as up, down, left, right, front, back, etc.), the directional indications are only used to explain the relative position relationship, movement status, etc. between the various components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indications will also change accordingly.
[0048] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present invention, the descriptions of "first", "second", etc. are only for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features specified as "first" and "second" may explicitly or implicitly include at least one of such features. In addition, the technical solutions between the various embodiments can be combined with each other, but this must be based on the fact that ordinary technicians in this field can implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0049] The video processing method described in the preferred embodiment of the present invention is as follows: Figure 1 As shown, the video processing method includes the following steps:
[0050] Step S10: Acquire the pre-uploaded video file and material file, process the video file to obtain a first video package and a first audio package, and process the material file to obtain a second video package.
[0051] like Figure 2 As shown, step S10 includes:
[0052] Step S11: pre-calling FFMpeg related library functions to register FFMpeg related components, and opening video files and material files based on the FFMpeg related components;
[0053] Step S12: calling a search function to obtain the first audio and video package of the video file and the second audio and video package of the source file respectively;
[0054] Step S13: Decode the first audio and video packet and the second audio and video packet respectively to obtain a first video packet, a first audio packet, a second video packet, and a second audio packet, save the first audio packet, and discard the second audio packet.
[0055] Specifically, if Figure 3As shown, the video file xxx1.mp4 (i.e., the video that needs to be processed) and the material file xxx2.mp4 (a material library can be established in advance, and the material library is used to store all material videos, wherein any video can be used as a material video) are uploaded to the processing software in advance. After uploading to the processing software, the function av_register_all() provided by FFMpeg is first called to register the FFmpeg related components, and then the av_format_open_input() function is called to open the video file to obtain the context; based on the context, the av_format_find_stream_info() function is called to find the first audio and video stream information in the video file (the first audio and video stream information includes The first video stream and the first audio stream are read out, and then the avcodec_find_decoder() function is called to find the corresponding video decoder and audio decoder. After that, the decoder avcodec_open2() is opened. Then the av_read_frame() function can be called in a loop to loop through the first video packet and the first audio packet in the video file. Each time a video packet is read out, the avcodec_send_packet() function is called to send it to the decoder. The avcodec_receive_frame() function is then called to read the decoded first frame AVFrame1 (i.e., a frame) from the decoder. Finally, the first frame AVFrame1 is passed to where it is needed.
[0056] Since av_register_all() has been called above to register FFmpeg related components (the av_register_all() function provided by FFmpeg only needs to be registered once), then here you only need to call av_format_open_input() function to open the material file to obtain the context; based on the context, call av_format_find_stream_info() function to find the second audio and video stream information in the material file (the second audio and video stream information includes the second video stream and the second audio stream), and then call avcodec_find_decoder() function to find the corresponding video decoder and audio decoder, and then open the decoder avcodec_open2(), and then you can call av_read_frame() function in a loop to loop read the second video package and second audio package in the material file; then each time a video packet is read out, you can call av_codec_send_packet() function to send it to the decoder, and then call avcodec_receive_frame() function to read the decoded second frame AVFrame2 (i.e., a frame) from the decoder, and finally pass the second frame AVFrame2 to where it is needed.
[0057] Furthermore, the uploaded video file can also be cut at the head or tail. The head cutting function is performed when the video file is opened. For example, if you want to cut off the 3-second head of the file video, after opening the video file, call the FFmpeg function av_seek_frame, and seek the video stream and audio stream to the 3-second position at the same time, and then perform loop decoding from this position to obtain the first frame AVFrame1 (Seek is an interface function av_seek_frame provided to us in FFmpeg. Through this function, we can jump directly to a certain moment in the video. Its effect is equivalent to that when we use a video player, we can pull the progress bar, and the video will start playing from the position of the progress bar we pulled. For example: the total length of our video is 100s, we can call av_seek_frame(25) during the decoding process, and the decoding will start directly from the 25th second. For example: we are decoding a video in a loop and have decoded to the 80th second of the video. At this time, we call av_seek_frame(25), and the loop will continue decoding from the 25th second until the video decoding is completed). The tail-cutting function first opens the video file we want to process, and then obtains the total length of the video file. If we want to cut off the tail 3s, the loop traversal time is "total video length - 3s". During the loop decoding process, if the current decoding time = "total video length - 3s", it means that the decoding has reached the position where cutting is required. At this time, it can be terminated in advance, thus realizing the tail-cutting function.
[0058] Furthermore, according to user needs, the frames that need to be filtered out can be converted before the video is cyclically decoded (judged according to the pts attribute of the frame AVFrame), and the reading function can be called to read the first video package and the second video package respectively, and the pts value of the filtered frame can be set; the first video package and the second video package are sent to the decoder for decoding to obtain the first frame AVFrame1 of the first video package and the second frame AVFrame2 of the second video package, and it is determined whether the pts value of the first frame AVFrame1 is equal to the pts value of the filtered frame; if it is not equal to the pts value of the filtered frame, the first frame AVFrame1 and the second frame AVFrame2 are frame-fused based on Opengl to obtain the target frame AVFrame3; if it is equal to the pts value of the filtered frame, the first frame AVFrame1 is filtered, and the first video package is continued to be decoded to obtain the next frame.
[0059] Step S20: Decode the first video packet and the second video packet respectively to obtain a first frame and a second frame, and fuse the first frame with the second frame to obtain a target frame.
[0060] like Figure 4 As shown, step S20 includes:
[0061] Step S21: calling a read function to read out the first video package and the second video package respectively;
[0062] Step S22: Send the first video packet and the second video packet to a decoder for decoding, respectively, to obtain a first frame of the first video packet and a second frame of the second video packet;
[0063] Step S23: Based on OpenGL, the first frame and the second frame are frame-fused to obtain a target frame.
[0064] Specifically, the av_read_frame() reading function is called to read the first video packet of the video file, and then the av_codec_send_packet() function is called each time a video packet is read out to be sent to the decoder, and then the avcodec_receive_frame() function is called to read the decoded first frame AVFrame1 (i.e., a frame picture) from the decoder, and finally the first frame AVFrame1 is transferred to where it is needed; at the same time, the av_read_frame() reading function is called to read the second video packet of the material file, and then the av_codec_send_packet() function is called each time a video packet is read out to be sent to the decoder, and then the avcodec_receive_frame() function is called to read the decoded second frame AVFrame2 (i.e., a frame picture) from the decoder, and finally the second frame AVFrame2 is transferred to where it is needed; based on Opengl, the first frame AVFrame1 and the second frame AVFrame2 are frame-fused to obtain the target frame AVFrame3.
[0065] Furthermore, before using Opengl to perform frame fusion on the first frame AVFrame1 and the second frame AVFrame2, parameters can be set to adjust the transparency of the second frame AVFrame2 (for example, 90%, 95% and 98%), and a new frame AVFrame is obtained after the fusion is completed.
[0066] Furthermore, a horizontal inversion parameter is set in advance, and after the first frame AVFrame1 and the second frame AVFrame2 are frame-fused using Opengl, the Opengl fragment shader is modified based on the horizontal inversion parameter to horizontally invert the target frame AVFrame3 to obtain a horizontally inverted frame.
[0067] Step S30: Encode the target frame to obtain a new video package, and encode the new video package and the first audio package to generate a target video file.
[0068] Specifically, the target frame AVFrame3 obtained by Opengl fusion is encoded using FFmpeg to obtain a new video packet, and then the new video packet and the first audio packet retained in the video file are sent to the encoder for encoding, and finally a new MP4 video file is generated.
[0069] Further, if Figure 5 As shown, the process of fusing the preprocessed video specifically includes: first, uploading the video file to be processed and the material video file to the processing software, and opening the video file and the material video file respectively; then calling the search function to obtain the first audio and video package of the preprocessed video file; at the same time, opening the material video file, and calling the search function to obtain the second audio and video package of the material video file; then decoding the first audio and video package and the second audio and video package respectively to obtain a first video package, a first audio package, a second video package and a second audio package, and saving the first audio package and discarding the second audio package; calling the read function to read out the first video package and the second video package respectively; sending the first video package and the second video package to the decoder for decoding respectively, and performing frame fusion on the retained first frame and the second frame based on Opengl to obtain a target frame; encoding the target frame to obtain a new video package, encoding the new video package and the first audio package to generate a new video file, that is, the target video file desired by the user.
[0070] Furthermore, in an embodiment of the present invention, Figure 6As shown, the processing flow of cutting the head and tail of the pre-processed video specifically includes: first, uploading the video file and the material video file to be processed to the processing software, opening the video file and the material video file respectively, calling the FFmpeg function av_seek_frame, and seeking the video stream and the audio stream to the position of the nth second (for example, the 3rd second), and then starting from this position to loop decode to obtain each frame 1, judging whether each frame 1 can be read, and ending if not; if so, obtaining the total length of the video file, and then subtracting the tail length to be cut (for example, 5 seconds) to obtain the "end time", when looping from the Seek position, detecting whether the current processing time is equal to the "end time", if it is equal, stopping the loop decoding process, and continuing the loop decoding process if not; when the cutting is completed, calling the search function to obtain the cut video file The method comprises the following steps: a first audio and video package of a component; at the same time, opening a material video file, calling a search function to obtain a second audio and video package of the material video file; then respectively decoding the first audio and video package and the second audio and video package to obtain a first video package, a first audio package, a second video package and a second audio package, saving the first audio package and discarding the second audio package; calling a read function to respectively read out the first video package and the second video package; sending the first video package and the second video package to a decoder for decoding respectively to obtain a first frame of the first video package and a second frame of the second video package; performing frame fusion on the first frame and the second frame based on Opengl to obtain a target frame; finally, encoding the target frame to obtain a new video package, encoding the new video package and the first audio package to generate a new video file, i.e., the target video file desired by the user.
[0071] Specifically, in the embodiment of the present invention, Figure 7As shown, the process of randomly extracting frames from a pre-processed video specifically includes: first, uploading the video file to be processed and the material video file to the processing software, and opening the video file and the material video file respectively; then calling the search function to obtain the first audio and video package of the cut video file; at the same time, opening the material video file, and calling the search function to obtain the second audio and video package of the material video file; then respectively decoding the first audio and video package and the second audio and video package to obtain the first video package, the first audio package, the second video package and the second audio package, and saving the first audio package and discarding the second audio package; calling the read function to read out the first video package and the second video package respectively; sending the first video package and the second video package to the decoder for decoding respectively, to obtain the first frame of the first video package and the second video package the second frame of the picture; before loop decoding and processing the video, calculate the frame to be filtered out (based on the pts attribute of the frame AVFrame), and judge whether the pts value of the first frame of the picture is equal to the pts value of the preset filtered frame; if it is not equal to the pts value of the filtered frame, retain the first frame of the picture; if it is equal to the pts value of the filtered frame, filter the first frame of the picture, and continue to decode the first video package to obtain the next frame, until the first frame of the picture with a pts value not equal to the filtered frame is decoded and retained; based on Opengl, the retained first frame of the picture and the second frame of the picture are frame-fused to obtain the target frame of the picture; finally, encode the target frame of the picture to obtain a new video package, encode the new video package with the first audio package, and generate a new video file, that is, the target video file desired by the user.
[0072] Specifically, in the embodiment of the present invention, Figure 8As shown, the process of horizontally reversing the pre-processed video specifically includes: first, uploading the video file to be processed and the source video file to the processing software, and opening the video file and the source video file respectively; then calling a search function to obtain the first audio and video package of the cut video file; at the same time, opening the source video file, and calling a search function to obtain the second audio and video package of the source video file; then, decoding the first audio and video package and the second audio and video package respectively to obtain a first video package, a first audio package, a second video package, and a second audio package, and saving the first audio package and discarding the second audio package; calling a read function to read the first video package and the second video package respectively; sending the first video package and the second video package respectively to the decoder for decoding, and performing frame fusion on the retained first frame and the second frame based on OpenGL to obtain a target frame; modifying the OpenGL fragment shader based on the horizontal reversal parameter to horizontally reverse the target frame to obtain a horizontally reversed frame; finally, encoding the horizontally reversed frame to obtain a new video package, and encoding the new video package with the first audio package to generate a new video file, i.e., the target video file desired by the user.
[0073] Furthermore, in an embodiment of the present invention, the present invention can also process the pre-processed video by any combination of at least one or more of cutting off the header and tail, performing horizontal reversal (mirroring), and random frame extraction, and generate a new video file after processing, that is, the target video file desired by the user.
[0074] Further, if Figure 9 As shown, based on the above video processing method, the present invention also provides a video processing system, which includes:
[0075] The data processing module 51 is configured to obtain a pre-uploaded video file and a source file, process the video file to obtain a first video package and a first audio package, and process the source file to obtain a second video package.
[0076] A data fusion module 52 is configured to decode the first video packet and the second video packet to obtain a first frame and a second frame, and fuse the first frame with the second frame to obtain a target frame;
[0077] The video generation module 53 is configured to encode the target frame to obtain a new video package, and encode the new video package and the first audio package to generate a target video file.
[0078] Further, if Figure 10As shown, based on the above video processing method, the present invention also provides a terminal, which includes a processor 10, a memory 20 and a display 30; Figure 10 Some components of the terminal are shown, but it should be understood that implementation of all of the shown components is not required, and more or fewer components may be implemented instead.
[0079] In some embodiments, the memory 20 can be an internal storage unit of the terminal, such as a hard disk or memory of the terminal. In other embodiments, the memory 20 can also be an external storage device of the terminal, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the terminal. Furthermore, the memory 20 can also include both an internal storage unit of the terminal and an external storage device. The memory 20 is used to store application software and various types of data installed on the terminal, such as the program code of the installation terminal. The memory 20 can also be used to temporarily store data that has been output or is to be output. In one embodiment, a video processing program 40 is stored on the memory 20, and the video processing program 40 can be executed by the processor 10, thereby implementing the video processing method in the present application.
[0080] In some embodiments, the processor 10 may be a central processing unit (CPU), a microprocessor, or other data processing chip, configured to run program codes or process data stored in the memory 20, such as executing the video processing method.
[0081] In some embodiments, the display 30 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen. The display 30 is used to display information on the terminal and to display a visual user interface. The components 10-30 of the terminal communicate with each other via a system bus.
[0082] In one embodiment, when the processor 10 executes the split-screen window interface display program 40 in the memory 20, the following steps are implemented:
[0083] Obtaining a pre-uploaded video file and a material file, processing the video file to obtain a first video package and a first audio package, and processing the material file to obtain a second video package;
[0084] Decoding the first video packet and the second video packet to obtain a first frame and a second frame, respectively, and fusing the first frame with the second frame to obtain a target frame;
[0085] The target frame is encoded to obtain a new video package, and the new video package and the first audio package are encoded to generate a target video file.
[0086] The obtaining of the pre-uploaded video file and the material file, processing the video file to obtain a first video package and a first audio package, and processing the material file to obtain a second video package specifically includes:
[0087] Call FFMpeg related library functions in advance to register FFMpeg related components, and open video files and material files based on the FFMpeg related components;
[0088] Calling a search function to obtain the first audio and video package of the video file and the second audio and video package of the source file respectively;
[0089] The first audio and video packet and the second audio and video packet are decoded respectively to obtain a first video packet, a first audio packet, a second video packet, and a second audio packet, and the first audio packet is saved and the second audio packet is discarded.
[0090] The method of pre-calling FFMpeg related library functions to register FFMpeg related components and opening video files and material files based on the FFMpeg related components also includes:
[0091] Position the audio and video of the video file to a set time, and jump to the time based on a seek function to complete the head cutting;
[0092] Alternatively, the total duration of the video file is obtained, and the end time is obtained based on the total duration minus the set tail time to complete the tail cutting.
[0093] The decoding of the first video packet and the second video packet to obtain a first frame and a second frame, and fusing the first frame with the second frame to obtain a target frame specifically includes:
[0094] Calling a read function to read out the first video packet and the second video packet respectively;
[0095] Sending the first video packet and the second video packet to a decoder for decoding respectively to obtain a first frame of the first video packet and a second frame of the second video packet;
[0096] The first frame and the second frame are frame-fused based on OpenGL to obtain a target frame.
[0097] The method further comprises: decoding the first video packet and the second video packet to obtain a first frame and a second frame, and fusing the first frame with the second frame to obtain a target frame.
[0098] Calling a read function to read the first video packet and the second video packet respectively, and setting the pts value of the filter frame;
[0099] Sending the first video packet and the second video packet to a decoder for decoding, obtaining a first frame of the first video packet and a second frame of the second video packet, and determining whether a pts value of the first frame is equal to a pts value of the filtered frame;
[0100] If it is not equal to the pts value of the filtered frame, performing frame fusion on the first frame and the second frame based on OpenGL to obtain a target frame;
[0101] If it is equal to the pts value of the filtered frame, the first frame is filtered and the first video packet is decoded to obtain the next frame.
[0102] The step of performing frame fusion on the first frame and the second frame based on OpenGL further includes:
[0103] A transparency group is preset, and the transparency of the second-first frame is adjusted to a target transparency in the transparency group, wherein the transparency group includes 90% transparency, 95% transparency, and 98% transparency.
[0104] The method further comprises: performing frame fusion on the first frame and the second frame based on OpenGL to obtain a target frame; and then:
[0105] A horizontal inversion parameter is preset, and an Opengl fragment shader is modified based on the horizontal inversion parameter to horizontally invert the target frame image to obtain a horizontal inverted frame image.
[0106] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a video processing program, and when the video processing program is executed by a processor, the steps of the video processing method described above are implemented.
[0107] In summary, the present invention provides a video processing method, system, terminal, and computer-readable storage medium, the method comprising: obtaining a pre-uploaded video file and a material file, processing the video file to obtain a first video package and a first audio package, and processing the material file to obtain a second video package; respectively decoding the first video package and the second video package to obtain a first frame and a second frame, and fusing the first frame with the second frame to obtain a target frame; encoding the target frame to obtain a new video package, encoding the new video package with the first audio package, and generating a target video file. The present invention decodes the video file to be uploaded and the material video, performs frame fusion on the decoded video, and sets the transparency of the material video to be invisible after fusion, finally obtaining the target video desired by the user, thereby achieving a more efficient processing effect.
[0108] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.
[0109] Of course, those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing related hardware (such as a processor, controller, etc.) through a computer program. The program can be stored in a computer-readable storage medium that can be read by a computer. When the program is executed, it can include the processes in the above-described method embodiments. The computer-readable storage medium can be a memory, a magnetic disk, an optical disk, etc.
[0110] It should be understood that the application of the present invention is not limited to the above examples. For those skilled in the art, improvements or changes can be made based on the above description. All these improvements and changes should fall within the scope of protection of the claims attached to the present invention.
Claims
1. A video processing method, characterized in that: The video processing method comprises: Obtaining a pre-uploaded video file and a material file, processing the video file to obtain a first video package and a first audio package, and processing the material file to obtain a second video package; The obtaining of the pre-uploaded video file and the material file, processing the video file to obtain a first video package and a first audio package, and processing the material file to obtain a second video package specifically includes: Call FFMpeg related library functions in advance to register FFMpeg related components, and open video files and material files based on the FFMpeg related components; Calling a search function to obtain the first audio and video package of the video file and the second audio and video package of the source file respectively; Decoding the first audio and video packet and the second audio and video packet respectively to obtain a first video packet, a first audio packet, a second video packet, and a second audio packet, and saving the first audio packet and discarding the second audio packet; Decoding the first video packet and the second video packet to obtain a first frame and a second frame, respectively, and fusing the first frame with the second frame to obtain a target frame; The decoding of the first video packet and the second video packet to obtain a first frame and a second frame, and fusing the first frame with the second frame to obtain a target frame, further comprising: Calling a read function to read the first video packet and the second video packet respectively, and setting the pts value of the filter frame; Sending the first video packet and the second video packet to a decoder for decoding, obtaining a first frame of the first video packet and a second frame of the second video packet, and determining whether a pts value of the first frame is equal to a pts value of the filtered frame; If it is not equal to the pts value of the filtered frame, performing frame fusion on the first frame and the second frame based on OpenGL to obtain a target frame; If it is equal to the pts value of the filtered frame, filtering the first frame, and continuing to decode the first video packet to obtain the next frame; Encoding the target frame to obtain a new video package, and encoding the new video package and the first audio package to generate a target video file; The pre-processed video is processed by cutting off the beginning and the end of the video, performing horizontal reversal, and randomly extracting frames in any combination of at least one or more of the methods, and a new video file is generated after the processing.
2. The video processing method according to claim 1, wherein: The method of pre-calling FFMpeg related library functions to register FFMpeg related components and opening video files and material files based on the FFMpeg related components also includes: Position the audio and video of the video file to a set time, and jump to the time based on a seek function to complete the head cutting; Alternatively, the total duration of the video file is obtained, and the end time is obtained based on the total duration minus the set tail time to complete the tail cutting.
3. The video processing method according to claim 1, wherein: The decoding of the first video packet and the second video packet to obtain a first frame and a second frame, and fusing the first frame with the second frame to obtain a target frame specifically includes: Calling a read function to read out the first video packet and the second video packet respectively; Sending the first video packet and the second video packet to a decoder for decoding respectively to obtain a first frame of the first video packet and a second frame of the second video packet; The first frame and the second frame are frame-fused based on OpenGL to obtain a target frame.
4. The video processing method according to claim 1, wherein: The step of performing frame fusion on the first frame and the second frame based on OpenGL further includes: A transparency group is preset, and the transparency of the second-first frame is adjusted to a target transparency in the transparency group, wherein the transparency group includes 90% transparency, 95% transparency, and 98% transparency.
5. The video processing method according to claim 1 or 3, characterized in that: The first frame and the second frame are frame-fused based on OpenGL to obtain a target frame, and then the method further includes: A horizontal inversion parameter is preset, and an Opengl fragment shader is modified based on the horizontal inversion parameter to horizontally invert the target frame image to obtain a horizontal inverted frame image.
6. A video processing system, characterized in that: The video processing system is applied to the video processing method according to any one of claims 1 to 5, and the video processing system includes: a data processing module, configured to obtain a pre-uploaded video file and a material file, process the video file to obtain a first video package and a first audio package, and process the material file to obtain a second video package; A data fusion module is configured to decode the first video packet and the second video packet to obtain a first frame and a second frame, and fuse the first frame with the second frame to obtain a target frame; The video generation module is configured to encode the target frame to obtain a new video package, and encode the new video package and the first audio package to generate a target video file.
7. A terminal, characterized in that: The terminal includes: a memory, a processor, and a video processing program stored in the memory and executable on the processor. When the video processing program is executed by the processor, the steps of the video processing method according to any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a video processing program, and when the video processing program is executed by a processor, the steps of the video processing method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Method and device for generating video file, and storage medium
CN108924464A