CN111787328B - Video transcoding method and device, electronic equipment and storage medium - Google Patents

Video transcoding method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN111787328B
CN111787328B CN202010730912.XA CN202010730912A CN111787328B CN 111787328 B CN111787328 B CN 111787328B CN 202010730912 A CN202010730912 A CN 202010730912A CN 111787328 B CN111787328 B CN 111787328B
Authority
CN
China
Prior art keywords
gop
transcoding
interval
gop interval
video
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
Application number
CN202010730912.XA
Other languages
Chinese (zh)
Other versions
CN111787328A (en
Inventor
张文杰
樊鸿飞
荆睿
蔡媛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Cloud Network Technology Co Ltd
Original Assignee
Beijing Kingsoft Cloud Network Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Cloud Network Technology Co Ltd filed Critical Beijing Kingsoft Cloud Network Technology Co Ltd
Priority to CN202010730912.XA priority Critical patent/CN111787328B/en
Publication of CN111787328A publication Critical patent/CN111787328A/en
Priority to PCT/CN2021/090639 priority patent/WO2022021973A1/en
Application granted granted Critical
Publication of CN111787328B publication Critical patent/CN111787328B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/40Methods 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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/177Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being a group of pictures [GOP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/234Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs
    • H04N21/2343Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements
    • H04N21/234309Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving reformatting operations of video signals for distribution or compliance with end-user requests or end-user device requirements by transcoding between formats or standards, e.g. from MPEG-2 to MPEG-4 or from Quicktime to Realvideo
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing 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/44Processing 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/4402Processing 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/440218Processing 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 invention provides a video transcoding method, a video transcoding device, electronic equipment and a storage medium, wherein the method comprises the following steps: acquiring a plurality of GOP intervals of a video to be transcoded and a set transcoding GOP interval; if the multiple GOP intervals meet the preset difference value condition, determining a source GOP interval according to the multiple GOP intervals; determining a target GOP interval based on the size relationship between the source GOP interval and the transcoding GOP interval; and transcoding the video to be transcoded by adopting the target GOP interval to obtain the transcoded video. By taking into account the source GOP interval when determining the target GOP interval, transcoding of different videos of different source GOP intervals can be accommodated. Compared with a method for transcoding the video by adopting a preset fixed GOP interval in the related technology, the quality of the transcoded video is improved.

Description

Video transcoding method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of video processing technologies, and in particular, to a video transcoding method, an apparatus, an electronic device, and a storage medium.
Background
With the development of internet technology, video service providers can provide various video services to users through the internet, thereby enriching the daily life and entertainment of people. However, due to the instability of network bandwidth, the processing of different terminals can be different, and the video requirements of different users are different, so that the video needs to be transcoded to adapt to different situations.
Currently, when transcoding a video by using the related technology, a preset fixed transcoding parameter is usually used, for example: GOP (Group of Pictures) interval, transcoding the video to be transcoded. A GOP usually contains an I-frame, at least one P-frame and at least one B-frame, and the I-frame is an image frame containing a complete picture, i.e. a key frame.
However, the inventor of the present application finds that when transcoding a video with a preset fixed GOP interval, the quality of the obtained transcoded video is not very high.
Disclosure of Invention
Embodiments of the present invention provide a video transcoding method and apparatus, an electronic device, and a storage medium, so as to improve quality of a transcoded video.
The specific technical scheme is as follows:
in a first aspect, an embodiment of the present invention provides a video transcoding method, where the method includes:
acquiring a plurality of frame group GOP intervals of a video to be transcoded and preset transcoding GOP intervals;
if the multiple GOP intervals meet the preset difference value condition, determining a source GOP interval according to the multiple GOP intervals;
determining a target GOP interval for transcoding the video to be transcoded based on the size relationship between the source GOP interval and the transcoding GOP interval;
and transcoding the video to be transcoded by adopting the target GOP interval to obtain the transcoded video.
Optionally, the preset difference condition includes: a plurality of GOP intervals are the same; determining a source GOP interval from a plurality of GOP intervals, comprising: the same GOP interval is taken as the source GOP interval.
Optionally, the preset difference condition includes: the difference value of any two GOP intervals in the GOP intervals is smaller than a preset GOP interval difference value threshold; or the difference value between each GOP interval in the GOP intervals and the average value of the GOP intervals is in a preset deviation range; determining a source GOP interval from a plurality of GOP intervals, comprising:
the average of the plurality of GOP intervals is taken as the source GOP interval.
Optionally, after obtaining a plurality of GOP intervals of the video to be transcoded and a preset transcoding GOP interval, the method further includes:
and if the GOP intervals do not meet the preset difference value condition, taking the transcoding GOP intervals as target GOP intervals, and executing the step of transcoding the video to be transcoded by adopting the target GOP intervals to obtain the transcoded video.
Optionally, determining a target GOP interval for transcoding the video to be transcoded based on a size relationship between the source GOP interval and the transcoding GOP interval includes:
if the transcoding GOP interval is an integral multiple of the source GOP interval or the source GOP interval is an integral multiple of the transcoding GOP interval, determining the transcoding GOP interval as a target GOP interval;
and if the transcoding GOP interval is between the preset fractional times of the source GOP interval and 2 times of the source GOP interval, determining the source GOP interval as a target GOP interval.
Optionally, determining a target GOP interval for transcoding the video to be transcoded based on a size relationship between the source GOP interval and the transcoding GOP interval includes:
if the transcoding GOP interval is positioned between k times of the source GOP interval and k-1 times of the source GOP interval, determining a value closest to the transcoding GOP interval in the k times of the source GOP interval and the k-1 times of the source GOP interval as a target GOP interval; wherein k > =2, and k is an integer.
Optionally, determining a target GOP interval for transcoding the video to be transcoded based on a size relationship between the source GOP interval and the transcoding GOP interval includes:
if the transcoding GOP interval is smaller than a source GOP interval which is multiple of a preset fraction, dividing the source GOP interval by the transcoding GOP interval to obtain a calculation result;
and if the calculation result is not an integer, determining a target GOP interval according to the size relation between the remainder in the calculation result and the transcoding GOP interval multiplied by the preset fraction.
Optionally, determining a target GOP interval according to a size relationship between a remainder in the calculation result and a transcoding GOP interval multiplied by a preset fraction includes:
if the remainder is not more than the transcoding GOP interval multiplied by the preset fraction, taking the quotient in the calculation result as a target GOP interval change period m; taking the transcoding GOP interval as the 1 st to the m-1 st target GOP interval in the change period; taking the sum of the transcoding GOP interval and the remainder as an mth target GOP interval;
if the remainder is larger than the transcoding GOP interval multiplied by the preset fraction, adding 1 to the quotient in the calculation result and taking the quotient as a target GOP interval change period n; taking the transcoding GOP interval as the 1 st to the n-1 st target GOP intervals in the change period; taking the remainder as the nth target GOP interval;
transcoding the video to be transcoded by adopting a target GOP interval to obtain the transcoded video, wherein the transcoding comprises the following steps:
transcoding the video to be transcoded by adopting the determined m target GOP intervals according to the target GOP interval change cycle m to obtain the transcoded video; or
And transcoding the video to be transcoded by adopting the determined n target GOP intervals according to the target GOP interval change period n to obtain the transcoded video.
In a second aspect, an embodiment of the present invention further provides a video transcoding apparatus, where the apparatus includes:
the first GOP interval acquisition module is used for acquiring a plurality of GOP intervals of the video to be transcoded and preset transcoding GOP intervals;
the second GOP interval acquisition module is used for determining a source GOP interval according to the GOP intervals if the GOP intervals meet the preset difference value condition;
the target GOP interval determining module is used for determining a target GOP interval for transcoding the video to be transcoded based on the size relationship between the source GOP interval and the transcoding GOP interval;
and the transcoding module is used for transcoding the video to be transcoded by adopting the target GOP interval to obtain the transcoded video.
Optionally, the preset difference condition includes: a plurality of GOP intervals are the same; the second GOP interval acquiring module is specifically configured to:
the same GOP interval is taken as the source GOP interval.
Optionally, the preset difference condition includes: the difference value of any two GOP intervals in the GOP intervals is smaller than a preset GOP interval difference value threshold; or the difference between each GOP interval in the multiple GOP intervals and the average value of the multiple GOP intervals is within a preset deviation range, and the second GOP interval acquiring module is specifically configured to:
the average of the plurality of GOP intervals is taken as the source GOP interval.
Optionally, the target GOP interval determining module is further configured to:
after a plurality of picture group GOP intervals of a video to be transcoded and a preset transcoding GOP interval are obtained, if the plurality of GOP intervals do not meet a preset difference value condition, the transcoding GOP interval is used as a target GOP interval, and a transcoding module is triggered to carry out transcoding operation.
Optionally, the target GOP interval determining module includes:
a first determining sub-module for determining the transcoding GOP interval as a target GOP interval if the transcoding GOP interval is an integer multiple of a source GOP interval or the source GOP interval is an integer multiple of the transcoding GOP interval;
and the second determining submodule is used for determining the source GOP interval as the target GOP interval if the transcoding GOP interval is between the source GOP interval of which the fraction is multiplied by the preset fraction and the source GOP interval of which the fraction is 2 times.
Optionally, the target GOP interval determining module includes:
a third determining submodule, configured to determine, as a target GOP interval, a value closest to a transcoding GOP interval in the k-times and k-1 times of source GOP intervals if the transcoding GOP interval is located between the k-times and k-1 times of source GOP intervals; wherein k > =2, and k is an integer.
Optionally, the target GOP interval determining module includes:
the calculation submodule is used for dividing the source GOP interval by the transcoding GOP interval to obtain a calculation result if the transcoding GOP interval is smaller than the source GOP interval which is multiplied by a preset fraction;
and the fourth determining submodule is used for determining the target GOP interval according to the size relation between the remainder in the calculation result and the transcoding GOP interval multiplied by the preset fraction if the calculation result is not an integer.
Optionally, the fourth determining submodule is specifically configured to:
if the remainder is not more than the transcoding GOP interval multiplied by the preset fraction, taking the quotient in the calculation result as a target GOP interval change period m; taking the transcoding GOP interval as a 1 st to an m-1 st target GOP interval in a variation period m; taking the sum of the transcoding GOP interval and the remainder as an mth target GOP interval; m is a positive integer;
if the remainder is larger than the transcoding GOP interval multiplied by the preset fraction, adding 1 to the quotient in the calculation result and taking the quotient as a target GOP interval change period n; taking the transcoding GOP interval as a 1 st to an n-1 st target GOP interval in a change period n; taking the remainder as the nth target GOP interval; n is a positive integer;
a transcoding module specifically configured to:
transcoding the video to be transcoded by adopting the determined m target GOP intervals according to the target GOP interval change cycle m to obtain the transcoded video; or
And transcoding the video to be transcoded by adopting the determined n target GOP intervals according to the target GOP interval change period n to obtain the transcoded video.
In a third aspect, an embodiment of the present invention further provides an electronic device, including a processor and a machine-readable storage medium, where the machine-readable storage medium stores machine-executable instructions capable of being executed by the processor, and the processor is caused by the machine-executable instructions to: and implementing the steps of the video transcoding method provided by the first aspect.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the video transcoding method provided in the first aspect are implemented.
In a fifth aspect, embodiments of the present invention further provide a computer program product including instructions, which when run on a computer, cause the computer to perform the steps of a video transcoding method provided in the first aspect.
In a sixth aspect, embodiments of the present invention further provide a computer program, which when run on a computer, causes the computer to perform the steps of the video transcoding method provided in the first aspect.
According to the video transcoding method, the video transcoding device, the electronic equipment and the storage medium, when a video to be transcoded is transcoded, a plurality of GOP intervals and preset transcoding GOP intervals of the video to be transcoded are obtained; then judging whether the multiple GOP intervals meet a preset difference value condition, and if so, determining a source GOP interval according to the multiple GOP intervals; determining a target GOP interval for transcoding the video to be transcoded based on the size relationship between the source GOP interval and the transcoding GOP interval; and finally, transcoding the video to be transcoded by adopting the target GOP interval to obtain the transcoded video. Because the target GOP interval for transcoding the video to be transcoded is determined based on the size relationship between the source GOP interval and the transcoding GOP interval, and then the video to be transcoded is transcoded by the target GOP interval, namely the source GOP interval is considered when the target GOP interval is determined, the method can adapt to transcoding of different videos with different source GOP intervals. Compared with a method for transcoding the video by adopting a preset fixed transcoding GOP interval in the related technology, the quality of the transcoded video is improved. Of course, it is not necessary for any product or method of practicing the invention to achieve all of the above-described advantages at the same time.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the prior art descriptions will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a flowchart of a first implementation of a video transcoding method according to an embodiment of the present invention;
fig. 2 is a flowchart of a second implementation of a video transcoding method according to an embodiment of the present invention;
fig. 3 is a flowchart of a video transcoding method according to a third implementation manner of the embodiment of the present invention;
fig. 4 is a flowchart of a fourth implementation of a video transcoding method according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a video transcoding apparatus according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Currently, when transcoding video by using the related art, transcoding video to be transcoded is generally performed by using preset fixed transcoding parameters, for example, GOP intervals. For example, each GOP of the video to be transcoded is decoded, and then the decoded video is re-encoded by adopting a preset GOP interval, so that the transcoded video can be obtained.
When a GOP is coded, the B-frame pictures and the P-frame pictures in the GOP generally need to be coded based on the I-frame pictures, and therefore the coded B-frame pictures and the coded P-frame pictures generally have errors compared with the corresponding original pictures. The error increases as the distance between the encoded B-frame picture and the encoded P-frame picture and the I-frame picture in the corresponding GOP increases.
Therefore, when transcoding the video to be transcoded by using the preset GOP interval, the I-frame images of the GOP redetermined based on the preset GOP interval may be B-frame images or P-frame images in the video to be transcoded. If the corresponding B frame image or P frame image is coded and decoded based on the newly determined I frame image of the GOP, error accumulation is formed, so that the coding quality of recoding the video to be transcoded is reduced, and the quality of the obtained transcoded video is not high.
In order to solve the problems in the prior art, embodiments of the present invention provide a video transcoding method, apparatus, electronic device, and storage medium, so as to improve the quality of a transcoded video.
First, a video transcoding method according to an embodiment of the present invention is introduced below, as shown in fig. 1, which is a flowchart of a first implementation manner of a video transcoding method according to an embodiment of the present invention, where the method may include:
s110, acquiring a plurality of GOP intervals of a video to be transcoded and a preset transcoding GOP interval;
s120, if the multiple GOP intervals meet the preset difference value condition, determining a source GOP interval according to the multiple GOP intervals;
s130, determining a target GOP interval for transcoding the video to be transcoded based on the size relationship between the source GOP interval and the transcoding GOP interval;
and S140, transcoding the video to be transcoded by adopting the target GOP interval to obtain the transcoded video.
In some examples, when transcoding the video to be transcoded, the video to be transcoded may be decoded first. After the video to be transcoded is decoded, a plurality of GOP intervals of the video to be transcoded can be obtained. In some examples, the number of the plurality of GOP intervals is not limited, and may be preset according to an empirical value, for example, may be set to 60, 100, or 150, etc.
In the present embodiment, the transcoding GOP interval is set in advance. Specifically, in some examples, the transcoding GOP interval may be a preset general transcoding GOP interval, or a preset specific transcoding GOP interval for the video to be transcoded. After the transcoding GOP interval is set, the transcoding GOP interval can be stored. When transcoding the video to be transcoded, the saved transcoded GOP interval can be directly read.
After the plurality of GOP intervals and the transcoding GOP intervals are obtained, it may be determined whether the plurality of GOP intervals meet a preset difference condition, where the preset difference condition is used to determine whether the plurality of GOP intervals are the same or similar.
If a preset difference condition is satisfied, a source GOP interval may be determined according to a plurality of GOP intervals.
In this embodiment, a target GOP interval for transcoding a video to be transcoded is determined based on a size relationship between a source GOP interval and a transcoding GOP interval. Specifically, the source GOP interval can be directly determined as the target GOP interval based on the size relationship between the source GOP interval and the transcoding GOP interval; or directly determining the transcoding GOP interval as a target GOP interval based on the size relationship between the source GOP interval and the transcoding GOP interval; or calculating the source GOP interval and the transcoding GOP interval based on the size relationship of the source GOP interval and the transcoding GOP interval to obtain the target GOP interval.
After the target GOP interval is determined, the target GOP interval can be adopted to transcode the video to be transcoded, so that the transcoded video can be obtained.
The embodiment of the invention provides a video transcoding method, which comprises the steps of firstly acquiring a plurality of GOP intervals of a video to be transcoded and preset transcoding GOP intervals when transcoding the video to be transcoded; then judging whether the multiple GOP intervals meet a preset difference value condition, and if so, determining a source GOP interval according to the multiple GOP intervals; determining a target GOP interval for transcoding the video to be transcoded based on the size relationship between the source GOP interval and the transcoding GOP interval; and finally, transcoding the video to be transcoded by adopting the target GOP interval to obtain the transcoded video. Because the target GOP interval for transcoding the video to be transcoded is determined based on the size relationship between the source GOP interval and the transcoding GOP interval, and then the video to be transcoded is transcoded by the target GOP interval, namely the source GOP interval is considered when the target GOP interval is determined, the method can adapt to transcoding of different videos with different source GOP intervals. Compared with a method for transcoding the video by adopting a preset fixed transcoding GOP interval in the related technology, the quality of the transcoded video is improved.
In some examples, the preset difference condition may include: a plurality of GOP intervals are the same; in contrast, when determining a source GOP interval from a plurality of GOP intervals, the same GOP interval may be used as the source GOP interval.
In some examples, the GOP intervals of the video to be transcoded may be the same or different, and therefore, the preset difference condition may further include: the difference value of any two GOP intervals in the GOP intervals is smaller than a preset GOP interval difference value threshold; or the difference value between each GOP interval in the GOP intervals and the average value of the GOP intervals is in a preset deviation range;
specifically, when the plurality of GOP intervals are different, it may be determined whether a difference between any two GOP intervals in the plurality of GOP intervals is smaller than a preset GOP interval difference threshold, or whether differences between each GOP interval in the plurality of GOP intervals and an average value of the plurality of GOP intervals are within a preset deviation range.
If the difference between any two GOP intervals in the GOP intervals is smaller than the preset GOP interval difference threshold, or the difference between each GOP interval in the GOP intervals and the average value of the GOP intervals is within the preset deviation range, it can be said that each GOP interval is small fluctuation in a certain range above and below the average value of the GOP intervals, and then each GOP interval can be considered to be close, therefore, it can be considered that the GOP intervals meet the preset difference condition, and then the average value of the GOP intervals is taken as the source GOP interval.
In still other examples, the preset deviation range may be a deviation range value that is empirically set in advance.
By the embodiment of the invention, when the difference of each GOP interval of the video to be transcoded is small, the video transcoding method of the embodiment of the invention can be adopted to determine the target GOP interval for transcoding the video to be transcoded and transcode the video to be transcoded by using the target GOP interval, so that the source GOP interval is considered when the target GOP interval is determined, and the method can be suitable for transcoding different videos with different source GOP intervals. Compared with a method for transcoding the video by adopting a preset fixed GOP interval in the related technology, the quality of the transcoded video is improved.
In some examples, the multiple GOP intervals may be close, at least two GOP intervals with a relatively large difference may exist, or a difference value between at least 1 GOP interval and an average value of the multiple GOP intervals is outside a preset deviation range, at this time, if the multiple GOP intervals do not satisfy a preset difference value condition, a preset transcoding GOP interval may be directly used as a target GOP interval, and then the target GOP interval is adopted to transcode a video to be transcoded, so as to obtain the transcoded video.
In some examples, when determining, through step S130 in fig. 1, a target GOP interval for transcoding a video to be transcoded based on a size relationship between a source GOP interval and a transcoding GOP interval, embodiments of the present invention provide multiple possible implementations, as shown in fig. 2, fig. 3, and fig. 4, which are exemplary implementations for determining a target transcoding interval in a video transcoding method according to an embodiment of the present invention.
As shown in fig. 2, which is a flowchart of a second implementation manner of a video transcoding method according to an embodiment of the present invention, the method may include:
s210, acquiring a plurality of GOP intervals of a video to be transcoded and a preset transcoding GOP interval;
s220, if the multiple GOP intervals meet the preset difference value condition, determining a source GOP interval according to the multiple GOP intervals;
s230, judging the size relationship between the source GOP interval and the transcoding GOP interval; if the transcoding GOP interval is an integer multiple of the source GOP interval, or the source GOP interval is an integer multiple of the transcoding GOP interval, executing step S240, if the transcoding GOP interval is between the preset fractional times of the source GOP interval and 2 times of the source GOP interval, executing step S250;
s240, determining the transcoding GOP interval as a target GOP interval, and executing the step S260;
s250, determining the source GOP interval as a target GOP interval, and executing the step S260;
and S260, transcoding the video to be transcoded by adopting the target GOP interval to obtain the transcoded video.
In some examples, in determining the size relationship of the source GOP interval and the transcoding GOP interval, it may be determined whether the transcoding GOP interval is an integer multiple of the source GOP interval or whether the source GOP interval is an integer multiple of the transcoding GOP interval, and if so, the transcoding GOP interval may be determined to be the target GOP interval.
In still other examples, in determining the size relationship of the source GOP interval and the transcoding GOP interval, it may also be determined whether the transcoding GOP interval is between a preset fractional multiple of the source GOP interval and 2 times the source GOP interval, and if so, the source GOP interval may be determined to be the target GOP interval.
For example, assume a source GOP interval of N Source Transcoding GOP interval of N Rotating shaft Target GOP interval of N Reset Then the transcoding GOP interval N can be judged Rotating shaft Whether or not it is the source GOP interval N Source Integral multiple of, or determining the source GOP interval N Source Whether it is a transcoding GOP interval N Rotating shaft Integer multiple of, if yes, the transcoded GOP interval N can be Rotating shaft Determined as a target GOP interval N Reset
Illustratively, assume N Rotating shaft =60,N Source =20, then the determined target GOP interval N Reset =N Rotating shaft =60; assume also N Rotating shaft =60,N Source =180, then the target GOP interval N is determined Reset =N Rotating shaft =60。
In some examples, the preset fraction multiple corresponding to the source GOP interval is empirically set in advance, for example, may be 1/2 times, and at this time, it may be determined that the transcoding GOP interval N is Rotating shaft Whether or not it is greater than 1/2N Source And less than 2 times N Source . If so, the source GOP may be spaced by N Source Determined as a target GOP interval N Reset of a memory cell
Illustratively, assume N Source =60, then 30<N Rotating shaft <120, the determined target GOP interval is the source GOP interval, namely N Reset =N Source =60。
It can be understood that steps S210, S220, and S260 in the embodiment of the present invention are the same as or similar to steps S110, S120, and S140 in the first implementation of the video transcoding method in the embodiment of the present invention, and are not described again here.
As shown in fig. 3, which is a flowchart of a third implementation of a video transcoding method according to an embodiment of the present invention, the method may include:
s310, acquiring a plurality of GOP intervals of the video to be transcoded and preset transcoding GOP intervals;
s320, if the multiple GOP intervals meet the preset difference value condition, determining a source GOP interval according to the multiple GOP intervals;
s330, judging the size relationship between the source GOP interval and the transcoding GOP interval; if the transcoding GOP interval is located between k times of the source GOP interval and k-1 times of the source GOP interval, step S340 is executed; wherein k > =2, and k is an integer;
s340, determining a value closest to a transcoding GOP interval as a target GOP interval from the k times of source GOP interval and the k-1 times of source GOP interval;
and S350, transcoding the video to be transcoded by adopting the target GOP interval to obtain the transcoded video.
In some examples, the above-described transcoding GOP interval may or may not be an integer multiple of the source GOP interval, and when the transcoding GOP interval is not an integer multiple of the source GOP interval, the transcoding GOP interval may be between k times the source GOP interval and k-1 times the source GOP interval.
When the transcoding GOP interval is between k times of the source GOP interval and k-1 times of the source GOP interval, k times of the source GOP interval and k-1 times of the source GOP interval may be calculated first, and then a value closest to the transcoding GOP interval in the k times of the source GOP interval and k-1 times of the source GOP interval is determined as a target GOP interval.
Illustratively, assume N Rotating shaft =60,N Source =9, then N Rotating shaft =60 located 7 times N Source =9 and 6 times N Source =9, due to 7 times of N Source Is closer to N Rotating shaft =60, therefore, 7 times N can be multiplied Source Corresponding value 63, determined as the target GOP interval, i.e., N Reset of a memory cell =7×N Source =63。
Assume also N Rotating shaft =60,N Source =28, then N Rotating device At 2 times of N Source And 3 times N Source Due to 2 times of N Source Is closer to N Rotating shaft Thus, 2 times N can be used Source Corresponding value 56, determined as the target GOP interval, i.e., N Reset of a memory cell =2×N Source =56。
By the embodiment of the invention, when the target GOP interval is determined, the I-frame image of the target GOP interval is the same as the I-frame image of at least one GOP interval in a plurality of source GOP intervals of the video to be transcoded and is close to the transcoded GOP interval. Therefore, error accumulation can be reduced, and the coding quality of recoding the video to be transcoded is improved, so that the quality of the obtained transcoded video is improved.
For example, assuming that the source GOP interval of the video to be transcoded is 10, the I-frame image of the determined target GOP interval may be the same as the I-frame image of the 4 th GOP interval in the source GOP interval, or the same as the I-frame image of the 6 th GOP interval in the source GOP interval, so that the I-frame image used in transcoding is at least the same as one original image frame of the video to be transcoded.
It can be understood that steps S310, S320, and S350 in the embodiment of the present invention are the same as or similar to steps S110, S120, and S140 in the first implementation of the video transcoding method in the embodiment of the present invention, and are not described again here.
As shown in fig. 4, which is a flowchart of a fourth implementation manner of a video transcoding method according to an embodiment of the present invention, the method may include:
s410, acquiring a plurality of GOP intervals of a video to be transcoded and a preset transcoding GOP interval;
s420, if the multiple GOP intervals meet the preset difference value condition, determining a source GOP interval according to the multiple GOP intervals;
s430, judging the size relationship between the source GOP interval and the transcoding GOP interval; if the transcoding GOP interval is smaller than the source GOP interval of which the fraction is multiple of the preset fraction, executing step S440;
s440, dividing the source GOP interval by the transcoding GOP interval to obtain a calculation result; if the calculation result is not an integer, executing step S450;
s450, determining a target GOP interval according to the size relation between the remainder in the calculation result and the transcoding GOP interval multiplied by the preset fraction;
and S460, transcoding the video to be transcoded by adopting the target GOP interval to obtain the transcoded video.
In some examples, when the transcoding GOP interval is not an integer multiple of the source GOP interval, the transcoding GOP interval may be less than a preset fraction of the source GOP interval, where the preset fraction of the source GOP interval may be empirically set in advance, for example, the preset fraction of the source GOP interval may be 1/2. The transcoding GOP interval N Rotating shaft Possibly less than 1/2 times the source GOP interval N Source
When the transcoding GOP interval is smaller than a source GOP interval which is multiple of a preset fraction, the source GOP interval can be divided by the transcoding GOP interval to obtain a calculation result, and then whether the calculation result is an integer is judged. If the number of the coded GOP intervals is not an integer, the target GOP intervals can be determined according to the size relation between the remainder in the calculation result and the transcoding GOP intervals which are multiplied by the preset fraction. And then transcoding the video to be transcoded by adopting the target GOP interval to obtain the transcoded video.
In some examples, when the target GOP interval is determined according to the size relationship between the remainder in the calculation result and the transcoding GOP interval multiplied by the preset fraction, whether the remainder in the calculation result is larger than the transcoding GOP interval multiplied by the preset fraction can be judged; the preset fraction times corresponding to the transcoding GOP interval may also be set empirically, for example, may be set to 1/2.
If the remainder is not more than the transcoding GOP interval multiplied by the preset fraction, taking the quotient in the calculation result as a target GOP interval change period m; taking the transcoding GOP interval as a 1 st to an m-1 st target GOP interval in a variation period m; taking the sum of the transcoding GOP interval and the remainder as an mth target GOP interval; m is a positive integer;
and transcoding the video to be transcoded by adopting the determined m target GOP intervals according to the target GOP interval change period m to obtain the transcoded video.
If the remainder is larger than the transcoding GOP interval multiplied by the preset fraction, adding 1 to the quotient in the calculation result and taking the quotient as a target GOP interval change period n; taking the transcoding GOP interval as a 1 st to an n-1 st target GOP interval in a variation period n; taking the remainder as the nth target GOP interval; n is a positive integer;
and then transcoding the video to be transcoded by adopting the determined n target GOP intervals according to the target GOP interval change period n to obtain the transcoded video.
For example, assume N Rotating shaft =60,N Source =149, then N Rotating shaft Less than 1/2 times N Source At this time, N may be Source =149 divided by N Rotating shaft =60, obtain the calculation result 2 and the remainder 29, and then determine whether the remainder 29 is larger than 1/2 times of the transcoding GOP interval N Rotating shaft =60, if no, then 2 may be set as target GOP interval change cycle, transcoding GOP interval is set as 1 st target GOP interval in the change cycle, and transcoding GOP interval N may be set Rotating shaft The sum 89 of =60 and the remainder 29 is taken as the 2 nd target GOP interval.
And finally, transcoding the video to be transcoded according to the target GOP interval change period 2 by adopting the determined 2 target GOP intervals 60 and 89, so as to obtain the transcoded video. Specifically, the determined 2 target GOP intervals 60 and 89 are adopted, the video to be transcoded is divided into a plurality of GOPs to be transcoded according to the target GOP interval change period, and then each GOP to be transcoded is transcoded respectively.
When the video to be transcoded is divided into a plurality of GOPs to be transcoded, a first target GOP interval 60 is adopted to divide a GOP, then a second target GOP interval 89 is adopted to divide a GOP, then the first target GOP interval 60 is adopted to divide a GOP, and … are adopted to circulate in sequence, so that the video to be transcoded can be divided into a plurality of GOPs to be transcoded according to the target GOP interval change period.
Also for example, assume N Rotating device =60,N Source =153, then the N Rotating shaft Less than 1/2 times N Source At this time, N may be Source =153 divided by N Rotating shaft =60, obtain the calculation result 2 and the remainder 33, and then determine whether the remainder 33 is larger than 1/2 times of the transcoding GOP interval N Rotating shaft If yes, 2 plus 1 may be used as the target GOP interval change period, the transcoding GOP interval may be used as the 1 st target GOP interval and the second target GOP interval in the change period, and the remainder 33 may be used as the 3 rd target GOP interval.
And finally, transcoding the video to be transcoded by adopting the determined 3 target GOP intervals 60, 60 and 33 according to the target GOP interval change cycle 3, so as to obtain the transcoded video.
By the embodiment of the invention, when the target GOP interval is determined, the I-frame image of the determined target GOP interval is the same as the I-frame image of at least one GOP interval in a plurality of source GOP intervals of the video to be transcoded and is the same as the transcoded GOP interval. Therefore, error accumulation can be reduced, and the coding quality of recoding the video to be transcoded is improved, so that the quality of the obtained transcoded video is improved.
It can be understood that steps S410, S420, and S460 in the embodiment of the present invention are the same as or similar to steps S110, S120, and S140 in the first implementation of the video transcoding method in the embodiment of the present invention, and are not described again here.
In a possible implementation manner of the embodiment of the present invention, when a program is used to execute step S130, and a target GOP interval for transcoding a video to be transcoded is determined based on a size relationship between a source GOP interval and a transcoding GOP interval, assuming that a preset fraction of the source GOP interval is 1/2 and a preset fraction of the transcoding GOP interval is also 1/2, a manner of determining the target GOP interval for transcoding the video to be transcoded shown in fig. 2, fig. 3, and fig. 4 may be represented as follows:
if N is present Rotating shaft =k×N Source Then N is Reset of a memory cell =N Rotating shaft
If N is present Rotating shaft ≠k×N Source And (k × N) Source -N Rotating shaft )≤N Rotating shaft -(k-1)×N Source Then N is Reset =k×N Source
If N is present Rotating shaft ≠k×N Source And N is Rotating device -(k-1)×N Source ≤(k×N Source -N Rotating shaft ) Then N is Reset =(k-1)×N Source
If it is used
Figure BDA0002603279240000141
Then N is Reset =N Source
If N is present Source =k×N Rotating shaft Then N is Reset of a memory cell =N Rotating shaft
If N is present Source ≠k×N Rotating shaft And is and
Figure BDA0002603279240000151
then
Figure BDA0002603279240000152
Wherein r is the target GOP interval change period m or n,1 is more than or equal to i is less than or equal to r,
Figure BDA0002603279240000153
the following conditions are satisfied:
Figure BDA0002603279240000154
it should be noted that the video transcoding method can be applied to any electronic device with a video transcoding function. For example, the present invention may be applied to a user terminal and may also be applied to a server.
When the method is applied to the user terminal, the method can be used for transcoding offline or online. For offline transcoding, the video transcoding method can be integrated into an offline video transcoding tool; under the condition that the video transcoding tool is installed on the user terminal, the user can upload the video file to be transcoded to the video transcoding tool for transcoding, and output a transcoding result for the user to use. For on-line transcoding, the video transcoding method can be integrated into software with a video playing function; under the condition that the software is installed in the user terminal, after the software acquires the video stream from the server, the video stream can be transcoded by using the method, and then the video playing operation is performed.
When the method is applied to the server, the user terminal can send a video stream acquisition request carrying a video format to the server; after the server receives the request, if the format of the original video stream is determined to be different from the video format carried in the request, the server can use the method to transcode the video stream first and then send the transcoded video stream to the user terminal for playing.
Corresponding to the foregoing method embodiment, an embodiment of the present invention further provides a video transcoding apparatus, as shown in fig. 5, which is a schematic structural diagram of a video transcoding apparatus according to an embodiment of the present invention, and the apparatus may include:
a first GOP interval obtaining module 510, configured to obtain multiple GOP intervals of a video to be transcoded and a preset transcoding GOP interval;
a second GOP interval obtaining module 520, configured to determine a source GOP interval according to multiple GOP intervals if the multiple GOP intervals meet a preset difference condition;
a target GOP interval determining module 530, configured to determine a target GOP interval for transcoding the video to be transcoded based on a size relationship between the source GOP interval and the transcoding GOP interval;
and the transcoding module 540 is configured to transcode the video to be transcoded by using the target GOP interval to obtain the transcoded video.
When a video to be transcoded is transcoded, a plurality of GOP intervals and a preset transcoding GOP interval of the video to be transcoded are obtained first; then judging whether the multiple GOP intervals meet a preset difference value condition, and if so, determining a source GOP interval according to the multiple GOP intervals; determining a target GOP interval for transcoding the video to be transcoded based on the size relationship between the source GOP interval and the transcoding GOP interval; and finally, transcoding the video to be transcoded by adopting the target GOP interval to obtain the transcoded video. Because the target GOP interval for transcoding the video to be transcoded is determined based on the size relationship between the source GOP interval and the transcoding GOP interval, and then the video to be transcoded is transcoded by using the target GOP interval, namely the source GOP interval is considered when the target GOP interval is determined, the method can adapt to the transcoding of different videos with different source GOP intervals. Compared with a method for transcoding the video by adopting a preset fixed transcoding GOP interval in the related technology, the quality of the transcoded video is improved.
In some examples, the preset difference condition includes: a plurality of GOP intervals are the same; the second GOP interval obtaining module 520 is specifically configured to: taking the same GOP interval as a source GOP interval;
in some examples, the preset difference condition includes: the difference value of any two GOP intervals in the GOP intervals is smaller than a preset GOP interval difference value threshold; or the difference between each GOP interval in the multiple GOP intervals and the average value of the multiple GOP intervals is within the preset deviation range, the second GOP interval obtaining module 520 is specifically configured to:
the average of the plurality of GOP intervals is taken as the source GOP interval.
In some examples, the target GOP interval determining module 530 is further configured to:
after acquiring a plurality of GOP intervals of a video to be transcoded and a preset transcoding GOP interval, if the GOP intervals do not meet a preset difference condition, the transcoding GOP interval is used as a target GOP interval, and a transcoding module 540 is triggered to perform transcoding operation.
In some examples, the target GOP interval determining module 530 includes:
a first determining sub-module for determining the transcoding GOP interval as a target GOP interval if the transcoding GOP interval is an integer multiple of a source GOP interval or the source GOP interval is an integer multiple of the transcoding GOP interval;
and the second determining submodule is used for determining the source GOP interval as the target GOP interval if the transcoding GOP interval is between the source GOP interval of which the fraction is multiplied by the preset fraction and the source GOP interval of which the fraction is 2 times.
In some examples, the target GOP interval determining module 530 includes:
a third determining submodule, configured to determine, as the target GOP interval, a value closest to the transcoding GOP interval in the k-fold source GOP interval and the k-1-fold source GOP interval if the transcoding GOP interval is located between the k-fold source GOP interval and the k-1-fold source GOP interval; wherein k > =2, and k is an integer.
In some examples, the target GOP interval determining module 530 includes:
the calculation submodule is used for dividing the source GOP interval by the transcoding GOP interval to obtain a calculation result if the transcoding GOP interval is smaller than the source GOP interval which is multiplied by a preset fraction;
and the fourth determining submodule is used for determining the target GOP interval according to the size relation between the remainder in the calculation result and the transcoding GOP interval multiplied by the preset fraction if the calculation result is not an integer.
In some examples, the fourth determination submodule is specifically configured to:
if the remainder is not more than the transcoding GOP interval multiplied by the preset fraction, taking the quotient in the calculation result as a target GOP interval change period m; taking the transcoding GOP interval as a 1 st to an m-1 st target GOP interval in a variation period m; taking the sum of the transcoding GOP interval and the remainder as an mth target GOP interval; m is a positive integer;
if the remainder is larger than the transcoding GOP interval of which the preset fraction is multiplied, adding 1 to the quotient in the calculation result and taking the quotient as a target GOP interval change period n; taking the transcoding GOP interval as a 1 st to an n-1 st target GOP interval in a change period n; taking the remainder as the nth target GOP interval; n is a positive integer;
the transcoding module 540 is specifically configured to:
transcoding the video to be transcoded by adopting the determined m target GOP intervals according to the target GOP interval change period m to obtain the transcoded video; or
And transcoding the video to be transcoded by adopting the determined n target GOP intervals according to the target GOP interval change cycle n to obtain the transcoded video.
An electronic device is further provided, as shown in fig. 6, and is a schematic structural diagram of the video transcoding method applied to the electronic device according to the embodiment of the present invention, where the electronic device may include a processor 601 and a machine-readable storage medium 602, where the machine-readable storage medium 602 stores machine-executable instructions capable of being executed by the processor 601, and the processor 601 is caused by the machine-executable instructions to: the steps of the video transcoding method shown in any of the above embodiments may be implemented, for example, as follows:
acquiring a plurality of picture group GOP intervals of a video to be transcoded and preset transcoding GOP intervals;
if the multiple GOP intervals meet the preset difference value condition, determining a source GOP interval according to the multiple GOP intervals;
determining a target GOP interval for transcoding the video to be transcoded based on the size relationship between the source GOP interval and the transcoding GOP interval;
and transcoding the video to be transcoded by adopting the target GOP interval to obtain the transcoded video.
The machine-readable storage medium 602 may include a Random Access Memory (RAM) and may also include a Non-Volatile Memory (NVM), 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 601 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.
When transcoding a video to be transcoded, the electronic device provided by the embodiment of the invention first acquires a plurality of GOP intervals of the video to be transcoded and a preset transcoding GOP interval; then judging whether the multiple GOP intervals meet a preset difference value condition, and if so, determining a source GOP interval according to the multiple GOP intervals; determining a target GOP interval for transcoding the video to be transcoded based on the size relationship between the source GOP interval and the transcoding GOP interval; and finally, transcoding the video to be transcoded by adopting the target GOP interval to obtain the transcoded video. Because the target GOP interval for transcoding the video to be transcoded is determined based on the size relationship between the source GOP interval and the transcoding GOP interval, and then the video to be transcoded is transcoded by the target GOP interval, namely the source GOP interval is considered when the target GOP interval is determined, the method can adapt to transcoding of different videos with different source GOP intervals. Compared with a method for transcoding the video by adopting a preset fixed transcoding GOP interval in the related art, the quality of the transcoded video is improved.
An embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the steps of a video transcoding method shown in any of the above embodiments are implemented, for example, the following steps may be implemented:
acquiring a plurality of picture group GOP intervals of a video to be transcoded and preset transcoding GOP intervals;
if the multiple GOP intervals meet the preset difference value condition, determining a source GOP interval according to the multiple GOP intervals;
determining a target GOP interval for transcoding the video to be transcoded based on the size relationship between the source GOP interval and the transcoding GOP interval;
and transcoding the video to be transcoded by adopting the target GOP interval to obtain the transcoded video.
When transcoding a video to be transcoded, a plurality of GOP intervals and preset transcoding GOP intervals of the video to be transcoded are obtained first; then judging whether the multiple GOP intervals meet a preset difference value condition, and if so, determining a source GOP interval according to the multiple GOP intervals; determining a target GOP interval for transcoding the video to be transcoded based on the size relationship between the source GOP interval and the transcoding GOP interval; and finally, transcoding the video to be transcoded by adopting the target GOP interval to obtain the transcoded video. Because the target GOP interval for transcoding the video to be transcoded is determined based on the size relationship between the source GOP interval and the transcoding GOP interval, and then the video to be transcoded is transcoded by the target GOP interval, namely the source GOP interval is considered when the target GOP interval is determined, the method can adapt to transcoding of different videos with different source GOP intervals. Compared with a method for transcoding the video by adopting a preset fixed transcoding GOP interval in the related technology, the quality of the transcoded video is improved.
Embodiments of the present invention further provide a computer program product including instructions, which when run on a computer, cause the computer to perform the steps of a video transcoding method shown in any of the above embodiments, for example, the following steps may be performed:
acquiring a plurality of picture group GOP intervals of a video to be transcoded and preset transcoding GOP intervals;
if the multiple GOP intervals meet the preset difference value condition, determining a source GOP interval according to the multiple GOP intervals;
determining a target GOP interval for transcoding the video to be transcoded based on the size relationship between the source GOP interval and the transcoding GOP interval;
and transcoding the video to be transcoded by adopting the target GOP interval to obtain the transcoded video.
When a video to be transcoded is transcoded, acquiring a plurality of GOP intervals of the video to be transcoded and a preset transcoding GOP interval; then judging whether the multiple GOP intervals meet a preset difference value condition, and if so, determining a source GOP interval according to the multiple GOP intervals; determining a target GOP interval for transcoding the video to be transcoded based on the size relationship between the source GOP interval and the transcoding GOP interval; and finally, transcoding the video to be transcoded by adopting the target GOP interval to obtain the transcoded video. Because the target GOP interval for transcoding the video to be transcoded is determined based on the size relationship between the source GOP interval and the transcoding GOP interval, and then the video to be transcoded is transcoded by the target GOP interval, namely the source GOP interval is considered when the target GOP interval is determined, the method can adapt to transcoding of different videos with different source GOP intervals. Compared with a method for transcoding the video by adopting a preset fixed transcoding GOP interval in the related technology, the quality of the transcoded video is improved.
Embodiments of the present invention further provide a computer program, which when running on a computer, causes the computer to execute the steps of a video transcoding method shown in any of the above embodiments, for example, the following steps may be executed:
acquiring a plurality of picture group GOP intervals of a video to be transcoded and preset transcoding GOP intervals;
if the multiple GOP intervals meet the preset difference value condition, determining a source GOP interval according to the multiple GOP intervals;
determining a target GOP interval for transcoding the video to be transcoded based on the size relationship between the source GOP interval and the transcoding GOP interval;
and transcoding the video to be transcoded by adopting the target GOP interval to obtain the transcoded video.
When transcoding a video to be transcoded, a computer program provided by the embodiment of the present invention first obtains a plurality of GOP intervals of the video to be transcoded and a preset transcoding GOP interval; then judging whether the multiple GOP intervals meet a preset difference value condition, and if so, determining a source GOP interval according to the multiple GOP intervals; determining a target GOP interval for transcoding the video to be transcoded based on the size relationship between the source GOP interval and the transcoding GOP interval; and finally, transcoding the video to be transcoded by adopting the target GOP interval to obtain the transcoded video. Because the target GOP interval for transcoding the video to be transcoded is determined based on the size relationship between the source GOP interval and the transcoding GOP interval, and then the video to be transcoded is transcoded by the target GOP interval, namely the source GOP interval is considered when the target GOP interval is determined, the method can adapt to transcoding of different videos with different source GOP intervals. Compared with a method for transcoding the video by adopting a preset fixed transcoding GOP interval in the related technology, the quality of the transcoded video is improved.
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 a … …" does not exclude the presence of another identical element 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 differences from other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (18)

1. A method of video transcoding, the method comprising:
acquiring a plurality of picture group GOP intervals of a video to be transcoded and preset transcoding GOP intervals;
if the GOP intervals meet the preset difference value condition, determining a source GOP interval according to the GOP intervals;
determining a target GOP interval for transcoding the video to be transcoded based on the size relationship between the source GOP interval and the transcoding GOP interval;
and transcoding the video to be transcoded by adopting the target GOP interval to obtain the transcoded video.
2. The method of claim 1, wherein the preset difference condition comprises: the plurality of GOP intervals are the same; determining a source GOP interval based on the plurality of GOP intervals, comprising:
the same GOP interval is taken as the source GOP interval.
3. The method of claim 1, wherein the preset difference condition comprises: the difference value of any two GOP intervals in the GOP intervals is smaller than a preset GOP interval difference value threshold; or the difference value between each GOP interval in the GOP intervals and the average value of the GOP intervals is in a preset deviation range; determining a source GOP interval according to the plurality of GOP intervals, comprising:
taking an average of the plurality of GOP intervals as the source GOP interval.
4. The method according to claim 2 or 3, wherein after said obtaining a plurality of group of pictures (GOP) intervals of the video to be transcoded and a pre-set transcoding GOP interval, the method further comprises:
and if the GOP intervals do not meet the preset difference value condition, taking the transcoding GOP intervals as the target GOP intervals, and executing the step of transcoding the video to be transcoded by adopting the target GOP intervals to obtain the transcoded video.
5. The method of claim 1, wherein determining a target GOP interval for transcoding the video to be transcoded based on a size relationship between the source GOP interval and the transcoding GOP interval comprises:
determining the transcoding GOP interval as the target GOP interval if the transcoding GOP interval is an integer multiple of the source GOP interval or the source GOP interval is an integer multiple of the transcoding GOP interval;
and if the transcoding GOP interval is between the source GOP interval of which the fraction is multiplied by a preset fraction and the source GOP interval of which the fraction is 2 times, determining the source GOP interval as a target GOP interval.
6. The method of claim 1, wherein determining a target GOP interval for transcoding the video to be transcoded based on a size relationship between the source GOP interval and the transcoding GOP interval comprises:
if the transcoding GOP interval is positioned between k times of the source GOP interval and k-1 times of the source GOP interval, determining a value closest to the transcoding GOP interval in the k times of the source GOP interval and the k-1 times of the source GOP interval as the target GOP interval; wherein k > =2, and the k is an integer.
7. The method of claim 1, wherein determining a target GOP interval for transcoding the video to be transcoded based on a size relationship between the source GOP interval and the transcoding GOP interval comprises:
if the transcoding GOP interval is smaller than the source GOP interval which is multiplied by a preset fraction, dividing the source GOP interval by the transcoding GOP interval to obtain a calculation result;
and if the calculation result is not an integer, determining the target GOP interval according to the size relationship between the remainder in the calculation result and the transcoding GOP interval multiplied by a preset fraction.
8. The method according to claim 7, wherein the determining the target GOP interval according to the size relationship between a remainder in the calculation result and the transcoding GOP interval multiplied by a preset fraction comprises:
if the remainder is not larger than the transcoding GOP interval multiplied by the preset fraction, taking the quotient in the calculation result as the target GOP interval change period m; taking the transcoding GOP interval as the 1 st to the m-1 st target GOP interval in the change period m; taking the sum of the transcoding GOP interval and the remainder as an mth target GOP interval; m is a positive integer;
if the remainder is larger than the transcoding GOP interval which is multiple of the preset fraction, adding 1 to the quotient in the calculation result and taking the quotient as the target GOP interval change period n; taking the transcoding GOP interval as a 1 st to an n-1 st target GOP interval in the variation period n; taking the remainder as an nth target GOP interval; n is a positive integer;
the transcoding the video to be transcoded by adopting the target GOP interval to obtain the transcoded video comprises the following steps:
transcoding the video to be transcoded by adopting the determined m target GOP intervals according to the target GOP interval change period m to obtain a transcoded video; or,
and transcoding the video to be transcoded by adopting the determined n target GOP intervals according to the target GOP interval change period n to obtain the transcoded video.
9. A video transcoding apparatus, the apparatus comprising:
the first GOP interval acquisition module is used for acquiring a plurality of GOP intervals of the video to be transcoded and preset transcoding GOP intervals;
a second GOP interval acquisition module, configured to determine a source GOP interval according to the multiple GOP intervals if the multiple GOP intervals meet a preset difference condition;
the target GOP interval determining module is used for determining a target GOP interval for transcoding the video to be transcoded based on the size relationship between the source GOP interval and the transcoding GOP interval;
and the transcoding module is used for transcoding the video to be transcoded by adopting the target GOP interval to obtain the transcoded video.
10. The apparatus of claim 9, wherein the preset difference condition comprises: the plurality of GOP intervals are the same; the second GOP interval obtaining module is specifically configured to:
the same GOP interval is taken as the source GOP interval.
11. The apparatus of claim 9, wherein the preset difference condition comprises: the difference value of any two GOP intervals in the GOP intervals is smaller than a preset GOP interval difference value threshold; or the difference between each GOP interval in the multiple GOP intervals and the average value of the multiple GOP intervals is within a preset deviation range, and the second GOP interval acquiring module is specifically configured to:
taking an average of the plurality of GOP intervals as the source GOP interval.
12. The apparatus according to claim 10 or 11, wherein the target GOP interval determining module is further configured to:
after the plurality of picture group GOP intervals of the video to be transcoded and the preset transcoding GOP intervals are obtained, if the plurality of GOP intervals do not meet the preset difference value condition, the transcoding GOP intervals are used as the target GOP intervals, and the transcoding module is triggered to carry out transcoding operation.
13. The apparatus of claim 9, wherein the target GOP interval determining module comprises:
a first determining sub-module configured to determine the transcoding GOP interval as the target GOP interval if the transcoding GOP interval is an integer multiple of the source GOP interval or the source GOP interval is an integer multiple of the transcoding GOP interval;
and the second determining submodule is used for determining the source GOP interval as a target GOP interval if the transcoding GOP interval is between the source GOP interval of which the fraction is multiplied by a preset fraction and the source GOP interval of which the fraction is 2 times.
14. The apparatus of claim 9, wherein the target GOP interval determining module comprises:
a third determining sub-module, configured to determine, if the transcoded GOP interval is located between k times of the source GOP interval and k-1 times of the source GOP interval, a value closest to the transcoded GOP interval, among the k times of the source GOP interval and the k-1 times of the source GOP interval, as the target GOP interval; wherein k > =2, and the k is an integer.
15. The apparatus of claim 9, wherein the target GOP interval determining module comprises:
the calculation submodule is used for dividing the source GOP interval by the transcoding GOP interval to obtain a calculation result if the transcoding GOP interval is smaller than the source GOP interval which is multiplied by a preset fraction;
and the fourth determining submodule is used for determining the target GOP interval according to the size relation between the remainder in the calculation result and the transcoding GOP interval multiplied by the preset fraction if the calculation result is not an integer.
16. The apparatus according to claim 15, wherein the fourth determination submodule is specifically configured to:
if the remainder is not larger than the transcoding GOP interval multiplied by the preset fraction, taking the quotient in the calculation result as the target GOP interval change period m; taking the transcoding GOP interval as the 1 st to the m-1 st target GOP interval in the change period m; taking the sum of the transcoding GOP interval and the remainder as an mth target GOP interval; m is a positive integer;
if the remainder is larger than the transcoding GOP interval which is multiplied by the preset fraction, adding 1 to the quotient in the calculation result and taking the quotient as the target GOP interval change period n; taking the transcoding GOP interval as a 1 st to an n-1 st target GOP interval in the variation period n; taking the remainder as an nth target GOP interval; n is a positive integer;
the transcoding module is specifically configured to:
transcoding the video to be transcoded by adopting the determined m target GOP intervals according to the target GOP interval change period m to obtain a transcoded video; or,
and transcoding the video to be transcoded by adopting the determined n target GOP intervals according to the target GOP interval change period n to obtain the transcoded video.
17. An electronic device comprising a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor, the processor being caused by the machine-executable instructions to: carrying out the method steps of any one of claims 1 to 8.
18. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the method steps of any one of claims 1 to 8.
CN202010730912.XA 2020-07-27 2020-07-27 Video transcoding method and device, electronic equipment and storage medium Active CN111787328B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202010730912.XA CN111787328B (en) 2020-07-27 2020-07-27 Video transcoding method and device, electronic equipment and storage medium
PCT/CN2021/090639 WO2022021973A1 (en) 2020-07-27 2021-04-28 Video transcoding method and apparatus, electronic device, and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010730912.XA CN111787328B (en) 2020-07-27 2020-07-27 Video transcoding method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111787328A CN111787328A (en) 2020-10-16
CN111787328B true CN111787328B (en) 2022-11-04

Family

ID=72764240

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010730912.XA Active CN111787328B (en) 2020-07-27 2020-07-27 Video transcoding method and device, electronic equipment and storage medium

Country Status (2)

Country Link
CN (1) CN111787328B (en)
WO (1) WO2022021973A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111787328B (en) * 2020-07-27 2022-11-04 北京金山云网络技术有限公司 Video transcoding method and device, electronic equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101917612A (en) * 2009-12-17 2010-12-15 新奥特(北京)视频技术有限公司 Streaming media video coding method and device
CN110062262A (en) * 2019-04-12 2019-07-26 北京字节跳动网络技术有限公司 Transcoding control method, device, electronic equipment and the storage medium of video data
CN110784718A (en) * 2019-10-31 2020-02-11 广州市网星信息技术有限公司 Video data encoding method, apparatus, device and storage medium

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9094641B1 (en) * 2011-06-08 2015-07-28 Arris Enterprises, Inc. Group of pictures size adjustment
CN103220550B (en) * 2012-01-19 2016-12-07 华为技术有限公司 The method and device of video conversion
US9930379B2 (en) * 2012-01-31 2018-03-27 Comcast Cable Communications, Llc System and method for data stream fragmentation
CN103702138A (en) * 2013-11-29 2014-04-02 乐视网信息技术(北京)股份有限公司 Method and system for self-adaptive appointed transcoding
CN111787328B (en) * 2020-07-27 2022-11-04 北京金山云网络技术有限公司 Video transcoding method and device, electronic equipment and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101917612A (en) * 2009-12-17 2010-12-15 新奥特(北京)视频技术有限公司 Streaming media video coding method and device
CN110062262A (en) * 2019-04-12 2019-07-26 北京字节跳动网络技术有限公司 Transcoding control method, device, electronic equipment and the storage medium of video data
CN110784718A (en) * 2019-10-31 2020-02-11 广州市网星信息技术有限公司 Video data encoding method, apparatus, device and storage medium

Also Published As

Publication number Publication date
CN111787328A (en) 2020-10-16
WO2022021973A1 (en) 2022-02-03

Similar Documents

Publication Publication Date Title
US20190297327A1 (en) Video encoding processing method, computer device and storage medium
CN109862359B (en) Code rate control method and device based on layered B frame and electronic equipment
CN106803992B (en) Video editing method and device
CN110446072B (en) Video stream switching method, electronic device and storage medium
US8548057B2 (en) Video coding redundancy reduction
CN110546953B (en) Complexity adaptive single-pass and double-pass transcoding
CN112203096B (en) Video encoding method, apparatus, computer device and storage medium
CN109089121B (en) Motion estimation method and device based on video coding and electronic equipment
US11539985B2 (en) No reference realtime video quality assessment
EP2941001B1 (en) Video management
US8442114B2 (en) Moving picture encoding apparatus and distribution system
US20110075726A1 (en) Moving picture encoding apparatus and distribution system
CN111787328B (en) Video transcoding method and device, electronic equipment and storage medium
US10819951B2 (en) Recording video from a bitstream
US10778991B1 (en) Adaptive group of pictures (GOP) encoding
US10812550B1 (en) Bitrate allocation for a multichannel media stream
KR20190010659A (en) Quality Estimation of Adaptive Multimedia Streaming
CN113259671B (en) Loop filtering method, device, equipment and storage medium in video coding and decoding
US20240187548A1 (en) Dynamic resolution switching in live streams based on video quality assessment
CN111183640A (en) Transmission device, transmission method, and program
CN114245196B (en) Screen recording and stream pushing method and device, electronic equipment and storage medium
US20210117480A1 (en) Artificial intelligence-assisted content source identification
US20230015443A1 (en) Video encoding for low-concurrency linear channels
CN115002517B (en) Video learning duration anti-theft method and device
US20220188549A1 (en) Context aware word cloud for context oriented dynamic actions

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