Media file loading control method and device and storage medium

文档序号:1784941 发布日期:2019-12-06 浏览:10次 中文

阅读说明:本技术 一种媒体文件加载控制方法、装置及存储介质 (Media file loading control method and device and storage medium ) 是由 银国徽 于 2018-05-29 设计创作,主要内容包括:本公开提供了一种媒体文件加载控制方法,包括:检测播放器播放媒体文件过程中所到达的播放点;获取播放时间晚于所述播放点的两个时间戳之间的分段媒体文件,所述两个时间戳构成所述分段媒体文件的播放时间段;通过所述播放器预加载所获取的分段媒体文件。本公开还提供一种媒体文件加载控制装置及存储介质。(The present disclosure provides a media file loading control method, including: detecting a playing point reached by a player in the process of playing a media file; acquiring a segmented media file between two timestamps of which the playing time is later than the playing point, wherein the two timestamps form the playing time period of the segmented media file; preloading the acquired segmented media files by the player. The disclosure also provides a media file loading control device and a storage medium.)

1. A media file loading control method is characterized by comprising the following steps:

Detecting a playing point reached by a player in the process of playing a media file;

Acquiring a segmented media file between two timestamps of which the playing time is later than the playing point, wherein the two timestamps form the playing time period of the segmented media file;

Preloading the acquired segmented media files by the player.

2. The method of claim 1,

the media file is divided into a plurality of segmented media files by the time stamps based on the play duration, or,

The media file is divided into a plurality of segmented media files by the time stamp based on a play time length after the play point.

3. The method of claim 1,

the timestamp information of the media file is acquired from a server and is set by the server according to the historical playing data of the media file.

4. The method of claim 1,

The information of the timestamp is set by the player when the player starts playing the media file.

5. The method of claim 1, wherein the obtaining the segmented media file corresponding to the timestamp with the playing time after the playing point comprises:

The two timestamps include a first timestamp and a second timestamp later than the first timestamp;

Searching a first key frame with the decoding time before the first timestamp and closest to the first timestamp, and a second key frame with the decoding time after the second timestamp and closest to the end time point of the second timestamp;

Extracting media data between the first key frame and the second key frame from the media file.

6. the method of claim 5, wherein said extracting media data between said first key frame and said second key frame from said media file comprises:

Extracting video frames between the first key frame and the second key frame from the media file;

Searching a first audio frame with the decoding time before the decoding time of the first key frame and closest to the decoding time of the first key frame, and a second audio frame with the decoding time after the decoding time of the second key frame and closest to the decoding time of the second key frame;

Extracting audio frames between the first audio frame and the second audio frame from the media file.

7. The method of claim 1, wherein loading, by the player, the retrieved segmented media file comprises:

When the player is running in an embedded web page,

and sending the segmented media file to a media resource expansion interface, wherein the media resource expansion interface is used for enabling the player to call the media elements of the webpage to play the segmented media file.

8. the method of claim 7, wherein the obtaining the segmented media file between two timestamps with a playback time later than the playback point comprises:

When the media file is in a non-streaming media package format,

Extracting media data between the two timestamps from the media file;

And filling the extracted media data and the corresponding metadata into a container of the segmented media file to obtain the corresponding segmented media file.

9. the method of claim 1, wherein loading, by the player, the retrieved segmented media file comprises:

Responding to the operation of selecting the playing time point;

determining the playing time period to which the selected playing time point belongs;

And loading the segmented media file corresponding to the determined playing time period through the player.

10. the method of claim 1, wherein loading, by the player, the retrieved segmented media file comprises:

When the selected segmented media file is not determined through human-computer interaction,

And sequentially loading the at least one segmented media file through the player according to the starting time of the timestamp corresponding to the acquired at least one segmented media file.

11. the method according to any of claims 1 to 10, wherein after said loading of the retrieved segmented media file by the player, the method further comprises:

In response to a request for changing the display resolution, determining a third timestamp corresponding to the time of receiving the request and a fourth timestamp which is not earlier than the playing end time of the currently played segmented media file;

Acquiring a new segmented media file with playing time between the third timestamp and the second time point and the switched target resolution;

and loading the acquired new segmented media file by the player to replace the segmented media file with the original resolution.

12. a media file loading control apparatus, comprising:

The detection unit is used for detecting the playing point reached by the player in the process of playing the media file;

The device comprises an acquisition unit, a storage unit and a playing unit, wherein the acquisition unit is used for acquiring a segmented media file between two timestamps of which the playing time is later than that of a playing point to which the segmented media file belongs, and the two timestamps form a playing time period of the segmented media file;

and the loading unit is used for preloading the acquired segmented media files through the player.

13. The apparatus of claim 12, wherein the media file is divided into a plurality of segmented media files by the time stamp based on a play duration, or,

the media file is divided into a plurality of segmented media files by the time stamp based on a play time length after the play point.

14. The apparatus of claim 12, wherein the timestamp information of the media file is obtained from a server and is set by the server according to historical playing data of the media file.

15. The apparatus of claim 12, wherein the timestamp information is set by the player when the player starts playing the media file.

16. The apparatus of claim 12, wherein the two timestamps include a first timestamp, and a second timestamp that is later than the first timestamp;

The acquisition unit is used for searching a first key frame with decoding time before a first timestamp and closest to the first timestamp, and a second key frame with decoding time after a second timestamp and closest to the end time point of the second timestamp;

Extracting media data between the first key frame and the second key frame from the media file.

17. The apparatus according to claim 16, wherein the obtaining unit is configured to extract a video frame between the first key frame and the second key frame from the media file;

Searching a first audio frame with the decoding time before the decoding time of the first key frame and closest to the decoding time of the first key frame, and a second audio frame with the decoding time after the decoding time of the second key frame and closest to the decoding time of the second key frame;

Extracting audio frames between the first audio frame and the second audio frame from the media file.

18. the apparatus according to claim 12, wherein the loading unit is configured to, when the player runs in a manner embedded in the webpage,

And sending the segmented media file to a media resource expansion interface, wherein the media resource expansion interface is used for enabling the player to call the media elements of the webpage to play the segmented media file.

19. The apparatus according to claim 18, wherein the obtaining unit is configured to, when the media file is in a non-streaming media package format,

extracting media data between the two timestamps from the media file;

And filling the extracted media data and the corresponding metadata into a container of the segmented media file to obtain the corresponding segmented media file.

20. The apparatus according to claim 12, wherein the loading unit is configured to respond to an operation of selecting a play time point;

Determining the playing time period to which the selected playing time point belongs;

And loading the segmented media file corresponding to the determined playing time period through the player.

21. the apparatus of claim 12, wherein the loading unit is configured to, when the selected segmented media file is not determined through human-computer interaction,

and sequentially loading the at least one segmented media file through the player according to the starting time of the timestamp corresponding to the acquired at least one segmented media file.

22. A media file loading control apparatus, comprising:

a memory for storing executable instructions;

A processor for implementing the media file loading control method of any of claims 1 to 11 by executing executable instructions stored in the memory.

23. A storage medium having stored therein executable instructions for implementing a media file loading control method as claimed in any one of claims 1 to 11 when executed.

Technical Field

The present disclosure relates to media file loading control technologies, and in particular, to a method and an apparatus for controlling media file loading, and a storage medium.

Background

when the multimedia information is played through the webpage, the buffering or loading of the multimedia information is completed by the webpage browser; the method is specifically realized in such a way that a webpage browser loads segmented multimedia data from a current playing point to an ending point from the current playing point, and the browser cannot control the size of the cached or loaded multimedia data in the loading process. Thus, when the user selectively views the loaded multimedia data, unnecessary consumption of traffic is caused.

disclosure of Invention

In view of this, embodiments of the present disclosure provide a method, an apparatus, and a storage medium for controlling loading of a media file, which can reduce unnecessary consumption of traffic when playing multimedia information.

In one aspect, an embodiment of the present disclosure provides a media file loading control method, including:

Detecting a playing point reached by a player in the process of playing a media file;

Acquiring a segmented media file between two timestamps of which the playing time is later than the playing point, wherein the two timestamps form the playing time period of the segmented media file;

Preloading the acquired segmented media files by the player.

On the other hand, an embodiment of the present disclosure further provides a media file loading control device, including:

The detection unit is used for detecting the playing point reached by the player in the process of playing the media file;

The device comprises an acquisition unit, a storage unit and a playing unit, wherein the acquisition unit is used for acquiring a segmented media file between two timestamps of which the playing time is later than that of a playing point to which the segmented media file belongs, and the two timestamps form a playing time period of the segmented media file;

And the loading unit is used for preloading the acquired segmented media files through the player.

in another aspect, an embodiment of the present disclosure provides a media file loading control apparatus, including:

A memory for storing executable instructions;

And the processor is used for realizing the media file loading control method provided by the embodiment of the disclosure by executing the executable instructions stored in the memory.

In another aspect, the present disclosure also provides a storage medium, where executable instructions are stored in the storage medium, and when executed, the executable instructions are used to implement the media file loading control method provided by the present disclosure.

executable instructions may be interpreted as a generic concept of installation packages, programs, code, plug-ins, libraries (dynamic/static libraries).

in the embodiment of the disclosure, the playing point reached by the player in the process of playing the media file is detected; acquiring a segmented media file between two timestamps of which the playing time is later than the playing point, wherein the two timestamps form the playing time period of the segmented media file; preloading the acquired segmented media files by the player. Therefore, the media files are divided in advance to obtain a plurality of segmented media files, and the player loads part of the segmented media files behind the playing point or loads only one segmented media file behind the playing point, so that when a user selectively watches the segmented media files loaded behind the playing point, the player loads the segmented media files behind the playing point in advance, and the consumption of flow can be avoided.

drawings

FIG. 1 is a schematic view of an alternative construction of a container provided by embodiments of the present disclosure;

fig. 2 is a schematic diagram of an alternative package structure of an MP4 file provided by an embodiment of the present disclosure;

Fig. 3 is a schematic structural diagram of a media data container storing media data in a media file provided by an embodiment of the present disclosure;

FIG. 4 is a schematic diagram of an alternative packaging structure of an FMP4 file provided by an embodiment of the present disclosure;

FIG. 5 is a schematic diagram of an alternative structure of a media file loading control device according to an embodiment of the disclosure;

FIG. 6 is a schematic diagram of an alternative processing flow of a media file loading control method according to an embodiment of the disclosure;

FIG. 7 is a schematic diagram of an alternative process for extracting media data between a first key frame and a second key frame from a media file according to an embodiment of the present disclosure;

FIG. 8 is an alternative flow diagram of encapsulating segmented media files provided by examples of the present disclosure;

FIG. 9 is a schematic diagram of an alternative process for parsing media information from a metadata container according to an embodiment of the present disclosure;

FIG. 10 is a schematic view of an alternative process flow for loading a segmented media file obtained by a player according to an embodiment of the present disclosure;

fig. 11 is a schematic flowchart illustrating that a player sends a segmented media file to a media element of a web page through a media source extension interface of the web page for decoding and playing according to an embodiment of the present disclosure;

FIG. 12 is an alternative diagram of a player according to an embodiment of the present disclosure playing a segmented media file through a media source extension interface of a web page;

FIG. 13 is a schematic diagram of an MP4 file being converted into an FMP4 file and being played through a media source extension interface according to an embodiment of the present disclosure;

fig. 14 is a schematic view of another alternative processing flow of a media file loading control method applied to a player according to an embodiment of the present disclosure;

Fig. 15 is a schematic structural diagram of a media file loading control device according to an embodiment of the present disclosure.

Detailed Description

for the purpose of making the purpose, technical solutions and advantages of the present disclosure clearer, the present disclosure will be described in further detail with reference to the accompanying drawings, the described embodiments should not be construed as limiting the present disclosure, and all other embodiments obtained by a person of ordinary skill in the art without making creative efforts shall fall within the protection scope of the present disclosure.

Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this disclosure belongs. The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure.

Before the present disclosure is explained in further detail, terms and expressions referred to in the embodiments of the present disclosure are explained, and the terms and expressions referred to in the embodiments of the present disclosure are applied to the following explanations.

1) a media file, a file storing encoded media data (e.g., at least one of audio data and video data) in a container (Box), includes metadata, i.e., data describing the media data, and carries media information to ensure that the media data is decoded correctly.

For example, a file in which multimedia data is encapsulated in an MP4 container format is referred to as an MP4 file, and typically, the MP4 file stores therein Advanced Video Coding (AVC, Advanced Video Coding, or h.264) or MPEG-4(Part 2) specification coded Video data and Advanced audio Coding (AAC, Advanced audio Coding) specification coded audio data, although other Coding modes of Video and audio are not excluded.

2) The container (Box), also called a Box, an object-oriented component defined by a unique type identifier and a length, see fig. 1, is an optional structural diagram of the container provided by the embodiment of the present disclosure, and includes a container Header (Box Header) and container Data (Box Data), which are filled with binary Data to express various information.

The container header includes a size (size) and a type (type), the size indicates a size (also referred to as a capacity or a length herein) of a storage space occupied by the container, the type indicates a type of the container, and fig. 2 is a schematic diagram of an alternative package structure of an MP4 file provided by an embodiment of the present disclosure, and basic container types referred to in an MP4 file include a file type container (ftyp box), a metadata container (moov box), and a media data container (mdat box).

The container data portion may store specific data, where the container is referred to as a "data container," and may further encapsulate other types of containers, where the container is referred to as a "container of a container.

3) Track (Track), a time-ordered sequence of related samples (Sample) in a container of media data, which represents a sequence of video frames or a sequence of audio frames for media data, and may also include a subtitle Track synchronized with the sequence of video frames, a set of consecutive samples in the same Track being called a Chunk (Chunk).

4) A file type container, a container for storing the capacity (i.e. length of occupied bytes) and type of a file in a media file, as shown in fig. 2, binary data stored in the file type container describes the type and capacity of the container according to the specified byte length.

5) a metadata container, a container in a media file for storing metadata (i.e., data describing multimedia data stored in the media data container), and information expressed by binary data stored in the metadata container in the MP4 file are referred to as media information.

As shown in fig. 2, the header of the metadata container represents the type of the container as "moovbox" using binary data, and the container data part encapsulates an mvhd container for storing general information of an MP4 file, is independent of an MP4 file, and is related to the playing of an MP4 file, including a time length, a creation time, a modification time, and the like.

The media data container of the media file may include sub-containers corresponding to a plurality of tracks, such as an audio track container (audio track box) and a video track container (video track box), in which references and descriptions of media data of the corresponding tracks are included, and the necessary sub-containers include: a container (denoted tkhd box) for describing the characteristics and overall information of the track (e.g. duration, width, height), and a container (denoted mdia box) for recording media information of the track (e.g. information of media type and sample).

As for the sub-containers packaged in the mdia box, it may include: recording the relevant attributes and content of the track (denoted mdhd box), recording the playing procedure information of the media (denoted hdlr box), describing the media information of the media data in the track (denoted minf box); the minf box in turn has a sub-container (denoted as dinf box) for explaining how to locate the media information, and a sub-container (denoted as stbl box) for recording all the time information (decoding time/display time), position information, codec etc. of the samples in the track.

Referring to fig. 3, which is a schematic structural diagram of a media data container in a media file for storing media data according to an embodiment of the present disclosure, the time, type, capacity and location of a sample in the media data container can be interpreted by using media information identified from binary data in a stbl box container, and each sub-container in the stbl box is described below.

The stsd box contains a sample description (sample description) table, and there may be one or more description tables in each media file according to different coding schemes and the number of files storing data, and the description information of each sample can be found through the description tables, and the description information can ensure correct decoding of the sample, and different media types store different description information, for example, the description information is the structure of the image in the case of video media.

The stts box stores the duration information of the samples and provides a table to map time (decoding time) and the serial numbers of the samples, and the samples at any time in the media file can be located through the sttx box; the stts box also uses other tables to map the sample size and pointers, where each entry in the table provides the serial number of consecutive samples within the same time offset and the offset of the sample, and increments these offsets to build a complete time-sample mapping table, and the calculation formula is as follows:

DT(n+1)=DT(n)+STTS(n)(1)

where STTS (n) is the duration of the nth sample, DT (n) is the display time of the nth sample, the samples are arranged in a time sequence, such that the offset is always non-negative, DT generally starts with 0, and the calculation formula is as follows, taking the display time DT (i) of the ith sample as an example:

DT(i)=SUM(for j=0to i-1of delta(j))(2)

The sum of all offsets is the duration of the media data in the track.

The stss box records the sequence number of the key frame in the media file.

the stsc box records the mapping relation between the samples and the blocks for storing the samples, the relation between the serial numbers of the samples and the serial numbers of the blocks is mapped through a table, and the blocks containing the specified samples can be found through table lookup.

The stco box defines the position of each block in the track, expressed in terms of the offset of the starting byte in the media data container, and the length (i.e., the size) relative to the starting byte.

The stsz box records the size (i.e., size) of each sample in the media file.

6) A media data container, a container for storing multimedia data in a media file, for example, a media data container in an MP4 file, as shown in fig. 3, a sample is a unit stored in the media data container, and is stored in a block of the media file, and the lengths of the block and the sample may be different from each other.

7) And segmenting the media files, wherein the media files are divided into subfiles, and each segmented media file can be independently decoded.

taking the MP4 file as an example, the media data in the MP4 file is divided according to the key frames, the divided media data and the corresponding metadata are packaged to form a segmented MP4 (segmented MP4) file, and the metadata in each FMP4 file can ensure that the media data is correctly decoded.

For example, when the MP4 file shown in fig. 2 is converted into multiple FMP4 files, referring to fig. 4, which is an optional packaging structure diagram of FMP4 files provided in the embodiment of the present disclosure, one MP4 file may be converted into multiple FMP4 files, and each FMP4 file includes three basic containers: moov containers, moof containers, and mdat containers.

the moov container includes MP4 file level metadata describing all media data in the MP4 file from which the FMP4 file is derived, such as the duration, creation time, and modification time of the MP4 file.

the moof container stores segment-level metadata describing media data packaged in the FMP4 file where it is located, ensuring that the media data in the FMP4 can be decoded.

the 1 moof container and the 1 mdat container constitute 1 segment of the segment MP4 file, and 1 or more such segments may be included in the 1 segment MP4 file, and the metadata encapsulated in each segment ensures that the media data encapsulated in the segment can be independently decoded.

8) media resource Extensions (MSE) interface, player-oriented interface implemented in web pages, interpreted by the browser's interpreter during loading in the web page, implemented by executing a front-end programming language (e.g., JavaScript), provides the player with the functionality to call the play Media stream of hypertext markup language (HTML) Media elements (Media elements), for example, to implement the play functionality of video/audio using video Element < video > and audio Element < audio >.

9) The streaming media packaging format is a packaging technology for packaging media data into a file of streaming media, the file of the streaming media can be decoded and played without complete downloading and extra transcoding, namely, the packaging technology supports downloading while playing once as is. Typical Streaming media encapsulation format files are, for example, TS media file fragments based on HTTP Live Streaming (HLS, HTTP Live Streaming) technology, flv (flash video) files, and the like.

10) A non-streaming media encapsulation format, which is an encapsulation technology for encapsulating media data into a media file and allowing the media file to be decoded and played after the media file is completely downloaded, and a typical file in the non-streaming media encapsulation format includes: MP4 files, Windows Media Video (WMV) files, Advanced Streaming Format (ASF) files, and the like.

it should be noted that MP4 file does not natively support streaming media playback, but the technical effect of filling invalid binary data in the transcoded media stream of the player after on-line transcoding (for example, in the case of full download of ftyp container and moov container, the missing part of the filled mdat container is replaced by invalid binary data) can also be achieved by filling invalid binary data in the missing part of the partially downloaded MP4 file.

The following describes a flow of a player implementing an embodiment of the present disclosure to acquire media data in a given period.

When playing a movie or a track, the player must be able to correctly parse the data stream, obtain the corresponding media data for a certain time and ensure that the piece of media data can be decoded independently.

1. Determining a time interval corresponding to the media data to be acquired, wherein the time interval is a period of time for continuously playing a current playing point, and the time corresponding to the playing point is time measurement relative to a media time coordinate system (taking the playing start time of the media file as a time origin).

2. The stts box is checked to determine the sequence number of the samples for a given period of decoding time.

for audio frame frames, the stts box is checked to determine the sequence number of the audio frame for a given period of decoding time.

For video frames, due to the compression algorithm, if the first frame in a given period is not a key frame, the first frame in the given period needs to be traced back to the key frame before the start time of the given period according to the time sequence to ensure that the frames in the given period can be decoded.

3. The sequence number of the block including the sample is determined by querying the stsc box according to the employed sequence number.

4. The offset of the block is looked up from the stco box.

5. And searching the stsz box according to the serial number of the sample, and finding the offset of the sample in the block and the volume of the sample.

The process of finding key frames implementing the embodiments of the present disclosure is described.

1. The sequence number of samples in a given time is determined.

2. the stss box is checked to find the key frame after this sample.

3. The stsc box is checked to find the block corresponding to the key frame.

4. the offset of the block is extracted from the stco box.

5. The stsz box is used to find the offset of the key frame sample within the block and the size of the key frame.

The following first describes a media file loading control device for implementing the embodiment of the present disclosure, where the media file loading control device detects a playing point reached by a player in a process of playing a media file; acquiring a segmented media file between two timestamps of which the playing time is later than the playing point, wherein the two timestamps form the playing time period of the segmented media file; preloading the acquired segmented media files by the player.

The following continues to describe the structure of a media file loading control apparatus that implements an embodiment of the present disclosure.

referring to fig. 5, which is a schematic diagram of an alternative structure of a media file loading control apparatus 100 according to an embodiment of the present disclosure, the media file loading control apparatus shown in fig. 5 includes: at least one processor 150, at least one communication bus 160, a user interface 180, at least one network interface 170, and memory 190. The various components in the media file load control device 100 are coupled together by a communication bus 160. It will be appreciated that a communication bus 160 is used to enable communications among the components. The communication bus 160 includes a power bus, a control bus, and a status signal bus in addition to a data bus. But for clarity of illustration the various busses are labeled in figure 5 as communication bus 160.

The user interface 180 may include, among other things, a display, a keyboard, a mouse, a trackball, a click wheel, a key, a button, a touch pad, or a touch screen. The network interface 170 may include a standard wired interface and the wireless interface may be a WiFi interface.

It is understood that the Memory 190 may be a high-speed RAM Memory or a Non-Volatile Memory (Non-Volatile Memory), such as at least one disk Memory. Memory 190 may also be at least one storage system physically located remote from processor 150.

the media file loading control method applied to the media file loading control device provided by the embodiment of the disclosure may be applied to the processor 150, or implemented by the processor 150. The processor 150 may be an integrated circuit chip having signal processing capabilities. In implementation, different operations in the media file loading control method applied to the media file loading control apparatus may be performed by an integrated logic circuit in the form of hardware or an instruction in the form of software in the processor 150. The processor 150 described above may be a general purpose processor, a DSP or other programmable logic device, discrete gate or transistor logic devices, discrete hardware components, or the like. The processor 150 may implement or execute a media file loading control method, a media file loading control procedure, and a logic block diagram of the media file loading control apparatus according to the embodiments of the disclosure. A general purpose processor may be a microprocessor or any conventional processor or the like. The media file loading control method applied to the media file loading control device provided by the embodiment of the disclosure can be directly implemented by a hardware decoding processor, or implemented by combining hardware and software modules in the decoding processor.

As an example, the software module may be located in a storage medium, which may be the memory 190 shown in fig. 5, and the processor 150 reads executable instructions in the memory 190, and completes an optional processing flow of the media file loading control method applied to the media file loading control device provided in the embodiment of the disclosure in combination with hardware thereof, as shown in fig. 6, including the following steps:

Step S101, detecting a playing point reached by a player in the process of playing a media file;

in an embodiment, the playing point may be a time reached by a jump operation of the playing progress, for example, the original playing point is 20% of the playing progress, and the jumped playing point is 30%; the playing point may also be a time reached by continuous playing, for example, a time reached from 30 th minute to 40 th minute.

The player may be a web-embedded H5 player or a dedicated video playing Application (APP).

The media file is divided into a plurality of segmented media files by the time stamp based on the playing time length, or the media file is divided into a plurality of segmented media files by the time stamp based on the playing time length behind the playing point; each segmented media file has two timestamps for defining a play start time and a play end time of the segmented media file. The segmented media files divided by the media files can be segmented media files with equal time length or segmented media files with unequal time length. The segmented media files with equal time length mean that the playing time lengths of all the segmented media files are equal. The segmented media files with unequal time lengths mean that the playing time lengths of a plurality of segmented media files are unequal; for example, it is preset to divide the playing time length after the playing point into N fixed segments, so that the playing time lengths after different playing points are also different, and correspondingly, based on the playing time lengths after different playing points, the playing time lengths corresponding to the segmented media files of fixed number obtained by dividing are also different.

In some embodiments, the timestamp may be retrieved by the player from a storage server for the media file, the storage server determining the timestamp based on the historical play times of the media file and the size of the media file. In one embodiment, the storage server calculates the viewing tendency of the user for the entire media file according to the data of the on-demand frequency, the complete playing frequency and the like of the media file, and correspondingly sets a timestamp to represent whether the media file is jumped to play or played completely. In specific implementation, the higher the historical playing frequency value of the media file is set, the higher the probability of completely playing the media file is, and the number of timestamps corresponding to the media file is relatively small, that is, the media file is divided into fewer segmented media files. In another embodiment, historical playing data of different types of audiences can be distinguished according to the user portrait, and corresponding time stamps are set for the different types of audiences; thus, the loaded segmented media file can be viewed to the longest extent, but not jumped to be viewed, and further the traffic is saved.

In other embodiments, the timestamp information is set by the player when the player begins playing the media file. In one embodiment, the time stamps for dividing the media file into the segmented media files not less than the segmented time threshold are set according to the playing time of the media file. In other embodiments, the media file is divided according to the characteristics of the history playing of the player, such as the complete playing probability, the jumping playing probability, or the time stamp set with the file jumping times, so that the division of the media file by the time stamp is in accordance with the viewing tendency of the current user.

Step S102, acquiring a segmented media file corresponding to a time stamp with playing time after a playing point.

Here, the segmented media file includes two timestamps, a first timestamp and a second timestamp, respectively, and the second timestamp is later than the first timestamp.

For the media file in the streaming media format, namely the segment between the playing start time and the playing end time of the segmented media file in the acquired media file, each segment can be decoded and played independently.

In one embodiment, the media file loading control device searches a first key frame with a decoding time before the first timestamp and closest to the first timestamp, and a second key frame with a decoding time after the second timestamp and closest to the second timestamp according to the decoding time of the key frame; and then extracting the media data between the first key frame and the second key frame from the media file. In this way, the integrity of the media data between the decoded first timestamp and the second timestamp can be guaranteed.

Next, two key frames corresponding to a given time period are determined, the time period with the decoding time of the two key frames as an endpoint includes the given time period, a segmented media file is constructed to play by taking media between the two key frames as media data corresponding to the given time period, and the given time period is used for continuing a real-time playing point of a player, so that continuous playing of the media file is realized.

As for the play point, it may be a play time that is reached by continuously playing the media file (i.e., naturally playing without user intervention), for example, from a play point of 30 th minute to a play point of 40 th minute; or, the media file may reach the playing time of the media file by means of jumping (i.e., the user clicks the progress bar through the cursor to realize page jumping), where for example, the original playing point is 20% of the playing progress, and the jumping playing point is 30% of the playing progress.

in some embodiments, a manner of determining two key frames (set as a first key frame and a second key frame after the first key frame at the decoding time) is described in accordance with a case where a video frame corresponding to a playback point and a video frame corresponding to the end time of a given period are normal frames or key frames, for a case where the playback point is a playback time that arrives by continuously playing a media file.

case 1) the video frame corresponding to the playing point is a normal frame, and since the player uses the media data between two key frames as a basic playing loading unit, the media data before the first key frame (the key frame whose decoding time is later than the key frame closest to the playing point in the key frames of the playing point) after the playing point is the loaded media data, and in order to avoid repeatedly acquiring the loaded media data, the first key frame in the two key frames of a given time period is: the first key frame in the media file whose decoding time is after the play point.

case 2) the video frame corresponding to the playing point is a key frame, and the first key frame of the two key frames in the given period is: the corresponding key frame of the playing point, i.e. the key frame aligned with the start time of the given period.

Case 3) if the video frame corresponding to the end time of the given time period is an ordinary frame, since the player uses the media data between two key frames as a basic playing loading unit, if the key frame before the end time is used as the second key frame of the given time period, the media data between the key frame and the video frame corresponding to the end time is missed to be acquired, and when the media file is played, the media data between the key frame before the end time and the video frame corresponding to the end time cannot be played and skipped, so that in order to ensure that the video frame corresponding to the end time of the given time period can be played normally without frame skipping, the second key frame in the two key frames of the given time period is: decoding a key frame closest to an end time among key frames having a time later than the end time of the given period;

Case 4) the video frame corresponding to the end time of the given period is a key frame, and the second key frame of the two key frames of the given period is: the second key frame, which is time-aligned with the end time of the given period, is decoded, i.e., the key frame aligned with the end time of the given period.

In the above cases 1) and 3), the key frame crossing the playing point is used as the end point of the media data in a given period, so that it can be ensured that the video frame corresponding to the playing point has enough information for correct decoding, and frame skipping due to lack of decoded data (i.e. key frame) does not occur.

In the above cases 2) and 4), for the case that the playing point aligns the key frames, the aligned key frames are directly used as the end points of the media data in the given time period, so as to reduce the situation of requesting redundant data to the maximum extent and avoid the situation that the occupation of connection and traffic causes the delay of non-media playing service in the web page.

in other embodiments, the manner of determining two key frames (set as the first key frame and the second key frame after the first key frame at the decoding time) is described according to the case where the video frame corresponding to the playback point and the video frame corresponding to the end time of the given period are normal frames or key frames, for the case where the playback point is the playback time that arrives by means of jumping.

case 1) the video frame corresponding to the play point is a normal frame, and since the play point is reached by jumping, the first key frame before the play point and the media data between the play point are not loaded, and the first key frame is: in the media file, the first key frame before the playing point of the decoding time, that is, the time of the media data (that is, the corresponding relationship between the sequence number represented by the media information and the decoding time of the frame) is searched for the key frame whose decoding time is earlier than the starting time of the given period and is closest to the starting time.

The media data between the extra request playing point and the key frame before the playing point can ensure that the jumping to any playing point can be decoded normally, and the condition that the frame jumping occurs because the frame can not be decoded when the playing point corresponds to the common frame is avoided.

case 2) the video frame corresponding to the play point is a key frame, and the first key frame is: the key frame corresponding to the playing point, that is, the key frame whose decoding time searched from the time of the media data (that is, the corresponding relationship between the sequence number represented by the media information and the decoding time of the frame) is aligned with the start time of the given period.

Case 3) the video frame corresponding to the end time of the given period is a normal frame, and the second key frame is: the key frame whose decoding time is later than the end time of the given period and is closest to the end time is decoded.

in the above cases 1) and 3), the key frame crossing the playing point is used as the end point of the media data in a given period, so that it can be ensured that the video frame corresponding to the playing point has enough information for correct decoding, and frame skipping due to lack of decoded data (i.e. key frame) does not occur.

Case 4) the video frame corresponding to the end time of the given period is a key frame, and the second key frame is: the key frames that are time aligned with the end time of a given period are decoded.

in the cases 2) and 4), the media data to be acquired is defined by aligning the key frames of the playing points, so that on the premise that the playing points can be correctly decoded, the situation of acquiring unnecessary media data is reduced to the maximum extent, occupation of connection and flow is reduced, and real-time performance of non-media playing services in the webpage is further ensured.

In some embodiments, an alternative process flow for extracting media data between a first key frame and a second key frame from a media file, as shown in fig. 7, comprises the steps of:

Step S1021, extracting a video frame between the first key frame and the second key frame from the media file.

Step S1022, find out a first audio frame whose decoding time is before the decoding time of the first key frame and is closest to the decoding time of the first key frame, and a second audio frame whose decoding time is after the decoding time of the second key frame and is closest to the decoding time of the second key frame.

In step S1023, audio frames between the first audio frame and the second audio frame are extracted from the media file.

The video frames between the first key frames and the second key frames and the audio frames between the first audio frames and the second audio frames together constitute the media data between the first key frames and the second key frames.

In some embodiments, when the media file is in a non-streaming media package format, (i.e., MPEG-4 file format, also referred to herein simply as MP4), the extracted media data, and corresponding metadata, are filled into a container of segmented media files, resulting in corresponding segmented media files.

Here, the media data includes video frames and audio frames.

In some embodiments, the player obtains media data corresponding to a given time period from the server, where the given time period is used for continuing a playback point, and encapsulates the media data according to the media data and metadata describing the media data according to an encapsulation structure of the segmented media file, so as to form a segmented media file that can be used for being independently decoded by media elements of the web page.

Referring to fig. 8, fig. 8 is an alternative flow chart of packaging segmented media files provided by the disclosed example, which will be described in conjunction with the steps shown in fig. 8.

and S media, filling data representing the type and compatibility of the segmented media files into a file type container of the segmented media files.

For example, taking as an example an FMP4 file packaged to form a package structure as shown in fig. 4, the type and length of a container (representing the entire length of the ftypbox) are filled in the header of the file type container of the FMP4 file, that is, the ftypbox, and data (binary data) representing that the file type is FMP4 and a compatible protocol is generated by filling in the data portion of the ftypbox.

Step S202, filling metadata indicating a file level of the segmented media file into a metadata container of the segmented media file.

in some embodiments, the metadata describing the media data required to fill the nested structure is calculated from the nested structure of the metadata container in the segmented media file, based on the media data to be filled into the encapsulation structure of the segmented media file.

Still taking fig. 4 as an example, metadata representing the file level of the FMP4 file is calculated and filled into a metadata container (i.e., moov box) of the FMP4, in which three containers of mvhd, track, and video extension (mvex) are nested.

Wherein, the metadata packaged in the mvhd container is used for representing the media information related to the playing of the segmented media file, including the position, the duration, the creation time, the modification time, and the like; the sub-containers nested in the track container represent references and descriptions of corresponding tracks in the media data, for example, a container (denoted as tkhd box) in which characteristics and overall information (such as duration and width) describing the tracks, and a container (denoted as mdia box) in which media information (such as information of media type and sample) of the tracks are nested in the track container.

Step S203, correspondingly filling the extracted media data and the metadata describing the media data into a media data container and a metadata container at a segment level in a segment container of the segmented media file.

In some embodiments, one or more segments (fragments) may be encapsulated in a segmented media file, and for media data to be filled, one or more segmented media data containers (i.e., mdat boxes) of the segmented media file may be filled, and a segment-level metadata container (denoted as moof box) is encapsulated in each segment, wherein the filled metadata is used to describe the media data filled in the segment, so that the segments can be independently decoded.

In conjunction with fig. 4, for example, the media data to be filled is filled into 2 segments of the packaging structure of the FMP4 file, and each segment is filled with the media data; the metadata that needs to be filled into the metadata container (i.e., moof box) of the segmentation level of the corresponding segment is calculated and correspondingly filled into the child containers nested in the moof box, wherein the head of the moof box is called moof box, and the filled binary data is used to indicate the type of the container as "moof box" and the length of the moof box.

In some embodiments of filling data into the corresponding container in steps S201 to S203, when the filling operation is performed, the write operation function of the calling class completes writing and merging of binary data in the memory buffer of the child container, and returns an instance of the class, where the returned instance is used to merge the child container with the child container having the nested relationship.

as an example of the stuffing data, a class MP4 for implementing a package function is established, and each sub-container in the segmented media file is packaged as a static method of class Stream; establishing class streams for realizing binary data operation functions, wherein each class Stream is provided with a memory buffer area for storing binary data to be filled; converting multi-byte decimal data to be padded into binary data by a static method provided by Stream; merging and filling binary data to be filled into the sub-containers in the memory buffer area through a write operation function provided by the Stream-like instance; the static method provided by Stream returns a new Stream instance, and the merging of the current child container and other child containers with nested relation can be realized.

Before the encapsulation of the segmented media file, metadata of the media data to be filled needs to be calculated, which needs to be calculated in combination with metadata in the media file to obtain metadata at the level of the segmented media file (for example, corresponding to metadata filled into moov box for FMP4 file), and metadata at the level of the segments in the segmented media file (for example, corresponding to metadata filled into moof box for FMP4 file).

In the following, an exemplary implementation is described in which metadata encapsulated in a metadata container of a media file is parsed to obtain media information describing media data encapsulated in a media data container of the media file.

in some embodiments of the present disclosure, the media file is an MP4 file, the nested structure of the sub-containers in the metadata container of the media file is parsed, and binary data in each sub-container is read according to the nested structure; and analyzing the media information of the media data represented by each sub-container from the read binary data.

With reference to the structure shown in fig. 2, the moov container of the MP4 file is a nested structure, the nested structure of the sub-containers in the metadata container is parsed, the sub-containers nested in the moov container, such as the mvhd container, the audio track container, and the video track container, are determined, if the sub-containers are also nested with containers, the parsing continues until the sub-containers are parsed, the binary data encapsulated in the corresponding sub-containers are read, and the media message represented by the binary data, such as the sequence number of the key frame in the media file recorded by the stss box, the volume (i.e., size) of each sample in the media file recorded by the stsz box, is parsed.

In some embodiments of the present disclosure, a manner is provided by which the parser is set according to the container type, and the child containers in the metadata container are parsed according to the container type, so as to obtain the media information, which will be described in conjunction with fig. 9.

Referring to fig. 9, fig. 9 is an alternative flowchart for parsing media information from a metadata container according to an embodiment of the present disclosure, which will be described with reference to the steps shown in fig. 9.

Step S301 locates the position of the metadata container in the media file.

In some embodiments, by reading binary data from the binary data of the media file that conforms to the container header specification, the offset and the size of the metadata container in the media file are located according to the type and length of the container identified in the read binary data.

For example, for binary data of a media file, binary data starting from zero bytes corresponds to a file type container, the starting position of the binary data of the media file is read through the specified length of the container header, the binary data conforming to the specified length of the container header is read, and the type and length of a container located behind the file type container in the media file can be determined by parsing the read binary data.

if the parsed type is a file type container, the length (i.e., capacity) of the metadata container can be parsed, and the offset of the metadata container is the length of the file type container.

If the parsed type is a media data container, the binary data conforming to the canonical length of the container header is continuously read according to the length of the media data container and the length of the classified type container as offsets, so that the length (i.e., the capacity) of the metadata container can be parsed, wherein the length of the metadata container is the sum of the length of the file type container and the length of the media data container.

the media file has no specification except that the initial container is a file type container, and the packaging sequence of the subsequent container is not specified, so that the positions of the file type container in the media file can be accurately and efficiently located no matter whether the packaging sequence of the container in the media file is the file type container, the metadata container and the media data container or the file type container, the media data container and the metadata container.

Step S302, according to the position of the metadata container in the media file, binary data corresponding to the metadata container is obtained from the binary data of the media file.

The position of the metadata container in the media file is represented by an offset and a capacity, the binary data is read from the media file at the position corresponding to the offset until the length of the read binary data conforms to the capacity of the metadata container, and therefore the binary data corresponding to the metadata container is read.

Step S303, sequentially analyzing binary data corresponding to the specified length of the container header in the binary data of the metadata container to obtain the container type of the child container in the metadata container and the length of the container data of the child container.

in some embodiments, for the case where multiple sub-containers are nested in a metadata container, the offset of each reading of binary data is the sum of the lengths of the sub-containers that have been identified, and the length of the read binary data conforms to the canonical length of the container header, so that the type and length of the currently processed sub-container can be parsed.

For example, when reading for the first time, the binary data is read from zero bytes of the binary data of the metadata container, and the length of the read binary data conforms to the specified length of the container header, so that the type and length of the first sub-container can be parsed; and in the second reading, the binary data is read by taking the length of the first read sub-container as an offset, and the length of the read binary data conforms to the specified length of the container header, so that the type and the length of the second sub-container can be analyzed.

The binary data is read in the mode, the condition of backspacing caused by multi-reading can not occur, the condition of secondary reading caused by less reading can not occur, and the analysis efficiency and the accuracy can be ensured.

And step S304, calling a parser with a type corresponding to the container type of the sub-container, and sequentially parsing binary data corresponding to the length of the container data in the unresolved data to obtain the media information represented by the container data.

in some embodiments, a typical container type nested in a metadata container is pre-marked for indicating whether the container is directly used for packaging binary data or is further packaged with a container, for example, a container is further packaged with a mark such as mvhd box, audio track box, and video track box shown in fig. 2, and a container is directly packaged with binary data with a mark such as stts box, stsd box shown in fig. 2.

Setting parsers corresponding to the container types one by one for the container types marked as directly encapsulating the binary data, wherein the parsers are used for parsing the represented media information according to the binary data; in step S304, when the container type of the child container parsed in step S303 is compared with the pre-marked container type, the following two cases are involved.

case 1) when the container type of the child container is determined to be pre-marked by comparison and pre-marked for directly encapsulating binary data, a parser corresponding to the container type of the child container is called, and the container data in the child container is parsed by the parser, so that the media information represented by the container data is obtained.

case 2) when it is determined by the comparison that the container type of the child container is pre-marked and pre-marked for continuously packaging the container, recursively parsing the binary data corresponding to the child container according to the canonical length of the container header in the media file until it is parsed that the container type of the container packaged in the child container is pre-marked and pre-marked for directly packaging the binary data, calling a parser corresponding to the container type of the container packaged in the child container, parsing the binary data byte by byte, the length of the parsed binary data corresponding to the length of the container data of the container packaged in the child container, to obtain the media information represented by the container data of the container packaged in the child container.

in some embodiments, a method for recording media information during parsing a metadata container is described, where binary data corresponding to a canonical length of a container header in binary data of the metadata container is sequentially parsed to obtain a container type of a child container in the metadata container, an object is established according to a nesting relationship between the child container and an attributed container and a nesting relationship between the child container and an encapsulated container, and when the container type of the child container is pre-marked to be used for directly encapsulating the binary data, an array including the media information is stored in the object established in the corresponding child container, where the stored media information is represented by the container data of the child container.

For example, in fig. 2, when the type of the parsed sub-container is stts box, since the stts box is pre-marked as direct package binary data, an array including media information is stored in an object created corresponding to the stts box, where the media information is duration information represented by container data of the stts box.

in some embodiments, the manner of recording the nesting relationship between the child containers in the process of parsing the metadata container is described in that when binary data corresponding to a canonical length of a container header in the binary data of the metadata container is sequentially parsed to obtain a container type of the child container in the metadata container, if the container type is pre-marked as directly encapsulating the binary data, the parsed child container is recorded in a invoked parser; and setting the recorded instances of the child containers into child container attributes, wherein the child container attributes are included in the containers to which the child containers belong, and are used for describing the nesting relation between the child containers and the belonged containers.

for example, in fig. 2, when the type of the parsed sub-container is stsd box, since stsd box is pre-marked as directly encapsulating binary data, stsd box is recorded in the parser corresponding to the stsd box, an instance of stsd box is set to the stbl box sub-container attribute, and so on, and finally a plurality of sub-containers nested in stbl box, such as stsd box, stts box, stsc box, etc., are recorded in the sub-container attribute of stsd box.

In some embodiments, when the container type of the sub-container is not pre-marked or the container type of the sub-container is pre-marked to directly package the binary data but a parser of the corresponding type is not called, the binary data corresponding to the sub-container is ignored for parsing, and according to the length of the sub-container, a part of the binary data corresponding to a next sub-container is jumped to for parsing.

In fact, the user-defined container type can appear in the media file, the progress of the overall analysis of the metadata container can not be influenced in a skipping mode, meanwhile, when the container type of the metadata container changes, the latest metadata container can be compatible and analyzed quickly by adding, deleting and modifying analyzers of corresponding types, and the media file has the characteristic of flexible and quick upgrading.

Step S103, loading the acquired segmented media file by the player.

when the player is implemented in the form of APP, loading the acquired segmented media file by the player means loading the acquired segmented media file into a cache of the player APP. When the player is implemented in the form of an H5 player, and the Media file is in a file format that does not support streaming Media (also referred to as MP4 file herein for short), loading the acquired segmented Media file by the player means that the H5 player sends the segmented Media file to an MSE interface, the MSE interface creates a Media Source object as a Source of a virtual Uniform Resource Locator (URL), creates a Buffer object (Source Buffer) as a Buffer of the Media Source, and adds Media data (including video frames and audio frames) corresponding to the segmented Media file to the Buffer object; calling a media element of the webpage to play the virtual URL; here, the media element is an audio/video tag.

here, the web page may be a web page of a browser, or a web page of an APP in which a browser kernel is embedded.

In one embodiment, when the selected segmented media file is determined through human-computer interaction, an optional process flow of loading the acquired segmented media file through a player is shown in fig. 10, and includes the following steps:

In step S1031, the user selects a play time point.

In some embodiments, the user selects a play time point by triggering a play point on the player's progress.

In step S1032, the player determines the playing time period to which the selected playing time point belongs.

The player determines the time stamp interval to which the play time point selected by the user belongs.

In step S1033, the player loads the segmented media file corresponding to the determined playing time period.

In another embodiment, when the selected segmented media file is not determined through human-computer interaction, the at least one segmented media file is sequentially loaded through the player according to the starting time of the timestamp corresponding to the acquired at least one segmented media file.

here, when there are a plurality of segmented media files after the play point, all of the segmented media files after the play point are not loaded at the same time, that is, only a part of the segmented media files after the play point are loaded. When there is only one segmented media file after the play point, the segmented media file is loaded.

it should be noted that the media file loading control method provided by the embodiment of the present disclosure may be implemented by a player.

the process of the player sending the segmented media file to the media source extension interface of the web page to the media element of the web page for decoding and playing will be described continuously.

referring to fig. 11, it is a schematic flowchart of a process that a player sends a segmented media file to a media element of a web page through a media source extension interface of the web page for decoding and playing, and the steps shown in fig. 11 will be described.

Step S401, the player adds the segmented media file to the media source object in the media resource extension interface.

Referring to fig. 12, fig. 12 is an optional schematic diagram of a player playing a segmented Media file through a Media Source extension interface of a web page according to an embodiment of the present disclosure, where when the player receives a play event of the Media file at a play window (corresponding to the play window) in the web page, the player creates a Media Source object by executing a Media Source method; executing an addSource buffer method packaged in a media source expansion interface to create a buffer of a MediaSource object, namely a Source buffer (Source buffer) object, wherein one MediaSource object has one or more Source buffer objects, and each Source buffer object can be used for corresponding to a playing window in a webpage and is used for receiving a segmented media file to be played in the window.

in the process of playing the media file, a Parser (Parser) in the player continuously constructs a new segmented media file by parsing newly acquired media data, and adds the segmented media file to a SourceBuffer object of the same SourceBuffer object by executing an appndbuffer method of the SourceBuffer object.

Step S402, the player calls the media resource expansion interface to create a virtual address corresponding to the media source object.

For example, the player executes the createObjectURL method encapsulated in the media source extension interface, and creates a virtual address, i.e. a virtual URL, of the corresponding media source object, in which the Blob-type segmented media file is encapsulated.

In addition, the player sets the MediaSource object as the source (src) attribute of the virtual URL, i.e., binds the virtual URL with a media element in the web page, such as a video/audio element, which is also referred to as associating the media source object to the media element in the web page.

In step S403, the player transmits a virtual address to the media element of the web page, where the virtual address is used for the media element to play with the media source object as a data source.

For example, the player includes a statement that calls the media element to play the virtual URL, such as: < audio > virtual URL. When the browser interprets the corresponding statement in the player embedded in the webpage, the media element of the browser reads the segmented media file from the SourceBuffer object bound by the virtual URL, and decodes and plays the segmented media file.

the following describes a process in which the player converts the MP4 file into the FMP4 file and plays the web page through the media source extension interface.

referring to fig. 13, fig. 13 is a schematic diagram of the MP4 file converted into the FMP4 file and played through the media source extension interface according to the embodiment of the disclosure, where the player requests to obtain part of the media data in the MP4 file from the server based on the real address (http:// www.toutiao.com/a/b. MP4) of the media file, for example, the data with decoding time at a given time period for continuing to the playing point.

The player constructs an FMP4 file based on the acquired media data, and then adds the FMP4 file to a Source buffer object corresponding to the MediaSource object, because the virtual URL is bound to the MediaSource object, when the player calls the code of the audio/video element to be executed, the audio/video element reads a new FMP4 file which is added continuously from the Source buffer object of the MediaSource object, decodes the new FMP4 file, and realizes the continuous playing of the media file.

As shown in fig. 14, the optional processing flow of the media file loading control method applied to a player according to the embodiment of the present disclosure includes the following steps:

In step S501, the player detects a playing point reached in the process of playing the media file.

Step S502, the player obtains the segmented media file between the two timestamps of which the playing time is later than the playing point from the server.

in step S503, the player preloads the acquired segmented media file.

In step S504, in response to a request for changing the display resolution from the user, the player determines a third timestamp and a fourth timestamp corresponding to the time of receiving the request.

In one embodiment, the player receives a user-triggered request to change the display resolution of a media file, and determines a third timestamp corresponding to the time of receiving the request and a fourth timestamp corresponding to the end time of the currently played segmented media file.

Here, the fourth timestamp is not earlier than the play end time of the currently played segmented media file.

In step S505, the player obtains a new segmented media file from the server, where the playing time is between the third timestamp and the second time point and is the target resolution of the switch.

in one embodiment, the player searches for a third video frame whose decoding time is after the third timestamp and closest to the third timestamp, and a fourth video frame whose decoding time is before the fourth timestamp and closest to the fourth timestamp; and the player extracts the video frame between the third video frame and the fourth video frame from the media file stored by the server to be used as a new segmented media file, and the new segmented media file is played at the requested target resolution.

In step S506, the player loads the acquired new segmented media file to replace the segmented media file of the original resolution.

in the embodiment of the present disclosure, the form of the player may be an H5 player embedded in a web page, or may be a dedicated video playing APP.

Based on the above media file loading control method, an embodiment of the present disclosure further provides a media file loading control device, where a composition structure of the media file loading control device 800, as shown in fig. 15, includes:

A detecting unit 801, configured to detect a playing point reached by a player in a process of playing a media file;

An obtaining unit 802, configured to obtain a segmented media file between two timestamps of which the playing time is later than a playing point to which the segmented media file belongs, where the two timestamps form a playing time period of the segmented media file;

A loading unit 803, configured to preload the acquired segmented media file by the player.

In some embodiments, the media file is divided into a plurality of segmented media files by the timestamp based on a play duration, or the media file is divided into a plurality of segmented media files by the timestamp based on a play duration located after the play point.

in some embodiments, the timestamp information of the media file is obtained from a server and set by the server according to historical play data of the media file.

In some embodiments, the information of the timestamp is set by the player when the player starts playing the media file.

In some embodiments, the two timestamps include a first timestamp and a second timestamp that is later than the first timestamp.

The obtaining unit 802 is configured to search for a first key frame whose decoding time is before a first timestamp and is closest to the first timestamp, and a second key frame whose decoding time is after a second timestamp and is closest to an end time point of the second timestamp;

Extracting media data between the first key frame and the second key frame from the media file.

in some embodiments, the obtaining unit 802 is configured to extract a video frame between the first key frame and the second key frame from the media file;

Searching a first audio frame with the decoding time before the decoding time of the first key frame and closest to the decoding time of the first key frame, and a second audio frame with the decoding time after the decoding time of the second key frame and closest to the decoding time of the second key frame;

Extracting audio frames between the first audio frame and the second audio frame from the media file.

In some embodiments, the loading unit 803 is configured to, when the player runs in a manner embedded in the webpage,

And sending the segmented media file to a media resource expansion interface, wherein the media resource expansion interface is used for enabling the player to call the media elements of the webpage to play the segmented media file.

In some embodiments, the obtaining unit 802 is configured to, when the media file is in a non-streaming media packaging format,

Extracting media data between the two timestamps from the media file;

And filling the extracted media data and the corresponding metadata into a container of the segmented media file to obtain the corresponding segmented media file.

In some embodiments, the loading unit 803 is configured to respond to an operation of selecting a playing time point;

determining the playing time period to which the selected playing time point belongs;

And loading the segmented media file corresponding to the determined playing time period through the player.

in some embodiments, the loading unit 803 is configured to, when the selected segmented media file is not determined through human-computer interaction,

and sequentially loading the at least one segmented media file through the player according to the starting time of the timestamp corresponding to the acquired at least one segmented media file.

an embodiment of the present disclosure further provides a media file loading control device, including:

a memory for storing executable instructions;

And the processor is used for realizing the media file loading control method by executing the executable instructions stored in the memory.

In the embodiment of the present disclosure, the media file loading control device may be implemented as a player, and the form of the player may be an H5 player embedded in a web page, or may be a dedicated video playing APP.

The embodiment of the present disclosure further provides a storage medium, where the storage medium stores computer-executable instructions, and the computer-executable instructions are used to execute the media file loading control method.

in summary, the above embodiments of the present disclosure have the following advantages:

1. the media file is divided in advance to obtain a plurality of media file segments, and the player loads part of the media file segments after the playing point or loads only one media file segment after the playing point, so that when a user selectively watches the media file segments loaded after the playing point, the player loads the media file segments after the playing point in advance, and the consumption of flow can be avoided.

2. When a given time interval of the media file needs to be played, only the media data of a given time needs to be extracted from the media file in the non-streaming media format and packaged into the segmented media file which can be independently decoded, and by the mode, on one hand, the limitation that the non-streaming media format file can be independently played after being completely downloaded is overcome, and the playing real-time performance is good; on the other hand, because the segmented media file is only required to be constructed for a given time period, rather than the complete media file is converted into the streaming media format in advance, the conversion delay is small, and therefore the segmented media file does not need to be stored in advance, the original media file does not occupy additional storage space, and the occupation of the storage space is obviously reduced.

3. The media data in the media file in the non-streaming media format is converted into the segmented media file, and the segmented media file is sent to the media element of the webpage for decoding and playing through the media source expansion interface of the webpage, so that the player can play the media file in the non-streaming media format through the embedded webpage, and the limitation that the file in the non-streaming media packaging format can be independently played after being completely downloaded is overcome.

4. The player acquires partial media data among the key frames of the media file, and the control of loading the media data in the process of playing the media file is realized.

5. The segmented media file obtained by encapsulation is based on partial media data of the obtained media file, but not all data of the media file, so that conversion delay is small, pre-storage is not needed, no additional storage space is occupied except for the original media file, occupation of the storage space is remarkably reduced, black screen or blockage can not occur when resolution ratio switching is carried out in the watching process of a user, and instantaneity of resolution ratio switching is improved.

6. The media elements of the webpage acquire the segmented media file based on the virtual address for decoding and playing, and not acquire and play the media data based on the real address of the media file, so that the real address of the MP4 file is protected.

the above description is only for the specific embodiments of the present disclosure, but the scope of the present disclosure is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present disclosure, and all the changes or substitutions should be covered within the scope of the present disclosure. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.

29页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:基于参数封装的媒体文件播放方法、装置及存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类