CN113423011B - Transcoding method for video file with any format - Google Patents

Transcoding method for video file with any format Download PDF

Info

Publication number
CN113423011B
CN113423011B CN202110964536.5A CN202110964536A CN113423011B CN 113423011 B CN113423011 B CN 113423011B CN 202110964536 A CN202110964536 A CN 202110964536A CN 113423011 B CN113423011 B CN 113423011B
Authority
CN
China
Prior art keywords
video
frame
transcoding
file
component
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
CN202110964536.5A
Other languages
Chinese (zh)
Other versions
CN113423011A (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.)
South Sagittarius Integration Co Ltd
Original Assignee
South Sagittarius Integration 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 South Sagittarius Integration Co Ltd filed Critical South Sagittarius Integration Co Ltd
Priority to CN202110964536.5A priority Critical patent/CN113423011B/en
Publication of CN113423011A publication Critical patent/CN113423011A/en
Application granted granted Critical
Publication of CN113423011B publication Critical patent/CN113423011B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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, rendering scenes according to MPEG-4 scene graphs
    • H04N21/4402Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream, rendering scenes according to MPEG-4 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, rendering scenes according to MPEG-4 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

Abstract

A transcoding method of an arbitrary format video file comprises the following steps: the method comprises the steps of obtaining the attribute of a video file to be transcoded and the transcoding requirement of a target file, creating at least two groups of transcoding process modules, determining the working mode of the transcoding process modules by comparing the attribute of the video file to be transcoded with the transcoding requirement, and creating components of the transcoding process modules; and writing the video frame generated by transcoding into a target file. The invention avoids the problems of time consumption caused by the segmentation of the video file to be transcoded and the repeated transmission of the video data on the network, and simultaneously, the transcoding method can be quickly, efficiently and stably realized aiming at the video file with any format and any reasonable transcoding requirement.

Description

Transcoding method for video file with any format
Technical Field
The invention relates to the field of audio and video streaming media, in particular to a transcoding method of a video file with any format.
Background
In recent years, with the rapid development of network and communication technologies, various applications in the video fields of video conferences, video monitoring, high-definition movies and the like are visible everywhere in daily life of people, and the common applications can store video data as video files for users to check historical videos online. Due to the fact that the stored video files are various in format and the online video file viewing modes of users are not uniform, it is determined that the video files with the confirmed format cannot be successfully accessed online by all users. In addition, video files may contain massive video data, and fast, efficient and stable transcoding is a basic requirement in the industry.
The main idea of the patent is that a transcoding subsystem acquires information of a file to be transcoded, the information content includes whether a key frame is an IDR frame, position information of the key frame, GOP description information, fragment description information, segment description information and the like, the transcoding subsystem generates a target file from the information of the file to be transcoded, and the file information of the target file is completely the same as the file information of the file to be transcoded. The transcoding method can ensure that the target file generated by transcoding is similar to most of information of the source file, and can realize file transcoding under partial scenes, but the method neglects the possibility that the transcoding of the video file needs encoding and decoding, the encoding and decoding are main factors restricting the video transcoding efficiency, the encoding and decoding are avoided, only the information of the file to be transcoded is noted, and the using scenes of the transcoding method are very limited.
The patent with the Chinese patent publication number of CN106851400B introduces a video distributed transcoding method and a system, and the main idea of the patent is to divide video files to be transcoded, assign the divided videos to corresponding client computers with the same dividing number, transcode the divided files allocated by the client computers, and send the divided files generated by transcoding to a video merging unit by the client computers after transcoding of all the divided files is successful, wherein the divided files generated by transcoding are recombined into a complete transcoded file by the video merging unit. The transcoding method can theoretically improve the transcoding efficiency of the video file under the condition that the number of the client computers is sufficient, if the number of the client computers is insufficient, the video file to be transcoded cannot be segmented, and the idea of distributed transcoding cannot be realized. In addition, not all video files can be divided, the divided subfiles may fail to be transcoded due to the fact that basic video information is lost and the divided subfiles cannot be decoded normally, but the divided subfiles are transmitted to the client computer, network delay exists when the transcoding generated subfiles are transmitted back to the video merging unit from the client computer, and even the packet loss of the subfiles due to network abnormality can occur, so that the normal transcoding effect of the video files is affected. In summary, the transcoding method can improve the transcoding efficiency of the video file in some specific scenes, but meanwhile, the transcoding quality is influenced by a plurality of objective factors.
The patent with the Chinese patent publication number of CN108551580A introduces a video file transcoding method in electronic equipment and the electronic equipment, and the main idea of the patent is to divide a video file into at least one subfile according to a division threshold, allocate at least one thread according to the current operating condition of the electronic equipment, and transcode the at least one subfile by using the at least one thread, so that the transcoding efficiency of the video file to be transcoded is improved. The transcoding method has certain practicability, but has the following defects that firstly, a video file to be transcoded is divided into subfiles, and the subfiles generated by transcoding are merged into a target file, the two processes have factors which can influence the transcoding quality, such as the subfiles to be transcoded cannot be decoded normally, the subfiles generated by transcoding are merged to cause lip-tone asynchrony of the target transcoding file, the time consumption of the merging process of the subfiles generated by transcoding is large, and the like; secondly, the use scene of the transcoding method is relatively limited, the application range is not wide, and if transcoding is needed, target video files with high resolution and low resolution are generated.
Some of the video file transcoding methods disclosed in the chinese patents basically seek innovation points in schemes of fragmenting a video file to be transcoded, or transcoding sub-files in a distributed manner, or generating a target video file according to media information of the file to be transcoded, and these schemes all have disadvantages simply introduced in the three above listed chinese patents.
Disclosure of Invention
In view of the above, the present invention has been made to provide a transcoding method of an arbitrary format video file that overcomes or at least partially solves the above problems.
In order to solve the technical problem, the embodiment of the application discloses the following technical scheme:
a transcoding method of an arbitrary format video file comprises the following steps:
s100, acquiring the attribute of a video file to be transcoded and the transcoding requirement of a target file, and creating at least two groups of transcoding process modules;
s200, determining a working mode of a transcoding process module and creating a component of the transcoding process module by comparing the attribute of the video file to be transcoded with the transcoding requirement in S100;
s300, reading the video frame by a video data reading module, attaching necessary information, and transmitting the necessary information to a transcoding process module;
s400, the transcoding process module transcodes video frames in parallel according to corresponding rules according to the working mode of the transcoding process module;
and S500, writing the video frame generated by transcoding into a target file.
Further, in S100, the attributes of the video file to be transcoded at least include: file encapsulation format, video encoding format, video resolution, video frame rate.
Further, in S100, the transcoding requirement of the target file at least includes: a target encoding format, a target resolution, and a packaging format of the target file.
Further, in S200, the specific method of S200 is: when the packaging format of the video file to be transcoded is directly converted and packaged into the packaging format of the target file, and the video frame data is not changed, the transcoding process module determines a first working mode; when the video frame data of the video file to be transcoded changes and a target video file is generated, the transcoding process module determines a second working mode; and when the video frame data of the video file to be transcoded changes and a plurality of target video files are generated, the transcoding process module determines a third working mode.
Further, in S300, the specific method of S300 is: the video data reading module reads video frames in a file to be transcoded frame by frame from the first frame of video data, judges whether the current frame is a reference frame or a non-reference frame, marks a judgment result on the video frame, simultaneously assigns a frame number which is monotonically increased for each frame of read video from a numerical value 1, and transmits the read reference frame and all non-reference frames depending on the reference frame to a group of transcoding process modules.
Further, in S400, when the transcoding process module operating mode is the first operating mode, the corresponding rule is: each group of transcoding process modules only comprises a storage component, and the transcoding process modules do not perform any operation on the video frames transmitted by the S300 and store the received video frames in the storage components.
Further, in S400, when the transcoding process module operating mode is the second operating mode, the corresponding rule is:
s401, decoding a video frame by a decoding assembly;
s402, original video data generated by a decoding component is transmitted to a uniform frame dropping component, the uniform frame dropping component drops video frames uniformly, and the sequence number value of the video frames is adjusted;
s403, the encoding component encodes the original video data into video frames and encodes the original video data according to the frame types marked by the data reading module;
and S404, assigning timestamps to the video frames generated by coding, and then sequentially storing the video frames into a storage component.
Further, in S400, when the transcoding process module operating mode is the third operating mode, the corresponding rule is:
s411, decoding the video frame by a decoding component;
s412, original video data generated by the decoding component is transmitted to the uniform frame dropping component, the uniform frame dropping component drops video frames uniformly, and the sequence number value of the video frames is adjusted;
s413, the original video data from the uniform frame dropping component is used for generating a high-resolution target file and a low-resolution target file; when the original video data is used for high resolution object file generation, performing S415-S416; when the original video data is used for low resolution object file generation, executing S414-S416;
s414, the zooming component generates low-resolution video original data;
s415, the encoding component encodes the original video data into a video frame and encodes the original video data according to the frame type marked by the data reading module;
and S416, assigning the timestamp to the video frames generated by encoding, and then sequentially storing the video frames into a storage component.
Further, the specific method of S500 is:
s501, a video data writing module acquires the frame type and the frame sequence number of a first frame of video in a storage assembly corresponding to the same resolution;
s502, determining a storage component to be written into a target file, and writing a group of video frames meeting requirements into the target file;
s503, judging whether the transcoding of the video file is finished or not, and if not, repeatedly executing S501-S502.
The technical scheme provided by the embodiment of the invention has the beneficial effects that at least:
the invention discloses a transcoding method of a video file with any format, which comprises the following steps: the method comprises the steps of obtaining the attribute of a video file to be transcoded and the transcoding requirement of a target file, creating at least two groups of transcoding process modules, determining the working mode of the transcoding process modules by comparing the attribute of the video file to be transcoded with the transcoding requirement, and creating components of the transcoding process modules; and writing the video frame generated by transcoding into a target file. The invention avoids the problems of time consumption caused by the segmentation of the video file to be transcoded and the repeated transmission of the video data on the network, and simultaneously, the transcoding method can be quickly, efficiently and stably realized aiming at the video file with any format and any reasonable transcoding requirement.
The technical solution of the present invention is further described in detail by the accompanying drawings and embodiments.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description serve to explain the principles of the invention and not to limit the invention. In the drawings:
fig. 1 is a flowchart of a transcoding method for video files with arbitrary formats according to embodiment 1 of the present invention;
fig. 2 is a flowchart of a second operating mode of the transcoding process module in embodiment 1 of the present invention;
fig. 3 is a flowchart of a third operating mode of the transcoding process module in embodiment 2 of the present invention;
FIG. 4 is a flow chart of video data writing according to embodiment 2 of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
In order to solve the problems in the prior art, embodiments of the present invention provide a transcoding method for video files in any format.
Example 1
A transcoding method of video files with arbitrary formats, as shown in fig. 1, includes:
s100, acquiring the attribute of a video file to be transcoded and the transcoding requirement of a target file, and creating at least two groups of transcoding process modules; in this embodiment, the attributes of the video file to be transcoded at least include: file encapsulation format, video encoding format, video resolution, video frame rate. The target file transcoding requirement at least comprises the following steps: a target encoding format, a target resolution, and a packaging format of the target file.
Specifically, for example: the transcoding server obtains a to-be-transcoded video file A.flv, analyzes that the file is packaged into flv, the video coding format is h264, the video resolution is 1280x720, the frame rate is 30 frames per second, the attribute of the generated target file is that the file packaging format is mp4, and the video coding format and the video resolution are the same as the to-be-transcoded video file.
S200, by comparing the attributes of the video file to be transcoded with the transcoding requirements in the S100, determining the working mode of the transcoding process module, and creating the components of the transcoding process module.
The specific method of this embodiment S200 is as follows: when the packaging format of the video file to be transcoded is directly converted and packaged into the packaging format of the target file, and the video frame data is not changed, the transcoding process module determines a first working mode; when the video frame data of the video file to be transcoded changes and a target video file is generated, the transcoding process module determines a second working mode; and when the video frame data of the video file to be transcoded changes and a plurality of target video files are generated, the transcoding process module determines a third working mode.
Specifically, the transcoding server determines the working mode of the transcoding process module by comparing the basic attribute and the transcoding target requirement of the video file to be transcoded in S100, and creates an assembly of the transcoding process module. If the video coding format and the video resolution of the file to be transcoded are the same as the video coding format and the video resolution required by the transcoding target, the transcoding process modules are in a first working mode, and each transcoding process module only comprises one storage assembly; if the video coding format or the video resolution of the file to be transcoded is different from the video coding format or the video resolution required by the transcoding target, the transcoding process modules are in a second working mode, and each transcoding process module comprises a decoding component, a uniform frame dropping component, a coding component and a storage component; if the transcoding target requirement requires to generate a target video file with high resolution and low resolution, the transcoding process modules are in a third working mode, and each transcoding process module comprises a decoding component, a uniform frame dropping component, a scaling component, two or one coding component and two storage components. The transcoding process module comprises a scaling component and an encoding component, wherein the scaling component and the encoding component consume the most system resources, the transcoding process modules are created as many as possible within the range allowed by the total calculation of the transcoding server, the front-back relation of the components contained in each transcoding process module is clear, and the components among the transcoding process modules are independent and do not interfere with each other. As is known in the video field, when a component is created, resources are preferentially allocated from a GPU, CPU resources are considered to be allocated after the calculation capacity of the GPU is completely allocated, and certain threshold resources are reserved for CPU resource allocation. It should be noted that, in the first operating mode, the GPU and CPU resources are not consumed much, and the usage of the server memory resources needs to be weighed when the number of the transcoding process modules is created, and in the second operating mode and the third operating mode, the GPU and CPU resources are consumed much, and the total computing power of the GPU and CPU needs to be weighed when the number of the transcoding process modules is created.
Specifically, for example: the system resource of the transcoding server is 8 cores 16G, if the packaging format of the video file to be transcoded is asf, the video coding format is h265, the video resolution is 1920x1080, the video frame rate is 30, the transcoding target requirement is that the file packaging format is mp4, the video coding format is h265, and the video resolution is 1920x1080, at this time, the transcoding process module only contains a storage component, and the number of the transcoding process modules is 10. If the packaging format of the video file to be transcoded is asf, the video coding format is h265, the video frame rate is 1920x1080, the video frame rate is 30, the transcoding target requirement is that the file packaging format is mp4, the video coding format is h264, the video resolution is 1920x1080, at this time, the transcoding process module comprises a decoding assembly, a uniform frame dropping assembly, a coding assembly and a storage assembly, and the number of the transcoding process modules is 8. If the packaging format of the video file to be transcoded is asf, the video coding format is h265, the video frame rate is 1920x1080, the video frame rate is 30, the transcoding target requirement is that the file packaging format is mp4, the video coding format is h264, the video resolutions are 1920x1080 and 640x352, the transcoding process module comprises a decoding component, an even frame dropping component, a scaling component, two coding components and two storage components, and the number of the transcoding process modules is 6. If the packaging format of the video file to be transcoded is asf, the video coding format is h265, the video frame rate is 1920x1080, the video frame rate is 30, the transcoding target requirement is that the file packaging format is mp4, the video coding format is h265, the video resolutions are 1920x1080 and 640x352, at this time, two types of transcoding process modules exist, the first type of transcoding process module is used for generating the target file with the resolution of 640x352, the type of transcoding process module contains a decoding component, a uniform frame dropping component, an encoding component and a storage component, the second type of transcoding process module is used for generating the target file with the resolution of 1920x1080, the type of transcoding process module only contains the storage component, the number of the first type of transcoding process module is 8, and the number of the second type of transcoding process module is 8.
S300, reading the video frame by a video data reading module, attaching necessary information, and transmitting the necessary information to a transcoding process module; in this embodiment, the specific method of S300 is as follows: the video data reading module reads video frames in a file to be transcoded frame by frame from the first frame of video data, judges whether the current frame is a reference frame or a non-reference frame, marks a judgment result on the video frame, simultaneously assigns a frame number which is monotonically increased for each frame of read video from a numerical value 1, and transmits the read reference frame and all non-reference frames depending on the reference frame to a group of transcoding process modules.
Specifically, the basic principle of video encoding is that a reference frame is encoded, a certain number of non-reference frames are encoded successively, the non-reference frames need to be relied on for decoding, and therefore repetition is achieved, and a strong correlation exists between one reference frame and the non-reference frame relying on the reference frame. The data reading module transmits the video frames with strong correlation to the same transcoding process module, when the video frames are transmitted, the video frames can be transmitted to the transcoding process module without the video frames in the storage assembly preferentially, if the video frames exist in the storage assemblies of all the transcoding process modules, the data reading module can pause data reading, and when the video frames exist in the storage assemblies or the video frames do not exist in the decoding assembly, the data reading is resumed.
For example: the packaging format of the file B.asf to be transcoded is asf, the video coding format is h265, the video resolution is 1920x1080, the video frame rate is 30, the number of transcoding process modules created by the transcoding server is 8, the data reading module starts to read the video frame of the B.asf, the video frame of the first frame is read, the frame serial number value is marked as 1, the frame is parsed into a reference frame, the frame serial number value, the frame type and the video frame data of the first frame are transmitted to the first transcoding process module together, the video frame of the second frame is read, the frame serial number value is marked as 2, the frame is parsed into a non-reference frame, the frame serial number value, the frame type and the video frame data of the second frame are transmitted to the first transcoding process module together, the operation is continuously repeated, the nth frame is read, the frame serial number value is marked as n, the frame is parsed into the reference frame, the frame serial number value, the frame type and the video frame data of the nth frame are transmitted to the second transcoding process module together, and continuously repeating the operation, if the storage assemblies of the 8 transcoding process modules all contain video frames, the data reading module temporarily stops data reading, and when the storage assembly of a certain transcoding process module does not contain video frames or the decoding assembly does not decode the video frames, the data reading module recovers the previous reading, value marking and transmission work.
S400, the transcoding process module transcodes video frames in parallel according to corresponding rules according to the working mode of the transcoding process module; specifically, when the working mode of the transcoding process module is the first working mode, the corresponding rule is as follows: each group of transcoding process modules only comprises a storage component, and the transcoding process modules do not perform any operation on the video frames transmitted by the S300 and store the received video frames in the storage components. If the transcoding process module is in the second working mode, the low-resolution target file is sequentially subjected to operations such as decoding, frame dropping, encoding and assignment of the timestamp and then stored in the storage assembly, if the transcoding process module is in the third working mode, the low-resolution target file is sequentially subjected to operations such as decoding, frame dropping, scaling, encoding and assignment of the timestamp and then stored in the storage assembly, and if the high-resolution target file is sequentially subjected to operations such as decoding, frame dropping, encoding and assignment of the timestamp, the high-resolution target file is stored in the storage assembly or the video frame is not subjected to any operation and is directly stored in the storage assembly.
For example: the package format of a video file to be transcoded is asf, the video coding format is h265, the video resolution is 1920x1080, the video frame rate is 30, the transcoding target requirement is that the file package format is mp4, the video coding format is h265, the video resolution is 1920x1080, and the transcoding process module directly stores the received video frame into the storage component.
Specifically, when the transcoding process module operating mode is the second operating mode, as shown in fig. 2, the corresponding rule is:
s401, decoding a video frame by a decoding assembly; it should be noted that when creating the decoding component, the decoding component needs to be informed of the resolution and decoding category of the video frame, otherwise the video frame is decoded abnormally. And when no video frame can be decoded by the decoding component, the data reading module is informed to transmit the video frame to the transcoding process module corresponding to the decoding component.
For example: when creating the decoding component, the decoding component is informed that the resolution of the decoded video frame is 1920x1080, the decoding category is a reference category, the received video frame is decoded into original video data, and the format of the original video data is YUV.
S402, original video data generated by a decoding component is transmitted to a uniform frame dropping component, the uniform frame dropping component drops video frames uniformly, and the sequence number value of the video frames is adjusted; original video data generated by the decoding component is transmitted to the uniform frame dropping component, because the minimum frame rate for smoothly watching video animation by human eyes is 25 frames per second, if the frame rate of the video file to be transcoded is more than 25, non-reference frames in the transcoding process module can be dropped uniformly, and the frame dropping video frame rate is 25 frames per second. In the process of frame loss, the reference frame is directly reserved and does not participate in frame loss calculation, but the frame sequence number value of the reference frame needs to be reassigned according to a uniform frame loss rule, all non-reference frames participate in uniform frame loss calculation, and the frame sequence number value is reassigned according to the uniform frame loss rule.
For example: the frame rate of the video file to be transcoded is 60, after the video file is subjected to frame dropping, the video frame rate is 25, namely the number of video frames per second is reduced by 35, and the video transcoding efficiency is greatly improved in the process. And in the frame loss process, a reference frame is specially reserved, so that the video cover of a video file generated by transcoding is prevented from being different from a source video file to be transcoded, and the reference frame is used as a mark for coding a reference frame of a coding component and can be used as a judgment basis for selecting a storage component by a data writing module.
S403, the encoding component encodes the original video data into video frames and encodes the original video data according to the frame types marked by the data reading module; and after the video data is successfully encoded, assigning a timestamp for the video frame by combining the frame rate of 25 frames per second and the frame sequence number value of the current video frame. It should be noted that, in order to reduce CPU consumption, the non-reference frame encoded by the encoding component is only referred to forward, and is not referred to backward.
For example: when the encoding component prepares to encode current original video data, reading a frame type and a frame sequence number value corresponding to the original video data, wherein the frame type is a reference frame, and the frame sequence number value is 60, the encoding component encodes the original video data into the reference frame, and then assigns a timestamp for the encoded video frame by combining a frame rate of 25 frames per second and the frame sequence number value of 60, wherein the frame interval is 40 milliseconds for 25 frames per second, the decoding and displaying time of the 60 th frame is 2.4 seconds, and assuming that the video time base of a target video file is 1000, the decoding timestamp and the displaying timestamp value of the 60 th frame are 2400.
And S404, assigning timestamps to the video frames generated by coding, and then sequentially storing the video frames into a storage component. For example: the storage component can be a queue or a linked list, and the video frame generated by the coding component is stored in the storage component together with the frame type and the frame sequence number marking value.
When the transcoding process module operating mode is the third operating mode, as shown in fig. 3, the corresponding rule is:
s411, decoding the video frame by a decoding component; at this time, the operation method of S411 is the same as S401, and is not described herein again.
S412, original video data generated by the decoding component is transmitted to the uniform frame dropping component, the uniform frame dropping component drops video frames uniformly, and the sequence number value of the video frames is adjusted; at this time, the operation method of S412 is the same as S402, and is not described herein again.
S413, the original video data from the uniform frame dropping component is used for generating a high-resolution target file and a low-resolution target file; S415-S416 are performed when the original video data is for high resolution object file generation, and S414-S416 are performed when the original video data is for low resolution object file generation.
For example: the system resource of the transcoding server is 8 cores 16G, the packaging format of a video file to be transcoded is asf, the video coding format is h265, the video frame rate is 1920x1080, the video frame rate is 30, the transcoding target requirement is that the file packaging format is mp4, the video coding format is h264, the video resolution is 1920x1080 and 640x352, the transcoding process module comprises a decoding component, a uniform frame dropping component, a scaling component, two coding components and two storage components, the number of the transcoding process modules is 6, after the uniform frame dropping component, a target video file of 1920x1080 is generated, original video data needs to go through the coding component of 1920x1080 and the storage component of 1920x1080, a target video file of 640x352 is generated, and the original video data needs to go through the scaling component, the coding component of 640x352 and the storage component of 640x 352.
S414, the zooming component generates low-resolution video original data; for example: referring to the example of S413, the resolution of the video file to be transcoded is 1920x1080, and after the video file is decoded and subjected to a uniform frame dropping component, after the 1920x1080 original video data enters the scaling component, 640x352 original video data is generated.
S415, the encoding component encodes the original video data into a video frame and encodes the original video data according to the frame type marked by the data reading module; and after the video data is successfully encoded, assigning a timestamp for the video frame by combining the frame rate of 25 frames per second and the frame sequence number value of the current video frame. It should be noted that, in order to reduce CPU consumption, the non-reference frame encoded by the encoding component is only referred to forward, and is not referred to backward. It should be noted that there are two encoding components of high and low resolution, where the two encoding components encode and assign timestamps independently, but the encoding rules and the timestamp assignment methods are the same.
For example: referring to the example of S303, the original video data 1920x1080 and 640x352 are encoded by referring to the labeled frame type value, and the video frames generated by encoding need to combine the frame rate and the frame number value of 25 frames per second when assigning the timestamp.
And S416, assigning the timestamp to the video frames generated by encoding, and then sequentially storing the video frames into a storage component. And the high-resolution video frame and the low-resolution video frame generated by the coding in the step S415 are respectively and correspondingly stored in two storage assemblies.
For example: the storage components may be queues or linked lists, in one transcoding process module, 1920x1080 video frames are stored in the first storage component of the transcoding process module, and 640x352 video frames are stored in the second storage component of the transcoding process module.
And S500, writing the video frame generated by transcoding into a target file. In this embodiment, as shown in fig. 4, the specific method of S500 is:
s501, a video data writing module acquires the frame type and the frame sequence number of a first frame of video in a storage assembly corresponding to the same resolution; the data writing module needs to select one storage component from the storage components of all transcoding process modules with the same resolution, and the selection method is to compare the frame type and the frame sequence number value of the first frame video frame mark of each storage component.
For example: the system resource of the transcoding server is 8 cores 16G, the packaging format of a video file to be transcoded is asf, the video coding format is h265, the video frame rate is 1920x1080, the video frame rate is 30, the transcoding target requirement is that the file packaging format is mp4, the video coding format is h264, the video resolutions are 1920x1080 and 640x352, the transcoding process module comprises a decoding component, a uniform frame dropping component, a scaling component, two coding components and two storage components, the number of the transcoding process module is 6, and a data writing module which is responsible for writing the video frame for the target video file with the resolution of 1920x1080 obtains the frame type and the frame number value of the first frame video frame from the 6 storage components with the storage resolution of 1920x1080 respectively, and the same is true, the data writing module responsible for writing video frames for the target video file with the resolution of 640x352 obtains the frame type and the frame sequence number value of the video frame of the first frame from only the 6 storage components with the storage resolution of 640x352 respectively.
S502, determining a storage component to be written into a target file, and writing a group of video frames meeting requirements into the target file; the storage component where the video frame with the frame type as the reference frame and the minimum frame sequence number value is located, namely the storage component which needs to be determined by the data writing module. And the data writing module acquires the video frame type in the selected storage assembly frame by frame from the first frame video frame, writes the video frame into the target video file, and stops writing the video frame until the acquired video frame type is a reference frame or the storage assembly does not contain the video frame. If the transcoding process module is in the third working mode, two data writing modules exist, and the two data writing modules work independently, but the working principles are completely the same.
For example: continuing with the example of S401, in 6 storage components with video frame corresponding resolution being 1920x1080, a first frame video frame currently stored by a 3 rd storage component is a reference frame and a frame sequence number value is the smallest among the 6 storage components, the 3 rd storage component is a storage component that needs to be selected by a data writing module, the data writing module reads a frame type value of each frame video frame in the 3 rd storage component frame by frame from a first frame, reads the frame type of the first frame as a reference frame, writes the frame into a target file with resolution being 1920x1080, reads a frame type of a second frame as a non-reference frame, writes the frame into a target file with resolution being 1920x1080, and continues to read until the frame type of an nth frame is a reference frame or the 3 rd storage component does not contain a video frame, and the data writing module stops writing the video frame. Similarly, in the 6 storage components with video resolution of 640x352, the first frame video frame currently stored by the 5 th storage component is a reference frame and the frame number value is the minimum in the 6 storage components, the 5 th storage component is a storage component that needs to be selected by the data writing module corresponding to the video resolution of 640x352, the data writing module corresponding to the video resolution of 640x352 reads the frame type value of each frame video frame in the 5 th storage component from the first frame by frame, and writes all video frames meeting the requirement into the target file with the video resolution of 640x 352.
S503, judging whether the transcoding of the video file is finished or not, and if not, repeatedly executing S501-S502. If all the storage assemblies corresponding to the same resolution do not contain video frames, transcoding of the video file is finished, and if at least one storage assembly also contains video frames, the data writing module starts to write the video frames from S501.
It should be understood that the specific order or hierarchy of steps in the processes disclosed is an example of exemplary approaches. Based upon design preferences, it is understood that the specific order or hierarchy of steps in the processes may be rearranged without departing from the scope of the present disclosure. The accompanying method claims present elements of the various steps in a sample order, and are not intended to be limited to the specific order or hierarchy presented.
In the foregoing detailed description, various features are grouped together in a single embodiment for the purpose of streamlining the disclosure. This method of disclosure is not to be interpreted as reflecting an intention that the claimed embodiments of the subject matter require more features than are expressly recited in each claim. Rather, as the following claims reflect, invention lies in less than all features of a single disclosed embodiment. Thus, the following claims are hereby expressly incorporated into the detailed description, with each claim standing on its own as a separate preferred embodiment of the invention.
Those of skill would further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present disclosure.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. Of course, the storage medium may also be integral to the processor. The processor and the storage medium may reside in an ASIC. The ASIC may reside in a user terminal. Of course, the processor and the storage medium may reside as discrete components in a user terminal.
For a software implementation, the techniques described herein may be implemented with modules (e.g., procedures, functions, and so on) that perform the functions described herein. The software codes may be stored in memory units and executed by processors. The memory unit may be implemented within the processor or external to the processor, in which case it can be communicatively coupled to the processor via various means as is known in the art.
What has been described above includes examples of one or more embodiments. It is, of course, not possible to describe every conceivable combination of components or methodologies for purposes of describing the aforementioned embodiments, but one of ordinary skill in the art may recognize that many further combinations and permutations of various embodiments are possible. Accordingly, the embodiments described herein are intended to embrace all such alterations, modifications and variations that fall within the scope of the appended claims. Furthermore, to the extent that the term "includes" is used in either the detailed description or the claims, such term is intended to be inclusive in a manner similar to the term "comprising" as "comprising" is interpreted when employed as a transitional word in a claim. Furthermore, any use of the term "or" in the specification of the claims is intended to mean a "non-exclusive or".

Claims (5)

1. A transcoding method of video files with any format is characterized by comprising the following steps:
s100, acquiring the attribute of a video file to be transcoded and the transcoding requirement of a target file, and creating at least two groups of transcoding process modules;
s200, determining a working mode of a transcoding process module and creating a component of the transcoding process module by comparing the attribute of the video file to be transcoded with the transcoding requirement in S100; the specific method of S200 is as follows: when the packaging format of the video file to be transcoded is directly converted and packaged into the packaging format of the target file, and the video frame data is not changed, the transcoding process module determines a first working mode; when the video frame data of the video file to be transcoded changes and a target video file is generated, the transcoding process module determines a second working mode; when the video frame data of the video file to be transcoded changes and a plurality of target video files are generated, the transcoding process module determines a third working mode;
s300, reading the video frame by a video data reading module, attaching necessary information, and transmitting the necessary information to a transcoding process module;
s400, the transcoding process module transcodes video frames in parallel according to corresponding rules according to the working mode of the transcoding process module; when the working mode of the transcoding process module is a first working mode, the corresponding rule is as follows: each group of transcoding process modules only comprises a storage component, and the transcoding process modules do not perform any operation on the video frames transmitted by the S300 and store the received video frames in the storage components; when the working mode of the transcoding process module is a second working mode, the corresponding rule is as follows:
s401, decoding a video frame by a decoding assembly;
s402, original video data generated by a decoding component is transmitted to a uniform frame dropping component, the uniform frame dropping component drops video frames uniformly, and the sequence number value of the video frames is adjusted;
s403, the encoding component encodes the original video data into video frames and encodes the original video data according to the frame types marked by the data reading module;
s404, assigning timestamps to video frames generated by coding, and sequentially storing the video frames into a storage component;
when the working mode of the transcoding process module is a third working mode, the corresponding rule is as follows:
s411, decoding the video frame by a decoding component;
s412, original video data generated by the decoding component is transmitted to the uniform frame dropping component, the uniform frame dropping component drops video frames uniformly, and the sequence number value of the video frames is adjusted;
s413, the original video data from the uniform frame dropping component is used for generating a high-resolution target file and a low-resolution target file; when the original video data is used for high resolution object file generation, performing S415-S416; when the original video data is used for low resolution object file generation, executing S414-S416;
s414, generating low-resolution video original data by a zooming component;
s415, the encoding component encodes the original video data into a video frame and encodes the original video data according to the frame type marked by the data reading module;
s416, assigning timestamps to the video frames generated by coding, and then sequentially storing the video frames into a storage component;
and S500, writing the video frame generated by transcoding into a target file.
2. The method for transcoding a video file with any format according to claim 1, wherein in S100, the attributes of the video file to be transcoded at least comprise: file encapsulation format, video encoding format, video resolution, video frame rate.
3. The method for transcoding a video file with arbitrary format as claimed in claim 1, wherein in S100, the transcoding requirement of the target file at least comprises: a target encoding format, a target resolution, and a packaging format of the target file.
4. The method for transcoding a video file with any format according to claim 1, wherein in S300, the specific method of S300 is as follows: the video data reading module reads video frames in a file to be transcoded frame by frame from the first frame of video data, judges whether the current frame is a reference frame or a non-reference frame, marks a judgment result on the video frame, simultaneously assigns a frame number which is monotonically increased for each frame of read video from a numerical value 1, and transmits the read reference frame and all non-reference frames depending on the reference frame to a group of transcoding process modules.
5. The method for transcoding the video file with any format according to claim 1, wherein the specific method of S500 is as follows:
s501, a video data writing module acquires the frame type and the frame sequence number of a first frame of video in a storage assembly corresponding to the same resolution;
s502, determining a storage component to be written into a target file, and writing a group of video frames meeting requirements into the target file;
s503, judging whether the transcoding of the video file is finished or not, and if not, repeatedly executing S501-S502.
CN202110964536.5A 2021-08-23 2021-08-23 Transcoding method for video file with any format Active CN113423011B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110964536.5A CN113423011B (en) 2021-08-23 2021-08-23 Transcoding method for video file with any format

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110964536.5A CN113423011B (en) 2021-08-23 2021-08-23 Transcoding method for video file with any format

Publications (2)

Publication Number Publication Date
CN113423011A CN113423011A (en) 2021-09-21
CN113423011B true CN113423011B (en) 2021-11-16

Family

ID=77719074

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110964536.5A Active CN113423011B (en) 2021-08-23 2021-08-23 Transcoding method for video file with any format

Country Status (1)

Country Link
CN (1) CN113423011B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113727112B (en) * 2021-09-23 2024-04-16 北京车和家信息技术有限公司 Video transcoding method, device, electronic equipment and medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103826138A (en) * 2014-03-12 2014-05-28 赛特斯信息科技股份有限公司 System and method for realizing cloud transcoding on various code rates and encoding formats of audio and video contents
CN106851336A (en) * 2017-02-07 2017-06-13 上海网达软件股份有限公司 The audio-video document code-transferring method and system of a kind of Dynamic Resource Allocation for Multimedia
CN111246215A (en) * 2018-11-28 2020-06-05 深圳市炜博科技有限公司 Video format conversion method and terminal

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9247312B2 (en) * 2011-01-05 2016-01-26 Sonic Ip, Inc. Systems and methods for encoding source media in matroska container files for adaptive bitrate streaming using hypertext transfer protocol
US10114835B2 (en) * 2015-04-29 2018-10-30 Box, Inc. Virtual file system for cloud-based shared content

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103826138A (en) * 2014-03-12 2014-05-28 赛特斯信息科技股份有限公司 System and method for realizing cloud transcoding on various code rates and encoding formats of audio and video contents
CN106851336A (en) * 2017-02-07 2017-06-13 上海网达软件股份有限公司 The audio-video document code-transferring method and system of a kind of Dynamic Resource Allocation for Multimedia
CN111246215A (en) * 2018-11-28 2020-06-05 深圳市炜博科技有限公司 Video format conversion method and terminal

Also Published As

Publication number Publication date
CN113423011A (en) 2021-09-21

Similar Documents

Publication Publication Date Title
Petrangeli et al. An http/2-based adaptive streaming framework for 360 virtual reality videos
US7743161B2 (en) Digital content buffer for adaptive streaming
US8606966B2 (en) Network adaptation of digital content
US8675740B2 (en) Hypothetical reference decoder
US8947492B2 (en) Combining multiple bit rate and scalable video coding
US20020131496A1 (en) System and method for adjusting bit rate and cost of delivery of digital data
CN102447906B (en) Low-latency video decoding
JP2017130966A (en) Media content decoding method in multimedia system
US20020136298A1 (en) System and method for adaptive streaming of predictive coded video data
US20100008419A1 (en) Hierarchical Bi-Directional P Frames
KR20140043767A (en) Reducing latency in video encoding and decoding
US11706427B2 (en) Optimal multi-codec ABR ladder design
US20060159352A1 (en) Method and apparatus for encoding a video sequence
EP2629476A1 (en) Adaptive display streams
US20170127152A1 (en) Information processing device and information processing method
CN113039804A (en) Bit stream merging
US20030076858A1 (en) Multi-layer data transmission system
CN113423011B (en) Transcoding method for video file with any format
US20060165172A1 (en) Method for transmitting data without jitter in synchronous Ethernet
US9001701B1 (en) Priority assignment and signaling of scalable video in a switch based system
US20110080945A1 (en) Apparatus and method for adapting scalable video coding bitstream
US20160080455A1 (en) Delivery device, reproduction device, and delivery system
KR102251576B1 (en) VR video receiving device and method based on ROI
US20090185620A1 (en) Video encoding apparatus and method for the same
CN114051737A (en) Information processing apparatus, information processing method, reproduction processing apparatus, and reproduction processing method

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