Embodiment
Below in conjunction with the attached drawing in the embodiment of the present invention, the technical solution in the embodiment of the present invention is carried out clear, complete
Site preparation describes, it is clear that described embodiment is only part of the embodiment of the present invention, instead of all the embodiments.It is based on
Embodiment in the present invention, those of ordinary skill in the art are obtained every other without creative efforts
Embodiment, belongs to the scope of protection of the invention.
It should be noted that HLS protocol is the agreement for real time streaming, its main feature is that media file is carried out
Segment transmissions, the content of transmission include two parts, and a part is TS (the Transport Stream for storage media data
(transport stream;Full name MPEG2-TS) media file, another part is the M3U8 index files for indexing TS media files.Terminal
M3U8 file acquisitions to TS media files can be passed through.
It should be noted that the streaming media server in all embodiments of the invention refers to support the live agreement of Conventional media
(such as RTMP, RTSP, mobile agent server protocol), while the streaming media server of HLS protocol is not supported.
An embodiment of the present invention provides a kind of method for making streaming media server support HLS protocol, as shown in Figure 1, including:
101st, the file of the media file stored in the server identification and streaming media server of streaming media server is obtained
Mark and characteristic parameter.
Wherein, the characteristic parameter of media file includes at least:The file size of media file, media file file when
It is long.
It should be noted that the identification information of streaming media server can be host number and the port of streaming media server
Number, the other identifier that can uniquely determine out streaming media server is can also be, for example, domain name, IP address (Internet
Protocol Address, internet protocol address) or node identification etc..The present invention is without limitation.
It should be noted that one or more media files can be stored with streaming media server, and the media stored
File is whole file.All embodiments of the present invention are illustrated from the angle of any one media file.
It should also be noted that, the server identification of streaming media server is used for one service of unique mark in internet
Device.The file identification of media file is used for one media file of unique mark in streaming media server.The file of media file
Size refers to the size of the memory space shared by the media file.The file duration of media file refers to play a media text
Time needed for part.
Specifically, can be from the server identification and streaming media server that streaming media server obtains streaming media server
The file identification and characteristic parameter of the media file of storage or by the server identification of streaming media server, Streaming Media
The file identification and characteristic parameter of the media file stored in server are stored into storage device, are obtained and are flowed from the storage device
The file identification and characteristic parameter of the media file stored in the server identification and streaming media server of media server.
102nd, fragment segmentation duration and fragment segmentation size are obtained.
It should be noted that media file to be virtually divided into multiple virtual clips, wherein virtual clip is to media
Division on Documents Logical, media file of the actual storage in streaming media server are still the audio/video text of an entirety
Part.When fragment segmentation duration refers to be divided media file, in addition to last virtual clip, other all virtual pieces
Duration corresponding to section, that is to say, that fragment segmentation duration is other all virtual clips in addition to last virtual clip
Average duration.Exemplary, if the file duration of a media file is 130 seconds, if a length of 3 seconds when fragment is split.So root
The media file can be divided into 44 virtual clips according to fragment segmentation duration, wherein, the duration of preceding 43 virtual clips is all
Equal to fragment segmentation duration 3 seconds, the 44th virtual clip when a length of 1 second.
Specifically, obtaining fragment segmentation duration set in advance, or obtain the fragment segmentation duration of user configuration.
It should be noted that fragment segmentation size refers to the size of the corresponding file of fragment segmentation duration.Fragment segmentation is big
It is small when referring to be divided media file, in addition to last virtual clip, the text corresponding to other all virtual clips
The size of part.
Specifically, it can obtain fragment segmentation size set in advance or acquisition to obtain fragment segmentation size
The fragment segmentation size of user configuration, can also be that splitting duration according to the characteristic parameter and fragment of media file determines fragment point
Cut size.
Under normal circumstances, default fragment segmentation size is the integral multiple of 188 bytes.
Wherein, determine that fragment segmentation size specifically includes according to the characteristic parameter of media file and fragment segmentation duration:It is first
Unit interval corresponding file size is first determined according to the file size and file duration of media file, then according to the unit interval
Corresponding file size and fragment segmentation duration determines that fragment splits size.
It should be noted that minimum dividing unit during due to division media file is byte (Byte), and according to above-mentioned
The fragment segmentation that method calculates not of uniform size is integral words section surely, then when dividing virtual clip, the first of virtual clip
A byte and last byte may not be a complete byte, the two bytes are imperfect when playing virtual clip pair
User's viewing sense is affected to be can be ignored.
In order to eliminate the shadow that each virtual clip first character section and last byte are not a complete bytes
Ring, the fragment calculated can be split to size according to the downward rounding of byte, if for example, the fragment segmentation size calculated is
384.125 bytes, then according to obtaining 384 bytes after the downward rounding of byte, then can determine that it is 384 words to separate clip size
Section, then the size of all virtual clips in addition to last virtual clip is equal to 384 bytes, except last is empty
Intend the error that all virtual clips outside fragment add up, can be all modified in last byte.In order to eliminate each void
Intend the influence that fragment first character section and last byte are not a complete bytes, each byte can also calculated
End position when, byte number is added one according to the integer part of end position or subtracts one, with to each virtual clip
The error of one byte or last byte is modified, if for example, calculating a certain void according to the clip size of calculating
The end position for intending fragment is the 122.875th byte, then according to rounding up, the end position of the virtual clip is arranged to
123rd byte.
It should be noted that obtained in the fragment segmentation size for obtaining fragment segmentation size or user configuration set in advance
In the case of fragment segmentation size, step 101 does not have sequencing with step 102, can first carry out step 101, then perform step
Rapid 102;Step 102 can also be first carried out, then performs step 101;Step 101 and step 102 can also be performed at the same time, the present invention
This is not restricted.In the case where the characteristic parameter according to media file and fragment segmentation duration determine fragment segmentation size,
" obtaining fragment segmentation duration " in step 101 and step 102 must be first carried out, then could obtain fragment segmentation size, but
It is not have sequencing between " obtaining fragment segmentation duration " in step 101 and step 102.
103rd, determined according to the characteristic parameter of media file, fragment segmentation duration, fragment segmentation size every in media file
The characteristic parameter of one virtual clip, and according to the server identification of streaming media server, the file identification of media file and each
Index entry in the characteristic parameter construction index file of virtual clip.
Wherein, the characteristic parameter of virtual clip is used to uniquely determine out virtual clip in media file.
It should be noted that before the index entry in constructing index file, it is also necessary to create index file and write basis
Character string.It is the character string required by the form of index file that index file, which is divided into basic character string,.
It should be noted that the characteristic parameter of all virtual clips in media file can be first calculated, and will be each virtual
The characteristic parameter of fragment is stored, then according to the server identification of streaming media server, media file file identification and
The construction index file of the characteristic parameter of each virtual clip of storage;The feature of a virtual clip can also often calculated
During parameter, with regard to adding the corresponding index entry of the virtual clip in indexed file.
It should be noted that in order to uniquely determine out a virtual clip, so the parameter needed has virtual clip in matchmaker
Specific location in body file, media file mark in the server and stores the server of the media file in a network
Mark.URL (Uniform Resource Locator (universal resource locator) sentence construction indexes are used in M3U8 files
, the wherein general type of URL is:<The access mode of URL:://<Host::<Port:/<Path:.
It should be noted that the characteristic parameter of each virtual clip includes:The clip durations of each virtual clip, start bit
Put and end position.Correspondingly, step 103 can be achieved by the steps of:
The initial position of S1, initialization of virtual fragment.
It should be noted that the initial position of virtual clip is exactly the phase for needing to configure respective index item respective file fragment
For the position of whole file.Generally using the first address of whole file as 0 into line displacement.
Specifically, in the case where needing to make the corresponding index file of entirety of media file, initialization of virtual fragment
Initial position relative to whole media file offset be 0.So under normal circumstances, at this time can rising the virtual clip
Beginning, position was arranged to 0.
S2, judge whether virtual clip is last virtual clip in media file.
It should be noted that due to needing to divide file according to fixed fragment segmentation size, it is possible that most
Differing in size for the virtual clip divided afterwards splits size in fragment, correspondingly, the time of the virtual clip may not also
Split duration equal to fragment, then the definite method of the relevant parameter of last virtual clip and the parameter of other virtual clips
Definite method it is different, so needing to judge whether the pending virtual clip such as current is last virtual clip.
It should be noted that it is different according to the result of judgement, perform different steps.If virtual clip is not media file
In last virtual clip, then perform step S3;If virtual clip is last virtual clip in media file,
Perform step S4.
If S3, virtual clip are not last virtual clips in media file, according to the start bit of virtual clip
Put and fragment splits the end position that size determines virtual clip, when fragment segmentation duration is determined as the fragment of virtual clip
It is long, rope is constructed according to the characteristic parameter of the server identification of streaming media server, the file identification of media file and virtual clip
The corresponding index entry of virtual clip in quotation part, and the initial position of virtual clip is updated, jump to and whether judge virtual clip
For last virtual clip in media file.
It should be noted that prepare calculate characteristic parameter virtual clip be not last virtual clip situation
Under, then the clip durations of this virtual clip are equal to fragment segmentation duration, and the size of this virtual clip is equal to fragment
Split size.
It should be noted that if the virtual clip is the virtual clip of first division, then the starting of the virtual clip
Address is exactly the initial position of virtual clip when initializing;If the virtual clip is not the virtual clip of first division, then
The initial position of the virtual clip is determined when its previous virtual clip divides.
Specifically, by the initial position of virtual clip plus the end for subtracting one and being determined as virtual clip after fragment segmentation size
The initial position of end position=virtual clip of position, i.e. virtual clip+fragment segmentation size -1 (byte), and virtual piece
The clip durations of section=fragment segmentation duration, then according to the construction rule of index entry, according to the server mark of media server
The corresponding index of the virtual clip is added in the characteristic parameter indexed file of knowledge, the file identification of media file and virtual clip
, the index entry construction of current virtual fragment finishes at this time, then just jumps to next virtual clip, specially updates virtual clip
Initial address for virtual clip end address plus fragment split size, then jump device step S2, continue to judge next
Whether virtual clip is last virtual clip.
If S4, virtual clip are last virtual clips in media file, according to the file size of media file
Determine the end position of virtual clip, virtual clip is determined according to the initial position of the characteristic parameter of media file and virtual clip
Clip durations, according to the feature of the server identification of streaming media server, the file identification of media file and virtual clip join
The corresponding index entry of virtual clip in number construction index file.
It should be noted that in the case where the virtual clip for preparing calculating characteristic parameter is last virtual clip,
So the clip durations of this virtual clip and clip size need specifically to be determined according to relevant parameter.
Specifically, the corresponding value of the file size of media file to be determined as to the end position of virtual clip, then basis
The size of media file and the initial position of virtual clip determine last virtual clip includes how many byte, then according to matchmaker
The file size and file duration of body file determine duration needed for each byte, are finally included according to last virtual clip
Duration needed for byte number and each byte determines the clip durations of last virtual clip.Then according to the construction of index entry
Rule, is indexing according to the characteristic parameter of the server identification of media server, the file identification of media file and virtual clip
The corresponding index entry of the virtual clip is added in file, the index entry construction of all virtual clips finishes at this time.
It should be noted that judge that the method for the clip durations of last virtual clip can also be media file
It is that the clip durations that file duration subtracts all virtual clips in addition to last virtual clip obtain as a result, being determined as last
The clip durations of a virtual clip.
It should be noted that due to initialization of virtual fragment initial position when by the initial position of first virtual clip
0 is arranged to relative to the offset of whole media file, so at this time the stop bits of last virtual clip can be installed
It is set to the value corresponding to media file size.If the initial position of first virtual clip sets N, then last virtual piece
The end position of section is equal to the value corresponding to N+ media file sizes.
An embodiment of the present invention provides a kind of method for making streaming media server support HLS protocol, obtains streaming media service
The file identification and characteristic parameter of the media file stored in the server identification and streaming media server of device, and obtain fragment point
Cut duration and fragment segmentation size;Media are determined according to the characteristic parameter of media file, fragment segmentation duration, fragment segmentation size
The characteristic parameter of each virtual clip in file, and according to the files-designated of the server identification of streaming media server, media file
Know and the index entry in the characteristic parameter of each virtual clip construction index file.By by media file it is virtual be divided into void
Intend fragment, the index entry of each virtual clip is then constructed in indexed file, so that stored in streaming media server
Whole media file has corresponding index file, only needs just be got respectively according to index file in program request each
The content of virtual clip so that streaming media server can support HLS protocol, simultaneously because index file is relative to the prior art
It is middle media file is split after segmental file greatly reduce compared to the memory spaces of needs, so the less clothes of occupancy
The memory space of business device.
An embodiment of the present invention provides a kind of method for making streaming media server support HLS protocol, as shown in Fig. 2, including:
201st, the file of the media file stored in the server identification and streaming media server of streaming media server is obtained
Mark and characteristic parameter.
Wherein, the characteristic parameter of media file includes at least:The file size of media file, media file file when
It is long.
Specifically, referring to step 101, details are not described herein.
202nd, fragment segmentation duration and fragment segmentation size are obtained.
Specifically, referring to step 102, details are not described herein.
203rd, the initial position of initialization of virtual fragment, and during broadcasting remaining according to the initialization of the file duration of media file
It is long.
It should be noted that when remaining playing duration is exactly the playback of media files a to virtual clip, the matchmaker is played
Body file is left the duration needed for content.
Specifically, the method for the initial position of initialization of virtual fragment refers to the S1 of step 103, details are not described herein.
Specifically, when constructing the index file of full content of media file, the corresponding residue of first virtual clip
Playing duration is determined as the file duration of media file.
204th, judge whether remaining playing duration is less than or equal to fragment segmentation duration.
It should be noted that step 204 be judge current virtual fragment whether be last virtual clip one kind side
Method, can also use other methods, such as be judged according to the size of remaining unallocated media file size and segmentation.This hair
It is bright without limitation.
It should be noted that when obtaining fragment segmentation size, if employ according to the characteristic parameter of media file and
The method that fragment segmentation duration determines fragment segmentation size, and in order to eliminate each virtual clip first character section and last
A byte is not the influence of a complete byte, and the fragment calculated is split size according to the downward rounding of byte, then by
Being less than segmentation duration in the clip size of other virtual clips in addition to last virtual clip actually should corresponding fragment
Size, is less than fragment segmentation duration it is possible that occurring when remaining time, but also unallocated file size is more than fragment
Split the situation of size, need to determine whether last virtual piece according to remaining playing duration and fragment segmentation duration at this time
Section.
If the 205, remaining playing duration is more than fragment segmentation duration, split according to the initial position of virtual clip and fragment
Size determines the end position of virtual clip, fragment segmentation duration is determined as to the clip durations of virtual clip, according to Streaming Media
Virtual piece in the characteristic parameter construction index file of the server identification of server, the file identification of media file and virtual clip
The corresponding index entry of section, and initial position and the played file residual time length of virtual clip are updated, jump to judgement virtual clip
Whether it is last virtual clip in media file.
Specifically, the end position of virtual clip is determined according to the initial position of virtual clip and fragment segmentation size, will
Fragment segmentation duration is determined as the clip durations of virtual clip, according to the server identification of streaming media server, media file
The corresponding index entry of virtual clip in file identification and the characteristic parameter of virtual clip construction index file, and update virtual clip
Initial position, jump to judge virtual clip whether be last virtual clip in media file method, refer to
S3 in step 103, is not repeating herein.
It should be noted that since in addition to last virtual clip, the duration of other virtual clips is equal to fragment point
Duration is cut, so specifically renewal played file residual time length subtracts fragment segmentation duration for current residual time length.
In the case that the 206th, if remaining playing duration is less than or equal to fragment segmentation duration, according to the file of media file
Size determines the end position of virtual clip, is determined virtually according to the initial position of the characteristic parameter of media file and virtual clip
The clip durations of fragment, according to the spy of the server identification of streaming media server, the file identification of media file and virtual clip
Levy the corresponding index entry of virtual clip in parametric configuration index file.
Specifically, referring to the S4 in step 103, do not repeating herein.
An embodiment of the present invention provides a kind of method for making streaming media server support HLS protocol, obtains streaming media service
The file identification and characteristic parameter of the media file stored in the server identification and streaming media server of device, and obtain fragment point
Cut duration and fragment segmentation size;Media are determined according to the characteristic parameter of media file, fragment segmentation duration, fragment segmentation size
The characteristic parameter of each virtual clip in file, and according to the files-designated of the server identification of streaming media server, media file
Know and the index entry in the characteristic parameter of each virtual clip construction index file.By by media file it is virtual be divided into void
Intend fragment, the index entry of each virtual clip is then constructed in indexed file, so that stored in streaming media server
Whole media file has corresponding index file, only needs just be got respectively according to index file in program request each
The content of virtual clip so that streaming media server can support HLS protocol, simultaneously because index file is relative to the prior art
It is middle media file is split after segmental file greatly reduce compared to the memory spaces of needs, so the less clothes of occupancy
The memory space of business device.
A kind of method for making streaming media server support HLS protocol of the embodiment of the present invention, at this time, user's program request is matchmaker
Part in body file, can not have to the corresponding index file of all the elements of construction media file, only construct program request part pair
The index file answered.It is corresponding as shown in figure 3, including:
301st, the file of the media file stored in the server identification and streaming media server of streaming media server is obtained
Mark and characteristic parameter.
Wherein, the characteristic parameter of media file includes at least:The file size of media file, media file file when
It is long.
Specifically, referring to step 101, details are not described herein.
302nd, initial time and the end time of played file are obtained.
Wherein, played file is part or all of in media file.
It should be noted that when user only carries out program request to the partial document in media file, user in media file
The part of program request is called played file, only can make index file to the partial document.Carried out in user using HLS protocol
During program request, it is merely able to there is the partial document in the media file of index file to carry out program request.
It should be noted that the initial time of played file and the value of end time are in 0 and the file duration of media file
Between.
Specifically, media file can be divided into several parts, each section can serve as a played file, at this time may be used
To obtain initial time and the end time of played file from streaming media server.It can also be the user program request media file
A part, at this time from terminal obtain played file initial time end time.
It should be noted that user only sets the initial time of program request under normal circumstances, so terminating at this point it is possible to give tacit consent to
Time is the file duration of media file.
It should be noted that in the case where played file is the whole of media file, when giving tacit consent to the starting of played file
Between be 0, end time of played file is the file duration of media file.
303rd, played file is determined according to the initial time and end time of the characteristic parameter of media file and played file
Initial position and end position.
Specifically, determine that unit interval corresponding file is big according to the file size of media file and file duration first
It is small, the initial position of played file is then determined according to the initial time of unit interval corresponding file size and played file,
And the end position of played file is determined according to the end time of unit interval corresponding file size and played file.
It should be noted that the mode of above-mentioned specific implementation be by the offset of the first address of media file be arranged to 0 into
Row calculates.If the offset for setting the first address of media file is M, correspondingly, the initial position of played file and end position
Add M on the basis of above-mentioned calculating respectively.
304th, fragment segmentation duration and fragment segmentation size are obtained.
Specifically, referring to step 102, details are not described herein.
305th, according to the characteristic parameter of media file, the initial time of played file and end time, fragment segmentation duration,
Fragment segmentation size, initial position and the end position of played file determine that the feature of each virtual clip in media file is joined
Number, and according to the characteristic parameter of the server identification of streaming media server, the file identification of media file and each virtual clip
Construct the index entry of the index file of played file in media file.
It should be noted that at this time except initialization of virtual fragment initial position for played file initial position, with
And judging whether virtual clip is last virtual clip in played file, other all refer to step 103, herein no longer
Repeat.
An embodiment of the present invention provides a kind of method for making streaming media server support HLS protocol, obtains streaming media service
The file identification and characteristic parameter of the media file stored in the server identification and streaming media server of device, obtain played file
Initial time and end time and the enlightenment initial position and the end position that calculate played file, then obtain fragment segmentation
Duration and fragment segmentation size;According to the characteristic parameter of media file, the initial time of played file and end time, fragment point
Cut duration, fragment segmentation size, the initial position of played file and end position and determine each virtual clip in media file
Characteristic parameter, and according to the spy of the server identification of streaming media server, the file identification of media file and each virtual clip
Levy the index entry of the index file of played file in parametric configuration media file.By the way that the played file in media file is virtual
The index entry for being divided into virtual clip, each virtual clip then being constructed in indexed file, so that streaming media service
Played file in device in media file has corresponding index file, only needs just be divided according to index file in program request
The content of each virtual clip is not got so that streaming media server can support HLS protocol simultaneously because index file phase
Greatly reduce for memory space of the segmental file after media file is split in the prior art compared to needs, so compared with
The memory space of the server taken is lacked.
Further, as shown in figure 4, on the basis of the index file method of construction media file, further include such as Fig. 4 institutes
The lookup flow shown.Including;
401st, the program request instruction of terminal is obtained.
Wherein, program request instruction is used in program request streaming media server the media file stored.
It should be noted that can first carry out step 401 obtains program request instruction, it is then interim dynamically to construct index text
Part;Can also be just that the media file in streaming media server constructs before performing step 401 and obtaining program request instruction
Index file.The present invention is without limitation.But the execution of step 402 must construct the media file that needs program request
Index file after perform.
402nd, instructed according to program request, virtual clip is searched from media file using index file, and successively by virtual piece
Section is sent to terminal.
Specifically, terminal first accesses the corresponding index file of media file for needing program request of program request instruction instruction, successively
Obtain index entry and parse index entry, then the server identification in index entry finds corresponding streaming media server,
Corresponding media file is found in streaming media server according to the file identification of media file, according to the feature of virtual clip
Parameter determines the virtual clip in media file, finally by the data sending in the virtual clip to terminal.
An embodiment of the present invention provides a kind of method for making streaming media server support HLS protocol, is making media file
Index file outside, the virtual clip searched according to index file in media file is additionally provided, and successively by virtual clip
Send to terminal, index file so can be used by program request instruction, streaming media server is supported HLS protocol.Together
When due to the storage of index file needs compared with the segmental file after media file is split in the prior art it is empty
Between greatly reduce, so the memory space of the less server taken.
As shown in figure 5, it is a kind of functional schematic of streaming media server provided in an embodiment of the present invention.With reference to figure 5
Shown, which includes:Acquiring unit 501 and processing unit 502.
Acquiring unit 501, the matchmaker stored in the server identification and streaming media server for obtaining streaming media server
The file identification and characteristic parameter of body file.
Wherein, the characteristic parameter of media file includes at least:The file size of media file, media file file when
It is long.
The identification information of streaming media server includes:The host number and port numbers of streaming media server.
Acquiring unit 501, is additionally operable to obtain fragment segmentation duration and fragment segmentation size.
Further, acquiring unit 501, determine specifically for the characteristic parameter according to media file and fragment segmentation duration
Fragment splits size.
Processing unit 502, determines for the characteristic parameter according to media file, fragment segmentation duration, fragment segmentation size
The characteristic parameter of each virtual clip in media file, and according to the server identification of streaming media server, the text of media file
Part identifies and the index entry in the characteristic parameter of each virtual clip construction index file.
Wherein, the characteristic parameter of virtual clip is used to uniquely determine out virtual clip in media file.
Specifically, the characteristic parameter of each virtual clip includes:Clip durations, initial position and the knot of each virtual clip
Beam position.
Processing unit 502, specifically for the initial position of initialization of virtual fragment, and judges whether virtual clip is matchmaker
Last virtual clip in body file;
In the case of last virtual clip during virtual clip is not media file, processing unit 502 is specifically used
The end position of virtual clip is determined in the initial position according to virtual clip and fragment segmentation size, fragment segmentation duration is true
It is set to the clip durations of virtual clip, according to the server identification of streaming media server, the file identification of media file and virtual
The corresponding index entry of virtual clip in the characteristic parameter construction index file of fragment, and the initial position of virtual clip is updated, jump
Go to and judge whether virtual clip is last virtual clip in media file;
In the case of last virtual clip during virtual clip is media file, processing unit 502 is specifically used for
The end position of virtual clip is determined according to the file size of media file, according to the characteristic parameter and virtual clip of media file
Initial position determine the clip durations of virtual clip, according to the server identification of streaming media server, the file of media file
Identify index entry corresponding with virtual clip in the characteristic parameter of virtual clip construction index file.
Further, processing unit 502, are additionally operable to initialize remaining playing duration according to the file duration of media file.
Correspondingly, processing unit 502, during specifically for judging whether remaining playing duration is less than or equal to fragment segmentation
It is long;
Virtual clip is not that last virtual clip in media file includes:If remaining playing duration is more than fragment point
Duration is cut, then it is not last virtual clip in media file to judge virtual clip;
Virtual clip is that last virtual clip in media file includes:If remaining playing duration is less than or equal to piece
Section segmentation duration, then it is last virtual clip in media file to judge virtual clip;
Processing unit 502, is additionally operable to renewal played file residual time length.
Further, acquiring unit 501, are additionally operable to obtain initial time and the end time of played file;
Wherein, played file is part or all of in media file.
Correspondingly, processing unit 502, be additionally operable to according to the characteristic parameter of media file and the initial time of played file and
End time determines initial position and the end position of played file.
Processing unit 502, specifically for the characteristic parameter according to media file, the initial time of played file and at the end of
Between, fragment segmentation duration, fragment segmentation size, played file initial position and end position determine each void in media file
Intend the characteristic parameter of fragment, and according to the server identification of streaming media server, the file identification of media file and each virtual
The index entry of the index file of played file in the characteristic parameter construction media file of fragment.
On the basis of Fig. 5, further, as shown in fig. 6, the streaming media server further includes:Transmitting element 503.
Correspondingly, acquiring unit 501, is additionally operable to obtain the program request instruction of terminal.
Wherein, program request instruction is used in program request streaming media server the media file stored.
Processing unit 502, is additionally operable to be instructed according to program request, and virtual clip is searched from media file using index file.
Transmitting element 503, for successively sending virtual clip to terminal.
An embodiment of the present invention provides a kind of streaming media server, obtains the server identification of streaming media server and flows matchmaker
The file identification and characteristic parameter of the media file stored in body server, obtain initial time and the end time of played file
And initial position and the end position of played file are calculated, then obtain fragment segmentation duration and fragment segmentation size;According to
The characteristic parameter of media file, the initial time of played file and end time, fragment segmentation duration, fragment are split size, are broadcast
Put the initial position of file and end position determines the characteristic parameter of each virtual clip in media file, and taken according to Streaming Media
It is engaged in playing in the characteristic parameter construction media file of the server identification of device, the file identification of media file and each virtual clip
The index entry of the index file of file.By by the played file in media file it is virtual be divided into virtual clip, Ran Hou
The index entry of each virtual clip is constructed in index file, so that the played file in streaming media server in media file
There is corresponding index file, only need just be got respectively in each virtual clip according to index file in program request
Hold so that streaming media server can support HLS protocol, simultaneously because index file is relative in the prior art by media file
Segmental file after being split greatly reduces compared to the memory space for needs, so the storage sky of the less server taken
Between.
In several embodiments provided herein, it should be understood that disclosed system, apparatus and method can be with
Realize by another way.For example, device embodiment described above is only schematical, for example, the unit
Division, is only a kind of division of logic function, can there is other dividing mode, such as multiple units or component when actually realizing
Another system can be combined or be desirably integrated into, or some features can be ignored, or do not perform.It is another, it is shown or
The mutual coupling, direct-coupling or communication connection discussed can be the indirect coupling by some interfaces, device or unit
Close or communicate to connect, can be electrical, machinery or other forms.
The unit illustrated as separating component may or may not be physically separate, be shown as unit
The component shown may or may not be physical location, you can with positioned at a place, or can also be distributed to multiple
In network unit.Some or all of unit therein can be selected to realize the mesh of this embodiment scheme according to the actual needs
's.
In addition, each functional unit in each embodiment of the present invention can be integrated in a processing unit, can also
That the independent physics of unit includes, can also two or more units integrate in a unit.Above-mentioned integrated list
Member can both be realized in the form of hardware, can also be realized in the form of hardware adds SFU software functional unit.
The above-mentioned integrated unit realized in the form of SFU software functional unit, can be stored in one and computer-readable deposit
In storage media.Above-mentioned SFU software functional unit is stored in a storage medium, including some instructions are used so that a computer
Equipment (can be personal computer, server, or network equipment etc.) performs the portion of each embodiment the method for the present invention
Step by step.And foregoing storage medium includes:USB flash disk, mobile hard disk, read-only storage (Read-Only Memory, abbreviation
ROM), random access memory (Random Access Memory, abbreviation RAM), magnetic disc or CD etc. are various to store
The medium of program code.
Finally it should be noted that:The above embodiments are merely illustrative of the technical solutions of the present invention, rather than its limitations;Although
The present invention is described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that:It still may be used
To modify to the technical solution described in foregoing embodiments, or equivalent substitution is carried out to which part technical characteristic;
And these modification or replace, do not make appropriate technical solution essence depart from various embodiments of the present invention technical solution spirit and
Scope.