Summary of the invention
The technical problem that the present invention mainly solves provides a kind of method and corresponding apparatus of recording files in stream media; The user can be listened on one side watch real-time media file; Record this media file on one side; But can not make portable terminal influence the normal operation of other module because of the deficiency of internal memory, thereby solve the problem that the user can preserve media file as required.
A kind of method of recording files in stream media comprises:
Obtain the frame data of Streaming Media;
Judge whether last frame data of the frame data that this obtains are kept at the end of first media file, and wherein, first media file is set to fixed size in advance;
If last frame data of these frame data are kept at the end of first media file that is provided with in advance; Then these frame data are saved in the position of first frame data in first media file; If last frame data of these frame data are not the ends that is kept at first media file that is provided with in advance, then these frame data are kept at the last frame data position afterwards of these frame data;
Continue to obtain next frame data; And whether last frame data of judging these next one frame data be kept in advance the end of first media file that is provided with, until stopping to obtain the frame data of said Streaming Media or until last frame data that gets access to said Streaming Media.
Further, this method also comprises:
After stopping to obtain the frame data of Streaming Media or getting access to last frame data of Streaming Media, first media file is carried out montage to generate second media file;
Preserve this second media file.
Further, comprise in the step that frame data is saved in the position of first frame data in first media file:
With first frame data deletion, write these frame data then earlier; Perhaps,
Cover first frame data in said first media file with these frame data.
Further, after stopping to obtain the frame data of Streaming Media or getting access to last frame data of Streaming Media, first media file is carried out montage comprises with the step that generates second media file:
Receive the end record command of user's input and stop obtaining the frame data of Media Stream;
Receive the montage instruction of user's input, thereby and the frame data in first media file are carried out montage according to the sequencing of preserving to the frame data that obtain generate second media file.
Further, thus the frame data in first media file are carried out the step that montage generates second media file according to the sequencing of preserving to the frame data that obtain to be comprised:
Play first media file according to putting in order of the frame data that obtain;
The instruction of start frame data validation and the ending frame data that receive user's input are confirmed instruction;
Confirm corresponding start frame data of confirmation command and ending frame data according to instruction of start frame data validation and ending frame data, and generate header file according to start frame data and ending frame data;
Generate second media file according to header file and start frame data with the ending frame data.
Further, after the step of the frame data that obtain Streaming Media, also comprise:
If said frame data are first frame data that obtain from Streaming Media, then write down the header file of said first medium again.
A kind of equipment of recording files in stream media comprises:
Acquisition module is used for when listening to or watch real-time files in stream media, and the function of pre-recording of this equipment is obtained the frame data of Streaming Media when opening;
Judge module is used to judge whether last frame data of these frame data are kept at the end of first media file that is provided with in advance, and wherein, first media file is set to fixed size in advance;
First preserves module; Be used for when last frame data of these frame data are kept at the end of first media file that is provided with in advance; These frame data are saved in the position of first frame data in said first media file; When the last frame data of these frame data are not when being kept at the end of first media file that is provided with in advance, these frame data are kept at the position after the said last frame data.
Further, this equipment also comprises:
The montage module is used for after stopping to obtain the frame data of Streaming Media or getting access to last frame data of Streaming Media, first media file being carried out montage to generate second media file;
Second preserves module, is used to preserve second media file after the montage of montage module is accomplished.
Further, montage module comprises:
First receiving element is used to receive the end record command and the montage instruction of user's input;
Broadcast unit is used for after first receiving element receives the end record command and montage instruction of user's input, playing said first media file according to putting in order of the frame data that obtain;
Second receiving element is used to receive the instruction of start frame data validation and the ending frame data affirmation instruction of user's input;
The montage unit, the instruction of start frame data validation and the ending frame data that are used for receiving according to said second receiving element are confirmed corresponding start frame data of confirmation command and ending frame data, and generate header file according to start frame data and ending frame data;
The second media file generation unit, the header file and the start frame data that are used for generating according to the montage unit generate second media file with the ending frame data.
Further, this equipment also comprises the header file logging modle, be used for when these frame data that obtain for from first frame data that Streaming Media obtains the time, write down the header file of first medium again.
In method provided by the invention,, then the frame data circulation of obtaining is saved in this first media file through first media file of a preset fixed size in this locality; Realize making the user to listen on one side and watched real-time media file; Record this media file on one side; But can not make portable terminal influence the normal operation of other module because of the deficiency of internal memory, thus solve the problem that the user can preserve media file as required, improve user experience.
Embodiment
Consult Fig. 2, the embodiment that the present invention records the method for files in stream media comprises:
201, when listening to or watch real-time files in stream media, and the function of pre-recording of this equipment is obtained the frame data of Streaming Media when opening;
202, judge whether last frame data of the frame data that obtained are kept at the end of first media file, and wherein, first media file is set to fixed size in advance;
203, if last frame data of these frame data are kept at the end of first media file that is provided with in advance, then said frame data are saved in the position of first frame data in said first media file;
If last frame data of these frame data are kept at the end of first media file that is provided with in advance; Then the frame data that obtain are saved in the position of first frame data in first media file; Continue to obtain next frame data then; And judge whether last frame data are kept in advance the end of first media file that is provided with, until stopping to obtain the frame data of Streaming Media or until last frame data that gets access to Streaming Media;
204,, then these frame data are kept at frame data position afterwards on this if last frame data of these frame data are not the ends that is kept at first media file that is provided with in advance;
If last frame data of these frame data are not the ends that is kept at first media file that is provided with in advance; Then the frame data that obtain are kept at the last frame data position afterwards of these frame data; Continue to obtain next frame data then; And judge whether last frame data are kept in advance the end of first media file that is provided with, until stopping to obtain the frame data of Streaming Media or until last frame data that gets access to Streaming Media;
205, judge whether to stop to obtain the frame data of Streaming Media or until last frame data that gets access to Streaming Media;
Judge whether to stop to obtain the frame data of Streaming Media or until last frame data that gets access to Streaming Media, if, process ends then; If not, then continue execution in step 201, obtain next frame data;
In the present embodiment, through first media file of a preset fixed size, then the frame data circulation of obtaining is saved in this first media file in this locality; Realize making the user to listen on one side and watched real-time media file; Record this media file on one side; But can not make portable terminal influence the normal operation of other module because of the deficiency of internal memory, thus solve the problem that the user can preserve media file as required, improve user experience.
After recording first media file; The user can repeat to listen and see first media file; To establish a capital be that the user is needed but the data in first media file differ, and in order to address this problem, the present invention obtains second media file that the user needs through first media file being carried out montage; See also Fig. 3 below and be elaborated, the preferred embodiment that the present invention records the method for files in stream media comprises:
301, when the user listens to or watches real-time files in stream media, judge whether the function of pre-recording of this equipment opens;
The function of pre-recording is set in this equipment in advance, a file that is specifically designed to record mobile phone state variable can be set in the file system of this equipment in advance, a marking variable is set hereof; Whether this marking variable is used for writing down the function of pre-recording and opens; For example, a file.txt file is set in advance in file system, and a marking variable flag is set in the file.txt file; When flag is 1; The function of pre-recording of equipment is opened, and when flag was 0, the function of pre-recording of equipment was closed; Certainly, the function of pre-recording is set in this equipment in advance also can realizes, do not limit here through the newly-increased function of pre-recording in function items;
When the user listens to or watches real-time files in stream media; Judge whether the function of pre-recording of this equipment opens, and for example can judge through the flag that reads in the file.txt file, if the function of pre-recording of this equipment is opened; Then write down the header file of first media file again; Continue execution in step 302 then, if pre-record function not unlatching, the then process ends of this equipment;
302, obtain first frame data of Streaming Media;
After the function of pre-recording of judging this equipment in the step 301 is opened, obtain the frame data of Streaming Media;
First frame data that 303, will obtain are saved in the header file position afterwards of first media file;
Because when beginning to record first media file each time, all need write down the header file of first media file again, first frame data that obtain are directly skipped header file, are recorded in header file position afterwards;
304, obtain the next frame data of Streaming Media;
305, judge whether last frame data are kept at the end of first media file;
After having obtained next frame data; Judge whether last frame data of the frame data that this obtains are kept at the end of first media file; Promptly whether first media file is filled with, if last frame data are kept at the end of first media file, then execution in step 306; If last frame data are not kept at the end of first media file, then execution in step 307;
306, frame data are saved in the position of first frame data in first media file;
Then the frame data that get access to are saved in the position of the 1st frame data in first media file; Concrete; Can be directly the frame data of the position of original the 1st frame data be covered; Also can be earlier with the frame data deletion of the position of original first frame data, and then, do not limit the position that the frame data that get access to are write first frame data here;
With Fig. 5 is that example specifies, and for example in first media file, can store n frame data, if n frame data are filled with, n+1 the frame data that will newly obtain so are saved in the position of the 1st frame data in first media file;
307, frame data are kept at last frame data position afterwards;
If judge the end that frame data are not kept at first media file in the step 305, so, the frame data that obtain are saved in last frame data position afterwards; Concrete; If the position after the last frame data is empty, the frame data that then write direct and obtain are not if the position after the last frame data is empty; Then can directly the frame data of the position after the last frame data be covered with the frame data that obtain; Also can earlier the frame data of the position after the last frame data be deleted, and then the frame data that get access to are write, not limit here;
308, the frame data that judge whether to stop to obtain the frame data of Streaming Media or whether obtained Streaming Media;
If instruction that user's input stops to obtain or the frame data that obtained Streaming Media; Then execution in step 309; If do not receive the instruction that stops to obtain that the user imports, do not obtained the frame data of Streaming Media yet, then return step 304 and continue to obtain next frame data;
309, receive the montage instruction of user's input;
If judge the frame data that the user imports the instruction that stops to obtain or obtained Streaming Media in the step 308; Think that the user wants that the media file of recording has been recorded and finishes; Because the frame data playing sequence of first media file of recording is not necessarily to play according to the time order and function that obtains frame data; As shown in Figure 5, at first play n+1 frame data, play the 2nd frame data, the 3rd frame data or the like then; And correct playing sequence is to play the 1st frame data earlier; Play the 2nd frame data again ... so how n+1 frame data are play in the back, complete media file is presented to the user, at this moment just need carry out montage to first media file;
At first receive the montage instruction of user's input, indication need be carried out montage to first media file;
310, play first media file according to putting in order of frame data;
311, the instruction of start frame data validation and the ending frame data that receive user's input are confirmed instruction;
When being played to a certain frame, the user can be through keyboard or other device input start frame data validation instructions, and the frame data that perhaps end up are confirmed instruction;
312, confirm corresponding start frame data of confirmation command and ending frame data according to instruction of start frame data validation and ending frame data, and generate header file according to start frame data and ending frame data;
Equipment is confirmed definite corresponding start frame data of instruction and ending frame data according to instruction of start frame data validation and ending frame data; Confirm file size, the regeneration header file according to start frame data and ending frame data again;
313, generate second media file according to header file and start frame data and the frame data that end up, and deposit this second media file in addition;
Behind intact first media file of montage, can the deletion of the frame data in first media file also can be kept, do not limit here;
In the present embodiment, as long as can reach the object of the invention, the sequencing of each step can be changed according to concrete design, does not limit here;
In the present embodiment; First media file through a preset fixed size in this locality; Then the frame data circulation of obtaining is saved in this first media file; After having recorded first media file, the needs according to the user carry out montage to first media file again, generate second media file that the user needs; Realize making the user to listen on one side and watched real-time media file; Record this media file on one side; But can not make portable terminal influence the normal operation of other module because of the deficiency of internal memory, thus solve the problem that the user can preserve media file as required, improve user experience.
See also Fig. 6, the embodiment that the present invention records the equipment of files in stream media comprises:
Acquisition module 601 is used for when listening to or watch real-time files in stream media, and the function of pre-recording of this equipment is obtained the frame data of Streaming Media when opening;
Judge module 602 is used to judge whether last frame data are kept at the end of first media file that is provided with in advance, and wherein, first media file is set to fixed size in advance;
First preserves module 603; Be used for when judge module 602 is judged last frame data and is kept in advance the end of first media file that is provided with; Frame data are saved in the position of first frame data in first media file; Acquisition module 601 continues to obtain next frame data then; And judge by judge module 602 whether last frame data are kept in advance the end of first media file that is provided with again, until stopping to obtain the frame data of Streaming Media or until last frame data that gets access to Streaming Media;
Further, the equipment in the present embodiment also comprises:
Montage module 604 is used for after stopping to obtain the frame data of Streaming Media or getting access to last frame data of Streaming Media, first media file being carried out montage to generate second media file;
Second preserves module 605, is used to preserve second media file after 604 montages of montage module are accomplished.
Further; It is not when being kept at the end of first media file that is provided with in advance that the first preservation module 603 also is used for judging last frame data when judge module 602; Frame data are kept at frame data position afterwards on this; Acquisition module 601 continues to obtain next frame data then; And judge by judge module 602 whether last frame data are kept in advance the end of first media file that is provided with again, until stopping to obtain the frame data of Streaming Media or until last frame data that gets access to Streaming Media;
Further, montage module 604 comprises:
First receiving element is used to receive the end record command and the montage instruction of user's input;
Broadcast unit is used for after first receiving element receives the end record command and montage instruction of user's input, playing said first media file according to putting in order of frame data;
Second receiving element is used to receive the instruction of start frame data validation and the ending frame data affirmation instruction of user's input;
The montage unit, the instruction of start frame data validation and the ending frame data that are used for receiving according to second receiving element are confirmed corresponding start frame data of confirmation command and ending frame data, and generate header file according to start frame data and ending frame data;
The second media file generation unit, the header file and the start frame data that are used for generating according to the montage unit generate second media file with the ending frame data;
Further, the equipment in the present embodiment also comprises header file logging modle 606, and the frame data that are used for obtaining when acquisition module 601 write down the header file of said first medium for from first frame data that Streaming Media obtains the time again.
In the present embodiment; First media file through a preset fixed size in this locality; Then the frame data circulation of obtaining is saved in this first media file; After having recorded first media file, the needs according to the user carry out montage to first media file again, generate second media file that the user needs; Realize making the user to listen on one side and watched real-time media file; Record this media file on one side; But can not make portable terminal influence the normal operation of other module because of the deficiency of internal memory, thus solve the problem that the user can preserve media file as required, improve user experience.
The above is merely embodiments of the invention; Be not so limit claim of the present invention; Every equivalent structure or equivalent flow process conversion that utilizes specification of the present invention and accompanying drawing content to be done; Or directly or indirectly be used in other relevant technical fields, all in like manner be included in the scope of patent protection of the present invention.