WO2018086303A1 - Advertisement inter-cut method and device, and readable storage medium - Google Patents

Advertisement inter-cut method and device, and readable storage medium Download PDF

Info

Publication number
WO2018086303A1
WO2018086303A1 PCT/CN2017/079592 CN2017079592W WO2018086303A1 WO 2018086303 A1 WO2018086303 A1 WO 2018086303A1 CN 2017079592 W CN2017079592 W CN 2017079592W WO 2018086303 A1 WO2018086303 A1 WO 2018086303A1
Authority
WO
WIPO (PCT)
Prior art keywords
advertisement
audio
video
data packet
thread
Prior art date
Application number
PCT/CN2017/079592
Other languages
French (fr)
Chinese (zh)
Inventor
宋明胜
Original Assignee
武汉斗鱼网络科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 武汉斗鱼网络科技有限公司 filed Critical 武汉斗鱼网络科技有限公司
Publication of WO2018086303A1 publication Critical patent/WO2018086303A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/433Content storage operation, e.g. storage operation in response to a pause request, caching operations
    • H04N21/4331Caching operations, e.g. of an advertisement for later insertion during playback
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/433Content storage operation, e.g. storage operation in response to a pause request, caching operations
    • H04N21/4333Processing operations in response to a pause request
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs
    • H04N21/44004Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving video buffer management, e.g. video decoder buffer or video display buffer
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs
    • H04N21/44008Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving operations for analysing video streams, e.g. detecting features or characteristics in the video stream
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/45Management operations performed by the client for facilitating the reception of or the interaction with the content or administrating data related to the end-user or to the client device itself, e.g. learning user preferences for recommending movies, resolving scheduling conflicts
    • H04N21/458Scheduling content for creating a personalised stream, e.g. by combining a locally stored advertisement with an incoming stream; Updating operations, e.g. for OS modules ; time-related management operations
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/80Generation or processing of content or additional data by content creator independently of the distribution process; Content per se
    • H04N21/81Monomedia components thereof
    • H04N21/812Monomedia components thereof involving advertisement data

Definitions

  • the present invention relates to the field of multimedia playback technologies, and in particular, to an advertisement insertion method, apparatus, and readable storage medium.
  • one method in the prior art is to re-encode video advertisements and video positives into one video, and then play them in a normal manner, but in decoding and re-writing
  • Another way is to pre-load video advertisements while playing video positives, and then switch to video advertisements for playback when video advertisements need to be inserted.
  • preloading video ads consumes a limited amount of bandwidth resources, which can easily lead to poor video playback.
  • an embodiment of the present invention provides an advertisement insertion method, where the method includes:
  • the media loading thread caches the positive media data and plays through the playing thread, when receiving the commercial insertion instruction, suspending the subsequent data of the positive media data by the media loading thread and causing the playing thread to continue playing has been Cache the positive media data;
  • the playing thread plays the already-captured positive media data
  • the playing thread is caused to play the advertising audio sample and the advertising video frame.
  • the embodiment of the present invention provides the first possible implementation manner of the foregoing first aspect, wherein the decoding of the advertisement media data by the decoding thread to obtain the advertisement audio sample and the advertisement video frame includes:
  • the embodiment of the present invention provides the second possible implementation manner of the foregoing first aspect, wherein the playing the playback thread and the advertisement video frame by the playing thread includes:
  • the audio play thread is caused to play the advertisement audio sample, causing the video play thread to play the advertisement video frame.
  • the embodiment of the present invention provides a third possible implementation manner of the foregoing first aspect, wherein, before the obtaining, by the media loading thread, the advertisement media data corresponding to the advertisement insertion instruction, :
  • the audio decoder configuration parameters and video decoder configuration parameters are parsed according to the format type of the advertising media stream.
  • the embodiment of the present invention provides the fourth possible implementation manner of the foregoing first aspect, wherein the media loading thread acquires an advertising medium corresponding to the advertisement insertion instruction. After the data, it also includes:
  • the advertisement audio data package and the advertisement video data package are parsed from the advertisement media data, and the parsed first advertisement audio data package and the first advertisement video data package are marked.
  • the embodiment of the present invention provides the fifth possible implementation manner of the foregoing first aspect, wherein the first advertisement audio data packet and the first advertisement are parsed by the mark Video packets, including:
  • An audio decoder configuration parameter is inserted in the first advertisement audio data packet, and a video decoder configuration parameter is inserted in the first advertisement video data packet.
  • the embodiment of the present invention provides the sixth possible implementation manner of the foregoing first aspect, wherein the decoding the advertisement media data by the decoding thread to obtain an advertisement audio sample And advertising video frames, including:
  • the advertisement audio data packet is the first advertisement audio data packet
  • the advertisement video data packet is the first advertisement video data packet
  • the parameter initializes the audio decoder, and initializes the video decoder according to the video decoder configuration parameter in the first advertisement video data packet
  • the embodiment of the present invention provides the seventh possible implementation manner of the foregoing first aspect, wherein, after the playing thread plays the cached media media data, the playing thread is caused to play the Advertising audio samples and the advertising video frames, including:
  • the configuration parameters of the current advertisement audio sample and the configuration parameters of the previous audio sample, and the current advertisement video frame are compared with the configuration parameters of the previous video frame, the configuration parameters of the audio sample include the number of samples of the audio sample, the sampling rate, and the number of channels, and the configuration parameters of the video frame include the color of the video frame. , format and width;
  • the embodiment of the present invention provides the eighth possible implementation manner of the foregoing first aspect, wherein the method further includes:
  • the positive media data or the advertisement media data currently being played is exited.
  • an advertisement insertion device where the device includes:
  • a loading module configured to cache the positive media data by the media loading thread; and configured to suspend subsequent data of the positive media data by the media loading thread according to the commercial insertion instruction, and obtain an advertisement corresponding to the commercial insertion instruction Media data;
  • a decoding module configured to decode the advertisement media data by the decoding thread to obtain an advertisement audio sample and an advertisement video frame
  • a playing module configured to play the positive media data cached by the media loading thread by the playing thread; and configured to cause the playing thread to play the advertisement after the playing thread plays the already-captured positive media data Audio samples and the advertising video frames.
  • the decoding module includes:
  • An audio decoding submodule configured to decode an advertisement audio data packet in the advertisement media data by an audio decoding thread to obtain the advertisement audio sample
  • the video decoding sub-module is configured to decode the advertisement video data packet in the advertisement media data by using a video decoding thread to obtain the advertisement video frame.
  • the embodiment of the present invention provides the second possible implementation manner of the foregoing second aspect, wherein the manner in which the playing module plays the advertisement audio sample and the advertisement video frame includes:
  • the audio play thread is caused to play the advertisement audio sample, causing the video play thread to play the advertisement video frame.
  • the embodiment of the present invention provides a third possible implementation manner of the foregoing second aspect, wherein the device further includes:
  • the determining module is configured to open an advertisement media stream corresponding to the advertisement insertion instruction by using the media loading thread, and parse a header byte of the advertisement media stream, and determine a format type of the advertisement media stream;
  • the parameter obtaining module is configured to obtain the audio decoder configuration parameter and the video decoder configuration parameter according to the format type of the advertisement media stream.
  • the embodiment of the present invention provides the fourth possible implementation manner of the foregoing second aspect, where the device also includes:
  • the marking module is configured to parse the advertisement audio data package and the advertisement video data package from the advertisement media data, and mark the parsed first advertisement audio data package and the first advertisement video data package.
  • the marking module includes:
  • a field setting submodule configured to set an attribute of the first advertisement audio data packet and a tag field of the first advertisement video data packet to true
  • a parameter insertion sub-module configured to insert an audio decoder configuration parameter in the first advertisement audio data packet, and insert a video decoder configuration parameter in the first advertisement video data packet.
  • the embodiment of the present invention provides a sixth possible implementation manner of the foregoing second aspect, wherein the decoding module obtains an advertisement audio sample and an advertisement video frame, including:
  • the advertisement audio data packet is the first advertisement audio data packet
  • the advertisement video data packet is the first advertisement video data packet
  • the parameter initializes the audio decoder, and initializes the video decoder according to the video decoder configuration parameter in the first advertisement video data packet
  • the embodiment of the present invention provides the seventh possible implementation manner of the foregoing second aspect, wherein the manner in which the playing module plays the advertisement audio sample and the advertisement video frame includes:
  • the configuration parameters of the audio sample including the audio sample
  • the number of sampling bits, the sampling rate, and the number of channels, and the configuration parameters of the video frame include the color, format, and width and height of the video frame
  • the embodiment of the present invention provides the eighth possible implementation manner of the foregoing second aspect, wherein the device further includes:
  • the exit module is configured to quit the positive media data or the advertisement media data currently being played after receiving the exit play instruction.
  • an embodiment of the present invention provides a readable storage medium stored in an electronic terminal, where the readable storage medium includes a plurality of instructions, and the multiple instructions are configured to implement the advertisement insertion method. .
  • the advertisement insertion method and device provided by the embodiments of the present invention do not cause loading delay and black screen when inserting advertisements, and avoid unnecessary occurrence of additional consumption of server resources and video film playback.
  • FIG. 1 is a flowchart of an advertisement insertion method provided by Embodiment 1 of the present invention.
  • FIG. 2 is a flowchart of decoding advertisement media data in an advertisement insertion method according to Embodiment 1 of the present invention
  • FIG. 3 is a flowchart of playing an advertisement audio sample and an advertisement video frame in an advertisement insertion method according to Embodiment 1 of the present invention
  • FIG. 4 is a schematic structural diagram of an advertisement insertion apparatus according to Embodiment 2 of the present invention.
  • an embodiment of the present invention provides an advertisement insertion method and apparatus, which are described below by way of embodiments.
  • An embodiment of the present invention provides an advertisement insertion method, as shown in FIG. 1 , when the advertisement is inserted by using the method.
  • Steps S110-S130 are as follows.
  • the advertisement insertion method provided by the embodiment of the invention is implemented by multi-threading, the media loading thread acquires the media data, the decoding thread decodes the obtained media data, and the playing thread plays the decoded media data.
  • the execution body of the advertisement insertion method in the embodiment of the present invention may be a video player on the terminal, and the terminal may be, but not limited to, a mobile phone, a computer, a tablet computer, or the like.
  • the advertisement insertion instruction includes the name of the advertisement to be inserted or other identifier capable of accurately indicating the advertisement to be inserted and the time of the advertisement insertion. For example, after receiving the advertisement insertion instruction, the advertisement insertion is immediately executed, and when the player receives the advertisement, the player inserts the advertisement. After the advertisement insertion instruction, the subsequent data of the thread positive media data is suspended through the media, and the playback thread continues to play the already-captured positive media data.
  • the advertisement media data and the positive media data are all media streams.
  • the player on the terminal When the advertisement insertion instruction is received, the player on the terminal temporarily suspends the subsequent data of the positive media data through the media loading thread, and at the same time, obtains the advertisement media data corresponding to the commercial insertion instruction through the media loading thread.
  • the player on the terminal can obtain the advertisement media data and the positive media data that need to be played from the same server, and can also obtain the advertisement media data and the positive media data that need to be played from different servers respectively.
  • suspending obtaining the subsequent data of the positive media data currently being played may be implemented by disconnecting the connection with the current server, and at the same time, in order to obtain and The advertisement media data corresponding to the advertisement play instruction is established by establishing a connection with the advertisement video server.
  • connection with the current server needs to be disconnected, and then the connection with the current server is re-established. Connection, this connection is a different connection from the last connection.
  • the method further includes: opening, by the media loading thread, an advertisement media stream corresponding to the advertisement insertion instruction, and parsing the header byte of the advertisement media stream, and determining the advertisement media.
  • the format type of the stream; the audio decoder configuration parameters and video decoder configuration parameters are parsed according to the format type of the ad media stream.
  • the format type of the above advertisement media stream may be, but not limited to, mp4, ts, and the like.
  • the foregoing may parse the configuration parameters of the audio decoder and the configuration parameters of the video decoder according to the format standard corresponding to the format type of the advertisement media stream.
  • the audio decoder configuration parameters include audio encoding type, sampling format, sampling rate, channel number, etc.
  • video decoder configuration parameters include encoding type, width, height, and color format of the video.
  • the media loading thread acquires the advertisement media data corresponding to the advertisement insertion instruction
  • the advertisement audio data package and the advertisement video data package are parsed from the advertisement media data, and the parsed first advertisement audio data package and the first advertisement video data package are marked.
  • the advertisement audio data package is not the first advertisement audio data package, and the advertisement video data package is not the first advertisement video data package, The advertisement audio data packet is cached in the advertisement audio data packet queue, and the advertisement video data package is cached in the advertisement video data packet queue. If the advertisement audio data package is the first advertisement audio data package, the first advertisement audio data package is marked. If the above advertisement video data packet is the first advertisement video data package, mark the first advertisement video data package.
  • the first advertisement audio data packet and the first advertisement video data packet parsed by the foregoing markings include: setting an attribute of a mark field of the first advertisement audio data packet and the first advertisement video data packet to true; in the first The audio decoder configuration parameters are inserted into the advertisement audio data packet, and the video decoder configuration parameters are inserted in the first advertisement video data packet.
  • the first advertisement audio data packet parsed from the advertisement media data is determined as the first advertisement audio data package, and the first advertisement video data packet parsed from the advertisement media data is determined as the first advertisement video data package.
  • the advertisement media data is then decoded by the decoding thread to obtain an advertisement audio sample and an advertisement video frame.
  • the advertisement audio data packet and the advertisement video data packet in the advertisement media data may be implemented by different threads. Specifically, the advertisement audio data packet in the advertisement media data is decoded by the audio decoding thread to obtain an advertisement audio sample. The advertisement video data packet in the advertisement media data is decoded by the video decoding thread to obtain an advertisement video frame.
  • the advertisement audio sample and the advertisement video frame are obtained by decoding the advertisement media data by the decoding thread, and specifically includes:
  • the audio decoder is initialized according to the audio decoder configuration parameter in the first advertisement audio data packet.
  • the video decoder is initialized based on the video decoder configuration parameters in the first advertisement video packet.
  • S230 Decode the advertisement audio data packet according to the initialized audio decoder, obtain an advertisement audio sample, and decode the advertisement video data packet according to the initialized video decoder to obtain an advertisement video frame.
  • determining whether the advertisement audio data packet in the current advertisement media data is the first advertisement audio data packet may determine whether the attribute of the mark field of the advertisement audio data package is true, if the attribute of the mark field of the advertisement audio data package is True, it is determined that the advertisement audio data packet is the first advertisement audio data packet. Similarly, if the advertisement video data packet in the current advertisement media data is the first advertisement video data packet, the marking field of the advertisement video data packet may be determined.
  • the attribute is a frame
  • determining that the advertisement video data packet is the first advertisement video data package and when determining that the advertisement audio data package is the first advertisement audio data package, and When the advertisement video data packet is the first advertisement video data packet, this indicates that the positive media data is decoded before, and the configuration parameters of the decoder are all set according to the positive media data, therefore, it is required to be based on the advertisement audio.
  • Audio decoder configuration parameters in the packet The audio decoder is initialized, that is the basis of well
  • the audio decoder configuration parameters in the audio data packet adjust the configuration parameters of the audio decoder and initialize the video decoder based on the video decoder configuration parameters in the advertising video data packet.
  • the configuration parameters of the audio decoder are consistent with the advertisement audio data packet, that is, the audio decoder at this time can decode the advertisement audio data packet
  • the configuration parameters of the video decoder Consistent with the advertisement video data packet that is, the video decoder at this time can decode the advertisement video data packet, decode the advertisement audio data packet according to the initialized audio decoder, obtain the advertisement audio sample, and obtain the obtained advertisement.
  • the audio sample is buffered into the advertisement audio sampling queue
  • the advertisement video data packet is decoded according to the initialized video decoder to obtain an advertisement video frame
  • the decoded advertisement video frame is buffered into the advertisement video frame queue.
  • the above advertisement audio data packet is not the first advertisement audio data package, and the above advertisement video data package is not the first advertisement video data package, it means that the advertisement audio data package and the advertisement video data package are decoded before. There is no need to initialize the audio decoder and video decoder at this time.
  • the playing thread After the playing thread plays the already-captured positive media data, the playing thread causes the playing thread to play the advertisement audio sample and the advertising video frame.
  • the playing thread will play the already-captured positive media data.
  • the playing thread starts playing the above-mentioned advertising audio decoded by the advertising media data. Sampling and advertising video frames.
  • playing the above-mentioned advertisement audio sample and advertisement video frame includes:
  • the playing thread reads the advertisement audio sample from the advertisement audio sampling queue, and reads the advertisement video frame from the advertisement video frame queue, if the configuration parameter of the currently read advertisement audio sample and the previous audio sample
  • the configuration parameters, and the configuration parameters of the currently read advertisement video frame are different from the configuration parameters of the previous video frame, indicating that the audio samples and video frames of the previous playback are positive audio samples and video frames.
  • Advertising audio sampling and advertising video frames so when playing the current advertising audio sampling and advertising video frames, it is necessary to reset the configuration parameters of the advertising audio sampling and the configuration parameters of the advertising video frame to inform the audio output system and the video output system that the video output system needs to be played. Audio samples and video frames have occurred Set change, and audio sample clock and the output clock reset output video samples and audio samples output current ad and ad video frames.
  • the advertisement insertion method provided by the embodiment of the present invention further includes:
  • the advertisement media data or the positive media data currently being played is exited.
  • the user can exit the game at any time.
  • the media loading thread receives the instruction to switch back to the positive film by the advertisement
  • the subsequent data of the advertisement media data is stopped, and the positive media data is acquired.
  • the advertisement insertion method provided by the embodiment of the present invention, after receiving the advertisement insertion instruction, the player performs the buffering of the advertisement media data while continuing to play the cached positive media data, so that the buffered positive media data is played. Once completed, you can immediately enter the decoding playback of the ad media data. In this way, there will be no load delay and black screen when inserting advertisements, and at the same time avoiding the extra consumption of server resources and the fact that the video film is not smooth.
  • the embodiment of the present invention provides an advertisement insertion device.
  • the device may include: a loading module 410, a decoding module 420, and a playing module 430;
  • the loading module 410 is configured to cache the positive media data by the media loading thread; and configured to suspend the subsequent data of the positive media data through the media loading thread according to the commercial insertion instruction, and obtain the advertising media data corresponding to the commercial insertion instruction.
  • the device may further include: a determining module and a parameter acquiring module.
  • the determining module is configured to open an advertisement media stream corresponding to the advertisement insertion instruction by using the media loading thread, and parse a header byte of the advertisement media stream to determine a format type of the advertisement media stream.
  • the parameter obtaining module is configured to obtain an audio decoder configuration parameter and a video decoder configuration parameter according to a format type of the advertisement media stream.
  • the device may further comprise a marking module.
  • the marking module is configured to parse the advertisement audio data package and the advertisement video data package from the advertisement media data, and mark the parsed first advertisement audio data package and the first advertisement video data package.
  • the marking module may include: a field setting submodule and a parameter insertion submodule.
  • the above field setting submodule is configured to set an attribute of the first advertisement audio data packet and a mark field of the first advertisement video data packet to true;
  • the parameter insertion sub-module is configured to insert an audio decoder configuration parameter into the first advertisement audio data packet, and insert a video decoder configuration parameter into the first advertisement video data packet.
  • the decoding module 420 is configured to decode the advertisement media data by the decoding thread to obtain an advertisement audio sample and an advertisement video frame.
  • the foregoing decoding module 420 may include an audio decoding submodule and a video decoding submodule.
  • the audio decoding submodule is configured to decode an advertisement audio data packet in the advertisement media data by using an audio decoding thread to obtain the advertisement audio sample.
  • the video decoding submodule is configured to decode the advertisement video data packet in the advertisement media data by using a video decoding thread to obtain the advertisement video frame.
  • the foregoing decoding module 420 obtains a manner of advertising audio samples and advertising video frames, including:
  • the advertisement audio data packet is the first advertisement audio data packet
  • the advertisement video data packet is the first advertisement video data packet
  • the parameter initializes the audio decoder, and initializes the video decoder according to the video decoder configuration parameter in the first advertisement video data packet
  • the playing module 430 is configured to play the positive media data cached by the media loading thread through the playing thread; and configured to enable the playing thread to play the advertising audio sample and the advertising video after the playing thread plays the cached positive media data. frame.
  • the manner in which the playing module 430 plays the advertisement audio sample and the advertisement video frame includes:
  • the audio play thread is caused to play the advertisement audio sample, causing the video play thread to play the advertisement video frame.
  • the manner in which the playing module 430 plays the advertisement audio sample and the advertisement video frame includes:
  • the configuration parameters of the audio sample including the audio sample
  • the number of sampling bits, the sampling rate, and the number of channels, and the configuration parameters of the video frame include the color, format, and width and height of the video frame
  • the device may further comprise an exit module.
  • the exit module is configured to, after receiving the exit play instruction, exit the positive media data or the advertisement media data currently being played.
  • the advertisement insertion device may obtain the advertisement media data and the positive media data that need to be played from the same server, and may also obtain the advertisement media data and the positive media data that need to be played from different servers.
  • the advertisement insertion instruction includes the name of the advertisement that needs to be inserted or other identifier that can accurately represent the advertisement that needs to be inserted.
  • the loading module 410 obtains the advertisement media data and the positive film media data that need to be played from different servers, suspending obtaining subsequent data of the positive media data currently being played may be disconnected from the current server.
  • the connection is implemented, and at the same time, in order to obtain the advertisement media data corresponding to the advertisement play instruction, the connection with the advertisement video server is established.
  • the loading module 410 obtains the advertisement media data and the positive media data that need to be played from the same server, after receiving the advertisement insertion instruction, the connection with the current server needs to be disconnected, and the connection with the current server is re-established. This connection is a different connection from the last connection.
  • the advertisement insertion device does not have a loading delay and a black screen when inserting an advertisement, and avoids the occurrence of additional consumption of server resources and unsmooth video playback.
  • the advertisement insertion device provided by the embodiment of the present invention may be specific hardware on the device or software or firmware installed on the device.
  • the implementation principle and the technical effects of the device provided by the embodiments of the present invention are the same as those of the foregoing method embodiments.
  • a person skilled in the art can clearly understand that for the convenience and brevity of the description, the specific working processes of the foregoing system, the device and the unit can refer to the corresponding processes in the foregoing method embodiments, and details are not described herein again.
  • the disclosed apparatus and method may be implemented in other manners.
  • the device embodiments described above are merely illustrative.
  • the division of the unit is only a logical function division.
  • multiple units or components may be combined or Can be integrated into another system, or some features can be ignored or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some communication interface, device or unit, and may be electrical, mechanical or otherwise.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in the embodiment provided by the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the functions may be stored in a computer readable storage medium if implemented in the form of a software functional unit and sold or used as a standalone product.
  • the technical solution of the present invention which is essential or contributes to the prior art, or a part of the technical solution, may be embodied in the form of a software product, which is stored in a storage medium, including
  • the instructions are used to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention.
  • the foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like. .

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Databases & Information Systems (AREA)
  • Business, Economics & Management (AREA)
  • Marketing (AREA)
  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)

Abstract

The present invention relates to the technical field of multimedia playing and provides an advertisement inter-cut method and device, and a readable storage medium. The method comprises: caching feature film media data by means of a media loading thread and during the process of playing by means of a playing thread, when an advertisement inter-cut instruction is received, suspending obtaining of subsequent data of the feature film media data by means of the media loading thread and continuing playing the cached feature film media data by means of the playing thread; obtaining advertisement media data corresponding to the advertisement inter-cut instruction by means of the media loading thread, and decoding the advertisement media data by means of a decoding thread to obtain an advertisement audio sample and an advertisement video frame; and after playing the cached feature film media data by means of the playing thread is completed, playing the advertisement audio sample and the advertisement video frame by means of the playing thread. In the present invention, loading delay and blank screen can be prevented during advertisement inter-cut, and phenomena that server resources are additionally consumed and video feature films cannot be played smoothly can be prevented.

Description

一种广告插播方法、装置及可读存储介质Advertising insertion method, device and readable storage medium
本申请要求于2016年11月14日提交中国专利局、申请号为CN201611002602.6、名称为“一种广告插播方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。The present application claims priority to Chinese Patent Application, filed on Nov. 14, 2016, the entire contents of which is hereby incorporated by reference. in.
技术领域Technical field
本发明涉及多媒体播放技术领域,具体而言,涉及一种广告插播方法、装置及可读存储介质。The present invention relates to the field of multimedia playback technologies, and in particular, to an advertisement insertion method, apparatus, and readable storage medium.
背景技术Background technique
随着互联网技术的快速发展,越来越多的用户开始在线观看视频,在线视频得到了广泛的应用,出于盈利的目的,在播放视频正片的过程中,需要插入视频广告。但是,在插入视频广告时,视频正片和视频广告之间需要进行切换,但是在进行切换时容易出现视频加载延时和黑屏的问题。With the rapid development of Internet technology, more and more users began to watch videos online, and online video has been widely used. For the purpose of profit, in the process of playing video positives, video ads need to be inserted. However, when a video ad is inserted, a switch between the video feature and the video ad needs to be switched, but the video loading delay and the black screen are prone to occur when switching.
为了解决视频正片和视频广告之间切换时产生的问题,现有技术中的一种方法是将视频广告和视频正片重新编码合并成一个视频,再按照普通的方式进行播放,但是在解码和重新编码的过程中会消耗大量的服务器资源,导致服务器资源的浪费;另一种方式,则是在播放视频正片的同时预加载视频广告,等到需要插播视频广告时,再切换到视频广告进行播放,但是,预加载视频广告会消耗有限的带宽资源,容易导致视频正片播放不流畅。In order to solve the problem that occurs when switching between video positives and video advertisements, one method in the prior art is to re-encode video advertisements and video positives into one video, and then play them in a normal manner, but in decoding and re-writing In the process of encoding, a large amount of server resources are consumed, resulting in waste of server resources. Another way is to pre-load video advertisements while playing video positives, and then switch to video advertisements for playback when video advertisements need to be inserted. However, preloading video ads consumes a limited amount of bandwidth resources, which can easily lead to poor video playback.
发明内容Summary of the invention
有鉴于此,本发明实施例的目的在于提供一种广告插播方法、装置及可读存储介质,以试图解决或者缓解上述出现的问题。In view of this, it is an object of embodiments of the present invention to provide an advertisement insertion method, apparatus, and readable storage medium in an attempt to solve or alleviate the above-mentioned problems.
第一方面,本发明实施例提供了一种广告插播方法,其中,所述方法包括:In a first aspect, an embodiment of the present invention provides an advertisement insertion method, where the method includes:
通过媒体加载线程缓存正片媒体数据并通过播放线程播放的过程中,当接收到广告插播指令时,暂停通过所述媒体加载线程获取所述正片媒体数据的后续数据以及使所述播放线程继续播放已经缓存的所述正片媒体数据;When the media loading thread caches the positive media data and plays through the playing thread, when receiving the commercial insertion instruction, suspending the subsequent data of the positive media data by the media loading thread and causing the playing thread to continue playing has been Cache the positive media data;
通过所述媒体加载线程获取与所述广告插播指令对应的广告媒体数据,通过解码线程对所述广告媒体数据解码得到广告音频采样和广告视频帧;Obtaining advertisement media data corresponding to the advertisement insertion instruction by the media loading thread, and decoding the advertisement media data by a decoding thread to obtain an advertisement audio sample and an advertisement video frame;
在所述播放线程播放已经缓存的所述正片媒体数据结束后,使所述播放线程播放所述广告音频采样和所述广告视频帧。After the playing thread plays the already-captured positive media data, the playing thread is caused to play the advertising audio sample and the advertising video frame.
结合第一方面,本发明实施例提供了上述第一方面的第一种可能的实现方式,其中,所述通过解码线程对所述广告媒体数据解码得到广告音频采样和广告视频帧,包括:With reference to the first aspect, the embodiment of the present invention provides the first possible implementation manner of the foregoing first aspect, wherein the decoding of the advertisement media data by the decoding thread to obtain the advertisement audio sample and the advertisement video frame includes:
通过音频解码线程对所述广告媒体数据中的广告音频数据包进行解码,得到所述广告音频采样;Decoding an advertisement audio data packet in the advertisement media data by an audio decoding thread to obtain the advertisement audio sample;
通过视频解码线程对所述广告媒体数据中的广告视频数据包进行解码,得到所述广告 视频帧。Decoding the advertisement video data packet in the advertisement media data by a video decoding thread to obtain the advertisement Video frame.
结合第一方面,本发明实施例提供了上述第一方面的第二种可能的实现方式,其中,所述使所述播放线程播放所述广告音频采样和所述广告视频帧,包括:With reference to the first aspect, the embodiment of the present invention provides the second possible implementation manner of the foregoing first aspect, wherein the playing the playback thread and the advertisement video frame by the playing thread includes:
使音频播放线程播放所述广告音频采样,使所述视频播放线程播放所述广告视频帧。The audio play thread is caused to play the advertisement audio sample, causing the video play thread to play the advertisement video frame.
结合第一方面,本发明实施例提供了上述第一方面的第三种可能的实现方式,其中,所述通过所述媒体加载线程获取与所述广告插播指令对应的广告媒体数据之前,还包括:With reference to the first aspect, the embodiment of the present invention provides a third possible implementation manner of the foregoing first aspect, wherein, before the obtaining, by the media loading thread, the advertisement media data corresponding to the advertisement insertion instruction, :
通过所述媒体加载线程打开与所述广告插播指令对应的广告媒体流,并解析所述广告媒体流的头部字节,判断广告媒体流的格式类型;Opening, by the media loading thread, an advertisement media stream corresponding to the advertisement insertion instruction, and parsing a header byte of the advertisement media stream, and determining a format type of the advertisement media stream;
根据所述广告媒体流的格式类型解析音频解码器配置参数和视频解码器配置参数。The audio decoder configuration parameters and video decoder configuration parameters are parsed according to the format type of the advertising media stream.
结合第一方面的第三种可能的实现方式,本发明实施例提供了上述第一方面的第四种可能的实现方式,其中,所述媒体加载线程获取与所述广告插播指令对应的广告媒体数据之后,还包括:With reference to the third possible implementation manner of the first aspect, the embodiment of the present invention provides the fourth possible implementation manner of the foregoing first aspect, wherein the media loading thread acquires an advertising medium corresponding to the advertisement insertion instruction. After the data, it also includes:
从所述广告媒体数据中解析出广告音频数据包和广告视频数据包,并标记解析出的首个广告音频数据包和首个广告视频数据包。The advertisement audio data package and the advertisement video data package are parsed from the advertisement media data, and the parsed first advertisement audio data package and the first advertisement video data package are marked.
结合第一方面的第四种可能的实现方式,本发明实施例提供了上述第一方面的第五种可能的实现方式,其中,所述标记解析出的首个广告音频数据包和首个广告视频数据包,包括:In conjunction with the fourth possible implementation of the first aspect, the embodiment of the present invention provides the fifth possible implementation manner of the foregoing first aspect, wherein the first advertisement audio data packet and the first advertisement are parsed by the mark Video packets, including:
将所述首个广告音频数据包和所述首个广告视频数据包的标记字段的属性设置为真;Setting the attribute of the first advertisement audio data packet and the tag field of the first advertisement video data packet to true;
在所述首个广告音频数据包中插入音频解码器配置参数,在所述首个广告视频数据包中插入视频解码器配置参数。An audio decoder configuration parameter is inserted in the first advertisement audio data packet, and a video decoder configuration parameter is inserted in the first advertisement video data packet.
结合第一方面的第四种可能的实现方式,本发明实施例提供了上述第一方面的第六种可能的实现方式,其中,所述通过解码线程对所述广告媒体数据解码得到广告音频采样和广告视频帧,包括:In conjunction with the fourth possible implementation of the first aspect, the embodiment of the present invention provides the sixth possible implementation manner of the foregoing first aspect, wherein the decoding the advertisement media data by the decoding thread to obtain an advertisement audio sample And advertising video frames, including:
判断当前所述广告媒体数据中的广告音频数据包是否为首个音频数据包,所述广告视频数据包是否为首个视频数据包;Determining whether the advertisement audio data packet in the current advertisement media data is the first audio data packet, and whether the advertisement video data packet is the first video data packet;
当确定所述广告音频数据包为所述首个广告音频数据包,所述广告视频数据包为所述首个广告视频数据包时,根据所述首个广告音频数据包中的音频解码器配置参数对音频解码器进行初始化,根据所述首个广告视频数据包中的视频解码器配置参数对视频解码器进行初始化;When it is determined that the advertisement audio data packet is the first advertisement audio data packet, and the advertisement video data packet is the first advertisement video data packet, according to an audio decoder configuration in the first advertisement audio data packet The parameter initializes the audio decoder, and initializes the video decoder according to the video decoder configuration parameter in the first advertisement video data packet;
根据初始化后的音频解码器对所述广告音频数据包进行解码,得到所述广告音频采样,根据初始化后的视频解码器对所述广告视频数据包进行解码,得到所述广告视频帧。Decoding the advertisement audio data packet according to the initialized audio decoder to obtain the advertisement audio sample, and decoding the advertisement video data packet according to the initialized video decoder to obtain the advertisement video frame.
结合第一方面,本发明实施例提供了上述第一方面的第七种可能的实现方式,其中,所述播放线程播放已经缓存的所述正片媒体数据结束后,使所述播放线程播放所述广告音频采样和所述广告视频帧,包括:With reference to the first aspect, the embodiment of the present invention provides the seventh possible implementation manner of the foregoing first aspect, wherein, after the playing thread plays the cached media media data, the playing thread is caused to play the Advertising audio samples and the advertising video frames, including:
将当前广告音频采样的配置参数与前一次的音频采样的配置参数,及当前广告视频帧 的配置参数与前一次的视频帧的配置参数进行比较,所述音频采样的配置参数包括所述音频采样的采样位数、采样率和通道数,所述视频帧的配置参数包括视频帧的颜色、格式和宽高;The configuration parameters of the current advertisement audio sample and the configuration parameters of the previous audio sample, and the current advertisement video frame The configuration parameters are compared with the configuration parameters of the previous video frame, the configuration parameters of the audio sample include the number of samples of the audio sample, the sampling rate, and the number of channels, and the configuration parameters of the video frame include the color of the video frame. , format and width;
当确定所述当前广告音频采样的配置参数与前一次的所述音频采样的配置参数,所述当前广告视频帧的配置参数与前一次的所述视频帧的配置参数不一样时,将所述当前广告音频采样的配置参数和所述当前广告视频帧的配置参数复位输出,并输出所述当前广告音频采样和广告视频帧。Determining, when the configuration parameter of the current advertisement audio sample is different from the configuration parameter of the previous audio sample, the configuration parameter of the current advertisement video frame is different from the configuration parameter of the previous video frame The configuration parameters of the current advertisement audio sample and the configuration parameters of the current advertisement video frame are reset output, and the current advertisement audio sample and the advertisement video frame are output.
结合第一方面,本发明实施例提供了上述第一方面的第八种可能的实现方式,其中,所述方法还包括:With reference to the first aspect, the embodiment of the present invention provides the eighth possible implementation manner of the foregoing first aspect, wherein the method further includes:
当接收到退出播放指令后,退出当前正在播放的所述正片媒体数据或广告媒体数据。After receiving the exit play instruction, the positive media data or the advertisement media data currently being played is exited.
第二方面,本发明实施例提供了一种广告插播装置,其中,所述装置包括:In a second aspect, an embodiment of the present invention provides an advertisement insertion device, where the device includes:
加载模块,配置成通过媒体加载线程缓存正片媒体数据;以及,配置成根据广告插播指令暂停通过所述媒体加载线程获取所述正片媒体数据的后续数据,并获取与所述广告插播指令对应的广告媒体数据;a loading module configured to cache the positive media data by the media loading thread; and configured to suspend subsequent data of the positive media data by the media loading thread according to the commercial insertion instruction, and obtain an advertisement corresponding to the commercial insertion instruction Media data;
解码模块,配置成通过解码线程所述广告媒体数据解码得到广告音频采样和广告视频帧;a decoding module configured to decode the advertisement media data by the decoding thread to obtain an advertisement audio sample and an advertisement video frame;
播放模块,配置成通过播放线程播放所述媒体加载线程缓存的正片媒体数据;以及,配置成在所述播放线程播放已经缓存的所述正片媒体数据结束后,使所述播放线程播放所述广告音频采样和所述广告视频帧。a playing module configured to play the positive media data cached by the media loading thread by the playing thread; and configured to cause the playing thread to play the advertisement after the playing thread plays the already-captured positive media data Audio samples and the advertising video frames.
结合第二方面,本发明实施例提供了上述第二方面的第一种可能的实现方式,其中,所述解码模块包括:With reference to the second aspect, the embodiment of the present invention provides the first possible implementation manner of the foregoing second aspect, wherein the decoding module includes:
音频解码子模块,配置成通过音频解码线程对所述广告媒体数据中的广告音频数据包进行解码,得到所述广告音频采样;An audio decoding submodule configured to decode an advertisement audio data packet in the advertisement media data by an audio decoding thread to obtain the advertisement audio sample;
视频解码子模块,配置成通过视频解码线程对所述广告媒体数据中的广告视频数据包进行解码,得到所述广告视频帧。The video decoding sub-module is configured to decode the advertisement video data packet in the advertisement media data by using a video decoding thread to obtain the advertisement video frame.
结合第二方面,本发明实施例提供了上述第二方面的第二种可能的实现方式,其中,所述播放模块播放所述广告音频采样和所述广告视频帧的方式,包括:With reference to the second aspect, the embodiment of the present invention provides the second possible implementation manner of the foregoing second aspect, wherein the manner in which the playing module plays the advertisement audio sample and the advertisement video frame includes:
使音频播放线程播放所述广告音频采样,使视频播放线程播放所述广告视频帧。The audio play thread is caused to play the advertisement audio sample, causing the video play thread to play the advertisement video frame.
结合第二方面,本发明实施例提供了上述第二方面的第三种可能的实现方式,其中,所述装置还包括:With reference to the second aspect, the embodiment of the present invention provides a third possible implementation manner of the foregoing second aspect, wherein the device further includes:
判断模块,配置成通过所述媒体加载线程打开与所述广告插播指令对应的广告媒体流,并解析所述广告媒体流的头部字节,判断广告媒体流的格式类型;The determining module is configured to open an advertisement media stream corresponding to the advertisement insertion instruction by using the media loading thread, and parse a header byte of the advertisement media stream, and determine a format type of the advertisement media stream;
参数获取模块,配置成根据所述广告媒体流的格式类型解析获得音频解码器配置参数和视频解码器配置参数。The parameter obtaining module is configured to obtain the audio decoder configuration parameter and the video decoder configuration parameter according to the format type of the advertisement media stream.
结合第二方面,本发明实施例提供了上述第二方面的第四种可能的实现方式,其中, 所述装置还包括:With reference to the second aspect, the embodiment of the present invention provides the fourth possible implementation manner of the foregoing second aspect, where The device also includes:
标记模块,配置成从所述广告媒体数据中解析出广告音频数据包和广告视频数据包,并标记解析出的首个广告音频数据包和首个广告视频数据包。The marking module is configured to parse the advertisement audio data package and the advertisement video data package from the advertisement media data, and mark the parsed first advertisement audio data package and the first advertisement video data package.
结合第二方面,本发明实施例提供了上述第二方面的第五种可能的实现方式,其中,所述标记模块包括:With reference to the second aspect, the embodiment of the present invention provides the fifth possible implementation manner of the foregoing second aspect, wherein the marking module includes:
字段设置子模块,配置成将所述首个广告音频数据包和所述首个广告视频数据包的标记字段的属性设置为真;a field setting submodule configured to set an attribute of the first advertisement audio data packet and a tag field of the first advertisement video data packet to true;
参数插入子模块,配置成在所述首个广告音频数据包中插入音频解码器配置参数,在所述首个广告视频数据包中插入视频解码器配置参数。a parameter insertion sub-module configured to insert an audio decoder configuration parameter in the first advertisement audio data packet, and insert a video decoder configuration parameter in the first advertisement video data packet.
结合第二方面,本发明实施例提供了上述第二方面的第六种可能的实现方式,其中,所述解码模块得到广告音频采样和广告视频帧的方式,包括:With reference to the second aspect, the embodiment of the present invention provides a sixth possible implementation manner of the foregoing second aspect, wherein the decoding module obtains an advertisement audio sample and an advertisement video frame, including:
判断当前所述广告媒体数据中的广告音频数据包是否为首个音频数据包,所述广告视频数据包是否为首个视频数据包;Determining whether the advertisement audio data packet in the current advertisement media data is the first audio data packet, and whether the advertisement video data packet is the first video data packet;
当确定所述广告音频数据包为所述首个广告音频数据包,所述广告视频数据包为所述首个广告视频数据包时,根据所述首个广告音频数据包中的音频解码器配置参数对音频解码器进行初始化,根据所述首个广告视频数据包中的视频解码器配置参数对视频解码器进行初始化;When it is determined that the advertisement audio data packet is the first advertisement audio data packet, and the advertisement video data packet is the first advertisement video data packet, according to an audio decoder configuration in the first advertisement audio data packet The parameter initializes the audio decoder, and initializes the video decoder according to the video decoder configuration parameter in the first advertisement video data packet;
根据初始化后的音频解码器对所述广告音频数据包进行解码,得到所述广告音频采样,根据初始化后的视频解码器对所述广告视频数据包进行解码,得到所述广告视频帧。Decoding the advertisement audio data packet according to the initialized audio decoder to obtain the advertisement audio sample, and decoding the advertisement video data packet according to the initialized video decoder to obtain the advertisement video frame.
结合第二方面,本发明实施例提供了上述第二方面的第七种可能的实现方式,其中,所述播放模块播放所述广告音频采样和所述广告视频帧的方式,包括:With reference to the second aspect, the embodiment of the present invention provides the seventh possible implementation manner of the foregoing second aspect, wherein the manner in which the playing module plays the advertisement audio sample and the advertisement video frame includes:
将当前广告音频采样的配置参数与前一次的音频采样的配置参数,及当前广告视频帧的配置参数与前一次的视频帧的配置参数进行比较,所述音频采样的配置参数包括所述音频采样的采样位数、采样率和通道数,所述视频帧的配置参数包括视频帧的颜色、格式和宽高;Comparing the configuration parameters of the current advertisement audio sample with the configuration parameters of the previous audio sample, and the configuration parameters of the current advertisement video frame with the configuration parameters of the previous video frame, the configuration parameters of the audio sample including the audio sample The number of sampling bits, the sampling rate, and the number of channels, and the configuration parameters of the video frame include the color, format, and width and height of the video frame;
当确定所述当前广告音频采样的配置参数与前一次的所述音频采样的配置参数,所述当前广告视频帧的配置参数与前一次的所述视频帧的配置参数不一样时,将所述当前广告音频采样的配置参数和所述当前广告视频帧的配置参数复位输出,并输出所述当前广告音频采样和广告视频帧。Determining, when the configuration parameter of the current advertisement audio sample is different from the configuration parameter of the previous audio sample, the configuration parameter of the current advertisement video frame is different from the configuration parameter of the previous video frame The configuration parameters of the current advertisement audio sample and the configuration parameters of the current advertisement video frame are reset output, and the current advertisement audio sample and the advertisement video frame are output.
结合第二方面,本发明实施例提供了上述第二方面的第八种可能的实现方式,其中,所述装置还包括:With reference to the second aspect, the embodiment of the present invention provides the eighth possible implementation manner of the foregoing second aspect, wherein the device further includes:
退出模块,配置成当接收到退出播放指令后,退出当前正在播放的所述正片媒体数据或广告媒体数据。The exit module is configured to quit the positive media data or the advertisement media data currently being played after receiving the exit play instruction.
第三方面,本发明实施例提供了一种存储于电子终端的可读取存储介质,其中,所述可读取存储介质包括多条指令,所述多条指令被配置成实现上述广告插播方法。 In a third aspect, an embodiment of the present invention provides a readable storage medium stored in an electronic terminal, where the readable storage medium includes a plurality of instructions, and the multiple instructions are configured to implement the advertisement insertion method. .
本发明实施例提供的广告插播方法及装置,在插播广告时不会出现加载延时和黑屏,同时避免了额外消耗服务器资源及视频正片播放不流畅情况的发生。The advertisement insertion method and device provided by the embodiments of the present invention do not cause loading delay and black screen when inserting advertisements, and avoid unnecessary occurrence of additional consumption of server resources and video film playback.
为使本发明的上述目的、特征和优点能更明显易懂,下文特举较佳实施例,并配合所附附图,作详细说明如下。The above described objects, features and advantages of the present invention will become more apparent from the aspects of the appended claims.
附图说明DRAWINGS
为了更清楚地说明本发明实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,应当理解,以下附图仅示出了本发明的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the embodiments will be briefly described below. It should be understood that the following drawings show only certain embodiments of the present invention, and therefore It should be seen as a limitation on the scope, and those skilled in the art can obtain other related drawings according to these drawings without any creative work.
图1示出了本发明实施例1所提供的一种广告插播方法的流程图;FIG. 1 is a flowchart of an advertisement insertion method provided by Embodiment 1 of the present invention;
图2示出了本发明实施例1所提供的一种广告插播方法中的对广告媒体数据解码的流程图;2 is a flowchart of decoding advertisement media data in an advertisement insertion method according to Embodiment 1 of the present invention;
图3示出了本发明实施例1所提供的一种广告插播方法中播放广告音频采样和广告视频帧的流程图;3 is a flowchart of playing an advertisement audio sample and an advertisement video frame in an advertisement insertion method according to Embodiment 1 of the present invention;
图4示出了本发明实施例2所提供的一种广告插播装置的结构示意图。FIG. 4 is a schematic structural diagram of an advertisement insertion apparatus according to Embodiment 2 of the present invention.
具体实施方式detailed description
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。通常在此处附图中描述和示出的本发明实施例的组件可以以各种不同的配置来布置和设计。因此,以下对在附图中提供的本发明的实施例的详细描述并非旨在限制要求保护的本发明的范围,而是仅仅表示本发明的选定实施例。基于本发明的实施例,本领域技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention. It is a partial embodiment of the invention, and not all of the embodiments. The components of the embodiments of the invention, which are generally described and illustrated in the figures herein, may be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the invention in the claims All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
考虑到现有技术中,为了解决在视频正片和视频广告之间切换时出现的视频加载延时和黑屏的问题,要么将视频广告和视频正片重新编码合成一个视频,再按照普通的方式进行播放,但是这样在解码和重新编码的过程中会消耗大量的服务器资源,导致服务器资源的浪费;要么,就是在播放视频正片的同时预加载视频广告,等到需要插播广告时,则切换到视频广告进行播放,但是,预加载广告会消耗有限的带宽资源,容易导致视频正片播放不流畅。基于此,本发明实施例提供了一种广告插播方法及装置,下面通过实施例进行描述。Considering the prior art, in order to solve the problem of video loading delay and black screen occurring when switching between video positive video and video advertisement, the video advertisement and the video positive film are re-encoded into one video, and then played in an ordinary manner. However, in the process of decoding and re-encoding, a large amount of server resources are consumed, resulting in waste of server resources; or, pre-loading video advertisements while playing video positives, and switching to video advertisements when it is necessary to insert commercials. Play, however, pre-loading ads consume limited bandwidth resources, which can easily lead to poor video playback. Based on this, an embodiment of the present invention provides an advertisement insertion method and apparatus, which are described below by way of embodiments.
实施例1Example 1
本发明实施例提供了一种广告插播方法,如图1所示,在采用该方法插播广告时包括 步骤S110-S130,具体如下。An embodiment of the present invention provides an advertisement insertion method, as shown in FIG. 1 , when the advertisement is inserted by using the method. Steps S110-S130 are as follows.
S110,通过媒体加载线程缓存正片媒体数据并通过播放线程播放的过程中,当接收到广告插播指令时,暂停通过媒体加载线程获取正片媒体数据的后续数据以及使播放线程继续播放已经缓存的正片媒体数据。S110. When the media loading thread caches the positive media data and plays through the playing thread, when receiving the commercial insertion instruction, suspending the subsequent data of the positive media data through the media loading thread and causing the playing thread to continue playing the already cached positive media. data.
本发明实施例提供的广告插播方法是通过多线程实现的,由媒体加载线程获取媒体数据,解码线程对获取的媒体数据进行解码,播放线程对解码后的媒体数据进行播放。The advertisement insertion method provided by the embodiment of the invention is implemented by multi-threading, the media loading thread acquires the media data, the decoding thread decodes the obtained media data, and the playing thread plays the decoded media data.
本发明实施例中广告插播方法的执行主体可以是终端上的视频播放器,该终端可以是,但不仅限于手机、计算机、平板电脑等。The execution body of the advertisement insertion method in the embodiment of the present invention may be a video player on the terminal, and the terminal may be, but not limited to, a mobile phone, a computer, a tablet computer, or the like.
上述广告插播指令包括需要插播的广告的名称或者其它能够准确地表示需要插播的广告的标识以及广告插播的时间,比如说,接到广告插播指令后,立即执行广告插播,当播放器接收到该广告插播指令后,则暂停通过媒体加载线程正片媒体数据的后续数据,同时使播放线程继续播放已经缓存的正片媒体数据。The advertisement insertion instruction includes the name of the advertisement to be inserted or other identifier capable of accurately indicating the advertisement to be inserted and the time of the advertisement insertion. For example, after receiving the advertisement insertion instruction, the advertisement insertion is immediately executed, and when the player receives the advertisement, the player inserts the advertisement. After the advertisement insertion instruction, the subsequent data of the thread positive media data is suspended through the media, and the playback thread continues to play the already-captured positive media data.
其中,上述广告媒体数据及正片媒体数据均为媒体流。The advertisement media data and the positive media data are all media streams.
S120,通过媒体加载线程获取与广告插播指令对应的广告媒体数据,通过解码线程对广告媒体数据解码得到广告音频采样和广告视频帧。S120. Obtain advertisement media data corresponding to the advertisement insertion instruction by using a media loading thread, and decode the advertisement media data by the decoding thread to obtain an advertisement audio sample and an advertisement video frame.
当接收到广告插播指令时,终端上的播放器会暂停通过媒体加载线程获取正片媒体数据的后续数据,同时,通过媒体加载线程获取与广告插播指令对应的广告媒体数据。When the advertisement insertion instruction is received, the player on the terminal temporarily suspends the subsequent data of the positive media data through the media loading thread, and at the same time, obtains the advertisement media data corresponding to the commercial insertion instruction through the media loading thread.
可选地,终端上的播放器可以从同一个服务器获取需要播放的广告媒体数据和正片媒体数据,也可以分别从不同的服务器获取需要播放的广告媒体数据和正片媒体数据。Optionally, the player on the terminal can obtain the advertisement media data and the positive media data that need to be played from the same server, and can also obtain the advertisement media data and the positive media data that need to be played from different servers respectively.
其中,如果终端上的播放器从不同的服务器获取广告媒体数据和正片媒体数据,则暂停获取当前正在播放的正片媒体数据的后续数据,可以通过断开与当前服务器的连接实现,同时为了获取与广告播放指令对应的广告媒体数据,则通过建立与广告视频服务器的连接。If the player on the terminal obtains the advertisement media data and the positive film media data from different servers, suspending obtaining the subsequent data of the positive media data currently being played may be implemented by disconnecting the connection with the current server, and at the same time, in order to obtain and The advertisement media data corresponding to the advertisement play instruction is established by establishing a connection with the advertisement video server.
如果终端上的播放器从同一个服务器获取需要播放的广告媒体数据和正片媒体数据,则在接收到广告插播指令时,也需要断开与当前服务器的连接,再重新建立与当前服务器之间的连接,此次连接与上次连接属于不同的连接。If the player on the terminal obtains the advertisement media data and the positive media data that need to be played from the same server, when the advertisement insertion instruction is received, the connection with the current server needs to be disconnected, and then the connection with the current server is re-established. Connection, this connection is a different connection from the last connection.
而在通过媒体加载线程获取与广告插播指令对应的广告媒体数据之前,还包括:通过媒体加载线程打开与广告插播指令对应的广告媒体流,并解析广告媒体流的头部字节,判断广告媒体流的格式类型;根据广告媒体流的格式类型解析音频解码器配置参数和视频解码器配置参数。Before the advertisement media data corresponding to the advertisement insertion instruction is obtained by the media loading thread, the method further includes: opening, by the media loading thread, an advertisement media stream corresponding to the advertisement insertion instruction, and parsing the header byte of the advertisement media stream, and determining the advertisement media. The format type of the stream; the audio decoder configuration parameters and video decoder configuration parameters are parsed according to the format type of the ad media stream.
上述广告媒体流的格式类型可以是,但不仅限于mp4、ts等类型。The format type of the above advertisement media stream may be, but not limited to, mp4, ts, and the like.
其中,上述可以根据广告媒体流的格式类型对应的格式标准解析出音频解码器的配置参数和视频解码器的配置参数。The foregoing may parse the configuration parameters of the audio decoder and the configuration parameters of the video decoder according to the format standard corresponding to the format type of the advertisement media stream.
上述音频解码器配置参数包括音频的编码类型、采样格式、采样率、通道数等,视频解码器配置参数包括视频的编码类型、宽高、颜色格式等。The audio decoder configuration parameters include audio encoding type, sampling format, sampling rate, channel number, etc., and video decoder configuration parameters include encoding type, width, height, and color format of the video.
在本发明实施例中,当通过媒体加载线程获取与广告插播指令对应的广告媒体数据之 后,从广告媒体数据中解析出广告音频数据包和广告视频数据包,并标记解析出的首个广告音频数据包和首个广告视频数据包。In the embodiment of the present invention, when the media loading thread acquires the advertisement media data corresponding to the advertisement insertion instruction, After that, the advertisement audio data package and the advertisement video data package are parsed from the advertisement media data, and the parsed first advertisement audio data package and the first advertisement video data package are marked.
当从广告媒体数据中解析出广告音频数据包和广告视频数据包后,如果该广告音频数据包不是首个广告音频数据包,及该广告视频数据包不是首个广告视频数据包,则将该广告音频数据包缓存到广告音频数据包队列中,将该广告视频数据包缓存到广告视频数据包队列中,如果上述广告音频数据包为首个广告音频数据包,则标记该首个广告音频数据包,如果上述广告视频数据包是首个广告视频数据包,则标记该首个广告视频数据包。After parsing the advertisement audio data package and the advertisement video data package from the advertisement media data, if the advertisement audio data package is not the first advertisement audio data package, and the advertisement video data package is not the first advertisement video data package, The advertisement audio data packet is cached in the advertisement audio data packet queue, and the advertisement video data package is cached in the advertisement video data packet queue. If the advertisement audio data package is the first advertisement audio data package, the first advertisement audio data package is marked. If the above advertisement video data packet is the first advertisement video data package, mark the first advertisement video data package.
其中,上述标记解析出的首个广告音频数据包和首个广告视频数据包,包括:将上述首个广告音频数据包和首个广告视频数据包的标记字段的属性设置为真;在首个广告音频数据包中插入音频解码器配置参数,在首个广告视频数据包中插入视频解码器配置参数。The first advertisement audio data packet and the first advertisement video data packet parsed by the foregoing markings include: setting an attribute of a mark field of the first advertisement audio data packet and the first advertisement video data packet to true; in the first The audio decoder configuration parameters are inserted into the advertisement audio data packet, and the video decoder configuration parameters are inserted in the first advertisement video data packet.
将从广告媒体数据中解析出的第一个广告音频数据包确定为首个广告音频数据包,将从广告媒体数据中解析出的第一个广告视频数据包确定为首个广告视频数据包。The first advertisement audio data packet parsed from the advertisement media data is determined as the first advertisement audio data package, and the first advertisement video data packet parsed from the advertisement media data is determined as the first advertisement video data package.
之后通过解码线程对广告媒体数据解码得到广告音频采样和广告视频帧。The advertisement media data is then decoded by the decoding thread to obtain an advertisement audio sample and an advertisement video frame.
其中,上述广告媒体数据中的广告音频数据包和广告视频数据包可以通过不同的线程来实现,具体的,通过音频解码线程对广告媒体数据中的广告音频数据包进行解码,得到广告音频采样;通过视频解码线程对广告媒体数据中的广告视频数据包进行解码,得到广告视频帧。The advertisement audio data packet and the advertisement video data packet in the advertisement media data may be implemented by different threads. Specifically, the advertisement audio data packet in the advertisement media data is decoded by the audio decoding thread to obtain an advertisement audio sample. The advertisement video data packet in the advertisement media data is decoded by the video decoding thread to obtain an advertisement video frame.
作为一个实施例,如图2所示,通过解码线程对广告媒体数据解码得到广告音频采样和广告视频帧,具体包括:As an embodiment, as shown in FIG. 2, the advertisement audio sample and the advertisement video frame are obtained by decoding the advertisement media data by the decoding thread, and specifically includes:
S210,判断当前广告媒体数据中的广告音频数据包是否为首个音频数据包,广告视频数据包是否为首个视频数据包。S210. Determine whether the advertisement audio data packet in the current advertisement media data is the first audio data packet, and whether the advertisement video data packet is the first video data packet.
S220,当确定上述广告音频数据包为首个广告音频数据包,上述广告视频数据包为首个广告视频数据包时,根据首个广告音频数据包中的音频解码器配置参数对音频解码器进行初始化,根据首个广告视频数据包中的视频解码器配置参数对视频解码器进行初始化。S220. When it is determined that the advertisement audio data packet is the first advertisement audio data packet, and the advertisement video data packet is the first advertisement video data packet, the audio decoder is initialized according to the audio decoder configuration parameter in the first advertisement audio data packet. The video decoder is initialized based on the video decoder configuration parameters in the first advertisement video packet.
S230,根据初始化后的音频解码器对广告音频数据包进行解码,得到广告音频采样,根据初始化后的视频解码器对广告视频数据包进行解码,得到广告视频帧。S230: Decode the advertisement audio data packet according to the initialized audio decoder, obtain an advertisement audio sample, and decode the advertisement video data packet according to the initialized video decoder to obtain an advertisement video frame.
其中,上述判断当前广告媒体数据中的广告音频数据包是否为首个广告音频数据包可以通过判断上述广告音频数据包的标记字段的属性是否为真,如果上述广告音频数据包的标记字段的属性为真,则确定上述广告音频数据包是首个广告音频数据包,同理,上述判断当前广告媒体数据中的广告视频数据包是否为首个广告视频数据包可以通过判断上述广告视频数据包的标记字段的属性是否为帧,如果上述广告视频数据包的标记字段的属性为真,则确定上述广告视频数据包是首个广告视频数据包,当确定出广告音频数据包为首个广告音频数据包,且广告视频数据包为首个广告视频数据包时,这说明在此之前都是在对正片媒体数据进行解码,解码器的配置参数都是根据正片媒体数据进行设置的,因此,这时需要根据广告音频数据包中的音频解码器配置参数对音频解码器进行初始化,即根据广 告音频数据包中的音频解码器配置参数对音频解码器的配置参数进行调整,并根据广告视频数据包中的视频解码器配置参数对视频解码器进行初始化。Wherein, determining whether the advertisement audio data packet in the current advertisement media data is the first advertisement audio data packet may determine whether the attribute of the mark field of the advertisement audio data package is true, if the attribute of the mark field of the advertisement audio data package is True, it is determined that the advertisement audio data packet is the first advertisement audio data packet. Similarly, if the advertisement video data packet in the current advertisement media data is the first advertisement video data packet, the marking field of the advertisement video data packet may be determined. Whether the attribute is a frame, if the attribute of the tag field of the advertisement video data packet is true, determining that the advertisement video data packet is the first advertisement video data package, and when determining that the advertisement audio data package is the first advertisement audio data package, and When the advertisement video data packet is the first advertisement video data packet, this indicates that the positive media data is decoded before, and the configuration parameters of the decoder are all set according to the positive media data, therefore, it is required to be based on the advertisement audio. Audio decoder configuration parameters in the packet The audio decoder is initialized, that is the basis of well The audio decoder configuration parameters in the audio data packet adjust the configuration parameters of the audio decoder and initialize the video decoder based on the video decoder configuration parameters in the advertising video data packet.
当对音频解码器和视频解码器进行初始化后,音频解码器的配置参数与广告音频数据包是一致的,即这时的音频解码器能够对广告音频数据包进行解码,视频解码器的配置参数与广告视频数据包是一致的,即这时的视频解码器能够对广告视频数据包进行解码,根据初始化后的音频解码器对广告音频数据包进行解码,得到广告音频采样,并将得到的广告音频采样缓存到广告音频采样队列中,根据初始化后的视频解码器对广告视频数据包进行解码,得到广告视频帧,将解码得到的广告视频帧缓存到广告视频帧队列中。When the audio decoder and the video decoder are initialized, the configuration parameters of the audio decoder are consistent with the advertisement audio data packet, that is, the audio decoder at this time can decode the advertisement audio data packet, and the configuration parameters of the video decoder Consistent with the advertisement video data packet, that is, the video decoder at this time can decode the advertisement video data packet, decode the advertisement audio data packet according to the initialized audio decoder, obtain the advertisement audio sample, and obtain the obtained advertisement. The audio sample is buffered into the advertisement audio sampling queue, and the advertisement video data packet is decoded according to the initialized video decoder to obtain an advertisement video frame, and the decoded advertisement video frame is buffered into the advertisement video frame queue.
如果上述广告音频数据包并不是第一个广告音频数据包,上述广告视频数据包并不是第一个广告视频数据包,则说明在此之前就是对广告音频数据包和广告视频数据包进行解码,这时不需要对音频解码器和视频解码器进行初始化。If the above advertisement audio data packet is not the first advertisement audio data package, and the above advertisement video data package is not the first advertisement video data package, it means that the advertisement audio data package and the advertisement video data package are decoded before. There is no need to initialize the audio decoder and video decoder at this time.
S130,在播放线程播放已经缓存的正片媒体数据结束后,使播放线程播放上述广告音频采样和广告视频帧。S130. After the playing thread plays the already-captured positive media data, the playing thread causes the playing thread to play the advertisement audio sample and the advertising video frame.
上述解码线程在对广告媒体数据进行解码的过程中,播放线程会一直播放已经缓存的正片媒体数据,当正片媒体数据播放完结束后,则播放线程开始播放上述对广告媒体数据解码得到的广告音频采样和广告视频帧。In the process of decoding the advertisement media data, the playing thread will play the already-captured positive media data. When the positive media data is played, the playing thread starts playing the above-mentioned advertising audio decoded by the advertising media data. Sampling and advertising video frames.
其中,作为一个实施例,如图3所示,播放上述广告音频采样和广告视频帧,包括:As shown in FIG. 3, as shown in FIG. 3, playing the above-mentioned advertisement audio sample and advertisement video frame includes:
S310,将当前广告音频采样的配置参数与前一次的音频采样的配置参数,以及将当前广告视频帧的配置参数与前一次的视频帧的配置参数进行比较,该音频采样的配置参数包括音频采样的采样位数、采样率和通道数,该视频帧的配置参数包括视频帧的颜色、格式和宽高。S310. Compare configuration parameters of the current advertisement audio sample with configuration parameters of the previous audio sample, and compare configuration parameters of the current advertisement video frame with configuration parameters of the previous video frame, where the configuration parameters of the audio sample include audio sampling. The number of samples, the sampling rate, and the number of channels. The configuration parameters of the video frame include the color, format, and width and height of the video frame.
S320,当确定当前广告音频采样的配置参数与前一次的音频采样的配置参数,当前广告视频帧的配置参数与前一次的视频帧的配置参数不一样时,将当前广告音频采样的配置参数和当前广告视频帧的配置参数复位输出,并输出所述当前广告音频采样和广告视频帧。S320, when determining the configuration parameter of the current advertisement audio sample and the configuration parameter of the previous audio sample, when the configuration parameter of the current advertisement video frame is different from the configuration parameter of the previous video frame, the configuration parameters of the current advertisement audio sample and The configuration parameters of the current advertisement video frame reset the output and output the current advertisement audio sample and the advertisement video frame.
在本发明实施例中,播放线程从广告音频采样队列中读取广告音频采样,从广告视频帧队列中读取广告视频帧,如果当前读取的广告音频采样的配置参数与前一次的音频采样的配置参数,以及当前读取的广告视频帧的配置参数与前一次的视频帧的配置参数不相同,则说明前一次播放的音频采样和视频帧为正片的音频采样和视频帧,这时,在播放当前的广告音频采样和广告视频帧时,需要告知音频输出系统需要播放的音频采样和告知视频输出系统需要播放的视频帧已经发生配置变化,这样负责播放的操作系统和硬件才能够正确输出广告音频采样和广告视频帧,所以在播放当前广告音频采样和广告视频帧时,需要将广告音频采样的配置参数以及广告视频帧的配置参数复位输出,以告知音频输出系统和视频输出系统需要播放的音频采样和视频帧已经发生配置变化,并将音频采样输出时钟和视频采样输出时钟进行复位,然后输出当前广告音频采样和广告视频帧。In the embodiment of the present invention, the playing thread reads the advertisement audio sample from the advertisement audio sampling queue, and reads the advertisement video frame from the advertisement video frame queue, if the configuration parameter of the currently read advertisement audio sample and the previous audio sample The configuration parameters, and the configuration parameters of the currently read advertisement video frame are different from the configuration parameters of the previous video frame, indicating that the audio samples and video frames of the previous playback are positive audio samples and video frames. When playing the current advertisement audio sample and advertisement video frame, it is necessary to inform the audio output system of the audio sample to be played and to inform the video output system that the video frame that needs to be played has been configured to change, so that the operating system and hardware responsible for playback can output correctly. Advertising audio sampling and advertising video frames, so when playing the current advertising audio sampling and advertising video frames, it is necessary to reset the configuration parameters of the advertising audio sampling and the configuration parameters of the advertising video frame to inform the audio output system and the video output system that the video output system needs to be played. Audio samples and video frames have occurred Set change, and audio sample clock and the output clock reset output video samples and audio samples output current ad and ad video frames.
可选地,当用户使用终端上的播放器在观看视频时,如果有其它事情要做或者要使用 该终端的其它应用程序时,用户需要退出当前视频播放,因此,本发明实施例提供的广告插播方法,还包括:Optionally, when the user uses the player on the terminal while watching the video, if there is something else to do or to use In other applications of the terminal, the user needs to quit the current video playback. Therefore, the advertisement insertion method provided by the embodiment of the present invention further includes:
当接收到退出播放指令后,退出当前正在播放的广告媒体数据或正片媒体数据。After receiving the exit play command, the advertisement media data or the positive media data currently being played is exited.
其中,用户可以随时退出播放。Among them, the user can exit the game at any time.
在本发明实施例中,当媒体加载线程接收到由广告切换回正片的指令后,则停止获取广告媒体数据的后续数据,同时获取正片媒体数据。In the embodiment of the present invention, after the media loading thread receives the instruction to switch back to the positive film by the advertisement, the subsequent data of the advertisement media data is stopped, and the positive media data is acquired.
基于上述设计,本发明实施例提供的广告插播方法,播放器接收到广告插播指令后,在继续播放已缓存的正片媒体数据的同时进行广告媒体数据的缓存,使得在已缓存的正片媒体数据播放完成后可以立即进入广告媒体数据的解码播放。如此,在插播广告时不会出现加载延时和黑屏,同时避免了额外消耗服务器资源及视频正片播放不流畅情况的发生。Based on the above design, the advertisement insertion method provided by the embodiment of the present invention, after receiving the advertisement insertion instruction, the player performs the buffering of the advertisement media data while continuing to play the cached positive media data, so that the buffered positive media data is played. Once completed, you can immediately enter the decoding playback of the ad media data. In this way, there will be no load delay and black screen when inserting advertisements, and at the same time avoiding the extra consumption of server resources and the fact that the video film is not smooth.
实施例2Example 2
本发明实施例提供了一种广告插播装置,如图4所示,该装置可以包括:加载模块410、解码模块420和播放模块430;The embodiment of the present invention provides an advertisement insertion device. As shown in FIG. 4, the device may include: a loading module 410, a decoding module 420, and a playing module 430;
上述加载模块410,配置成通过媒体加载线程缓存正片媒体数据;以及,配置成根据广告插播指令暂停通过媒体加载线程获取正片媒体数据的后续数据,并获取与广告插播指令对应的广告媒体数据。The loading module 410 is configured to cache the positive media data by the media loading thread; and configured to suspend the subsequent data of the positive media data through the media loading thread according to the commercial insertion instruction, and obtain the advertising media data corresponding to the commercial insertion instruction.
可选的,所述装置还可以包括:判断模块及参数获取模块。Optionally, the device may further include: a determining module and a parameter acquiring module.
上述判断模块,配置成通过所述媒体加载线程打开与所述广告插播指令对应的广告媒体流,并解析所述广告媒体流的头部字节,判断广告媒体流的格式类型。The determining module is configured to open an advertisement media stream corresponding to the advertisement insertion instruction by using the media loading thread, and parse a header byte of the advertisement media stream to determine a format type of the advertisement media stream.
上述参数获取模块,配置成根据所述广告媒体流的格式类型解析获得音频解码器配置参数和视频解码器配置参数。The parameter obtaining module is configured to obtain an audio decoder configuration parameter and a video decoder configuration parameter according to a format type of the advertisement media stream.
可选的,所述装置还可以包括标记模块。Optionally, the device may further comprise a marking module.
上述标记模块,配置成从所述广告媒体数据中解析出广告音频数据包和广告视频数据包,并标记解析出的首个广告音频数据包和首个广告视频数据包。The marking module is configured to parse the advertisement audio data package and the advertisement video data package from the advertisement media data, and mark the parsed first advertisement audio data package and the first advertisement video data package.
可选的,所述标记模块可以包括:字段设置子模块及参数插入子模块。Optionally, the marking module may include: a field setting submodule and a parameter insertion submodule.
上述字段设置子模块,配置成将所述首个广告音频数据包和所述首个广告视频数据包的标记字段的属性设置为真;The above field setting submodule is configured to set an attribute of the first advertisement audio data packet and a mark field of the first advertisement video data packet to true;
上述参数插入子模块,配置成在所述首个广告音频数据包中插入音频解码器配置参数,在所述首个广告视频数据包中插入视频解码器配置参数。The parameter insertion sub-module is configured to insert an audio decoder configuration parameter into the first advertisement audio data packet, and insert a video decoder configuration parameter into the first advertisement video data packet.
上述解码模块420,配置成通过解码线程对广告媒体数据解码得到广告音频采样和广告视频帧。The decoding module 420 is configured to decode the advertisement media data by the decoding thread to obtain an advertisement audio sample and an advertisement video frame.
可选地,上述解码模块420可以包括音频解码子模块及视频解码子模块。Optionally, the foregoing decoding module 420 may include an audio decoding submodule and a video decoding submodule.
上述音频解码子模块,配置成通过音频解码线程对所述广告媒体数据中的广告音频数据包进行解码,得到所述广告音频采样; The audio decoding submodule is configured to decode an advertisement audio data packet in the advertisement media data by using an audio decoding thread to obtain the advertisement audio sample.
上述视频解码子模块,配置成通过视频解码线程对所述广告媒体数据中的广告视频数据包进行解码,得到所述广告视频帧。The video decoding submodule is configured to decode the advertisement video data packet in the advertisement media data by using a video decoding thread to obtain the advertisement video frame.
可选地,上述解码模块420得到广告音频采样和广告视频帧的方式,包括:Optionally, the foregoing decoding module 420 obtains a manner of advertising audio samples and advertising video frames, including:
判断当前所述广告媒体数据中的广告音频数据包是否为首个音频数据包,所述广告视频数据包是否为首个视频数据包;Determining whether the advertisement audio data packet in the current advertisement media data is the first audio data packet, and whether the advertisement video data packet is the first video data packet;
当确定所述广告音频数据包为所述首个广告音频数据包,所述广告视频数据包为所述首个广告视频数据包时,根据所述首个广告音频数据包中的音频解码器配置参数对音频解码器进行初始化,根据所述首个广告视频数据包中的视频解码器配置参数对视频解码器进行初始化;When it is determined that the advertisement audio data packet is the first advertisement audio data packet, and the advertisement video data packet is the first advertisement video data packet, according to an audio decoder configuration in the first advertisement audio data packet The parameter initializes the audio decoder, and initializes the video decoder according to the video decoder configuration parameter in the first advertisement video data packet;
根据初始化后的音频解码器对所述广告音频数据包进行解码,得到所述广告音频采样,根据初始化后的视频解码器对所述广告视频数据包进行解码,得到所述广告视频帧。Decoding the advertisement audio data packet according to the initialized audio decoder to obtain the advertisement audio sample, and decoding the advertisement video data packet according to the initialized video decoder to obtain the advertisement video frame.
上述播放模块430,配置成通过播放线程播放上述媒体加载线程缓存的正片媒体数据;以及,配置成在上述播放线程播放已经缓存的正片媒体数据结束后,使播放线程播放上述广告音频采样和广告视频帧。The playing module 430 is configured to play the positive media data cached by the media loading thread through the playing thread; and configured to enable the playing thread to play the advertising audio sample and the advertising video after the playing thread plays the cached positive media data. frame.
可选地,上述播放模块430播放所述广告音频采样和所述广告视频帧的方式包括:Optionally, the manner in which the playing module 430 plays the advertisement audio sample and the advertisement video frame includes:
使音频播放线程播放所述广告音频采样,使视频播放线程播放所述广告视频帧。The audio play thread is caused to play the advertisement audio sample, causing the video play thread to play the advertisement video frame.
可选地,上述播放模块430播放所述广告音频采样和所述广告视频帧的方式,包括:Optionally, the manner in which the playing module 430 plays the advertisement audio sample and the advertisement video frame includes:
将当前广告音频采样的配置参数与前一次的音频采样的配置参数,及当前广告视频帧的配置参数与前一次的视频帧的配置参数进行比较,所述音频采样的配置参数包括所述音频采样的采样位数、采样率和通道数,所述视频帧的配置参数包括视频帧的颜色、格式和宽高;Comparing the configuration parameters of the current advertisement audio sample with the configuration parameters of the previous audio sample, and the configuration parameters of the current advertisement video frame with the configuration parameters of the previous video frame, the configuration parameters of the audio sample including the audio sample The number of sampling bits, the sampling rate, and the number of channels, and the configuration parameters of the video frame include the color, format, and width and height of the video frame;
当确定所述当前广告音频采样的配置参数与前一次的所述音频采样的配置参数,所述当前广告视频帧的配置参数与前一次的所述视频帧的配置参数不一样时,将所述当前广告音频采样的配置参数和所述当前广告视频帧的配置参数复位输出,并输出所述当前广告音频采样和广告视频帧。Determining, when the configuration parameter of the current advertisement audio sample is different from the configuration parameter of the previous audio sample, the configuration parameter of the current advertisement video frame is different from the configuration parameter of the previous video frame The configuration parameters of the current advertisement audio sample and the configuration parameters of the current advertisement video frame are reset output, and the current advertisement audio sample and the advertisement video frame are output.
可选地,所述装置还可以包括退出模块。Optionally, the device may further comprise an exit module.
上述退出模块,配置成当接收到退出播放指令后,退出当前正在播放的所述正片媒体数据或广告媒体数据。The exit module is configured to, after receiving the exit play instruction, exit the positive media data or the advertisement media data currently being played.
其中,上述广告插播装置可以从同一个服务器获取需要播放的广告媒体数据和正片媒体数据,也可以分别从不同的服务器获取需要播放的广告媒体数据和正片媒体数据。The advertisement insertion device may obtain the advertisement media data and the positive media data that need to be played from the same server, and may also obtain the advertisement media data and the positive media data that need to be played from different servers.
上述广告插播指令包括需要插播的广告的名称或者其它能够准确地表示需要插播的广告的标识,当接收到该广告插播指令后,加载模块410暂停获取当前正在播放的正片媒体数据的后续数据,并获取需要插播的广告媒体数据。The advertisement insertion instruction includes the name of the advertisement that needs to be inserted or other identifier that can accurately represent the advertisement that needs to be inserted. After receiving the advertisement insertion instruction, the loading module 410 pauses to acquire the subsequent data of the positive media data currently being played, and Get the ad media data that needs to be inserted.
其中,如果加载模块410从不同的服务器获取需要播放的广告媒体数据和正片媒体数据,则暂停获取当前正在播放的正片媒体数据的后续数据,可以通过断开与当前服务器的 连接实现,同时为了获取与广告播放指令对应的广告媒体数据,则通过建立与广告视频服务器的连接。If the loading module 410 obtains the advertisement media data and the positive film media data that need to be played from different servers, suspending obtaining subsequent data of the positive media data currently being played may be disconnected from the current server. The connection is implemented, and at the same time, in order to obtain the advertisement media data corresponding to the advertisement play instruction, the connection with the advertisement video server is established.
如果上述加载模块410从同一个服务器获取需要播放的广告媒体数据和正片媒体数据,则在接收到广告插播指令后,也需要断开与当前服务器的连接,再重新建立与当前服务器之间的连接,此次连接与上次连接属于不同的连接。If the loading module 410 obtains the advertisement media data and the positive media data that need to be played from the same server, after receiving the advertisement insertion instruction, the connection with the current server needs to be disconnected, and the connection with the current server is re-established. This connection is a different connection from the last connection.
本发明实施例提供的广告插播装置,在插播广告时不会出现加载延时和黑屏,同时避免了额外消耗服务器资源及视频正片播放不流畅情况的发生。The advertisement insertion device provided by the embodiment of the invention does not have a loading delay and a black screen when inserting an advertisement, and avoids the occurrence of additional consumption of server resources and unsmooth video playback.
本发明实施例所提供的广告插播装置可以为设备上的特定硬件或者安装于设备上的软件或固件等。本发明实施例所提供的装置,其实现原理及产生的技术效果和前述方法实施例相同,为简要描述,装置实施例部分未提及之处,可参考前述方法实施例中相应内容。所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,前述描述的系统、装置和单元的具体工作过程,均可以参考上述方法实施例中的对应过程,在此不再赘述。The advertisement insertion device provided by the embodiment of the present invention may be specific hardware on the device or software or firmware installed on the device. The implementation principle and the technical effects of the device provided by the embodiments of the present invention are the same as those of the foregoing method embodiments. For a brief description, where the device embodiment is not mentioned, reference may be made to the corresponding content in the foregoing method embodiments. A person skilled in the art can clearly understand that for the convenience and brevity of the description, the specific working processes of the foregoing system, the device and the unit can refer to the corresponding processes in the foregoing method embodiments, and details are not described herein again.
在本发明所提供的实施例中,应该理解到,所揭露装置和方法,可以通过其它的方式实现。以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,又例如,多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些通信接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the embodiments provided by the present invention, it should be understood that the disclosed apparatus and method may be implemented in other manners. The device embodiments described above are merely illustrative. For example, the division of the unit is only a logical function division. In actual implementation, there may be another division manner. For example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some communication interface, device or unit, and may be electrical, mechanical or otherwise.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
另外,在本发明提供的实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, each functional unit in the embodiment provided by the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。The functions may be stored in a computer readable storage medium if implemented in the form of a software functional unit and sold or used as a standalone product. Based on such understanding, the technical solution of the present invention, which is essential or contributes to the prior art, or a part of the technical solution, may be embodied in the form of a software product, which is stored in a storage medium, including The instructions are used to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like. .
应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释,此外,术语“第一”、“第二”、“第三”等仅用于区分描述,而不能理解为指示或暗示相对重要性。It should be noted that similar reference numerals and letters indicate similar items in the following figures. Therefore, once an item is defined in a drawing, it is not necessary to further define and explain it in the subsequent drawings. Moreover, the terms "first", "second", "third", and the like are used merely to distinguish a description, and are not to be construed as indicating or implying a relative importance.
最后应说明的是:以上所述实施例,仅为本发明的具体实施方式,用以说明本发明的技术方案,而非对其限制,本发明的保护范围并不局限于此,尽管参照前述实施例对本发 明进行了详细的说明,本领域的普通技术人员应当理解:任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,其依然可以对前述实施例所记载的技术方案进行修改或可轻易想到变化,或者对其中部分技术特征进行等同替换;而这些修改、变化或者替换,并不使相应技术方案的本质脱离本发明实施例技术方案的精神和范围。都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应以所述权利要求的保护范围为准。 Finally, it should be noted that the above-mentioned embodiments are merely specific embodiments of the present invention, and are used to explain the technical solutions of the present invention, and are not limited thereto, and the scope of protection of the present invention is not limited thereto, although reference is made to the foregoing. Example for this hair The detailed description of the present invention will be understood by those skilled in the art, and any technical person skilled in the art can still modify or easily modify the technical solutions described in the foregoing embodiments within the technical scope disclosed by the present invention. The present invention is not limited to the spirit and scope of the technical solutions of the embodiments of the present invention. The present invention is not limited to the spirit and scope of the technical solutions of the embodiments of the present invention. All should be covered by the scope of the present invention. Therefore, the scope of the invention should be determined by the scope of the appended claims.

Claims (19)

  1. 一种广告插播方法,其特征在于,所述方法包括:An advertisement insertion method, characterized in that the method comprises:
    通过媒体加载线程缓存正片媒体数据并通过播放线程播放的过程中,当接收到广告插播指令时,暂停通过所述媒体加载线程获取所述正片媒体数据的后续数据以及使所述播放线程继续播放已经缓存的所述正片媒体数据;When the media loading thread caches the positive media data and plays through the playing thread, when receiving the commercial insertion instruction, suspending the subsequent data of the positive media data by the media loading thread and causing the playing thread to continue playing has been Cache the positive media data;
    通过所述媒体加载线程获取与所述广告插播指令对应的广告媒体数据,通过解码线程对所述广告媒体数据解码得到广告音频采样和广告视频帧;Obtaining advertisement media data corresponding to the advertisement insertion instruction by the media loading thread, and decoding the advertisement media data by a decoding thread to obtain an advertisement audio sample and an advertisement video frame;
    在所述播放线程播放已经缓存的所述正片媒体数据结束后,使所述播放线程播放所述广告音频采样和所述广告视频帧。After the playing thread plays the already-captured positive media data, the playing thread is caused to play the advertising audio sample and the advertising video frame.
  2. 根据权利要求1所述的方法,其特征在于,所述通过解码线程对所述广告媒体数据解码得到广告音频采样和广告视频帧,包括:The method according to claim 1, wherein the decoding of the advertisement media data by the decoding thread to obtain an advertisement audio sample and an advertisement video frame comprises:
    通过音频解码线程对所述广告媒体数据中的广告音频数据包进行解码,得到所述广告音频采样;Decoding an advertisement audio data packet in the advertisement media data by an audio decoding thread to obtain the advertisement audio sample;
    通过视频解码线程对所述广告媒体数据中的广告视频数据包进行解码,得到所述广告视频帧。The advertisement video data packet in the advertisement media data is decoded by a video decoding thread to obtain the advertisement video frame.
  3. 根据权利要求1或2所述的方法,其特征在于,所述使所述播放线程播放所述广告音频采样和所述广告视频帧,包括:The method according to claim 1 or 2, wherein the causing the playing thread to play the advertisement audio sample and the advertisement video frame comprises:
    使音频播放线程播放所述广告音频采样,使视频播放线程播放所述广告视频帧。The audio play thread is caused to play the advertisement audio sample, causing the video play thread to play the advertisement video frame.
  4. 根据权利要求1-3任意一项所述的方法,其特征在于,所述通过所述媒体加载线程获取与所述广告插播指令对应的广告媒体数据之前,还包括:The method according to any one of claims 1-3, wherein before the obtaining, by the media loading thread, the advertisement media data corresponding to the advertisement insertion instruction, the method further comprises:
    通过所述媒体加载线程打开与所述广告插播指令对应的广告媒体流,并解析所述广告媒体流的头部字节,判断广告媒体流的格式类型;Opening, by the media loading thread, an advertisement media stream corresponding to the advertisement insertion instruction, and parsing a header byte of the advertisement media stream, and determining a format type of the advertisement media stream;
    根据所述广告媒体流的格式类型解析获得音频解码器配置参数和视频解码器配置参数。The audio decoder configuration parameters and the video decoder configuration parameters are obtained according to the format type of the advertisement media stream.
  5. 根据权利要求4所述的方法,其特征在于,所述通过所述媒体加载线程获取与所述广告插播指令对应的广告媒体数据之后,还包括:The method according to claim 4, wherein after the obtaining, by the media loading thread, the advertisement media data corresponding to the advertisement insertion instruction, the method further comprises:
    从所述广告媒体数据中解析出广告音频数据包和广告视频数据包,并标记解析出的首个广告音频数据包和首个广告视频数据包。The advertisement audio data package and the advertisement video data package are parsed from the advertisement media data, and the parsed first advertisement audio data package and the first advertisement video data package are marked.
  6. 根据权利要求5所述的方法,其特征在于,所述标记解析出的首个广告音频数据包和首个广告视频数据包,包括:The method according to claim 5, wherein the first advertisement audio data packet and the first advertisement video data package parsed by the mark comprise:
    将所述首个广告音频数据包和所述首个广告视频数据包的标记字段的属性设置为真;Setting the attribute of the first advertisement audio data packet and the tag field of the first advertisement video data packet to true;
    在所述首个广告音频数据包中插入音频解码器配置参数,在所述首个广告视频数据包中插入视频解码器配置参数。 An audio decoder configuration parameter is inserted in the first advertisement audio data packet, and a video decoder configuration parameter is inserted in the first advertisement video data packet.
  7. 根据权利要求5或6所述的方法,其特征在于,所述通过解码线程对所述广告媒体数据解码得到广告音频采样和广告视频帧,包括:The method according to claim 5 or 6, wherein the decoding of the advertisement media data by the decoding thread to obtain the advertisement audio sample and the advertisement video frame comprises:
    判断当前所述广告媒体数据中的广告音频数据包是否为首个音频数据包,所述广告视频数据包是否为首个视频数据包;Determining whether the advertisement audio data packet in the current advertisement media data is the first audio data packet, and whether the advertisement video data packet is the first video data packet;
    当确定所述广告音频数据包为所述首个广告音频数据包,所述广告视频数据包为所述首个广告视频数据包时,根据所述首个广告音频数据包中的音频解码器配置参数对音频解码器进行初始化,根据所述首个广告视频数据包中的视频解码器配置参数对视频解码器进行初始化;When it is determined that the advertisement audio data packet is the first advertisement audio data packet, and the advertisement video data packet is the first advertisement video data packet, according to an audio decoder configuration in the first advertisement audio data packet The parameter initializes the audio decoder, and initializes the video decoder according to the video decoder configuration parameter in the first advertisement video data packet;
    根据初始化后的音频解码器对所述广告音频数据包进行解码,得到所述广告音频采样,根据初始化后的视频解码器对所述广告视频数据包进行解码,得到所述广告视频帧。Decoding the advertisement audio data packet according to the initialized audio decoder to obtain the advertisement audio sample, and decoding the advertisement video data packet according to the initialized video decoder to obtain the advertisement video frame.
  8. 根据权利要求1-7任意一项所述的方法,其特征在于,所述在所述播放线程播放已经缓存的所述正片媒体数据结束后,使所述播放线程播放所述广告音频采样和所述广告视频帧,包括:The method according to any one of claims 1 to 7, wherein after the playing thread plays the already-captured positive media data, the playing thread is caused to play the advertising audio sample and the Said advertising video frames, including:
    将当前广告音频采样的配置参数与前一次的音频采样的配置参数,及当前广告视频帧的配置参数与前一次的视频帧的配置参数进行比较,所述音频采样的配置参数包括所述音频采样的采样位数、采样率和通道数,所述视频帧的配置参数包括视频帧的颜色、格式和宽高;Comparing the configuration parameters of the current advertisement audio sample with the configuration parameters of the previous audio sample, and the configuration parameters of the current advertisement video frame with the configuration parameters of the previous video frame, the configuration parameters of the audio sample including the audio sample The number of sampling bits, the sampling rate, and the number of channels, and the configuration parameters of the video frame include the color, format, and width and height of the video frame;
    当确定所述当前广告音频采样的配置参数与前一次的所述音频采样的配置参数,所述当前广告视频帧的配置参数与前一次的所述视频帧的配置参数不一样时,将所述当前广告音频采样的配置参数和所述当前广告视频帧的配置参数复位输出,并输出所述当前广告音频采样和广告视频帧。Determining, when the configuration parameter of the current advertisement audio sample is different from the configuration parameter of the previous audio sample, the configuration parameter of the current advertisement video frame is different from the configuration parameter of the previous video frame The configuration parameters of the current advertisement audio sample and the configuration parameters of the current advertisement video frame are reset output, and the current advertisement audio sample and the advertisement video frame are output.
  9. 根据权利要求1-8任意一项所述的方法,其特征在于,所述方法还包括:The method of any of claims 1-8, wherein the method further comprises:
    当接收到退出播放指令后,退出当前正在播放的所述正片媒体数据或广告媒体数据。After receiving the exit play instruction, the positive media data or the advertisement media data currently being played is exited.
  10. 一种广告插播装置,其特征在在于,所述装置包括:An advertisement insertion device, characterized in that the device comprises:
    加载模块,配置成通过媒体加载线程缓存正片媒体数据;以及,配置成根据广告插播指令暂停通过所述媒体加载线程获取所述正片媒体数据的后续数据,并获取与所述广告插播指令对应的广告媒体数据;a loading module configured to cache the positive media data by the media loading thread; and configured to suspend subsequent data of the positive media data by the media loading thread according to the commercial insertion instruction, and obtain an advertisement corresponding to the commercial insertion instruction Media data;
    解码模块,用于配置成通过解码线程对所述广告媒体数据解码得到广告音频采样和广告视频帧;a decoding module, configured to decode the advertisement media data by a decoding thread to obtain an advertisement audio sample and an advertisement video frame;
    播放模块,配置成通过播放线程播放所述媒体加载线程缓存的正片媒体数据;以及,配置成在所述播放线程播放已经缓存的所述正片媒体数据结束后,使所述播放线程播放所述广告音频采样和所述广告视频帧。a playing module configured to play the positive media data cached by the media loading thread by the playing thread; and configured to cause the playing thread to play the advertisement after the playing thread plays the already-captured positive media data Audio samples and the advertising video frames.
  11. 根据权利要求10所述的装置,其特征在于,所述解码模块包括: The apparatus according to claim 10, wherein the decoding module comprises:
    音频解码子模块,配置成通过音频解码线程对所述广告媒体数据中的广告音频数据包进行解码,得到所述广告音频采样;An audio decoding submodule configured to decode an advertisement audio data packet in the advertisement media data by an audio decoding thread to obtain the advertisement audio sample;
    视频解码子模块,配置成通过视频解码线程对所述广告媒体数据中的广告视频数据包进行解码,得到所述广告视频帧。The video decoding sub-module is configured to decode the advertisement video data packet in the advertisement media data by using a video decoding thread to obtain the advertisement video frame.
  12. 根据权利要求10或11所述的装置,其特征在于,所述播放模块播放所述广告音频采样和所述广告视频帧的方式,包括:The device according to claim 10 or 11, wherein the manner in which the playing module plays the advertisement audio sample and the advertisement video frame comprises:
    使音频播放线程播放所述广告音频采样,使视频播放线程播放所述广告视频帧。The audio play thread is caused to play the advertisement audio sample, causing the video play thread to play the advertisement video frame.
  13. 根据权利要求10-12任意一项所述的装置,其特征在于,所述装置还包括:The device according to any one of claims 10-12, wherein the device further comprises:
    判断模块,配置成通过所述媒体加载线程打开与所述广告插播指令对应的广告媒体流,并解析所述广告媒体流的头部字节,判断广告媒体流的格式类型;The determining module is configured to open an advertisement media stream corresponding to the advertisement insertion instruction by using the media loading thread, and parse a header byte of the advertisement media stream, and determine a format type of the advertisement media stream;
    参数获取模块,配置成根据所述广告媒体流的格式类型解析获得音频解码器配置参数和视频解码器配置参数。The parameter obtaining module is configured to obtain the audio decoder configuration parameter and the video decoder configuration parameter according to the format type of the advertisement media stream.
  14. 根据权利要求13所述的装置,其特征在于,所述装置还包括:The device according to claim 13, wherein the device further comprises:
    标记模块,配置成从所述广告媒体数据中解析出广告音频数据包和广告视频数据包,并标记解析出的首个广告音频数据包和首个广告视频数据包。The marking module is configured to parse the advertisement audio data package and the advertisement video data package from the advertisement media data, and mark the parsed first advertisement audio data package and the first advertisement video data package.
  15. 根据权利要求14所述的装置,其特征在于,所述标记模块包括:The device according to claim 14, wherein said marking module comprises:
    字段设置子模块,配置成将所述首个广告音频数据包和所述首个广告视频数据包的标记字段的属性设置为真;a field setting submodule configured to set an attribute of the first advertisement audio data packet and a tag field of the first advertisement video data packet to true;
    参数插入子模块,配置成在所述首个广告音频数据包中插入音频解码器配置参数,在所述首个广告视频数据包中插入视频解码器配置参数。a parameter insertion sub-module configured to insert an audio decoder configuration parameter in the first advertisement audio data packet, and insert a video decoder configuration parameter in the first advertisement video data packet.
  16. 根据权利要求14或15所述的装置,其特征在于,所述解码模块得到广告音频采样和广告视频帧的方式,包括:The device according to claim 14 or 15, wherein the decoding module obtains an advertisement audio sample and an advertisement video frame, including:
    判断当前所述广告媒体数据中的广告音频数据包是否为首个音频数据包,所述广告视频数据包是否为首个视频数据包;Determining whether the advertisement audio data packet in the current advertisement media data is the first audio data packet, and whether the advertisement video data packet is the first video data packet;
    当确定所述广告音频数据包为所述首个广告音频数据包,所述广告视频数据包为所述首个广告视频数据包时,根据所述首个广告音频数据包中的音频解码器配置参数对音频解码器进行初始化,根据所述首个广告视频数据包中的视频解码器配置参数对视频解码器进行初始化;When it is determined that the advertisement audio data packet is the first advertisement audio data packet, and the advertisement video data packet is the first advertisement video data packet, according to an audio decoder configuration in the first advertisement audio data packet The parameter initializes the audio decoder, and initializes the video decoder according to the video decoder configuration parameter in the first advertisement video data packet;
    根据初始化后的音频解码器对所述广告音频数据包进行解码,得到所述广告音频采样,根据初始化后的视频解码器对所述广告视频数据包进行解码,得到所述广告视频帧。Decoding the advertisement audio data packet according to the initialized audio decoder to obtain the advertisement audio sample, and decoding the advertisement video data packet according to the initialized video decoder to obtain the advertisement video frame.
  17. 根据权利要求10-16任意一项所述的装置,其特征在于,所述播放模块播放所述广告音频采样和所述广告视频帧的方式,包括:The device according to any one of claims 10-16, wherein the manner in which the playing module plays the advertisement audio sample and the advertisement video frame comprises:
    将当前广告音频采样的配置参数与前一次的音频采样的配置参数,及当前广告视频帧的配置参数与前一次的视频帧的配置参数进行比较,所述音频采样的配置参数包 括所述音频采样的采样位数、采样率和通道数,所述视频帧的配置参数包括视频帧的颜色、格式和宽高;Comparing the configuration parameters of the current advertisement audio sample with the configuration parameters of the previous audio sample, and the configuration parameters of the current advertisement video frame with the configuration parameters of the previous video frame, the configuration parameter package of the audio sample The number of sampling bits, the sampling rate, and the number of channels of the audio sample, and the configuration parameters of the video frame include a color, a format, and a width and height of the video frame;
    当确定所述当前广告音频采样的配置参数与前一次的所述音频采样的配置参数,所述当前广告视频帧的配置参数与前一次的所述视频帧的配置参数不一样时,将所述当前广告音频采样的配置参数和所述当前广告视频帧的配置参数复位输出,并输出所述当前广告音频采样和广告视频帧。Determining, when the configuration parameter of the current advertisement audio sample is different from the configuration parameter of the previous audio sample, the configuration parameter of the current advertisement video frame is different from the configuration parameter of the previous video frame The configuration parameters of the current advertisement audio sample and the configuration parameters of the current advertisement video frame are reset output, and the current advertisement audio sample and the advertisement video frame are output.
  18. 根据权利要求10-17任意一项所述的装置,其特征在于,所述装置还包括:The device according to any one of claims 10-17, wherein the device further comprises:
    退出模块,配置成当接收到退出播放指令后,退出当前正在播放的所述正片媒体数据或广告媒体数据。The exit module is configured to quit the positive media data or the advertisement media data currently being played after receiving the exit play instruction.
  19. 一种存储于电子终端的可读取存储介质,其特征在于,包括多条指令,所述多条指令被配置成实现如权利要求1-9任一项所述的方法。 A readable storage medium stored in an electronic terminal, comprising a plurality of instructions configured to implement the method of any of claims 1-9.
PCT/CN2017/079592 2016-11-14 2017-04-06 Advertisement inter-cut method and device, and readable storage medium WO2018086303A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201611002602.6 2016-11-14
CN201611002602.6A CN106375837B (en) 2016-11-14 2016-11-14 A kind of advertisement cut-in method and device

Publications (1)

Publication Number Publication Date
WO2018086303A1 true WO2018086303A1 (en) 2018-05-17

Family

ID=57894020

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/079592 WO2018086303A1 (en) 2016-11-14 2017-04-06 Advertisement inter-cut method and device, and readable storage medium

Country Status (2)

Country Link
CN (1) CN106375837B (en)
WO (1) WO2018086303A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112770176A (en) * 2020-12-23 2021-05-07 北京爱奇艺科技有限公司 Video frame determination method and device, electronic equipment and computer readable medium
CN112785333A (en) * 2021-01-12 2021-05-11 北京奇艺世纪科技有限公司 Advertisement putting method, electronic device, storage medium and device
CN116347124A (en) * 2023-03-29 2023-06-27 上海枭柯文化传播有限公司 Advertisement loading method based on video playing state

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106375837B (en) * 2016-11-14 2017-10-10 武汉斗鱼网络科技有限公司 A kind of advertisement cut-in method and device
CN108366271B (en) * 2018-02-09 2020-12-01 腾讯音乐娱乐科技(深圳)有限公司 Multimedia file playing method and device and storage medium
CN109218763A (en) * 2018-11-12 2019-01-15 青岛海信传媒网络技术有限公司 A kind of method and smart television of streaming media video switching
CN112163895A (en) * 2020-10-14 2021-01-01 广州欢网科技有限责任公司 High-concurrency advertisement putting method, device, equipment and system based on asynchronous programming

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101345882A (en) * 2008-08-20 2009-01-14 北京搜狗科技发展有限公司 Playing device and method for inter-cutting audio files
CN102196312A (en) * 2010-03-02 2011-09-21 北大方正集团有限公司 Audio and video data stream playing method and device
CN102238139A (en) * 2010-04-27 2011-11-09 华为技术有限公司 Method, device and system for inserting advertisement
CN102905188A (en) * 2012-11-01 2013-01-30 北京奇艺世纪科技有限公司 Video code stream switching method and device
US20140368734A1 (en) * 2013-06-17 2014-12-18 Spotify Ab System and method for switching between media streams while providing a seamless user experience
CN105451034A (en) * 2015-12-04 2016-03-30 合一网络技术(北京)有限公司 Advertisement playing control method and system
CN106375837A (en) * 2016-11-14 2017-02-01 武汉斗鱼网络科技有限公司 Advertisement inter-cut method and device

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101179700B (en) * 2006-12-20 2011-05-11 腾讯科技(深圳)有限公司 Program source switch method and stream media play system
CN101198022B (en) * 2007-12-26 2010-06-02 青岛海信移动通信技术股份有限公司 Method for inter cutting video information in stream media broadcasting or buffering course
KR20140126094A (en) * 2013-04-22 2014-10-30 삼성전자주식회사 Method and apparatus for playing contents in multimedia system

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101345882A (en) * 2008-08-20 2009-01-14 北京搜狗科技发展有限公司 Playing device and method for inter-cutting audio files
CN102196312A (en) * 2010-03-02 2011-09-21 北大方正集团有限公司 Audio and video data stream playing method and device
CN102238139A (en) * 2010-04-27 2011-11-09 华为技术有限公司 Method, device and system for inserting advertisement
CN102905188A (en) * 2012-11-01 2013-01-30 北京奇艺世纪科技有限公司 Video code stream switching method and device
US20140368734A1 (en) * 2013-06-17 2014-12-18 Spotify Ab System and method for switching between media streams while providing a seamless user experience
CN105451034A (en) * 2015-12-04 2016-03-30 合一网络技术(北京)有限公司 Advertisement playing control method and system
CN106375837A (en) * 2016-11-14 2017-02-01 武汉斗鱼网络科技有限公司 Advertisement inter-cut method and device

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112770176A (en) * 2020-12-23 2021-05-07 北京爱奇艺科技有限公司 Video frame determination method and device, electronic equipment and computer readable medium
CN112770176B (en) * 2020-12-23 2022-10-25 北京爱奇艺科技有限公司 Video frame determination method and device, electronic equipment and computer readable medium
CN112785333A (en) * 2021-01-12 2021-05-11 北京奇艺世纪科技有限公司 Advertisement putting method, electronic device, storage medium and device
CN112785333B (en) * 2021-01-12 2023-09-01 北京奇艺世纪科技有限公司 Advertisement putting method, electronic equipment, storage medium and device
CN116347124A (en) * 2023-03-29 2023-06-27 上海枭柯文化传播有限公司 Advertisement loading method based on video playing state
CN116347124B (en) * 2023-03-29 2024-03-29 上海枭柯文化传播有限公司 Advertisement loading method based on video playing state

Also Published As

Publication number Publication date
CN106375837A (en) 2017-02-01
CN106375837B (en) 2017-10-10

Similar Documents

Publication Publication Date Title
WO2018086303A1 (en) Advertisement inter-cut method and device, and readable storage medium
US9282381B2 (en) Media playback control
US7707485B2 (en) System and method for dynamic transrating based on content
US8670072B1 (en) Method and apparatus for streaming media data processing, and streaming media playback equipment
US9736552B2 (en) Authoring system for IPTV network
TWI332358B (en) Media player apparatus and method thereof
CN105791889A (en) Advertisement inter-cut method for video live broadcasting and advertisement inter-cut device for video live broadcasting
KR20160113230A (en) Media application backgrounding
WO2016090889A1 (en) Promotion information processing method, device and apparatus, and non-volatile computer storage medium
US9438876B2 (en) Method for semantics based trick mode play in video system
CN103747317A (en) A smooth playing control method of a play database in an instable network
US9027052B2 (en) System and method for in-stream advertising on an internet connected device
US20140267337A1 (en) Pre-Defined Streaming Media Buffer Points
WO2021136161A1 (en) Playback mode determining method and apparatus
CN107690090A (en) Video broadcasting method and the electronic installation using the video broadcasting method
WO2023051068A1 (en) Video display method and apparatus, and computer device and storage medium
CN105187897B (en) The media file span playback method and system more being segmented
CN115623264A (en) Live stream subtitle processing method and device and live stream playing method and device
CN110679153A (en) Time placement of rebuffering events
CN108989905B (en) Media stream control method and device, computing equipment and storage medium
WO2016197759A1 (en) Information presentation method, terminal device, server and system
WO2024098836A1 (en) Video alignment method and apparatus
US20200401496A1 (en) Method and device of displaying video comments, computing device, and readable storage medium
JP2023528366A (en) Server Side Ad Insertion (SSAI) with additional metadata and client functionality
WO2023010402A1 (en) Media file playing method and apparatus, and computer device and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17870433

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17870433

Country of ref document: EP

Kind code of ref document: A1