# Patent

## Title
Key frame aligned transcoding using statistics file

## Abstract

Systems and methods are provided for transcoding a set of key frame aligned output files from a source file. A statistics file is generated while transcoding a first output file of the set. Subsequent output files having the same frame size but different bitrates of the set may be created non-sequentially and in parallel using the statistics file.

## Background
TECHNICAL FIELD
The present disclosure relates generally to digital media encoding, and more particularly, some embodiments relate to systems and methods for producing key frame aligned video files.
DESCRIPTION OF THE RELATED ART
Due to the growing number of digital media distribution platforms that are available, a single piece of media content, such as a movie, is often digitized or transcoded into different formats and bit-rates. In some cases, a set of output files are key frame aligned. For example, such output files may be used in adaptive streaming distribution.
BRIEF SUMMARY
Systems and methods are provided for producing sets of key frame aligned digital media files from a source file. These key frame aligned files may then be used in adaptive video streaming. Adaptive video streaming often uses multiple digital media files having the same content but differing quality levels. Key frame alignment across the set of files allows relatively seamless switching between different files to adapt to changing connection conditions. In some implementations, statistics file is generated while transcoding a first output file of the set. Subsequent output files of the set having the same frame size as the first output file may be created non-sequentially and in parallel using the statistics file. Additionally, a key frame list file may be generated while transcoding a first output file of the set. Subsequent output files of the set, such as those having different bitrates or different frame sizes, may be created non-sequentially and in parallel using the key frame list file.
Other features and aspects of the disclosure will become apparent from the following detailed description, taken in conjunction with the accompanying drawings, which illustrate, by way of example, the features in accordance with various implementations.



BRIEF DESCRIPTION OF THE DRAWINGS
The drawings are provided for purposes of illustration only and merely depict typical or example implementations. These drawings are provided to facilitate the reader's understanding and shall not be considered limiting of the breadth, scope, or applicability of the disclosure. For clarity and ease of illustration, these drawings are not necessarily to scale.
FIG. 1 illustrates an example transcoding system.
FIGS. 2A and 2B illustrate an example transcoding method that may be implemented using the system of FIG. 1.
FIG. 3 illustrates an example of output file presets for a set of key frame aligned transcoded files that may be produced by the method of FIGS. 2A and 2B.
FIG. 4 illustrates an example statistics file produced during a transcoding pass of the method of FIGS. 2A and 2B.
FIG. 5 illustrates an example key frame listing file produced and used during the method of FIGS. 2A and 2B.
FIG. 6 illustrates an example transcoding node and associated system devices of the system of FIG. 1.



DETAILED DESCRIPTION
A lossy encoding process sacrifices information to compress data. Many digital media encoding techniques follow a common chain of steps: (1) prediction; (2) transformation and quantization; and (3) entropy coding. The output files produced by many such techniques are in the form of a sequence of groups of pictures (GOPs). A GOP comprises a key frame, or intra-frame (I-frame), followed by various inter-frames, such as P-frames, B-frames, or b-frames.
Many content distributors create multiple versions of a single video, song, or other digital media program for multiple avenues of distribution. For example, for a single piece of content, a video distributor might maintain a plurality of different files having the same resolution but different bitrates. These groups of files may be used in web distribution using adaptive variable bitrate streaming techniques. These adaptive streaming techniques typically require key frame alignment across the group of files.
One way of creating key frame aligned output files is to place key frames at predefined intervals. After the interval is defined, the transcoder blindly places key frames at this interval, and only this interval. However, video quality is improved when key frames can be placed at varying locations that do not follow strict interval separation, such as scene changes.
FIG. 1 illustrates a transcoding system for production of key frame aligned digital media files from a source file, such as a mezzanine file. The system comprises a controller 101 in communication with a plurality of transcoding nodes 102, 103, 104, and a network storage 105.
The controller 101 maintains records and manages the transcoding processes performed by the transcoding nodes 102, 103, 104. In some implementations, the controller 101 maintains records of where source files are stored on network storage 105 and records of where transcoded files should be stored on network storage 105. The controller 101 may comprise a server or other network attached computer.
The transcoding nodes 102, 103, 104 are a plurality of network attached computers in communication with the controller 101. Each transcoding node 102, 103, or 104 receives transcoding instruction from the controller 101. In accordance with the instructions, the transcoding nodes 102, 103, 104 retrieve a copy of the source file from the network storage 105 and transcode the source file to produce an output video file. The transcoding nodes 102, 103, 104 then store the output video file and associated statistics file on the network storage 105.
The network storage 105 may comprise a storage area network, a network attached storage, a server system, or other network storage system. The storage 105 stores the source file, the output files, associated statistics files, and a key frame list file for the output files.
FIGS. 2A and 2B illustrate an example method of producing a set of key frame aligned output files, for example by the transcoding system of FIG. 1. In step 201, the controller 101 obtains and sorts a set of presets for the key frame aligned output files. The presets are defined as a collection of settings, such as compressed video bitrate and output frame size, that define how the transcoder, such as a transcoding node 102, 103, 104 of FIG. 1, processes the source file to produce the corresponding output files. In some implementations, the presets may be obtained from a system user, from a storage location, or by being generated by the controller 101. If the presets are unordered, in step 201, the controller 101 sorts the presets, first by frame size, and then by bitrate.
FIG. 3 illustrates an example table of presets sorted by frame size and bitrate. Presets 1-4 designate output files having a frame size of 1920×1080, with bitrates of 8000 Kb/s, 4000 Kb/s, 3500 Kb/s, and 2000 Kb/s, respectively. Presets 5 and 6 designate output files having a frame size of 1280×720, with bitrates of 1500 Kb/s and 1400 Kb/s. Preset 7 designates an output file having a frame size of 852×480 and a bitrate of 1250 Kb/s. In various implementations, greater or fewer numbers of presets may be employed, along with various combinations of frame sizes and bitrates.
In step 202 of FIG. 2A, the controller 101 identifies an available transcoder node (Node 1) and assigns the node to transcode the source file to produce the first output file. In some implementations, the controller 101 transmits a JavaScript Object Notation (JSON) based instruction over the network to Node 1. The JSON based instruction may contain an instruction to transcode the preset according to the preset frame size and bitrate. The instruction may also include information on where the source file is stored, and where to upload output files such as the output transcode, statistics files, and key frame list files.
In step 203, Node 1 receives the message from the controller 101, parses the message and encodes the file specified in the instruction using the preset parameters. During step 203, Node 1 performs a first pass of a transcoding step to generate a statistics file 204 (stats file). An example of a transcoding statistics file (stats file) is shown in FIG. 4. Such stats files may be output by transcoders, such as H.264 compliant coders like the x264 transcoder. Stats files detail various parameters that were used when transcoding a file and may be used by transcoders in future encoding passes. For example, a two-pass transcoding procedure may comprise an analysis pass and an encoding pass. In the analysis pass, a source video is analyzed by the transcoder to produce a preliminary stats file. The preliminary stats file is then used in the encoding pass to produce a transcoded file. During the encoding pass, the stats file is also updated according to various decisions made by the transcoder during the second encoding pass. Transcoding procedures may also implement multiple encoding passes. In each subsequent encoding pass, the stats file from the previous encoding pass is used as an input and updated according to various decisions made during the subsequent encoding pass. The stats file comprises a list of options 401 that are used to set various transcoding parameters. The stats file further comprises parameters that are used to encode each frame of the video. The parameters may include input and output frame number, frame type, bit allocations for the frame, motion vectors, and residuals, and other transcoding parameters. Groups 402, 403, 404, and 405 are groups of parameters for a sequence of GOPs of the video.
Returning to FIG. 2A, after Node 1 generates the stats file in step 204, Node 1 uses the stats file to generate 205 a key frame list file. The key frame list file comprises a listing by frame of each key frame in the stats file. The key frame list file maintains the same number of frames between each key frame as the stats file from which it is derived.
FIG. 5 illustrates an example key frame list file derived from the stats file of FIG. 4. The key frame file is generated by using the stats file to make a list by frame number of each key frame (I-frame) of the first output file. In this example, each entry 501, 502, 503 includes the frame number, frame type (here, ‘I’), and a quantization parameter (QP). In this particular example, the QP value ‘−1’ indicates that the transcoder should decide what QP to use for transcoding the frame.
Returning to FIG. 2A, in step 205, after generating the key frame list file, Node 1 informs the controller 101 that the key frame list file has been created. In some implementations, Node 1 also uploads the key frame list file to a network storage, such as storage 105 in FIG. 1, at a location determined by the controller 101 (for example, in the original transcode instruction message). In further implementations, Node 1 also uploads the stats file to the network storage 105 at a location determined by the controller 101. In these implementations, Node 1 may upload the stats file to the network storage 105 as part of step 204. Node 1 may also upload the updated stats file as part of step 207.
When using multi-pass encoding, in step 207, Node 1 begins the second pass of the transcoding procedure using the stats file generated 204 during the first pass.
In parallel, in step 206, the controller 101 identifies further available nodes and transmits transcode instructions to the available transcoding nodes 102, 103, 104. Similar to the first instruction, the instructions may be transmitted as JSON formatted messages to the network connected transcoding nodes. The instructions may include a location of the source file and locations to store transcoded output files.
Moving to FIG. 2B, in step 215, after the first node finishes the transcode, it uploads the output file and informs the controller 101. The location for the output file may be indicated in the original transcode instruction message transmitted in step 202.
Additionally, each transcoding node 102, 103, 104 determines 208 if a stats file is available for use in transcoding the source file at the assigned preset values. For example, a stats file for the preset might be available if the source file had been previously transcoded at the preset value, or if a transcoder node 102, 103, 104 performed a first pass but was interrupted during a second pass. In a further implementation, a stats file is considered available if a stats file for a previous output file having the same frame size but a different bitrate is available. For example, referring FIG. 3, a transcoding node 102, 103, 104 instructed to create an output file with preset 2 would determine 208 that a stats file is available if a stats for preset 1 is available. In some implementations, the step of determining 208 if the stats file is available may comprise inspecting the network storage 105 at a predetermined location. For instance, the predetermined location may be included in the transcoding instruction received from the controller 101.
If the stats file is not available, then the transcoder node obtains 209 the key frame list file. For example, the key frame list file may be obtained from a predetermined location on the network storage 105. In some instances, the predetermined location for the key frame list file is the same as that for the possible stats file. In other instances, the key frame list file is stored at a different location than the possible stats file. When creating a transcoded output file having a different frame size than the output file created in steps 203-207, transcoding nodes 102, 103, 104 may use the key frame list file created in step 205. In these cases, step 206 may be performed in a parallel with step 207.
After obtaining 209 the key frame list file, the transcoding node uses the key frame list file to transcode the source file according to its assigned preset. The key frame list file is used to ensure that the output transcoded video file has the same key frame locations as the first transcoded video file that was used to create the key frame list file. In some implementations, the key frame list file is used 210 in an analysis pass to generate a stats file for the transcoded video file. The analysis pass may comprise a first encoding pass of the source file using the key frame list file as an input to ensure that key frames are placed at the proper locations. The output of this analysis pass is a stats file that may be used in subsequent transcoding passes.
After the analysis pass 201, the transcoder transcodes the source file 211 to produce an output transcoded file. In some implementations, the transcoding process 211 includes at least two passes: a first pass using the stats file generated by step 210, and a second pass using the stats file generated by the first pass.
The node then uploads 212 the output transcoded file and updated stats file to the network storage 105. The node further informs 212 the controller 101 that its assigned transcode has been completed.
If the stats file is available 208, then the transcoding node performs 213 a second (or later) pass transcode of the source file using the stats file. When the node uses the stats file to transcode 213, the output transcoded video file has key frames at the locations indicated by the stats file. Since the stats file was originally created by the original node, or by a node using the key frame list file, the transcoded file has the same key frame locations as the other output files in the preset tables. Accordingly, key frame alignment is maintained across the set of output transcoded files. Additionally, the transcoding 213 creates an updated stats file that pertains to the preset assigned in step 206.
The node then uploads 214 the output transcoded file and updated stats file to the network storage 105. The node further informs 214 the controller 101 that its assigned transcode has been completed.
As discussed above, in some implementations a previous stats file for a previous output file having the same frame size but different bitrate is used as the input stats file in step 213. In these implementations, step 213 may comprise modifying the options 401 of the previous stats file to reflect the desired bitrate of the output file to be created in step 213. In these implementations, step 213 may also comprise a first analysis pass using the modified previous stats file to create an input stats file. The input stats file may then be used in an encoding pass of the transcoding process.
In some cases, the stats file used as the input to step 213 may be the stats file created in step 204. In these cases, steps 206-213 may be performed in parallel with step 205 or step 207. In other cases, the stats file may be the updated stats file output by a node after an encoding pass of a transcoding process. For example, the input stats file to step 213 may be an output stats file from step 207 or a previously performed step 213. In these cases, step 206 may be performed after step 207 or a previous iteration of step 213. The controller 101 is informed in steps 215, 212, and 214 of when stats file and key frame listing files are created. Accordingly, in some implementations, the controller 101 manages the which steps occur in parallel or in serial on transcoding nodes 102, 103, 104
In summary, after the first pass transcode in step 203, all subsequent transcodes use one of: a stats file derived from the first stats file of the first transcoded file; the key frame list file; or a stats file derived from transcoding a file using the key frame list file. Thus, each output video has key frames at the same location. As illustrated, each node's operations may be performed in parallel. Accordingly, the entire set of key frame aligned output files may be created at the preset values in parallel and non-sequentially.
Where components or modules are implemented in whole or in part using software, in one embodiment, these software elements can be implemented to operate with a computing or processing module capable of carrying out the functionality described with respect thereto. After reading this description, it will become apparent to a person skilled in the relevant art how to implement the disclosure using other computing modules or architectures.
FIG. 6 presents an exemplary diagram of transcoding node in a transcoding system as illustrated in FIG. 1. The system includes a transcoding node 102, display 609, input device 601, network 611, controller 101, and network storage 105. In this implementation, the transcoding node 102 comprises a computer workstation. Transcoding node 102 includes processor 602, memory 606, and, optionally, hardware transcoder 613. In addition to memory 606, the transcoding node 102 may include other non-transitory computer readable media, such as non-volatile storage devices. Various data elements and programs may be stored in memory 606. For example, the transcoding program 604 may be stored and executed from memory 606. Data that is used by the transcoding program 604 may also be stored in memory 606. As described above, such data may include digital media files 608 and associated stats file 605. In some cases, all digital media files 608 that will be used by transcoding program 604 are stored in memory 606. In other cases, the files 608, 605 are a subset of the files to be processed. Other files may be provided to the transcoding node 102 over the network 611 or may be stored in local non-volatile storage.
Transcoding node 102 may comprise any computing device such as a rackmount server, desktop computer, or mobile computer. A system user may utilize input device 601, for example a keyboard and mouse, to direct the operation of transcoding program 604 executing from memory 606 by processor 602. Additionally, aspects of the transcoding program may be executed by a GPU or a hardware transcoder 613. In some implementations, the files 608, 605 may be received over network 611 from network storage 105 or controller 101. Alternatively, some or all of the files 608, 605 may be generated in the transcoding node 102. Network 611 may be a high speed network suitable for high performance computing (HPC), for example a 10 GigE network or an InfiniBand network.
While various implementations have been described above, it should be understood that they have been presented by way of example only, and not of limitation. Likewise, the various diagrams may depict an example architectural or other configuration for the disclosure, which is done to aid in understanding the features and functionality that can be included in the disclosure. The disclosure is not restricted to the illustrated example architectures or configurations, but the desired features can be implemented using a variety of alternative architectures and configurations. Indeed, it will be apparent to one of skill in the art how alternative functional, logical or physical partitioning and configurations can be implemented to implement the desired features of the present application. Also, a multitude of different constituent module names other than those depicted herein can be applied to the various partitions. Additionally, with regard to flow diagrams, operational descriptions and method claims, the order in which the steps are presented herein shall not mandate that various embodiments be implemented to perform the recited functionality in the same order unless the context dictates otherwise.
Although described above in terms of various exemplary embodiments and implementations, it should be understood that the various features, aspects and functionality described in one or more of the individual embodiments are not limited in their applicability to the particular embodiment with which they are described, but instead can be applied, alone or in various combinations, to one or more of the other embodiments of the application, whether or not such embodiments are described and whether or not such features are presented as being a part of a described embodiment. Thus, the breadth and scope of the present application should not be limited by any of the above-described exemplary embodiments.
Terms and phrases used in this document, and variations thereof, unless otherwise expressly stated, should be construed as open ended as opposed to limiting. As examples of the foregoing: the term “including” should be read as meaning “including, without limitation” or the like; the term “example” is used to provide exemplary instances of the item in discussion, not an exhaustive or limiting list thereof; the terms “a” or “an” should be read as meaning “at least one,” “one or more” or the like; and adjectives such as “conventional,” “traditional,” “normal,” “standard,” “known” and terms of similar meaning should not be construed as limiting the item described to a given time period or to an item available as of a given time, but instead should be read to encompass conventional, traditional, normal, or standard technologies that may be available or known now or at any time in the future. Likewise, where this document refers to technologies that would be apparent or known to one of ordinary skill in the art, such technologies encompass those apparent or known to the skilled artisan now or at any time in the future.
The presence of broadening words and phrases such as “one or more,” “at least,” “but not limited to” or other like phrases in some instances shall not be read to mean that the narrower case is intended or required in instances where such broadening phrases may be absent. The use of the term “module” does not imply that the components or functionality described or claimed as part of the module are all configured in a common package. Indeed, any or all of the various components of a module, whether control logic or other components, can be combined in a single package or separately maintained and can further be distributed in multiple groupings or packages or across multiple locations.
Additionally, the various embodiments set forth herein are described in terms of exemplary block diagrams, flow charts and other illustrations. As will become apparent to one of ordinary skill in the art after reading this document, the illustrated embodiments and their various alternatives can be implemented without confinement to the illustrated examples. For example, block diagrams and their accompanying description should not be construed as mandating a particular architecture or configuration.

## Claims

1. A method comprising:
obtaining a source file;
obtaining an instruction to transcode the source file to produce an output file that is key frame aligned with a previous output file, the output file having an output frame size and an output bitrate;
obtaining a previous statistics file for the previous output file, the previous output file having a same frame size as the output frame size and a different bitrate than the output bitrate;
transcoding the source file using the previous statistics file to produce an output statistics file for the output file;
obtaining a second instruction to transcode the source file to produce a second output file that is key frame aligned with the previous output file, the second output file having a second output frame size that is the same as the previous output file and having a second output bitrate that is different than the output file and the previous output file; and
transcoding the source file using the previous statistics file or the output statistics file to produce a second output statistics file for the second output file;
wherein the steps of transcoding the source file to produce the output statistics file and transcoding the source file to produce the second output statistics file are performed in parallel.

2. The method of claim 1, further comprising:
transcoding the source file using the output statistics file to produce the output file.

3. The method of claim 1, further comprising:
determining if the statistics file for the previous output file is not available; and
if the statistics file for the previous output file is not available, obtaining a key frame listing file, and transcoding the source file using the key frame listing file to produce the output file and output statistics file.

4. The method of claim 1, further comprising:
transcoding the source file using a key frame listing file to produce a third output file that is key frame aligned with the output file.

5. The method of claim 1, wherein the step of obtaining the previous statistics file for the previous output file or the output statistics file for the output file comprises obtaining the previous statistics file for the previous output file.

6. A transcoder, comprising:
a processor;
a transcoding module; and
a memory; the memory storing computer executable instructions configured to cause the transcoder to perform a method comprising:
obtaining a source file;
obtaining an instruction to transcode the source file to produce an output file that is key frame aligned with a previous output file, the output file having an output frame size and an output bitrate;
obtaining a previous statistics file for the previous output file, the previous output file having a same frame size as the output frame size and a different bitrate than the output bitrate;
transcoding the source file using the previous statistics file to produce an output statistics file for the output file;
obtaining a second instruction to transcode the source file to produce a second output file that is key frame aligned with the previous output file, the second output file having a second output frame size that is the same as the previous output file and having a second output bitrate that is different than the output file and the previous output file; and
transcoding the source file using the previous statistics file or the output statistics file to produce a second output statistics file for the second output file;
wherein the steps of transcoding the source file to produce the output statistics file and transcoding the source file to produce the second output statistics file are performed in parallel.

7. The transcoder of claim 6, wherein the method further comprises:
transcoding the source file using the output statistics file to produce the output file.

8. The transcoder of claim 6, wherein the method further comprises:
determining if the statistics file for the previous output file is not available; and
if the statistics file for the previous output file is not available, obtaining a key frame listing file, and transcoding the source file using the key frame listing file to produce the output file.

9. The transcoder of claim 6, wherein the method further comprises:
transcoding the source file using a key frame listing file to produce a third output file that is key frame aligned with the output file.

10. The transcoder of claim 6, wherein the step of obtaining the previous statistics file for the previous output file or the output statistics file for the output file comprises obtaining the previous statistics file for the previous output file.

11. A non-transitory computer memory storing computer executable instructions configured to cause a transcoder to perform a method comprising:
obtaining a source file;
obtaining an instruction to transcode the source file to produce an output file that is key frame aligned with a previous output file, the output file having an output frame size and an output bitrate;
obtaining a previous statistics file for the previous output file, the previous output file having a same frame size as the output frame size and a different bitrate than the output bitrate;
transcoding the source file using the previous statistics file to produce an output statistics file for the output file;
obtaining a second instruction to transcode the source file to produce a second output file that is key frame aligned with the previous output file, the second output file having a second output frame size that is the same as the previous output file and having a second output bitrate that is different than the output file and the previous output file; and
transcoding the source file using the previous statistics file or the output statistics file to produce a second output statistics file for the second output file;
wherein the steps of transcoding the source file to produce the output statistics file and transcoding the source file to produce the second output statistics file are performed in parallel.

12. The non-transitory computer memory of claim 11, wherein the method further comprises:
transcoding the source file using the output statistics file to produce the output file.

13. The non-transitory computer memory of claim 12, wherein the step of obtaining the previous statistics file for the previous output file or the output statistics file for the output file comprises obtaining the previous statistics file for the previous output file.

14. The non-transitory computer memory of claim 11, wherein the method further comprises:
determining if the statistics file for the previous output file is not available; and
if the statistics file for the previous output file is not available, obtaining a key frame listing file, and transcoding the source file using the key frame listing file to produce the output file.

15. The non-transitory computer memory of claim 11, wherein the method further comprises:
transcoding the source file using a key frame listing file to produce a third output file that is key frame aligned with the output file.