Summary of the invention
Technical matters to be solved by this invention is, at defective that has the integrality that can't guarantee to compress the back data in the existing DVD data of optical disk compress technique and the defective that when the size of data after the compression exceeds the destination disk size, can cause imprinting to be failed, provide a kind of DVD optical disc data compression method and system.
One of the technical solution adopted for the present invention to solve the technical problems is: a kind of DVD optical disc data compression method is provided, comprises the steps:
S1) obtain source tray size X and destination disk size Y, calculate the big or small W that does not need compressed file in the source tray, calculate compressibility factor a;
S2) copy does not need the file that compresses in the source tray;
S3) resolve the IFO file of each VTS in the source tray, obtain big or small M and the time span T of each cell, locate each cell in the data of corresponding vob file;
S4) go out video, track and caption data from each cell extracting data, obtain the video data size N of each cell;
S5) calculate the code rate V of the video data of each cell of compression back, the video data of corresponding cell is carried out re-compression and encoding according to V;
S6) generate new vob file, IFO file and BUP file.
In DVD optical disc data compression method of the present invention, the computing formula of a of compressibility factor described in the step S1 is: a=(Y-W)/(X-W).
In DVD optical disc data compression method of the present invention, the IFO file of resolving each VTS in the source tray described in the step S3 further comprises: according to the IFO file of each VTS in the source tray, obtain the initial sector and the address information that stops the sector of each cell of corresponding VTS, calculate big or small M=(stop sector-initial sector+1) the * P of each cell, P is the size of each sector of giving tacit consent among the DVD.
In DVD optical disc data compression method of the present invention, the method of each cell of location described in the step S3 in the data of corresponding vob file be for to regard all vob files of each VTS as a contiguous file, positions according to initial mountain area and the termination sevtor address information of each cell.
In DVD optical disc data compression method of the present invention, the code rate V of the rear video of compression described in step S5 data=(M*a-M+N)/T, described in the step S5 video data is carried out re-compression and encoding and further comprise the reduction code rate V, with V*k, k ∈ (0,1) is as actual compression bit rate.
In DVD optical disc data compression method of the present invention, step S6 further comprises track and the synthetic new cell data of caption data of the corresponding cell that will extract among each the cell video data after the re-compression and encoding among the step S5, the step S4.
In DVD optical disc data compression method of the present invention, step S6 further comprises, new cell data after synthetic are write in the new vob file of corresponding VTS in proper order, generate new vob file, and note the new initial sector of new cell and stop sevtor address information.
In DVD optical disc data compression method of the present invention, step S6 further comprises, replaces the cell address information in the source IFO file of former corresponding VTS with the address information of all new cell, generates the new IFO file of each VTS correspondence.
Two of the technical solution adopted for the present invention to solve the technical problems is: a kind of DVD data of optical disk compressibility is provided, comprises:
Compressibility factor generation module: be used to obtain source tray size and destination disk size, calculate the size that does not need compressed file in the source tray, calculate compressibility factor;
Copy module: be used for copying source tray and do not need the file that compresses;
Parsing module: be used for resolving the IFO file of each VTS of source tray, obtain size and the time span of each cell, locate each cell in the data of corresponding vob file;
Extraction module: be used for going out video, track and caption data, obtain the video data size of each cell from each cell extracting data;
Coding module: be used to calculate the code rate V of the video data of each cell of compression back, the video data of corresponding cell carried out re-compression and encoding according to V;
New file generation module: be used to generate new vob file, IFO file and BUP file.
In DVD data of optical disk compressibility of the present invention, parsing module comprises:
Cell parameter generating unit: be used for IFO file, obtain the initial sector and the address information that stops the sector of each cell of corresponding VTS, obtain the time span of each cell, calculate the size of each cell according to each VTS of source tray;
Cell data locking unit: be used for regarding all vob files of each VTS as a contiguous file, locate each cell in the data of corresponding vob file according to initial sector and the termination sector of each cell.
In DVD data of optical disk compressibility of the present invention, new file generation module comprises:
New cell data generation unit: be used for track and the synthetic new cell data of caption data with the video data of each cell after the re-compression and encoding, corresponding cell that extraction module extracts;
New vob file generation unit: new cell data are write in proper order in the new vob file of corresponding VTS, generate new vob file, and note the address information of new new initial sector of each cell and termination sector;
New IFO file generation unit: be used for the address information of all new cell is replaced the cell address information of the source IFO file of former corresponding VTS, generate the new IFO file of each VTS correspondence;
New BUP file generation unit: be used to generate new BUP file.
Implement technical scheme of the present invention, have following beneficial effect: the data of optical disk after can guaranteeing to compress guarantees the imprinting success less than the size of destination disk, also can guarantee to compress the integrality of back data of optical disk.
Embodiment
In order to make purpose of the present invention, technical scheme and advantage clearer,, the present invention is further elaborated below in conjunction with drawings and Examples.Should be appreciated that specific embodiment described herein only in order to explanation the present invention, and be not used in qualification the present invention.
The data encapsulation form of the last employing of DVD is PS (Program Stream) form, and the DVD of PS form encapsulation has three kinds of file: VOB (Video Object) file, IFO (Information) file and BUP (Backup) file.
Vob file comprises the data that mix: video data, voice data, caption data and film menu data.The IFO file provides crucial navigation information for broadcast, and such as playing from where beginning, specific audio stream or caption stream etc. are extracted the part film somewhere like this.The BUP file is the backup file of IFO file.Cell is the minimum unit on the DVD, and the data on the vob file all are that unit organizes with cell.
Dvd video disc comprises and comprises AUDIO_TS and two files of VIDEO_TS that AUDIO_TS is an empty folder, has only used the VIDEO_TS file.The VIDEO_TS file is made up of IFO, BUP, three kinds of files of VOB, and the hierarchical structure of whole file is as follows:
VIDEO_TS.IFO: root IFO file
VIDEO_TS.BUP: the backup of root IFO file
VIDEO_TS.VOB: root menu
The IFO file of VTS_nn_0.IFO:VTS
The backup of the IFO file of VTS_nn_0.BUP:VTS
The film menu file of VTS_nn_0.VOB:VTS
The film data file of VTS_nn_m.VOB:VTS
Root IFO is used for depositing the description and the control information of the overall situation, includes what VTS (VideoTransport Stream), the description and the control information of the IFO document storage of each VTS oneself, comprise comprise the information of whole Cell.The VIDEO_TS file accompanies several VTS files, and each VTS has a label nn, wherein 1<=nn<=99.Each VTS file has only an IFO file, 10 vob files can be arranged at most, the label of the vob file of each VTS file is m, 0<=m<=9 wherein, the first vob file of each VTS file, be VTS_xx_0.VOB first vob file menu file of VTS file for this reason just, the vob file of all the other VTS is the film data file.
Fig. 1 is the process flow diagram of a kind of DVD optical disc data compression method of providing of a preferred embodiment of the present invention, and as shown in Figure 1, details are as follows:
In step S1, obtain source tray size and destination disk size, calculate the size that does not need compressed file in the source tray, calculate compressibility factor.
In an embodiment of the present invention, dvd video disc comprises AUDIO_TS and two files of VIDEO_TS, because AUDIO_TS is an empty list, only used the VIDEO_TS catalogue, so what source tray size X referred to is exactly VIDEO_TS file size, destination disk size Y is exactly the space size that destination disk can be used.
In an embodiment of the present invention, except the vob file of each VTS needs compression, other file does not need compression, and calculating these does not need the file size W that compresses.
The computing formula of compressibility factor a is: a=(Y-W)/(X-W).
In step S2, do not need the file that compresses in the copy source tray.
As one embodiment of the present of invention, can in storage mediums such as hard disk, create a file VIDEO_TS_NEW, the document copying of determining among the step S1 that does not need to compress is arrived this file.
In step S3, resolve the IFO file of each VTS in the source tray, obtain size and the time span of each cell, locate each cell in the data of corresponding vob file.
The IFO file of each VTS has comprised whole cell information, can therefrom obtain the time span T of each cell, the address information of obtaining each cell comprises initial sector and stops the sector, calculate big or small M=(stop sector-initial sector+1) the * P of each cell, P is the size of each sector of giving tacit consent among the DVD.In one embodiment of the invention, the size of each sector of DVD is 2048 bytes, so the big or small M=of each cell (stopping sector-initial sector+1) 2048 bytes of *.
Locate the method for each cell in the data of corresponding vob file for to regard all vob files of each VTS as a contiguous file, stop the sector according to the initial sum of each cell and position.Suppose that certain VTS has 3 film data vob file: VTS_xx_1.VOB, VTS_xx_2.VOB, VTS_xx_3.VOB except the menu vob file, the size of three files all is 100 sectors, and the size of supposing cell is 30 sectors.If it is 60 and 90 that the initial sum of certain cell of IFO file description stops the sector, the data of this cell correspondence are the 60-90 sectors of VTS_xx_1.VOB file so; If, be 90 and 120 if the initial sum of certain cell of IFO file description stops the sector, the data of this cell correspondence are back 10 sectors of VTS_xx_1.VOB file and preceding 20 sectors of VTS_xx_2.VOB file so.
In step S4, go out video, track and caption data from each cell extracting data, obtain each cell video data size N.
In step S5, calculate the code check of the video data of each cell of compression back, according to code check the video data of corresponding cell is carried out re-compression and encoding.
The code rate V of each cell video data of compression back=(M*a-M+N)/T, because the reference value that code rate V is provided with when being a coding, actual bit rate and V after scrambler can not guarantee to encode are in full accord, so for the size of the real data after preventing to encode surpasses predetermined size (M*a-M+N), need suitable reduction code rate V, according to the situation of reality test, with V*k, k ∈ (0,1) just can guarantee to compress the back data as the compression bit rate of reality can not exceed predetermined size.In an embodiment of the present invention, V*0.9 the back data can be guaranteed to compress as the compression bit rate of reality and predetermined size can be do not exceeded.
In step S6, generate new vob file, IFO file and BUP file.
Step S6 further comprises and will extract track and the synthetic new cell data of caption data of corresponding cell among each the cell video data after the re-compression and encoding among the step S5, the step S3.
Step S6 further comprises, the new cell data after synthetic are write in the new vob file of corresponding VTS in proper order, generates new vob file, and notes the new initial sector of new cell and stop sevtor address information.Because it is 524287 (every sector-size is 2048 bytes) that dvd video disc has limited the maximum sector number of single vob file, so when data volume surpasses this maximum sector number restriction, will produce a new vob file successively.For example, begin to produce VTS_01_0.VOB, this is the menu data of this VTS, producing VTS_01_1.VOB afterwards is film data, when VTS_01_1.VOB counts above the maximum sector that allows, can produce VTS_01_2.VOB automatically, and the like, the multipotency of VTS file has 10 vob files, promptly VTS_01_0.VOB, VTS_01_1.VOB ... VTS_01_9.VOB.
In an embodiment of the present invention, the new vob file that produces is saved among the file VIDEO_TS_NEW that creates in the storage medium such as hard disk.
Step S6 further comprises, replaces the cell address information in the source IFO file of former corresponding VTS with the address information of all new cell, generates the new IFO file of each VTS correspondence.
In an embodiment of the present invention, the new IFO file that produces is saved among the file VIDEO_TS_NEW that creates in the storage medium such as hard disk.
In an embodiment of the present invention, step S6 also comprises according to the new IFO file that produces, duplicating IFO and revising suffix is BUP, forms new BUP file, the new BUP file that produces is saved among the file VIDEO_TS_NEW that creates in the storage medium such as hard disk.
In an embodiment of the present invention, file VIDEO_TS_NEW has deposited the DVD data of optical disk file after whole compressions, can all files in the VIDEO_TS_NEW file be burnt to the VIDEO_TS file that target DVD CD forms object optical disc by recording device.
Fig. 2 is the synoptic diagram of a kind of DVD data of optical disk compressibility of providing of a preferred embodiment of the present invention, as shown in Figure 2, comprises that compressibility factor produces 21, copy module 22, parsing module 23, extraction module 24, coding module 25 and new file generation module 26.Parsing module 23 further comprises cell parameter generating unit 231 and cell data locking unit 232; New file generation module 26 further comprises: new cell data generation unit 261, new vob file generation unit 262, new IFO file generation unit 263 and new BUP file generation unit 264.
Compressibility factor generation module 21 obtains source tray size and destination disk size, calculates the size and the compressibility factor that do not need compressed file in the source tray; Do not need the file that compresses in the copy module 22 copy source traies; Parsing module 23 is resolved the IFO file of each VTS in the source tray, obtains size and the time span of each cell, locatees each cell in the data of corresponding vob file; Extraction module 24 goes out video, track and caption data from each cell extracting data, obtains the video data size of each cell; Coding module 25 calculates the code check of each cell compression rear video data, according to code check the video data of corresponding cell is carried out re-compression and encoding; New file generation module 26 generates new vob file, IFO file and BUP file.
As embodiments of the invention, the process that parsing module 23 is resolved the IFO file of each VIS is specially: cell parameter generating unit 231 obtains the time span T of each cell from the IFO file of each VTS, the address information of obtaining each cell comprises initial sector and stops the sector, calculate big or small M=(stop sector-initial sector+1) the * P of each cell, P is the size of each sector of giving tacit consent among the DVD.The method of each cell of location, cell data locking unit 232 in the data of corresponding vob file be for to regard all vob files of each VTS as a contiguous file, positions according to the initial sum termination sector of each cell.
As embodiments of the invention, the process that new file generation module 26 produces new file is specially: track and the synthetic new cell data of caption data that new cell data generation unit 261 extracts corresponding cell with each the cell video data after the re-compression and encoding, extraction module 24; New vob file generation unit 262 writes new cell data in the new vob file of corresponding VTS in proper order, generates new vob file, and notes the address information of new new initial sector of each cell and termination sector.New IFO file generation unit 263 is replaced the address information of all new cell the cell address information in the source IFO file of former corresponding VTS, generates the new IFO file of each VTS correspondence; New BUP file generation unit 264 is according to the new IFO file that produces, and duplicating IFO and revising suffix is BUP, forms new BUP file.
The above only is preferred embodiment of the present invention, not in order to restriction the present invention, all any modifications of being done within the spirit and principles in the present invention, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.