A kind of method that is used for rapidly importing media material
Technical field
The invention belongs to the video program production field, be specifically related to a kind of method that is used for the rapidly importing media material of television program designing.
Background technology
Various non-volume users need use the material in various sources when editing program, for satisfying user's this demand, need import nonlinear editing system to them and edit.Because the restriction of these media materials self characters, and be not suitable for directly they being carried out accurate, the high efficiency editor of frame.Along with the raising of current computer performance, the particularly raising of the lifting of many CPU handling property and disk read-write ability realizes that the high speed importing of material has become possibility.
The method of existing importing media material is in the nonlinear editing system: one independently thread from hard disk, CD-ROM drive, read in the internal memory looking the audio material data, split (Splitter) to video data and voice data respectively then and come out.This thread is decoded, is changed voice data, is written to then in the audio file; Simultaneously video data is resolved (Parser), write video file at other thread then.The boot speed of existing introduction method is slower, mainly contains the reason of following several respects: the first, one thread in the reading and writing file (read-write of computer take be the Computer I bandwidth), and the resource of CPU has been caused the waste of resource by idle; The second, one thread carries out operations such as Splitter, Parser, decoding and written document successively to data, and this has just increased the weight of the workload of this thread, and other thread leaves unused at this moment, has also caused the waste of many cpu resources.The waste of resource certainly will cause the reduction of boot speed, also can't reach the purpose of the advanced feature that makes full use of active computer.
Summary of the invention
The objective of the invention is to demand, a kind of method of ability rapidly importing media material is provided, thereby saves the importing time, improve the editorial efficiency of material to present television program designing.
Technical scheme of the present invention is following: a kind of method that is used for rapidly importing media material comprises the steps:
1) utilize an independent thread--thread 1, be responsible for from disk, reading the data of source media file, and among this deposit data to one store list List1;
2) utilize independently thread of another one--thread 2, media file among the store list List1 is split, and deposit the audio result of looking that splits respectively among two store list List2 and the List3;
3) utilize independently thread of another one--thread 3, the video data among the store list List2 is resolved, simultaneously the voice data among the store list List3 is carried out decoding, conversion and the written document of audio frequency;
4) utilize other thread to be packaged into new file, and write disk resolving, analyze good video data.
The aforesaid method that is used for rapidly importing media material; Wherein, when in the step (3) video data among the store list List2 being resolved, at first analyze the video heads information in the ES flow data; Form the video data of single frames; And draw the type (type comprises I, B or P frame) of each frame data, and be beginning with the current I frame, form independently image sequence GOP to the frame of video between the next I frame; Analyzing decoding order and the broadcast order of these frame of video in this GOP, is that unit sends other thread to and writes video file then with GOP.
The aforesaid method that is used for rapidly importing media material; Wherein, In the step (3) voice data among the store list List3 carried out decoding, when conversion of audio frequency; From the voice data of List3, extract earlier their compressed format and the relevant information of sample rate, the mode that decision is decoded, changed according to relevant information then.
The aforesaid method that is used for rapidly importing media material, wherein, the new file that is packaged in the step (4) is an avi file.
Method provided by the present invention has made full use of the advantage of disk read-write speed and many cpu performances.Because what the read-write of computer took is the IO bandwidth of computer; And other fractionation, parsing, audio decoder and sample rate conversion take is computer CPU resource; Handle them with thread independently respectively; Can make the read-write disk like this and do other asynchronous execution of dealing with the work, save the time with CPU.This method is supported the importing of the media file of various frame per second, various video resolution, various audio sample rate and multiple standard.
Description of drawings
Fig. 1 is a method flow diagram of the present invention.
Embodiment
Below in conjunction with accompanying drawing and embodiment the present invention is carried out detailed description.
A kind of method that is used for rapidly importing media material comprises the steps:
1) utilize an independent thread--thread 1, be responsible for from disk, reading the data of source media file, and among this deposit data to one store list List1.
2) utilize independently thread of another one--thread 2, media file among the store list List1 is split, and deposit the audio result of looking that splits respectively among two store list List2 and the List3.
Each media file all has the encapsulation reference format of its respective specific, and their video/audio is kept in the data file according to these standards with some other information.Through analyzing its form, from source file, split these video/audios to come out.
3) utilize independently thread of another one--thread 3, the video data among the store list List2 is resolved, simultaneously the voice data among the store list List3 is carried out decoding, conversion and the written document of audio frequency.
What preserve among the List2 is the video mpeg-ES flow data after Spitter comes out.At first need analyze the video heads information in the ES flow data, form the video data of a frame frame, and draw the type (type comprises I, B or P frame) of each frame data.With the current I frame is beginning, forms independently image sequence GOP (Group Of Picture) to the frame of video between the next I frame, and analyzes decoding order and the broadcast order of these frame of video in this GOP, be convenient to frame accurately, efficiently editor.Be that unit sends other thread to and writes video file then with GOP.
What preserve among the List3 is the voice data after Spitter comes out.The various situation of the compressed format of these voice datas are all possible, such as Mpeg-Lay1, mpeg-lay2, mpeg-lay3 and AC3 etc.Sample rate also possibly be 24KHz, 48KHz etc.Extract earlier their relevant informations such as compressed format and sample rate in the voice data from List3; Which type of mode of decision sampling is decoded then; Whether need carry out the conversion of sample rate, whether need carry out monophony and stereo between conversion or the like.
4) utilize other thread to be packaged into new avi file, and write disk resolving, analyze good video data.
In the method; What List1 kept is the source of media data; After in the List1 media data being arranged, have one independently thread begin media data is split (Splitter), video after the fractionation and voice data deposit in respectively two the tabulation (List2; List3) in, the data in these two tabulations by another one independently thread carry out Parser and Decode, write audio file.Find through calculating this three times that process consumed, the Splitter Parser of being substantially equal to consuming time and Decode, write these two process sums of audio file, and workload that ought two threads is when just the cpu resource utilance is the highest roughly suitable the time.
Method of the present invention is not limited to the embodiment described in the embodiment, and those skilled in the art's technical scheme according to the present invention draws other execution mode, belongs to technological innovation scope of the present invention equally.