A kind of virtual sliced sheet method and system for disributed media file trans-coding systemTechnical field
It is specifically a kind of to be used for disributed media file trans-coding system the present invention relates to multi-media processing technical fieldVirtual sliced sheet method and system.
Background technology
Along with the intellectuality of the development of Internet technology, particularly mobile terminal, audio frequency and video rise in production and lifeMore and more important effect, to cater to different use demands and applied on distinct device, for the processing of audio frequency and video, going outA variety of coding techniques and different audio-video document forms are showed.In order to efficiently utilize multimedia resource, mobile platform is adapted toViewing demand, it is necessary to be the higher standard such as H.264 of compression efficiency by various converting coding formats, multimedia transcoding technologyThe active demand in Internet technology is become.
Multi-media transcoding is the process that a kind of code stream is converted to another code stream, is substantially first to decode, rear coding.PassThe multi-media transcoding mode of system is file not to be cut into slices, with regard to directly carrying out transcoding, a but transcoding task to source fileEfficiency be limited, especially for the audio-video document for needing release quickly, inefficient transcoding process can not meetThe requirement of issue, also, this problem with the increase of audio-video frequency media file duration and code check it is more obvious.Therefore, occurImproved burst code-transferring method, improved method are that first file is cut into slices, such as the physics section in Fig. 1, then to cuttingEach section of video after piece carries out segmentation transcoding, and multiple video segments after transcoding finally are incorporated as into a file, so as toObtain final transcoding file.
But during using NAS storage media files, dicing method after using above-mentioned improvement carries out audio frequency and video transcodingDuring processing, it may appear that following Railway Project:
(1) physics dicing method is that all data are read from NAS file system, searches cut point, then cuts dataIt is divided into small documents write-in NAS storages, in this process, source file is read and write-in accesses NAS storages, a large amount of transcoding tasksIt is parallel then NAS storage loads can be caused high, while occupy substantial amounts of bandwidth, write-in in LAN and be blocked, cause I O error,So as to cause transcoding task termination;
(2) when handling HD video, the duration ratio that dicing process takes in whole transcoding process is very big, and withThe incrementation synchronization of audio frequency and video code check and audio-video document duration is incremented by, and particularly big file process is slow;
(3) because the video data volume is big, the section file of output can write NAS storages, section text again after cuttingPart occupies the memory space with source file formed objects, wastes NAS memory spaces.
The content of the invention
The present invention is to solve above-mentioned problems of the prior art, and a kind of disributed media file that is used for of design turnsThe virtual sliced sheet method and system of code system, effectively reduce the I/O operation of media file dicing process and IO error rates, reduction are depositedStorage takes, and reduces the time consumption of video slicing in transcoding process, constructs more efficient distributed document trans-coding system.
In order to solve the above-mentioned technical problem, present invention employs following technical scheme:
A kind of virtual sliced sheet method for disributed media file trans-coding system, described virtual sliced sheet method it is specificStep is as follows:
S1a):Media source file is obtained, reads the slicing parameter that user is set, section starting position is arranged to t0=0,Defined parameters n, n initial value is arranged to 1;
S1b):The slicing parameter set according to user, the key behind the section duration interval of user's setting is found successivelyFrame end, the position of key frame is defined as tn, this section section lookup terminates, and records the beginning of this section section to the section terminatedData are [tn-1,tn), judge whether the ending for reaching media source file, if media source file terminates, jump to step S1d;
S1c):Starting position using the end position of the key frame found out in step s1b as next section of section, i.e.,tn-1=tn, while n=n+1 is set, is reentered in step s1b and is generated next section of key frame and start to the slice of data of end;
S1d):Whole media source file section terminates, and slice of data is generated into section index list file.Further,Described media source file carries out transcoding merging after section, concretely comprises the following steps:
S2a):The transcoding parameter that user is set is read, initializes encoder;
S2b):Transcoding module reads slice of data as transcoding task from section index list file;
S2c):According to the transcoding task of acquisition, video data is obtained from media source file, after video data decoding againIt is sent into encoder to be encoded, generates the video segment after this section section transcoding;
S2d the voice data corresponding with video data) is obtained from media source file according to transcoding task, to audio numberEncoded according to encoder is sent into after decoding, generate the voice data after this section section transcoding;
S2e) merging module reads the initialization merging module of user configuration, is merged according to section index list file generatedTask;
S2f the video segment after transcoding, the voice data added in video segment after transcoding, by all sounds) are readVideo file is written in a file destination, completes to merge.
Further, described slice of data is stored in section index list file by the sequencing of section.
Further, described section index list file is stored in a text form.、
Further, in slicing processes, the first frame of every section of section is key frame.
Further, in the slicing processes of media source file, in addition to the slice of data of final stage, remaining every section is cutThe duration of sheet data is equal.
The present invention also provides a kind of virtual sliced sheet system of disributed media file trans-coding system, described slice systems bagCutting module, transcoding module, merging module are included,
Described cutting module is used to cut into slices to media source file, and slice of data is generated into section index list textPart;
Described transcoding module is used to carry out transcoding to audio, video data, according to section index list file, from source of mediaBeing read in file needs the audio, video data of transcoding;
Each section of audio, video data Piece file mergence that described merging module is used to obtain transcoding is file destination.
Further, described cutting module searches the starting position of key frame and end position in media source file, rightMedia source file should be cut into N number of fragment, and the data of each fragment are preserved successively in index list file of cutting into slices.
Further, described transcoding module is according to section index list file acquisition transcoding task, from media source fileIt is middle to obtain video data and voice data respectively, it is fed again into encoder after being decoded and is encoded, generates regarding after transcodingFrequency fragment and voice data.
Further, described merging module according to slice information generate merging task, by the video segment after transcoding according toIt is secondary to connect, while the voice data of transcoding generation is added, file destination is generated, completes to merge.
The present invention is allowed to compared with prior art, have the following advantages that and actively imitate due to using above technical schemeFruit:
1. whole media source file need not be read, it is only necessary to according to slicing parameter handle dicing position two key frames itBetween content, processing data amount significantly reduces;
2. not having to actually be syncopated as physics section during section, the dicing position of record media file is only needed, even if big when havingFile or when need to largely handle, cutting, transcoding, have dramatically speeded up the speed of video segment when can also carry out simultaneously;
3. using index list file of cutting into slices as follow-up transcoding, merging treatment, section index list file is with textForm recorded NAS storage in, avoid the substantial amounts of I/O operation of system, saved NAS memory spaces, reduced inside transcodingThe network load of system;
4. transcoding module separates video data and voice data, parallel transcoding is carried out, transcoding speed is accelerated, carries significantlyThe high transcoding efficiency of media file, realize the fast transcoding of media file.
Brief description of the drawings
Fig. 1 is the present invention and the contrast schematic diagram of physics section;
Fig. 2 is section exemplary plot;
Fig. 3 is the section schematic flow sheet of the present invention;
Fig. 4 is that transcoding of the present invention merges schematic flow sheet;
Fig. 5 is the system construction drawing of the present invention.
Embodiment
Technical scheme proposed by the present invention is further described below in conjunction with the drawings and specific embodiments.According to followingIllustrate and claims, advantages and features of the invention will become apparent from.It should be noted that accompanying drawing is using very simplified shapeFormula and non-accurately ratio is used, be only used for conveniently, lucidly aiding in illustrating the purpose of the embodiment of the present invention.
The present invention is the characteristics of utilizing key frame (I frames) in media file video, and by default cutting point mode, lookup regardsThe actual key frame cut-off of frequency, between the processing data of video slicing is limited into two key frames, meanwhile, the position of cut-offConfidence breath is recorded in virtual section index file, so as to efficiently complete the transcoding work of media file.It is of the invention and existingThe contrast schematic diagram of some physics sections is referring to Fig. 1, from figure 1 it appears that the processing procedure of traditional physics section is firstFormer media file is read in, is then written in temporary file, next file is write when reaching cut point, until the end of file.This method is to read in whole media file from NAS storages, then exports physics section and is put into NAS storages, reads and writes processing procedureThere is substantial amounts of I/O operation, in the file system of NAS storages, take system massive band width, IO obstructions and mistake can be caused, andOutput section takes the NAS memory spaces with source media file formed objects.And during the virtual sliced sheet of the present invention, it is eachIndividual slicing treatment, parameter position point is only read in the data between next I frames, while only with the text of section index list fileThis form preserves cutting position, avoids the substantial amounts of I/O operation of system.As shown in Figure 2, conventional physical dicing method needs to readGo out and write [tn-1,tn] all data to NAS store, dicing method of the invention only need read in [t'n,tn] data,The text for being only written section index list file stores to NAS.
Embodiment 1
Dicing method in the present invention is that media source file is carried out to get processing ready, and record is needed in the video of transcodingThe position of key frame, is preserved in the form of a list, so as to complete virtualization section.In conjunction with accompanying drawing to cutting in the present inventionPoint method is specifically described.Referring to Fig. 2, need can have key frame (I frames), key frame in each media source file of transcodingCan independently decode, and follow-up P frames, B frames determine next key frame all referring to I frames before, I frames before all figuresWhether correct as decoding, therefore, the cutting method in the present invention can not be according to absolute duration cutting file.In order to ensure mediaThe cutting correctness of source file, the cut-off of media source file must are fulfilled for:First frame of each segmentation must be key frame.
The idiographic flow of cutting method can be found in Fig. 3, concretely comprise the following steps:
1. first, obtaining media source file, the slicing parameter that user is set is read, slicing parameter can be made by oneself as neededJustice, code check of the general default slicing parameter including every section of media file after section duration, interval, section number, section etc., willSection starting position is arranged to t0=0, a parameter n is defined, parameter is used for recording the number of section fragment, by n initial valueIt is arranged to 1;
2. the slicing parameter set according to user, the key frame knot behind the section duration interval of user's setting is found successivelyBeam, the position of key frame is defined as tn, for example, the position of first key frame is t1, the like, knot is searched in section sectionBeam, beginning to the slice of data terminated for recording this section section is [tn-1,tn), judge whether the ending for reaching media source file,If media source file terminates, step 4 is jumped to;
3. using the end position of the key frame found out in step 2 as the starting position of next section of section, i.e. tn-1=tn, while n=n+1 is set, is reentered in step 2 and is generated next section of key frame and start to the slice of data of end;
4.:Whole media source file section terminates, and slice of data is stored in section index list by the sequencing of sectionIn file, section index list file can be used as follow-up transcoding, merging treatment, and it is to recorded NAS in a text form to depositChu Zhong so that avoid the substantial amounts of I/O operation of system in follow-up transcoding process.
The slicing processes of whole media source file be a cyclic process, and until media source file terminates, generation is cut into slices ropeUntill drawing listing file.After virtual sliced sheet, then there are follow-up transcoding module, merging module to regard the sound for being cut into N number of segmentFrequency carries out transcoding, merged, and the schematic flow sheet of the process can be found in Fig. 4, and step is as follows:
1. reading the transcoding parameter that user is set, encoder is initialized;
2. transcoding module reads slice of data as transcoding task from section index list file;
3. according to the transcoding task of acquisition, video data is obtained from media source file, is sent again after video data decodingEnter encoder to be encoded, generate the video segment after this section section transcoding;
4. the voice data corresponding with video data is obtained from media source file according to transcoding task, to voice dataEncoder is sent into after decoding to be encoded, and generates the voice data after this section section transcoding, such as audio code stream;
Transcoding process terminates, it should be noted that, the transcoding process in the present invention includes audio transcoding and video code conversion, to addFast transcoding speed, can separate transcoding as parallel transcoding task, voice data by audio transcoding and video code conversion with video data.Finally, merging module merges the video segment after transcoding, and adds voice data, generates file destination, the processIt is specific as follows:
1. merging module reads the initialization merging module of user configuration, merged according to section index list file generated and appointedBusiness;
2. reading the video segment after transcoding, the voice data added in video segment after transcoding, all sounds are regardedFrequency file is written in a file destination, completes to merge.
So far, the section of a media source file, transcoding, merging process terminate, and complete the fast transcoding of media file.In the slicing treatment of actual media file transcoding, the present invention need not read whole media source file, it is only necessary to handle cuttingContent between the key frame of position two, processing data amount significantly reduce, and have dramatically speeded up the speed of video segment, avoid and areUnite substantial amounts of I/O operation, saved NAS memory spaces, reduced the network load of distributed trans-coding built-in system.
Embodiment 2
The present invention also provides a kind of virtual sliced sheet system of disributed media file trans-coding system, and slice systems include cuttingModule, transcoding module, merging module, its structural representation are shown in Fig. 5, wherein, cutting module is used to cut media source filePiece, and slice of data is generated into section index list file;Transcoding module is used to carry out transcoding to audio, video data, according to sectionIndex list file, the audio, video data for needing transcoding is read from media source file;Merging module is used for obtain transcodingEach section of audio, video data Piece file mergence is file destination.
Cutting module searches the starting position of key frame and end in media source file according to the cutting method in embodiment 1Position, media source file is subjected to cutting, and the data of each fragment are preserved successively in index list file of cutting into slices.TranscodingModule obtains video data and audio number respectively according to section index list file acquisition transcoding task from media source fileAccording to, it is fed again into encoder after being decoded and is encoded, video segment and voice data after generation transcoding.Merging module is thenMerging task is generated according to slice information, the video segment after transcoding is connected in turn, while adds the sound of transcoding generationFrequency evidence, file destination is generated, complete to merge.
Media source file is cut into N number of segment by cutting module, and transcoding module is according to the result of virtual sliced sheet, while by NThe transcoding of individual fragment, it is dispatched on node different in system, to N number of fragment, parallel transcoding, merging module exist the system simultaneouslyOn the basis of transcoding is completed, the video segment that transcoding generates is connected, while adds the audio stream of transcoding generation, generates meshMark file.
Embodiment 3
Now it is illustrated according to the description of above-described embodiment, referring to Fig. 2 to Fig. 5:
Assuming that a length of T during media source file, a length of T during target slicem, then the 1st section of starting point cut into slices is t0=0, whenMedia source file is read in after target slice duration, finds first crucial frame end backward successively, first detectedKey frame position t1, the first segment search terminates, and the 1st segment table of section is shown as into [t0,t1);Second segment is from t1Start, skip TmWhenBetween ... the like, N sections are then expressed as [tn-1,tn);After the completion of section, slice position is preserved by the sequencing of sectionIn same file, so far, virtual sliced sheet is completed, and whole video file is by virtual cuttingSection, except final stageTime is less than TmOutside, remaining section clip durations is of substantially equal.
Following table is using the system in the present invention and dicing method and the data comparison of physics section:
As can be seen from the table, when the invention in using the present invention and system, the high-definition movie of a 3.8GB size,Cutting takes 51.872s, and NAS storages network traffics amount to 0.12GB, NAS memory space 2.4KB taken, relative to conventional physicalDicing method, cutting are saved time 173.622s, and NAS storages network traffics have saved 7.48GB, and NAS memory spaces, which take, to be saved3.8GB, above-mentioned data are the data that NAS system carries out individual task cutting, when having a large amount of transcoding tasks while carrying out, this hairThe advantage of virtual sliced sheet method in bright will be more obvious.
Obviously, those skilled in the art can carry out the spirit of various changes and modification without departing from the present invention to inventionAnd scope.So, if these modifications and variations of the present invention belong to the claims in the present invention and its equivalent technologies scope itInterior, then the present invention is also intended to comprising including these changes and modification.