CN111050179B - Video transcoding method and device - Google Patents
Video transcoding method and device Download PDFInfo
- Publication number
- CN111050179B CN111050179B CN201911394223.XA CN201911394223A CN111050179B CN 111050179 B CN111050179 B CN 111050179B CN 201911394223 A CN201911394223 A CN 201911394223A CN 111050179 B CN111050179 B CN 111050179B
- Authority
- CN
- China
- Prior art keywords
- video file
- decoding
- video
- image processing
- data information
- 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.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 55
- 238000004891 communication Methods 0.000 claims description 19
- 238000004590 computer program Methods 0.000 claims description 13
- 238000000638 solvent extraction Methods 0.000 claims description 10
- 230000000694 effects Effects 0.000 claims description 8
- 230000008569 process Effects 0.000 description 6
- 230000009471 action Effects 0.000 description 3
- 238000001514 detection method Methods 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 230000006872 improvement Effects 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 230000000670 limiting effect Effects 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/40—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using video transcoding, i.e. partial or full decoding of a coded input stream followed by re-encoding of the decoded output stream
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/42—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/44—Decoders specially adapted therefor, e.g. video decoders which are asymmetric with respect to the encoder
-
- 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/435—Processing of additional data, e.g. decrypting of additional data, reconstructing software from modules extracted from the transport stream
-
- 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
-
- 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
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Compression Or Coding Systems Of Tv Signals (AREA)
Abstract
The embodiment of the application provides a video transcoding method and a video transcoding device, which relate to the technical field of computers, and the method comprises the following steps: the electronic equipment can acquire the first video file and judge whether the first video file needs to be subjected to image processing after the first video file is decoded; when image processing does not need to be carried out on the first video file after decoding and the preset decoding mode of the first video file is hardware decoding, carrying out software decoding on the first video file to obtain video data information; and then, according to a second coding format, carrying out software coding on the video data information to obtain a second video file in the second coding format. Based on the scheme, the electronic equipment can utilize the CPU resource to perform software decoding and encoding on the video file, so that the speed of decoding and encoding the video file is increased, the time length of decoding and encoding the video file is shortened, and the user experience is improved.
Description
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to a video transcoding method and device.
Background
With the popularization of intelligent equipment and the continuous improvement of the processing performance of the intelligent equipment, the short video industry is rapidly developed. The video files have various coding formats, and on an intelligent device, a Graphics Processing Unit (GPU) is used for decoding a video file with one coding format, performing image Processing on the video file after decoding, and then coding the video file after image Processing to obtain a video file with another coding format, so as to achieve the purpose of mutual conversion between the video files with various coding formats.
However, the GPU of some smart devices is configured poorly, which causes the smart devices to have a long decoding and encoding time when decoding and encoding video files, and affects user experience.
Disclosure of Invention
An object of the present invention is to provide a video transcoding method and apparatus, so as to reduce the time duration for decoding and encoding a video file. The specific technical scheme is as follows:
in a first aspect of embodiments of the present application, there is provided a video transcoding method, where the method includes the following steps:
acquiring a first video file, wherein the coding format of the first video file is a first coding format;
predicting the image processing condition of the first video file; wherein the image processing condition of the first video file is as follows: a condition whether image processing needs to be performed on the first video file after the first video file is decoded;
when the first video file does not need to be subjected to image processing after decoding and the preset decoding mode of the first video file is hardware decoding, a software decoding mode is adopted to replace the preset decoding mode, and the first video file is decoded to obtain video data information;
and according to a second coding format, carrying out software coding on the video data information to obtain a second video file in the second coding format.
Optionally, the predicting the image processing condition of the first video file includes:
detecting a target application scene of the first video file;
judging whether the target application scene is an application scene needing image processing; wherein the application scene requiring image processing at least comprises: filter processing scene, special effect processing scene and caption adding processing scene.
If so, determining that the first video file needs to be subjected to image processing after being decoded;
if not, determining that the first video file does not need to be subjected to image processing after being decoded.
Optionally, the step of decoding the first video file by using a software decoding manner instead of the preset decoding manner to obtain video data information includes:
dividing the first video file into a plurality of decoding tasks;
replacing the preset decoding mode with a software decoding mode, and performing software decoding on the plurality of decoding tasks through a plurality of threads to obtain a plurality of sub-video data information;
and combining the plurality of pieces of sub video data information to obtain video data information corresponding to the first video file.
Optionally, the step of performing software coding on the video data information according to the second coding format to obtain the second video file in the second coding format includes:
dividing the video data information into a plurality of encoding tasks;
according to a second coding format, performing software coding on the plurality of coding tasks through a plurality of threads to obtain a plurality of sub-video files;
and combining the plurality of sub video files to obtain a second video file in the second coding format.
Optionally, when image processing needs to be performed on the first video file after decoding, the method further includes:
acquiring a preset decoding mode of the first video file, and decoding the first video file by adopting the preset decoding mode to obtain video data information;
performing image processing on the video data information to obtain image processing data;
and according to a second coding format, carrying out hardware coding on the image processing data to obtain a second video file in the second coding format.
In a second aspect of the embodiments of the present application, there is also provided a video transcoding apparatus, including:
the device comprises an acquisition module, a storage module and a processing module, wherein the acquisition module is used for acquiring a first video file, and the coding format of the first video file is a first coding format;
the prediction module is used for predicting the image processing condition of the first video file; wherein the image processing condition of the first video file is as follows: a condition whether image processing needs to be performed on the first video file after the first video file is decoded;
the first decoding module is used for decoding the first video file by adopting a software decoding mode to replace a preset decoding mode when the first video file does not need to be subjected to image processing after decoding and the preset decoding mode of the first video file is hardware decoding, so that video data information is obtained;
and the first coding module is used for carrying out software coding on the video data information according to a second coding format to obtain a second video file of the second coding format.
Optionally, the prediction module includes:
the detection submodule is used for detecting a target application scene of the first video file;
the judgment submodule is used for judging whether the target application scene is an application scene needing image processing; wherein the application scene requiring image processing at least comprises: a filter processing scene, a special effect processing scene and a caption adding processing scene;
the determining submodule is used for determining that the first video file needs to be subjected to image processing after the first video file is decoded if the application scene needs to be subjected to image processing; and if the application scene does not need image processing, determining that the first video file does not need image processing after being decoded.
Optionally, the first decoding module includes:
a first partitioning module for partitioning the first video file into a plurality of decoding tasks;
the first decoding submodule is used for replacing the preset decoding mode with a software decoding mode and performing software decoding on the decoding tasks through a plurality of threads to obtain a plurality of sub-video data information;
and the first combination submodule is used for combining the plurality of sub video data information to obtain the video data information corresponding to the first video file.
Optionally, the first encoding module includes:
a second partitioning sub-module for partitioning the video data information into a plurality of encoding tasks;
the second coding submodule is used for carrying out software coding on the plurality of coding tasks through a plurality of threads according to a second coding format to obtain a plurality of sub-video files;
and the second combination submodule is used for combining the plurality of sub video files to obtain a second video file in the second coding format.
Optionally, the apparatus further comprises:
the second decoding module is used for acquiring a preset decoding mode of the first video file when the first video file needs to be subjected to image processing after decoding, and decoding the first video file by adopting the preset decoding mode to obtain video data information;
the image processing module is used for carrying out image processing on the video data information to obtain image processing data;
and the second coding module is used for carrying out hardware coding on the image processing data according to a second coding format to obtain a second video file of the second coding format.
In a third aspect of the embodiments of the present application, there is further provided an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of the first aspect when executing the program stored in the memory.
In yet another aspect of the embodiments of the present application, there is further provided a computer-readable storage medium having a computer program stored therein, where the computer program, when executed by a processor, implements the video transcoding method described in any of the above.
In yet another aspect of embodiments of the present application, there is also provided a computer program product comprising instructions which, when run on a computer, cause the computer to perform any of the video transcoding methods described above.
According to the video transcoding method and device provided by the embodiment of the application, for the video file which does not need to be subjected to image processing, software decoding and software encoding are carried out on the video file to obtain the video file in other encoding formats. The software decoding and the software encoding are both realized by a Central Processing Unit (CPU). As the CPU coding and decoding can meet the requirement of video file processing for the video file without image processing, and the operation performance of the CPU is superior to that of the GPU, the CPU is adopted to carry out software decoding and software coding on the video file without image processing, and the speed of video file decoding and coding can be effectively improved under the condition of meeting the requirement of video file processing, thereby reducing the time length of video file decoding and coding and improving the user experience.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below.
Fig. 1 is a schematic flowchart of a video transcoding method according to an embodiment of the present disclosure;
fig. 2 is a schematic flowchart of another video transcoding method according to an embodiment of the present disclosure;
fig. 3 is a schematic flowchart of a video transcoding method according to an embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of a video transcoding apparatus according to an embodiment of the present disclosure;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application without any creative effort belong to the protection scope of the embodiments in the present application.
In the prior art, a GPU is mainly used to decode and encode video files to realize transcoding of the video files, i.e., to realize interconversion between video files of various encoding formats. However, the GPU of some intelligent devices is configured poorly, so that when the intelligent devices decode and encode video files, the decoding and encoding time durations are long, which affects user experience.
In order to solve the above problem, an embodiment of the present application provides a video transcoding method. Referring to fig. 1, fig. 1 is a schematic flowchart of a video transcoding method according to an embodiment of the present disclosure. The method can be applied to electronic equipment such as smart phones, personal computers, and notebooks, and the embodiment of the present application is not particularly limited thereto. The method comprises the following steps.
And 103, when the image processing of the first video file is not needed after the decoding and the preset decoding mode of the first video file is hardware decoding, a software decoding mode is adopted to replace the preset decoding mode, and the first video file is decoded to obtain video data information.
And step 104, performing software coding on the video data information according to the second coding format to obtain a second video file in the second coding format.
In the video transcoding method provided by the embodiment of the application, for a video file which does not need image processing, software decoding and software encoding are performed on the video file to obtain video files in other encoding formats. Wherein the software decoding and the software encoding are both implemented by the CPU. As the CPU coding and decoding can meet the requirement of video processing for the video file without image processing, and the operating performance of the CPU is superior to that of the GPU, the CPU is adopted to carry out software decoding and software encoding on the video file, and the speed of decoding and encoding the video file can be effectively improved under the condition of meeting the requirement of video processing, so that the time for decoding and encoding the video file is shortened, and the user experience is improved.
For convenience of understanding, the following explains and does not limit the video transcoding method provided in the embodiments of the present application, with an electronic device as an execution subject.
In the step of acquiring the first video file in step 101, the first video file may be any video file, and the embodiment of the present application only takes the first video file as an example, and does not have a limiting effect. The encoding format of the first video file includes, but is not limited to, MP3, MP4, etc., and the first encoding format is only used as an example and is not limited.
Optionally, before performing step 101, the user may add, to the white list, the electronic device with the better CPU configuration and the poorer GPU configuration in advance with respect to the hardware configuration of the electronic device. For example, the hardware configuration may include a CPU configuration and a GPU configuration, and the above step 101 and step 104 may be performed on the electronic device in the white list to perform transcoding processing on the video file.
After the electronic device acquires the first video file, the electronic device executes step 102 to predict the image processing condition of the first video file. The image processing condition of the first video file may be: a condition whether image processing is required to be performed on the first video file after the first video file is decoded; image processing may include, but is not limited to, filter processing, special effects processing, subtitling processing, and the like.
For predicting the image processing condition of the first video file in step 102, after the electronic device decodes the first video file, the electronic device may or may not need to perform image processing on the first video file. The image processing is required to be implemented by the GPU, and therefore, before the electronic device decodes the first video file, the electronic device determines whether the image processing is required to be performed on the first video file after the decoding of the first video file. If the first video file does not require image processing of the first video file after decoding, the electronic device may determine that transcoding of the first video file is not to be performed by the GPU and perform step 103.
When the image processing on the first video file is not required after the decoding in the step 103 and the preset decoding mode of the first video file is hardware decoding, decoding the first video file by adopting a software decoding mode instead of the preset decoding mode to obtain video data information; the software decoding is realized by the CPU, and the electronic equipment performs software decoding on the first video file by using the CPU to obtain video data information. Here, the video data information is the decoded first video file.
For step 103, in an optional embodiment, a software decoding manner is used to replace a preset decoding manner, and the decoding of the first video file to obtain the video data information may include:
dividing the first video file into a plurality of decoding tasks;
replacing a preset decoding mode with a software decoding mode, and performing software decoding on the plurality of decoding tasks through a plurality of threads to obtain a plurality of sub-video data information;
and combining the plurality of pieces of sub-video data information to obtain video data information corresponding to the first video file.
The electronic equipment can perform multi-thread software decoding on the first video file, so that the decoding time of the first video file is shortened.
In an alternative embodiment, when the electronic device performs software decoding on the first video file, the electronic device may first divide the first video file into a plurality of decoding tasks by using a widget (e.g., Frame) in the FFmpeg. Then, the electronic device may perform multi-thread software decoding on the plurality of decoding tasks through a plurality of threads by using FFmpeg to obtain a plurality of sub-video data information. Next, the electronic device may combine the plurality of pieces of sub-video data information to obtain video data information corresponding to the first video file. And the number of decoding tasks is greater than or equal to the number of threads.
The FFmpeg is an open-source free cross-platform video and audio streaming scheme, belongs to free software, provides a complete solution for recording, converting and streaming audio and video, and comprises a very advanced audio/video coding and decoding library (such as libavcodec). Based on the method, the electronic equipment can perform multi-thread software decoding on the first video file by using FFmpeg, so that the decoding time length of the first video file is reduced.
And aiming at the step 104, performing software coding on the video data information according to the second coding format to obtain a second video file in the second coding format, wherein the software coding is realized by a CPU, and the electronic equipment performs software coding on the video data information by using the CPU according to the second coding format to obtain the second video file in the second coding format. The encoding format of the second video file includes, but is not limited to, MP3, MP4, etc., and the second encoding format is only used as an example and is not limited.
With reference to step 104, in an optional embodiment, the performing software coding on the video data information according to the second coding format to obtain a second video file in the second coding format may include:
dividing video data information into a plurality of encoding tasks;
according to a second coding format, performing software coding on the multiple coding tasks through multiple threads to obtain multiple sub-video files;
and combining the plurality of sub video files to obtain a second video file in a second coding format.
Therefore, the electronic equipment can perform multi-thread software coding on the video data information according to the second coding format to obtain a second video file in the second coding format, and the video file coding time length is reduced.
In an alternative embodiment, after obtaining the video data information, the electronic device may divide the video data information into a plurality of encoding tasks by using a widget (e.g., Frame) in a lossy video encoder (e.g., X264). Then, the electronic device may perform software encoding on the plurality of encoding tasks according to the second encoding format by using the X264 through a plurality of threads, so as to obtain a plurality of sub video files. Next, the electronic device may combine the plurality of sub-video files to obtain a second video file in a second encoding format. The number of encoding tasks is greater than or equal to the number of threads, and the second encoding format may be one of MP3, MP4, and the like.
In addition, X264 is an open source video coding function library, and is the best lossy video encoder. Based on this, the electronic device can perform multi-thread software coding on the video data information by using X264 according to the second coding format to obtain a second video file in the second coding format, so that the time length for coding the video file is reduced.
In an optional embodiment, the present application further provides a video transcoding method. Referring to fig. 2, fig. 2 is another schematic flow chart of a video transcoding method provided in an embodiment of the present application, where the method may include the following steps.
And 203, when the image processing of the first video file is not needed after the decoding and the preset decoding mode of the first video file is hardware decoding, a software decoding mode is adopted to replace the preset decoding mode, and the first video file is decoded to obtain video data information.
And step 204, according to the second coding format, performing software coding on the video data information to obtain a second video file in the second coding format.
And step 206, performing image processing on the video data information to obtain image processing data.
And step 207, performing hardware coding on the image processing data according to the second coding format to obtain a second video file in the second coding format.
The steps 201-204 are the same as the steps 101-104, and the specific implementation process of the steps 201-204 can refer to the description of the step 101-104.
In step 205, when the first video file needs to be image processed, a preset decoding manner of the first video file is obtained, the first video file is decoded by using the preset decoding manner to obtain video data information, the preset decoding manner may be hardware decoding, the hardware decoding is implemented by a GPU, and the electronic device performs hardware decoding on the first video file by using the GPU to obtain the video data information. Here, the video data information is the decoded first video file.
As for the above step 206, image processing is performed on the video data information to obtain image processing data, where the image processing is implemented by a GPU, and the electronic device may perform image processing on the video data information by using the GPU to obtain image processing data, where the image processing may include, but is not limited to, filter processing, special effect processing, subtitle adding processing, and the like.
In step 207, the image processing data is subjected to hardware coding according to the second coding format to obtain a second video file in the second coding format, the hardware coding is implemented by a GPU, and the electronic device can perform hardware coding on the image processing data by using the GPU, where the image processing data is video data information after image processing.
In addition, regarding step 205, step 206, and step 207, in an alternative embodiment, the electronic device may perform hardware decoding, image processing, and hardware encoding on the first video file by using a media code, and then the electronic device may obtain a second video file. The MediaCoder is a tool for the general audio/video batch transcoding, integrates various decoders, encoder back ends and mixed flow tools, and can realize the interconversion between various audio and video formats.
In the embodiment of the application, the electronic device can perform hardware decoding, image processing and hardware encoding on the video file which needs to be subjected to image processing after decoding, wherein the hardware decoding, the image processing and the hardware encoding are all realized by a GPU; for the video file which does not need to be subjected to image processing after decoding, the electronic equipment can be used for carrying out software decoding and software encoding on the video file, wherein the software decoding and the software encoding are both realized by utilizing a CPU (central processing unit), the operational performance of the CPU is superior to that of a GPU (graphics processing unit) for the video file which does not need to be subjected to image processing, the CPU is adopted for realizing transcoding of the video file, and the time length for decoding and encoding the video file can be effectively reduced.
In an embodiment, the electronic device may determine whether image processing needs to be performed on the first video file after the first video file is decoded by detecting a target application scene of the first video file, specifically referring to fig. 3, where fig. 3 is a further flowchart of a video transcoding method provided in an embodiment of the present application, and the method may include the following steps:
And step 304, performing software decoding on the first video file to obtain video data information.
And 308, carrying out hardware coding on the image processing data according to the second coding format to obtain a second video file in the second coding format.
The steps 301-305 are the same as the steps 101-104, and the specific implementation process of the steps 301-305 can refer to the description of the step 101-104. The step 306-.
In the embodiment of the application, the electronic device may detect a target application scene of the first video file, and determine whether the target application scene is an application scene requiring image processing. With respect to the step 303, determining whether the target application scene is an application scene requiring image processing, the application scene requiring image processing may include, but is not limited to, a filter processing scene, a special effect processing scene, a subtitle adding processing scene, and the like. The electronic device may determine whether image processing is required for the first video file after decoding the first video file according to the determination result. Specifically, if the target application scene is an application scene that requires image processing, the electronic device determines that image processing needs to be performed on the first video file after the first video file is decoded, and then executes step 306. If the target application scene is an application scene that does not require image processing, the electronic device determines that the first video file does not require image processing after decoding the first video file, and then executes step 304.
Based on the same technical concept, an embodiment of the present application further provides a video transcoding apparatus, as shown in fig. 4, the apparatus includes:
an obtaining module 401, configured to obtain a first video file, where a coding format of the first video file is a first coding format;
a prediction module 402, configured to predict an image processing condition of a first video file; wherein, the image processing condition of the first video file is as follows: a condition whether image processing is required to be performed on the first video file after the first video file is decoded;
the first decoding module 403 is configured to, when image processing does not need to be performed on the first video file after decoding and a preset decoding manner of the first video file is hardware decoding, replace the preset decoding manner with a software decoding manner to decode the first video file, so as to obtain video data information;
the first encoding module 404 is configured to perform software encoding on the video data information according to the second encoding format to obtain a second video file in the second encoding format.
Optionally, the predicting module 402 includes:
the detection submodule is used for detecting a target application scene of the first video file;
the judgment submodule is used for judging whether the target application scene is an application scene needing image processing; wherein, the application scene needing image processing at least comprises: a filter processing scene, a special effect processing scene and a caption adding processing scene;
the determining submodule is used for determining that the first video file needs to be subjected to image processing after the first video file is decoded if the application scene needs to be subjected to image processing; and if the application scene does not need image processing, determining that the first video file does not need image processing after the first video file is decoded.
Optionally, the first decoding module 403 includes:
the first dividing module is used for dividing the first video file into a plurality of decoding tasks;
the first decoding submodule is used for replacing a preset decoding mode with a software decoding mode and performing software decoding on a plurality of decoding tasks through a plurality of threads to obtain a plurality of sub-video data information;
and the first combination submodule is used for combining the plurality of sub video data information to obtain the video data information corresponding to the first video file.
Optionally, the first encoding module 404 includes:
a second partitioning sub-module for partitioning the video data information into a plurality of encoding tasks;
the second coding submodule is used for carrying out software coding on a plurality of coding tasks through a plurality of threads according to a second coding format to obtain a plurality of sub-video files;
and the second combination submodule is used for combining the plurality of sub video files to obtain a second video file in a second coding format.
Optionally, the apparatus further comprises:
the second decoding module is used for acquiring a preset decoding mode of the first video file when the first video file needs to be subjected to image processing after decoding, and decoding the first video file by adopting the preset decoding mode to obtain video data information;
the image processing module is used for carrying out image processing on the video data information to obtain image processing data;
and the second coding module is used for carrying out hardware coding on the image processing data according to the second coding format to obtain a second video file in the second coding format.
In the video transcoding device provided by the embodiment of the application, for a video file which does not need image processing, software decoding and software encoding are performed on the video file to obtain video files in other encoding formats. Wherein the software decoding and the software encoding are both implemented by the CPU. As for the video file which does not need to be subjected to image processing, the CPU coding and decoding can meet the requirement of video file processing, the operating performance of the CPU is superior to that of the GPU, and the CPU is adopted to carry out software decoding and software encoding on the video file, the speed of video file decoding and encoding can be effectively improved under the condition of meeting the requirement of video file processing, so that the time length of video file decoding and encoding is reduced, and the user experience is improved.
An embodiment of the present application further provides an electronic device, as shown in fig. 5, including a processor 501, a communication interface 502, a memory 503 and a communication bus 504, where the processor 501, the communication interface 502 and the memory 503 complete mutual communication through the communication bus 504;
a memory 503 for storing a computer program;
the processor 501, when executing the program stored in the memory 503, implements the following steps:
acquiring a first video file, wherein the coding format of the first video file is a first coding format;
predicting the image processing condition of the first video file; wherein, the image processing condition of the first video file is as follows: a condition whether image processing is required to be performed on the first video file after the first video file is decoded;
when the first video file does not need to be subjected to image processing after decoding and the preset decoding mode of the first video file is hardware decoding, a software decoding mode is adopted to replace the preset decoding mode, and the first video file is decoded to obtain video data information;
and according to the second coding format, performing software coding on the video data information to obtain a second video file in the second coding format.
Optionally, predicting the image processing condition of the first video file includes:
detecting a target application scene of a first video file;
judging whether the target application scene is an application scene needing image processing; wherein, the application scene needing image processing at least comprises: filter processing scene, special effect processing scene and caption adding processing scene.
If so, determining that the first video file needs to be subjected to image processing after being decoded;
if not, determining that the first video file does not need to be subjected to image processing after being decoded.
Optionally, the step of decoding the first video file by using a software decoding method instead of a preset decoding method to obtain video data information includes:
dividing the first video file into a plurality of decoding tasks;
replacing a preset decoding mode with a software decoding mode, and performing software decoding on a plurality of decoding tasks through a plurality of threads to obtain a plurality of sub-video data information;
and combining the plurality of pieces of sub-video data information to obtain video data information corresponding to the first video file.
Optionally, the step of performing software coding on the video data information according to the second coding format to obtain a second video file in the second coding format includes:
dividing video data information into a plurality of encoding tasks;
according to a second coding format, performing software coding on the multiple coding tasks through multiple threads to obtain multiple sub-video files;
and combining the plurality of sub video files to obtain a second video file in a second coding format.
Optionally, when image processing needs to be performed on the first video file after decoding, the method further includes:
acquiring a preset decoding mode of a first video file, and decoding the first video file by adopting the preset decoding mode to obtain video data information;
performing image processing on the video data information to obtain image processing data;
and according to the second coding format, carrying out hardware coding on the image processing data to obtain a second video file in the second coding format.
In the electronic device provided by the embodiment of the application, for a video file which does not need image processing, software decoding and software encoding are performed on the video file to obtain video files in other encoding formats. Wherein the software decoding and the software encoding are both implemented by the CPU. As for the video file which does not need to be subjected to image processing, the CPU coding and decoding can meet the requirement of video file processing, the operating performance of the CPU is superior to that of the GPU, and the CPU is adopted to carry out software decoding and software encoding on the video file, the speed of video file decoding and encoding can be effectively improved under the condition of meeting the requirement of video file processing, so that the time length of video file decoding and encoding is reduced, and the user experience is improved.
The communication bus mentioned in the above terminal may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the terminal and other equipment.
The Memory may include a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components.
In a further embodiment provided by the embodiments of the present application, there is further provided a computer-readable storage medium having a computer program stored therein, the computer program, when executed by a processor, implementing any of the method steps described above.
In yet another embodiment provided by the embodiments of the present application, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform the video transcoding method described in any of the above embodiments.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the application to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium, (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the embodiments of the apparatus, the electronic device, and the computer-readable storage medium, since they are substantially similar to the embodiments of the method, the description is simple, and for the relevant points, reference may be made to the partial description of the embodiments of the method.
The above description is only a preferred embodiment of the present application, and is not intended to limit the scope of the embodiments of the present application. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the embodiments of the present application are included in the scope of protection of the embodiments of the present application.
Claims (10)
1. A video transcoding method is applied to an electronic device, wherein the electronic device comprises a Central Processing Unit (CPU) and a Graphics Processing Unit (GPU), and the operation performance of the CPU is superior to that of the GPU, and the method comprises the following steps:
acquiring a first video file, wherein the coding format of the first video file is a first coding format;
predicting the image processing condition of the first video file; wherein the image processing condition of the first video file is as follows: a condition whether image processing needs to be performed on the first video file after the first video file is decoded;
when the first video file does not need to be subjected to image processing after decoding and the preset decoding mode of the first video file is hardware decoding, a software decoding mode is adopted to replace the preset decoding mode, and the first video file is decoded to obtain video data information;
according to a second coding format, carrying out software coding on the video data information to obtain a second video file of the second coding format;
wherein the operations of decoding the first video file and software encoding the video data information are performed by the CPU.
2. The method of claim 1, wherein the step of predicting the image processing condition of the first video file comprises:
detecting a target application scene of the first video file;
judging whether the target application scene is an application scene needing image processing; wherein the application scene requiring image processing at least comprises: a filter processing scene, a special effect processing scene and a caption adding processing scene;
if so, determining that the first video file needs to be subjected to image processing after being decoded;
if not, determining that the first video file does not need to be subjected to image processing after being decoded.
3. The method according to claim 1, wherein the step of decoding the first video file by using a software decoding method instead of the preset decoding method to obtain video data information comprises:
dividing the first video file into a plurality of decoding tasks;
replacing the preset decoding mode with a software decoding mode, and performing software decoding on the plurality of decoding tasks through a plurality of threads to obtain a plurality of sub-video data information;
and combining the plurality of pieces of sub video data information to obtain video data information corresponding to the first video file.
4. The method of claim 1, wherein said step of software encoding said video data information in accordance with a second encoding format to obtain a second video file in said second encoding format comprises:
dividing the video data information into a plurality of encoding tasks;
according to a second coding format, performing software coding on the plurality of coding tasks through a plurality of threads to obtain a plurality of sub-video files;
and combining the plurality of sub video files to obtain a second video file in the second coding format.
5. The method of claim 1, wherein when image processing of the first video file is required after decoding, the method further comprises:
acquiring a preset decoding mode of the first video file, and decoding the first video file by adopting the preset decoding mode to obtain video data information;
performing image processing on the video data information to obtain image processing data;
and according to a second coding format, carrying out hardware coding on the image processing data to obtain a second video file in the second coding format.
6. A video transcoding apparatus, applied to an electronic device, wherein the electronic device includes a Central Processing Unit (CPU) and a Graphics Processing Unit (GPU), and an operation performance of the CPU is better than an operation performance of the GPU, the apparatus comprising:
the device comprises an acquisition module, a storage module and a processing module, wherein the acquisition module is used for acquiring a first video file, and the coding format of the first video file is a first coding format;
the prediction module is used for predicting the image processing condition of the first video file; wherein the image processing condition of the first video file is as follows: a condition whether image processing needs to be performed on the first video file after the first video file is decoded;
the first decoding module is used for decoding the first video file by adopting a software decoding mode to replace a preset decoding mode when the first video file does not need to be subjected to image processing after decoding and the preset decoding mode of the first video file is hardware decoding, so that video data information is obtained;
the first coding module is used for carrying out software coding on the video data information according to a second coding format to obtain a second video file of the second coding format;
wherein the operations of decoding the first video file and software encoding the video data information are performed by the CPU.
7. The apparatus of claim 6, wherein the first decoding module comprises:
a first partitioning module for partitioning the first video file into a plurality of decoding tasks;
the first decoding submodule is used for replacing the preset decoding mode with a software decoding mode and performing software decoding on the decoding tasks through a plurality of threads to obtain a plurality of sub-video data information;
and the first combination submodule is used for combining the plurality of sub video data information to obtain the video data information corresponding to the first video file.
8. The apparatus of claim 6, wherein the first encoding module comprises:
a second partitioning sub-module for partitioning the video data information into a plurality of encoding tasks;
the second coding submodule is used for carrying out software coding on the plurality of coding tasks through a plurality of threads according to a second coding format to obtain a plurality of sub-video files;
and the second combination submodule is used for combining the plurality of sub video files to obtain a second video file in the second coding format.
9. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any one of claims 1 to 5 when executing a program stored in the memory.
10. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of the claims 1-5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911394223.XA CN111050179B (en) | 2019-12-30 | 2019-12-30 | Video transcoding method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911394223.XA CN111050179B (en) | 2019-12-30 | 2019-12-30 | Video transcoding method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111050179A CN111050179A (en) | 2020-04-21 |
CN111050179B true CN111050179B (en) | 2022-04-22 |
Family
ID=70241672
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911394223.XA Active CN111050179B (en) | 2019-12-30 | 2019-12-30 | Video transcoding method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111050179B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116055738B (en) * | 2022-05-30 | 2023-10-20 | 荣耀终端有限公司 | Video compression method and electronic equipment |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103402100A (en) * | 2013-08-23 | 2013-11-20 | 北京奇艺世纪科技有限公司 | Video processing method and mobile terminal |
CN103702124A (en) * | 2012-09-27 | 2014-04-02 | 深圳市快播科技有限公司 | Transcoding acceleration method and transcoder |
CN104980752A (en) * | 2015-06-11 | 2015-10-14 | 武汉大千信息技术有限公司 | Method for realizing multipath self-adaptive parallel transcoding through CPU and GPU and system thereof |
CN105245897A (en) * | 2014-03-20 | 2016-01-13 | 南京云岩信息科技有限公司 | Efficient software for transcoding to hevc on multi-core processors |
CN106973298A (en) * | 2008-11-04 | 2017-07-21 | 先进微装置公司 | The software video transcoder accelerated with GPU |
CN107277616A (en) * | 2017-07-21 | 2017-10-20 | 广州爱拍网络科技有限公司 | Special video effect rendering intent, device and terminal |
CN108289228A (en) * | 2017-01-09 | 2018-07-17 | 阿里巴巴集团控股有限公司 | A kind of panoramic video code-transferring method, device and equipment |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080278595A1 (en) * | 2007-05-11 | 2008-11-13 | Advance Micro Devices, Inc. | Video Data Capture and Streaming |
-
2019
- 2019-12-30 CN CN201911394223.XA patent/CN111050179B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106973298A (en) * | 2008-11-04 | 2017-07-21 | 先进微装置公司 | The software video transcoder accelerated with GPU |
CN103702124A (en) * | 2012-09-27 | 2014-04-02 | 深圳市快播科技有限公司 | Transcoding acceleration method and transcoder |
CN103402100A (en) * | 2013-08-23 | 2013-11-20 | 北京奇艺世纪科技有限公司 | Video processing method and mobile terminal |
CN105245897A (en) * | 2014-03-20 | 2016-01-13 | 南京云岩信息科技有限公司 | Efficient software for transcoding to hevc on multi-core processors |
CN104980752A (en) * | 2015-06-11 | 2015-10-14 | 武汉大千信息技术有限公司 | Method for realizing multipath self-adaptive parallel transcoding through CPU and GPU and system thereof |
CN108289228A (en) * | 2017-01-09 | 2018-07-17 | 阿里巴巴集团控股有限公司 | A kind of panoramic video code-transferring method, device and equipment |
CN107277616A (en) * | 2017-07-21 | 2017-10-20 | 广州爱拍网络科技有限公司 | Special video effect rendering intent, device and terminal |
Also Published As
Publication number | Publication date |
---|---|
CN111050179A (en) | 2020-04-21 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109257646B (en) | Video processing method and device, electronic equipment and computer readable medium | |
US9727318B2 (en) | Techniques to identify and purge unused code | |
US20240314382A1 (en) | Claiming delayed live reference streams | |
US10558447B2 (en) | Application push method, and a service device | |
CN108551481B (en) | File uploading method and device, server and storage medium | |
CN109828859B (en) | Mobile terminal memory analysis method and device, storage medium and electronic equipment | |
CN111147926B (en) | Data transcoding method and device | |
CN103942750A (en) | Screen image recording method and device | |
WO2020026009A1 (en) | Video object recommendation method and apparatus, and device/terminal/server | |
CN111050179B (en) | Video transcoding method and device | |
US11284074B2 (en) | Cross-channel look ahead rate control for multi-channel video encoding | |
CN112735445A (en) | Method, apparatus and storage medium for adaptively selecting audio track | |
CN110944197B (en) | Method and device for coding images and audios | |
CN112015529B (en) | Data task scheduling method, system, electronic device and storage medium | |
US10659321B2 (en) | Electronic apparatus for recording debugging information and control method thereof | |
CN111200744A (en) | Multimedia playing control method and device and intelligent equipment | |
CN113066140A (en) | Image encoding method, image encoding device, computer device, and storage medium | |
CN112565886A (en) | Video frame extraction method and device, electronic equipment and readable storage medium | |
US8533354B1 (en) | Initiating media presentation prior to receiving seek index data | |
CN111246214B (en) | Video decoding method and device | |
CN108377359B (en) | Video error code resisting method and device, electronic equipment and storage medium | |
CN113111200B (en) | Method, device, electronic equipment and storage medium for auditing picture files | |
CN115019231A (en) | Video frame identification method and device, electronic equipment and storage medium | |
WO2016032383A1 (en) | Sharing of multimedia content | |
CN113613058A (en) | Local storage method, equipment and medium for network video stream |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |