Summary of the invention
The technical problem that the present invention mainly solves is to provide a kind of method and corresponding equipment of recording streaming media file, make user can watch and listen real-time media file on one side, record this media file on one side, affect the normal operation of other module because of the deficiency of internal memory but can not make mobile terminal, thereby solve the problem that user can preserve media file as required.
A method for recording streaming media file, comprising:
When listening to or watch real-time files in stream media, and pre-recording function is while opening, obtains the frame data of Streaming Media;
Judge whether upper frame data of these frame data that obtain are kept at the end of the first media file, and wherein, the first media file is set in advance as fixed size;
If upper frame data of these frame data are kept at the end of the first media file setting in advance, these frame data are saved in to the position of first frame data in the first media file, cover first frame data in the first media file with frame data, if upper frame data of these frame data are not the ends that is kept at the first media file setting in advance, these frame data are kept to the position after the upper frame data of these frame data;
Continue to obtain next frame data, and judge whether upper frame data of these next one frame data are kept at the end of the first media file setting in advance, until stop obtaining the frame data of Streaming Media or until getting last frame data of Streaming Media.
Further, this method also comprises:
When stopping after last frame data that obtains the frame data of Streaming Media or get Streaming Media, the first media file is carried out to montage to generate the second media file;
Preserve this second media file.
Further, in frame data are saved in to the first media file, the step of the position of first frame data comprises:
First first frame data are deleted, then write these frame data; Or,
Cover first frame data in the first media file with these frame data.
Further, after last frame data that obtains the frame data of Streaming Media or get Streaming Media, the first media file is carried out to montage and comprises with the step that generates the second media file when stopping:
Receive the end record command of user input and stop obtaining of frame data to Media Stream;
Receive the montage instruction of user's input, thereby and the frame data in the first media file are carried out to montage generation the second media file according to the sequencing of preserving to the frame data that obtain.
Further, thus the frame data in the first media file are carried out to montage according to the sequencing of preserving to the frame data that obtain to be generated the step of the second media file and comprises:
Play the 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 the corresponding start frame data of confirmation command and ending frame data according to the instruction of start frame data validation and ending frame data, and generate header file according to start frame data and ending frame data;
Generate the second media file according to header file and start frame data and the frame data that end up.
Further, after the step of frame data of obtaining Streaming Media, also comprise:
If frame data are first frame data that obtain from Streaming Media, again record the header file of the first media.
An equipment for recording streaming media file, comprising:
Acquisition module, for when listening to or watch real-time files in stream media, and the pre-recording function of this equipment is while opening, obtains the frame data of Streaming Media;
Judge module, for judging whether upper frame data of these frame data are kept at the end of the first media file setting in advance, and wherein, the first media file is set in advance as fixed size;
First preserves module, for in the time that upper frame data of these frame data are kept at the end of the first media file setting in advance, these frame data are saved in to the position of first frame data in the first media file, cover first frame data in the first media file with frame data, when upper frame data of these frame data are not while being kept at the end of the first media file setting in advance, these frame data are kept to upper frame data position afterwards.
Further, this equipment also comprises:
Montage module, for when stopping after last frame data that obtains the frame data of Streaming Media or get Streaming Media, carries out montage to generate the second media file to the first media file;
Second preserves module, for preserving the second media file after the montage of montage module completes.
Further, montage module comprises:
The first receiving element, for receiving end record command and the montage instruction of user's input;
Broadcast unit, for receiving when the first receiving element after the end record command and montage instruction of user's input, plays the first media file according to putting in order of the frame data that obtain;
The second receiving element, confirms instruction for the instruction of start frame data validation and the ending frame data that receive user's input;
Montage unit, confirms the corresponding start frame data of confirmation command and ending frame data for the instruction of start frame data validation and the ending frame data that receive according to the second receiving element, and generates header file according to start frame data and ending frame data;
The second media file generation unit, generates the second media file for header file and the start frame data that generate according to montage unit and the frame data that end up.
Further, this equipment also comprises header file logging modle, while being first frame data that obtain from Streaming Media, again records the header file of the first media for the frame data that obtain when this.
In method provided by the invention, by the first media file of a default fixed size in this locality, then the frame data circulation of obtaining is saved in to this first media file; Realize and made user can watch and listen real-time media file on one side, record this media file on one side, affect the normal operation of other module because of the deficiency of internal memory but can not make mobile terminal, thereby solve the problem that user can preserve media file as required, improve user experience.
Embodiment
Consult Fig. 2, the embodiment of the method for recording streaming media file of the present invention comprises:
201, when listening to or watching real-time files in stream media, and the pre-recording function of this equipment is while opening, obtains the frame data of Streaming Media;
Whether upper frame data of the frame data that 202, judgement is obtained are kept at the end of the first media file, and wherein, the first media file is set in advance as fixed size;
If upper frame data of 203 these frame data are kept at the end of the first media file setting in advance, described frame data are saved in to the position of first frame data in described the first media file;
If upper frame data of these frame data are kept at the end of the first media file setting in advance, the frame data that obtain are saved in to the position of first frame data in the first media file, then continue to obtain next frame data, and judge whether upper frame data are kept at the end of the first media file setting in advance, until stop obtaining the frame data of Streaming Media or until get last frame data of Streaming Media;
If upper frame data of 204 these frame data are not the ends that is kept at the first media file setting in advance, these frame data are kept to the position after frame data on this;
If upper frame data of these frame data are not the ends that is kept at the first media file setting in advance, the frame data that obtain are kept to the position after the upper frame data of these frame data, then continue to obtain next frame data, and judge whether upper frame data are kept at the end of the first media file setting in advance, until stop obtaining the frame data of Streaming Media or until get last frame data of Streaming Media;
205, judge whether to stop obtaining the frame data of Streaming Media or until get last frame data of Streaming Media;
Judge whether to stop to obtain the frame data of Streaming Media or until get last frame data of Streaming Media, if so, process ends; If not, continue execution step 201, obtain next frame data;
In the present embodiment, by the first media file of a default fixed size in this locality, then the frame data circulation of obtaining is saved in to this first media file; Realize and made user can watch and listen real-time media file on one side, record this media file on one side, affect the normal operation of other module because of the deficiency of internal memory but can not make mobile terminal, thereby solve the problem that user can preserve media file as required, improve user experience.
Recording after the first media file, user can repeat to listen and see the first media file, but the data in the first media file differ, to establish a capital be that user is needed, and in order to address this problem, the present invention obtains by the first media file being carried out to montage the second media file that user needs; Refer to Fig. 3 below and be elaborated, the preferred embodiment of the method for recording streaming media file of the present invention comprises:
301,, in the time that user listens to or watch real-time files in stream media, judge whether the pre-recording function of this equipment is opened;
In this equipment, set in advance a pre-recording function, can in the file system of this equipment, set in advance one and be specifically designed to the file that records mobile phone state variable, a marking variable is set hereof, whether this marking variable is used for recording pre-recording function and opens, for example, in file system, set in advance a file.txt file, and a marking variable flag is set in file.txt file, in the time that flag is 1, the pre-recording function of equipment is opened, in the time that flag is 0, the pre-recording function of equipment is closed; Certainly, in this equipment, set in advance a pre-recording function and also can realize by newly-increased pre-recording function in function items, do not limit herein;
In the time that user listens to or watches real-time files in stream media, whether the pre-recording function that judges this equipment is opened, for example can judge by the flag reading in file.txt file, if the pre-recording function of this equipment is opened, again record the header file of the first media file, then continue execution step 302, if the pre-recording function of this equipment do not open, process ends;
302, obtain first frame data of Streaming Media;
When judging in step 301 after the pre-recording function unlatching of this equipment, obtain the frame data of Streaming Media;
303, first frame data that obtain are saved in to the position after the header file of the first media file;
Because in the time starting to record the first media file each time, all need again to record the header file of the first media file, 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 upper frame data are kept at the end of the first media file;
Obtaining after next frame data, judge whether upper frame data of these frame data that obtain are kept at the end of the first media file, whether the first media file is filled with, if upper frame data are kept at the end of the first media file, perform step 306, if upper frame data are not kept at the end of the first media file, perform step 307;
306, frame data are saved in to the position of first frame data in the first media file;
The frame data that get are saved in to the position of the 1st frame data in the first media file, concrete, can directly the frame data of the position of original the 1st frame data be covered, also can first the frame data of the position of original first frame data be deleted, and then the position of the frame data that get being write to first frame data, do not limit herein;
Be specifically described as an example of Fig. 5 example, for example, in the first media file, can store n frame data, if n frame data are filled with, so n+1 frame data that newly obtain are saved in to the position of the 1st frame data in the first media file;
307, frame data are kept to upper frame data position afterwards;
If judge frame data in step 305 and be not kept at the end of the first media file, so, the frame data that obtain are saved in to upper frame data position afterwards, concrete, if the position after upper frame data is empty, the frame data that obtain write direct, if the position after upper frame data is not empty, can directly the frame data of the position after upper frame data be covered with the frame data that obtain, also can first the frame data of the position after upper frame data be deleted, and then the frame data that get are write, do not limit herein,
308, judge whether the frame data that stop obtaining the frame data of Streaming Media or whether obtained Streaming Media;
If user inputs the instruction that stops obtaining or the frame data that obtained Streaming Media, perform step 309, if do not receive the instruction that stops obtaining that user inputs, do not obtain the frame data of Streaming Media yet, return to step 304 and continue to obtain next frame data;
309, receive the montage instruction of user's input;
Input the instruction that stops obtaining or the frame data that obtained Streaming Media if judge user in step 308, think that user wants that the media file of recording recorded complete, because the frame data playing sequence of the first media file of recording is not necessarily play according to the time order and function that obtains frame data, as shown in Figure 5, first play n+1 frame data, then play the 2nd frame data, the 3rd frame data etc., and correct playing sequence is first to play the 1st frame data, play again the 2nd frame data ... finally play n+1 frame data, so how complete media file is presented to user, at this moment just need to carry out montage to the first media file,
First receive the montage instruction of user's input, instruction need to be carried out montage to the first media file;
310, play the 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;
In the time being played to a certain frame, user can input the instruction of start frame data validation by keyboard or other devices, or ending frame data are confirmed instruction;
312, confirm the corresponding start frame data of confirmation command and ending frame data according to the instruction of start frame data validation and ending frame data, and generate header file according to start frame data and ending frame data;
Equipment confirms that according to the instruction of start frame data validation and ending frame data corresponding start frame data are determined in instruction and the frame data that end up; Determine file size, regeneration header file according to start frame data and ending frame data again;
313, generate the second media file according to header file and start frame data and the frame data that end up, and separately deposit this second media file;
After complete the first media file of montage, the frame data in the first media file can be deleted, also can retain, do not limit herein;
In the present embodiment, as long as can reach object of the present invention, the sequencing of each step can be changed according to concrete design, does not limit herein;
In the present embodiment, by the first media file of a default fixed size in this locality, then the frame data circulation of obtaining is saved in to this first media file, record after the first media file, again according to user need to carry out montage to the first media file, generate user need the second media file; Realize and made user can watch and listen real-time media file on one side, record this media file on one side, affect the normal operation of other module because of the deficiency of internal memory but can not make mobile terminal, thereby solve the problem that user can preserve media file as required, improve user experience.
Refer to Fig. 6, the embodiment of the equipment of recording streaming media file of the present invention comprises:
Acquisition module 601, for when listening to or watch real-time files in stream media, and the pre-recording function of this equipment is while opening, obtains the frame data of Streaming Media;
Judge module 602, for judging whether upper frame data are kept at the end of the first media file setting in advance, and wherein, the first media file is set in advance as fixed size;
First preserves module 603, while being kept at the end of the first media file setting in advance for judging upper frame data when judge module 602, frame data are saved in to the position of first frame data in the first media file, then acquisition module 601 continues to obtain next frame data, and judge by judge module 602 whether upper frame data are kept at the end of the first media file setting in advance again, until stop obtaining the frame data of Streaming Media or until get last frame data of Streaming Media;
Further, the equipment in the present embodiment also comprises:
Montage module 604, for when stopping after last frame data that obtains the frame data of Streaming Media or get Streaming Media, carries out montage to generate the second media file to the first media file;
Second preserves module 605, for preserving the second media file after 604 montages of montage module complete.
Further, the first preservation module 603 is not also while being kept at the end of the first media file setting in advance for judge upper frame data when judge module 602, frame data are kept to the position after frame data on this, then acquisition module 601 continues to obtain next frame data, and judge by judge module 602 whether upper frame data are kept at the end of the first media file setting in advance again, until stop obtaining the frame data of Streaming Media or until get last frame data of Streaming Media;
Further, montage module 604 comprises:
The first receiving element, for receiving end record command and the montage instruction of user's input;
Broadcast unit, for receiving when the first receiving element after the end record command and montage instruction of user's input, plays described the first media file according to putting in order of frame data;
The second receiving element, confirms instruction for the instruction of start frame data validation and the ending frame data that receive user's input;
Montage unit, confirms the corresponding start frame data of confirmation command and ending frame data for the instruction of start frame data validation and the ending frame data that receive according to the second receiving element, and generates header file according to start frame data and ending frame data;
The second media file generation unit, generates the second media file for header file and the start frame data that generate according to montage unit and the frame data that end up;
Further, the equipment in the present embodiment also comprises header file logging modle 606, while being first frame data that obtain from Streaming Media, again records the header file of described the first media for the frame data that obtain when acquisition module 601.
In the present embodiment, by the first media file of a default fixed size in this locality, then the frame data circulation of obtaining is saved in to this first media file, record after the first media file, again according to user need to carry out montage to the first media file, generate user need the second media file; Realize and made user can watch and listen real-time media file on one side, record this media file on one side, affect the normal operation of other module because of the deficiency of internal memory but can not make mobile terminal, thereby solve the problem that user can preserve media file as required, improve user experience.
The foregoing is only embodiments of the invention; not thereby limit the scope of the claims of the present invention; every equivalent structure or conversion of equivalent flow process that utilizes specification of the present invention and accompanying drawing content to do; or be directly or indirectly used in other relevant technical fields, be all in like manner included in scope of patent protection of the present invention.