









技术领域technical field
本发明涉及计算机技术领域,尤其涉及一种流媒体数据缓存方法,装置、电子设备、计算机可读存储介质及计算机程序产品。The present invention relates to the field of computer technology, in particular to a streaming media data caching method, device, electronic equipment, computer-readable storage medium and computer program product.
背景技术Background technique
相关技术中,需要对某些场景进行实时监控。实时监控时,先通过流媒体框架实时获取摄像头的音视频数据流,再通过TCP/RTP/RTSP等媒体传输协议将音视频数据流传输至终端,终端对该音视频数据流进行解析播放。In related technologies, real-time monitoring of certain scenes is required. In real-time monitoring, the audio and video data stream of the camera is obtained in real time through the streaming media framework, and then the audio and video data stream is transmitted to the terminal through media transmission protocols such as TCP/RTP/RTSP, and the terminal analyzes and plays the audio and video data stream.
也就是说,实时监控中,需要将摄像头拍摄的音视频数据流通过流媒体传输协议实时传输至终端进行解析播放,而连续拍摄记录期间会消耗到更多的摄像头、网络、终端设备等多方资源;且存储视频文件也需要耗费大量的ROM资源,增加了设备成本。由于实时监控往往是采取相同视频格式输出到终端进行监控,无法对突发状况的场景进行特殊处理,监控灵活性较差。That is to say, in real-time monitoring, the audio and video data stream captured by the camera needs to be transmitted to the terminal for analysis and playback in real time through the streaming media transmission protocol, and more resources such as the camera, network, and terminal equipment will be consumed during continuous shooting and recording. ; And storing video files also needs to consume a large amount of ROM resources, which increases the equipment cost. Since real-time monitoring often uses the same video format to output to the terminal for monitoring, it is impossible to perform special processing for emergencies, and the monitoring flexibility is poor.
发明内容Contents of the invention
本发明提供一种流媒体数据的缓存方法,装置、电子设备、计算机可读存储介质及计算机程序产品,以至少解决相关技术中由于实时监控的数据采取相同视频格式输出到终端进行存储播放,不能对突发情况的监控场景进行特殊处理,导致设备成本增加,监控灵活性较差的技术问题。本发明的技术方案如下:The present invention provides a streaming media data caching method, device, electronic equipment, computer-readable storage medium, and computer program product to at least solve the problem in the related art that real-time monitoring data is output to a terminal in the same video format for storage and playback. Special handling of monitoring scenarios in emergencies leads to technical problems such as increased equipment costs and poor monitoring flexibility. Technical scheme of the present invention is as follows:
根据本发明实施例的第一方面,提供一种流媒体数据缓存方法,包括:According to a first aspect of an embodiment of the present invention, a streaming media data caching method is provided, including:
响应于至少一个监控场景触发的缓存请求,根据每个缓存请求获取对应的流媒体数据;Responding to at least one caching request triggered by a monitoring scene, obtaining corresponding streaming media data according to each caching request;
按照设定缓存时长将获取的每路流媒体数据缓存到不同的缓存队列中。According to the set cache duration, each channel of streaming media data obtained is cached into different cache queues.
可选的,在按照设定缓存时长将获取的每路流媒体数据缓存到不同的缓存队列中之前,所述方法还包括:Optionally, before caching the acquired streaming media data into different cache queues according to the set cache duration, the method further includes:
选择获取的所述每路流媒体数据对应的媒体编码格式;Selecting the media encoding format corresponding to each channel of streaming media data obtained;
按照选择的所述媒体编码格式分别对获取的所述每路流媒体数据进行编码,得到编码后的每路流媒体数据;Encoding the obtained stream media data of each channel respectively according to the selected media encoding format to obtain encoded stream media data of each channel;
所述按照设定缓存时长将获取的每路流媒体数据缓存到不同的缓存队列中,包括:按照设定缓存时长将编码后的所述每路流媒体数据缓存到不同的缓存队列中。Said caching each path of acquired streaming media data into different buffer queues according to the set buffer duration includes: buffering the encoded stream media data into different buffer queues according to the set cache duration.
可选的,在响应于至少一个监控场景触发的缓存请求之后,所述方法还包括:Optionally, after responding to the caching request triggered by at least one monitoring scenario, the method further includes:
在存储与与所述至少一个监控场景对应的缓存队列的情况下,执行所述根据每个缓存请求获取对应的流媒体数据的步骤;In the case of storing the cache queue corresponding to the at least one monitoring scene, performing the step of obtaining corresponding streaming media data according to each cache request;
在不存在与所述至少一个监控场景对应的缓存队列的情况下,创建与所述至少一个监控场景对应的缓存队列,执行所述根据每个缓存请求获取对应的流媒体数据的步骤。If there is no cache queue corresponding to the at least one monitoring scene, create a cache queue corresponding to the at least one monitoring scene, and execute the step of obtaining corresponding streaming media data according to each cache request.
可选的,所述方法还包括:Optionally, the method also includes:
在缓存的所述流媒体数据的时间长度超过所述设定缓存时长的情况下,移除所述缓存队列中的头部数据,继续缓存所述流体数据到所述缓存队列的尾部。When the time length of the cached streaming media data exceeds the set cache time length, remove the header data in the cache queue, and continue to cache the fluid data to the end of the cache queue.
可选的,所述按照下述步骤确定缓存的流媒体数据的时间长度:Optionally, the time length of the cached streaming media data is determined according to the following steps:
确定开始缓存所述媒体流数据的时间戳到结束缓存所述媒体流数据的时间戳之差为缓存所述媒体数据流的时间长度。Determine the difference between the time stamp when the media stream data starts to be buffered and the time stamp when the media stream data ends when buffering is the time length for buffering the media data stream.
根据本发明实施例的第二方面,提供一种流媒体数据缓存方法,包括:According to a second aspect of the embodiments of the present invention, a streaming media data caching method is provided, including:
检测到获取流媒体数据的请求,所述请求包括:请求缓存队列中流媒体数据的请求开始时间和请求结束时间;A request for obtaining streaming media data is detected, and the request includes: a request start time and a request end time of the streaming media data in the request cache queue;
根据所述流媒体数据的请求开始时间和请求结束时间,确定所述缓存队列中待获取的流媒体数据;Determine the streaming media data to be acquired in the cache queue according to the request start time and request end time of the streaming media data;
获取所述缓存队列中待获取的流媒体数据。Obtain the streaming media data to be obtained in the cache queue.
可选的,所述根据所述流媒体数据的请求开始时间和请求结束时间,确定所述缓存队列中待获取的流媒体数据,包括:Optionally, the determining the streaming media data to be acquired in the cache queue according to the request start time and request end time of the streaming media data includes:
在所述流媒体数据的请求开始时间和请求结束时间为有效时间的情况下,将所述流媒体数据的请求开始时间和请求结束时间与所述缓存队列中流媒体数据的每帧数据的时间戳从缓存队列的头部依次进行匹配;In the case that the request start time and the request end time of the streaming media data are effective time, the request start time and the request end time of the streaming media data are combined with the timestamp of each frame data of the streaming media data in the cache queue Match sequentially from the head of the cache queue;
确定匹配成功的对应时间段内的流媒体数据为待获取的流媒体数据。It is determined that the streaming media data within the corresponding time period that is successfully matched is the streaming media data to be acquired.
可选的,获取所述缓存队列中待获取的流媒体数据包括:Optionally, obtaining the streaming media data to be obtained in the cache queue includes:
从所述缓存队列的头部开始获取未读取的流媒体数据;Obtain unread streaming media data from the head of the cache queue;
在所述未读取的流媒体数据的所述请求结束时间大于或等于所获取流媒体数据的时间戳,且所获取流媒体数据的时间戳大于或等于所述未读取的流媒体数据的请求开始时间的情况下,存储获取的所述流媒体数据;The request end time of the unread streaming media data is greater than or equal to the timestamp of the acquired streaming media data, and the timestamp of the acquired streaming media data is greater than or equal to the timestamp of the unread streaming media data In the case of requesting the start time, store the acquired streaming media data;
在所述缓存队列中最后一帧数据的时间戳小于所述未读取的流媒体数据的请求结束时间的情况下,执行所述从所述缓存队列的头部开始获取未读取的流媒体数据的步骤;In the case that the timestamp of the last frame of data in the buffer queue is less than the request end time of the unread streaming media data, perform the acquiring the unread streaming media from the head of the buffer queue data steps;
在所述未读取的流媒体数据的所述请求结束时间小于所获取流媒体数据的时间戳,且所获取流媒体数据的时间戳小于所述未读取的流媒体数据的请求开始时间,或所述所述缓存队列中最后一帧数据的时间戳大于或等于所述未读取的流媒体数据的请求结束时间的情况下,结束获取流媒体数据。When the request end time of the unread streaming media data is less than the timestamp of the acquired streaming media data, and the timestamp of the acquired streaming media data is less than the request start time of the unread streaming media data, Or when the time stamp of the last frame of data in the cache queue is greater than or equal to the request end time of the unread streaming media data, the acquisition of the streaming media data ends.
可选的,当检测到获取流媒体数据的请求为多个请求时,所述方法还包括:Optionally, when it is detected that the request for obtaining streaming media data is multiple requests, the method further includes:
在所述多个请求中的请求开始时间或请求结束时间存在交错时间段覆盖的情况下,更新存在交错时间段覆盖的请求中的请求开始时间或请求结束时间,以使更新后的所述请求开始时间或请求结束时间包括更新前的所述请求开始时间或请求结束时间;In the case that the request start time or request end time in the multiple requests is covered by an interleaved time period, update the request start time or request end time in the requests covered by the interleaved time period, so that the updated request the start time or request end time includes said request start time or request end time prior to the update;
将更新后的所述多个请求合并为一个请求。Merge the updated requests into one request.
根据本发明实施例的第三方面,提供一种流媒体数据缓存装置,包括:According to a third aspect of the embodiments of the present invention, a streaming media data caching device is provided, including:
获取模块,用于响应于至少一个监控场景触发的缓存请求,根据每个缓存请求获取对应的流媒体数据;An acquisition module, configured to acquire corresponding streaming media data according to each cache request in response to at least one cache request triggered by a monitoring scene;
第一缓存模块,用于按照设定缓存时长将获取的每路流媒体数据缓存到不同的缓存队列中。The first caching module is configured to cache the acquired stream media data of each channel into different cache queues according to the set cache duration.
可选的,所述装置还包括:Optionally, the device also includes:
选择模块,用于在所述第一缓存模块在按照设定缓存时长将获取的每路流媒体数据缓存到不同的缓存队列中之前,选择获取的所述每路流媒体数据对应的媒体编码格式;The selection module is used to select the media encoding format corresponding to each stream media data obtained before the first caching module caches each stream media data obtained into different cache queues according to the set buffer duration ;
编码模块,用于按照选择的所述媒体编码格式分别对获取的所述每路流媒体数据进行编码,得到编码后的每路流媒体数据;An encoding module, configured to encode each channel of the acquired streaming media data according to the selected media encoding format, to obtain encoded streaming media data of each channel;
所述第一缓存模块,还用于按照设定缓存时长将编码后的所述每路流媒体数据缓存到不同的缓存队列中。The first caching module is further configured to cache the encoded streaming media data of each channel into different cache queues according to the set cache duration.
可选的,所述装置还包括:Optionally, the device also includes:
第一判断模块,用于在所述响应于至少一个监控场景触发的缓存请求之后,判断是否存在与所述至少一个监控场景对应的缓存队列;A first judging module, configured to judge whether there is a cache queue corresponding to the at least one monitoring scene after the cache request triggered in response to the at least one monitoring scene;
创建模块,用于在所述第一判断模块判定不存在与所述至少一个监控场景对应的缓存队列的情况下,创建与所述少一个监控场景对应的缓存队列;A creation module, configured to create a cache queue corresponding to the one less monitoring scene when the first judging module determines that there is no cache queue corresponding to the at least one monitoring scene;
所述获取模块,还用于在所述创建模块创建与所述少一个监控场景对应的缓存队列后,根据每个缓存请求获取对应的流媒体数据。The acquisition module is further configured to acquire corresponding streaming media data according to each cache request after the creation module creates a cache queue corresponding to the one less monitoring scene.
可选的,所述获取模块,还用于在所述第一判断模块判定存在与所述至少一个监控场景对应的缓存队列的情况下,根据每个缓存请求获取对应的流媒体数据。Optionally, the acquiring module is further configured to acquire corresponding streaming media data according to each cache request when the first judging module determines that there is a cache queue corresponding to the at least one monitoring scene.
可选的,所述装置还包括:Optionally, the device also includes:
第二判断模块,用于判断缓存的所述流媒体数据的时间长度是否超过所述设定缓存时长;A second judging module, configured to judge whether the time length of the cached streaming media data exceeds the set cache time;
移除模块,用于在所述第二判断模块判定所述缓存时长超过所述设定缓存时长的情况下,移除所述缓存队列中的头部数据;A removal module, configured to remove header data in the cache queue when the second judging module determines that the cache duration exceeds the set cache duration;
所述第一缓存模块,还用于在所述移除模块移除所述缓存队列中的头部数据后,继续缓存所述流体数据到所述缓存队列的尾部。The first cache module is further configured to continue to cache the fluid data to the end of the cache queue after the removal module removes the head data in the cache queue.
可选的,所述装置还包括:Optionally, the device also includes:
差值确定模块,用于在所述第二判断模判断缓存的所述流媒体数据的时间长度是否超过所述设定缓存时长之前,确定开始缓存所述媒体流数据的时间戳到结束缓存所述媒体流数据的时间戳之差为缓存所述流媒体数据的时间长度。The difference determination module is used to determine whether the time length of the buffered streaming media data exceeds the set buffering time before the second judgment module judges whether the time stamp of the buffering of the media stream data to the end of the buffering time is determined. The difference between the time stamps of the media streaming data is the time length for caching the streaming media data.
根据本发明实施例的第四方面,提供一种流媒体数据缓存装置,包括:According to a fourth aspect of the embodiments of the present invention, a streaming media data caching device is provided, including:
检测模块,用于检测到获取流媒体数据的请求,所述请求包括:请求缓存队列中流媒体数据的请求开始时间和请求结束时间;The detection module is used to detect the request for obtaining streaming media data, and the request includes: the request start time and the request end time of the streaming media data in the request cache queue;
确定模块,用于根据所述流媒体数据的请求开始时间和请求结束时间确定所述缓存队列中待获取的流媒体数据;A determining module, configured to determine the streaming media data to be acquired in the cache queue according to the request start time and request end time of the streaming media data;
获取模块,用于获取所述缓存队列中待获取的的流媒体数据。An acquisition module, configured to acquire the streaming media data to be acquired in the cache queue.
可选的,所述确定模块包括:Optionally, the determination module includes:
第一判断模块,用于判断所述流媒体数据的请求开始时间和请求结束时间是否为有效时间;The first judging module is used to judge whether the request start time and the request end time of the streaming media data are valid time;
匹配模块,用于在所述第一判断模块判定所述请求开始时间和请求结束时间为有效时间的情况下,将所述流媒体数据的请求开始时间和请求结束时间与所述缓存队列中流媒体数据的每帧数据的时间戳从缓存队列的头部依次进行匹配;A matching module, configured to combine the request start time and request end time of the streaming media data with the streaming media in the cache queue when the first judging module judges that the request start time and the request end time are valid time The timestamp of each frame of data is sequentially matched from the head of the cache queue;
数据确定模块,用于在所述匹配模块匹配成功时,确定匹配成功的对应时间段内的流媒体数据为待获取的流媒体数据。The data determination module is configured to determine that the streaming media data within the corresponding time period of the successful matching is the streaming media data to be acquired when the matching module successfully matches.
可选的,所述获取模块包括:Optionally, the acquisition module includes:
数据获取模块,用于从所述缓存队列的头部开始获取未读取的流媒体数据;A data acquisition module, configured to acquire unread streaming media data from the head of the cache queue;
存储模块,用于在所述数据获取模块获取的所述未读取的流媒体数据的所述请求结束时间大于或等于所获取流媒体数据的时间戳,且所获取流媒体数据的时间戳大于或等于所述未读取的流媒体数据的请求开始时间的情况下;存储获取的所述流媒体数据;A storage module, configured to obtain the request end time of the unread streaming media data obtained by the data obtaining module greater than or equal to the timestamp of the obtained streaming media data, and the obtained streaming media data's timestamp is greater than Or in the case of being equal to the request start time of the unread streaming media data; storing the acquired streaming media data;
所述数据获取模块,还用于在所述缓存队列中最后一帧数据的时间戳小于所述未读取的流媒体数据的请求结束时间的情况下,从所述缓存队列的头部开始获取未读取的流媒体数据;The data acquisition module is further configured to start acquiring from the head of the cache queue when the timestamp of the last frame of data in the cache queue is less than the request end time of the unread streaming media data Unread streaming data;
结束模块,用于在所述数据获取模块获取的所述未读取的流媒体数据的所述请求结束时间小于所获取流媒体数据的时间戳,且所获取流媒体数据的时间戳小于所述未读取的流媒体数据的请求开始时间,或所述所述缓存队列中最后一帧数据的时间戳大于或等于所述未读取的流媒体数据的请求结束时间的情况下,结束获取流媒体数据。An end module, used for the request end time of the unread streaming media data acquired by the data acquisition module to be less than the timestamp of the acquired streaming media data, and the timestamp of the acquired streaming media data is less than the When the request start time of the unread streaming media data, or the timestamp of the last frame data in the cache queue is greater than or equal to the request end time of the unread streaming media data, end the stream acquisition media data.
可选的,所述装置还包括:Optionally, the device also includes:
第二判断模块,用于在所述获取模块获取流媒体数据的请求为多个请求的情况下,判断所述多个请求中的请求开始时间或请求结束时间是否存在交错时间段覆盖;The second judging module is used to judge whether the request start time or the request end time in the plurality of requests is covered by an interleaved time period when the request of the acquisition module to acquire streaming media data is a plurality of requests;
更新模块,用于在所述第二判断模块判断存在交错时间段覆盖的情况下,更新存在交错时间段覆盖的请求中的请求开始时间或请求结束时间,以使更新后的所述请求开始时间或请求结束时间包括更新前的所述请求开始时间或请求结束时间;An update module, configured to update the request start time or request end time in the request with staggered time period coverage when the second judging module judges that there is staggered time period coverage, so that the updated request start time or the request end time includes said request start time or request end time prior to the update;
合并模块,用于在所述更新模块更新后的所述多个请求合并为一个请求。A merging module, configured to merge the multiple requests updated by the updating module into one request.
根据本发明实施例的第五方面,提供一种电子设备,包括:According to a fifth aspect of the embodiments of the present invention, there is provided an electronic device, including:
处理器;processor;
用于存储所述处理器可执行指令的存储器;memory for storing said processor-executable instructions;
其中,所述处理器被配置为执行所述指令,以实现如上所述的流媒体数据缓存方法。Wherein, the processor is configured to execute the instructions, so as to implement the streaming media data caching method as described above.
根据本发明实施例的第六方面,提供一种计算机可读存储介质,当所述计算机可读存储介质中的指令由电子设备的处理器执行时,使得电子设备能够执行如上所述的流媒体数据缓存方法。According to a sixth aspect of the embodiments of the present invention, there is provided a computer-readable storage medium. When the instructions in the computer-readable storage medium are executed by the processor of the electronic device, the electronic device can perform the streaming media described above. Data caching method.
根据本发明实施例的第七方面,提供一种计算机程序产品,包括计算机程序或指令,其特征在于,所述计算机程序或指令被处理器执行时实现如上所述的流媒体数据缓存方法。According to a seventh aspect of the embodiments of the present invention, there is provided a computer program product, including computer programs or instructions, wherein, when the computer programs or instructions are executed by a processor, the method for caching streaming media data as described above is implemented.
本发明的实施例提供的技术方案至少带来以下有益效果:The technical solutions provided by the embodiments of the present invention bring at least the following beneficial effects:
本发明实施例中,响应于至少一个监控场景触发的缓存请求,根据每个缓存请求获取对应的流媒体数据;按照设定缓存时长将根据每个缓存请求获取的所述流媒体数据缓存到不同的缓存队列中。本发明实施例中,在检测到各个监控场景触发的缓存请求的情况下,记录各个监控场景下的流媒体数据,并将记录的流媒体数据按照设定缓存时长缓存到对应的缓存队列中,实现了对突发异常现场的前后时间内的音视频数据按照设定缓存时长进行记录保存,不但节省了内存资源,降低缓存成本,降低了异常场景各方的资源消耗,而且还提高了监控异常场景下数据存储的灵活性。In the embodiment of the present invention, in response to at least one cache request triggered by a monitoring scene, the corresponding streaming media data is obtained according to each cache request; according to the set cache duration, the streaming media data obtained according to each cache request is cached in different in the cache queue. In the embodiment of the present invention, when the cache request triggered by each monitoring scene is detected, the streaming media data under each monitoring scene is recorded, and the recorded streaming media data is cached in the corresponding cache queue according to the set cache duration, Realized the recording and saving of audio and video data before and after the sudden abnormal scene according to the set cache time, which not only saves memory resources, reduces the cache cost, reduces the resource consumption of all parties in the abnormal scene, but also improves the monitoring abnormality. The flexibility of data storage in scenarios.
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本发明。It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention.
附图说明Description of drawings
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本发明的实施例,并与说明书一起用于解释本发明的原理,并不构成对本发明的不当限定。The accompanying drawings here are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present invention, and used together with the specification to explain the principle of the present invention, and do not constitute an improper limitation of the present invention.
图1为本发明实施例提供的一种流媒体数据缓存方法的流程图。FIG. 1 is a flow chart of a streaming media data caching method provided by an embodiment of the present invention.
图2为本发明实施例提供的一种按照设定的缓存时长缓存数据的示意图。FIG. 2 is a schematic diagram of caching data according to a set caching duration provided by an embodiment of the present invention.
图3为本发明实施例提供的一种流媒体数据缓存方法的第一应用实例图。Fig. 3 is a diagram of a first application example of a streaming media data caching method provided by an embodiment of the present invention.
图4为本发明实施例提供的一种流媒体数据缓存方法的另一流程图。FIG. 4 is another flow chart of a streaming media data caching method provided by an embodiment of the present invention.
图5为本发明实施例提供的一种流媒体数据缓存方法的第二应用实例图。FIG. 5 is a diagram of a second application example of a streaming media data caching method provided by an embodiment of the present invention.
图6为本发明实施例提供的一种判断多个请求是否存在时间段覆盖的示意图。FIG. 6 is a schematic diagram of judging whether multiple requests have time period coverage provided by an embodiment of the present invention.
图7为本发明实施例提供的一种流媒体数据缓存装置的框图。Fig. 7 is a block diagram of a streaming media data caching device provided by an embodiment of the present invention.
图8为本发明实施例提供的一种流媒体数据缓存装置的另一框图。Fig. 8 is another block diagram of a streaming media data caching device provided by an embodiment of the present invention.
图9为本发明实施例提供的一种电子设备的框图。Fig. 9 is a block diagram of an electronic device provided by an embodiment of the present invention.
图10为本发明实施例提供的一种具有流媒体数据缓存的装置的框图。Fig. 10 is a block diagram of a device with streaming media data cache provided by an embodiment of the present invention.
具体实施方式Detailed ways
为了使本领域普通人员更好地理解本发明的技术方案,下面将结合附图,对本发明实施例中的技术方案进行清楚、完整地描述。In order to enable ordinary persons in the art to better understand the technical solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings.
需要说明的是,本发明的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本发明的实施例能够以除了在这里图示或描述的那些以外的顺序实施。以下示例性实施例中所描述的实施方式并不代表与本发明相一致的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本发明的一些方面相一致的装置和方法的例子。It should be noted that the terms "first" and "second" in the description and claims of the present invention and the above drawings are used to distinguish similar objects, but not necessarily used to describe a specific sequence or sequence. It is to be understood that the data so used are interchangeable under appropriate circumstances such that the embodiments of the invention described herein can be practiced in sequences other than those illustrated or described herein. The implementations described in the following exemplary examples do not represent all implementations consistent with the present invention. Rather, they are merely examples of apparatuses and methods consistent with aspects of the invention as recited in the appended claims.
图1是本发明实施例提供的一种流媒体数据缓存方法的流程图,该实施例以缓存流媒体数据为例。如图1所示,流媒体数据缓存方法用于终端或服务器中,所述方法包括以下步骤:Fig. 1 is a flow chart of a streaming media data caching method provided by an embodiment of the present invention, and this embodiment takes caching streaming media data as an example. As shown in Figure 1, the streaming media data caching method is used in a terminal or a server, and the method includes the following steps:
在步骤101中,响应于至少一个监控场景触发的缓存请求,根据每个缓存请求获取对应的流媒体数据;In
该实施例中,可以检测到一个监控场景触发的缓存请求,也可以检测到多个监控场景触发的缓存请求,针对检测到的每个缓存请求,都会去获取对应的媒体流数据。比如,零售店,当检测到店门发生异动时,触发缓存请求,以便于对该门店内的场景进行记录,即获取对应的流媒体数据。In this embodiment, a caching request triggered by one monitoring scene or multiple caching requests triggered by a monitoring scene may be detected, and corresponding media stream data will be acquired for each detected caching request. For example, in a retail store, when a change in the store door is detected, a cache request is triggered to record the scene in the store, that is, to obtain the corresponding streaming media data.
其中,本实施例中的媒体流数据可以是音频数据,视频数据,或者是音视频数据等。获取音视频流数据,可通过主流的流媒体框架,比如FFMPEG、Gstreamer等,都可以获取到摄像头拍摄的音视频数据,并且,相关的流媒体框架都提供了编解码技术,使缓存占用更小的内存空间,使用比较灵活;需要说明的是,该流媒体框架能够将流媒体数据中的每一帧数据进行信息结构化,可以包括每帧数据的时间戳字段,该时间戳字段是用来计算缓存预设缓存时长(即设定的固定时间长度)的数据量的重要依据。而由于各种数据格式的存储优劣不同,比如,存储JPEG等数据量较多且成像清晰度较高的视频格式时,需要占用大量的内存空间,再比如,存储H264等这种数据量图片质量较低的视频格式时,占用的内存相对会少些,减少了各方(比如CPU、内存和ROM等)资源消耗。Wherein, the media stream data in this embodiment may be audio data, video data, or audio and video data. To obtain audio and video stream data, the audio and video data captured by the camera can be obtained through mainstream streaming media frameworks, such as FFMPEG, Gstreamer, etc., and the relevant streaming media frameworks provide codec technology to make the cache footprint smaller The memory space is relatively flexible; it should be noted that the streaming media framework can structure the information of each frame of data in the streaming media, and can include the timestamp field of each frame of data, which is used to An important basis for calculating the amount of data in the cache for the preset cache duration (that is, the set fixed time length). However, due to the different storage advantages and disadvantages of various data formats, for example, when storing JPEG and other video formats with a large amount of data and high imaging definition, it needs to occupy a large amount of memory space, and for example, storing H264 and other such data-volume pictures When the video format is of lower quality, the memory occupied will be relatively less, which reduces the resource consumption of all parties (such as CPU, memory and ROM, etc.).
在步骤102中,按照设定缓存时长将获取的每路流媒体数据缓存到不同的缓存队列中。In
该步骤中,通常情况下,针对每个监控场景,触发的每个缓存请求都在内存中对应一个缓存队列,缓存队列是用来缓存特殊场景下获取的流媒体数据。其中,缓存的流媒体数据(比如音视频流数据等)的格式可以是任何数据流格式,可以包括如JPEG、MPEG4或H264等格式的视频流数据,也可以包括如AAC或G726等格式的音频流数据等。In this step, under normal circumstances, for each monitoring scenario, each triggered cache request corresponds to a cache queue in the memory, and the cache queue is used to cache streaming media data obtained in a special scenario. Wherein, the format of the streaming media data (such as audio and video streaming data, etc.) that is buffered can be any data streaming format, and can include video streaming data in formats such as JPEG, MPEG4 or H264, and can also include audio in formats such as AAC or G726. streaming data, etc.
该实施例中,为了达到缓存媒体流数据能够灵活取用,本实施例将流媒体数据存入终端的内存中,也就是说,本实施例在终端中预先申请一段内存区域来存放根据缓存请求而获取的流媒体数据(比如音视频流数据等),其中,该将该内存区域划分为可以存储设定缓存时长的多个缓存队列,并为每个缓存队列设定不同的ID标识,以便于区别存储不同类型的流媒体数据(每个类型对应一路流媒体数据)。其中,设定缓存时长可以是存储一分钟内的流媒体数据等,当然,也可以根据需要设置其它的缓存时长,比如2分钟或3分钟等,本实施例不做限制。比如,零售店,当检测到店门发生异动时,触发缓存请求,控制摄像头对该门店内的监控场景进行拍摄,记录该场景下的流媒体数据,其记录的时长可以是预先设定的时长,比如一分钟等,将记录的所述流媒体数据缓存到对应的缓存队列中,以便于存储该场景下的流媒体数据。In this embodiment, in order to achieve flexible access to the cached media stream data, this embodiment stores the streaming media data in the memory of the terminal, that is to say, this embodiment pre-applies for a section of memory area in the terminal to store And the streaming media data (such as audio and video stream data etc.) that obtains, wherein, this memory area should be divided into a plurality of cache queues that can store the set cache duration, and set different ID marks for each cache queue, so that It is used to store different types of streaming media data (each type corresponds to one channel of streaming media data). Wherein, setting the cache duration can be to store streaming media data within one minute, etc. Of course, other cache durations can also be set as required, such as 2 minutes or 3 minutes, etc., which are not limited in this embodiment. For example, in a retail store, when a change in the store door is detected, a cache request is triggered, the camera is controlled to shoot the monitoring scene in the store, and the streaming media data in the scene is recorded, and the recording time can be a preset time length , such as one minute, etc., cache the recorded streaming media data into the corresponding cache queue, so as to store the streaming media data in this scenario.
本实施例中,由于缓存流媒体数据的长度也会影响内存的占用,所以,本实施例可以根据实际需求来设定缓存时长。通常情况下,对于监控的大部分突发事件,在事件发生前一分钟到事件发生时的这段时间足够。所以,本实施例中,对缓存流媒体数据(比如音视频流)的时间长度可以以单位时间为基准,即缓存一分钟内的音视频流数据于内存的缓存队列中,并且,该缓存的流媒体数据为一分钟前到当前时间点之间的流媒体数据,以此达到对过去监控场景记录和存储要求。In this embodiment, since the length of the cached streaming media data will also affect the memory usage, in this embodiment, the cache duration can be set according to actual requirements. Typically, the time between one minute before and when the event occurs is sufficient for most incidents that are monitored. Therefore, in this embodiment, the time length for buffering streaming media data (such as audio and video streams) can be based on unit time, that is, the audio and video stream data within one minute is cached in the cache queue of the internal memory, and the buffered The streaming media data is the streaming media data from one minute ago to the current time point, so as to meet the recording and storage requirements of past monitoring scenes.
本发明实施例中,响应于至少一个监控场景触发的缓存请求,根据每个缓存请求获取对应的流媒体数据;按照设定缓存时长将根据每个缓存请求获取的所述流媒体数据缓存到不同的缓存队列中。也就是说,本发明实施例中,在检测到各个监控场景触发的缓存请求的情况下,记录各个监控场景下的流媒体数据,并将记录的流媒体数据按照设定缓存时长缓存到对应的缓存队列中,实现了对突发异常现场的前后时间内的音视频数据按照设定缓存时长进行记录保存,不但节省了内存资源,降低缓存成本,降低了异常场景各方的资源消耗,而且还提高了监控异常场景下数据存储的灵活性。In the embodiment of the present invention, in response to at least one cache request triggered by a monitoring scene, the corresponding streaming media data is obtained according to each cache request; according to the set cache duration, the streaming media data obtained according to each cache request is cached in different in the cache queue. That is to say, in the embodiment of the present invention, in the case of detecting the cache request triggered by each monitoring scene, record the streaming media data under each monitoring scene, and cache the recorded streaming media data to the corresponding In the cache queue, the audio and video data before and after the sudden abnormal scene are recorded and saved according to the set cache duration, which not only saves memory resources, reduces the cost of caching, and reduces the resource consumption of all parties in the abnormal scene, but also Improves the flexibility of data storage in abnormal monitoring scenarios.
可选的,在另一实施例中,该实施例在上述实施例的基础上,在按照设定缓存时长将获取的每路流媒体数据缓存到不同的缓存队列中之前,所述方法还可以包括:选取获取的所述每路流媒体数据对应的媒体编码格式;按照选择的所述媒体编码格式分别对获取的所述每路流媒体数据进行编码,得到编码后的每路流媒体数据;按照设定缓存时长将编码后的所述每路流媒体数据缓存到不同的缓存队列中。Optionally, in another embodiment, on the basis of the above embodiment, before buffering each channel of streaming media data obtained according to the set buffer duration into different buffer queues, the method may also Including: selecting the acquired media encoding format corresponding to each channel of streaming media data; respectively encoding each acquired channel of streaming media data according to the selected media encoding format to obtain encoded streaming media data of each channel; The encoded streaming media data of each channel is cached in different cache queues according to the set cache duration.
该步骤中,由于流媒体数据的格式对终端内存消耗的影响较大,本实施例中,为了节省内存资源,可以根据实际需求决定是否需要将获取的原始流媒体数据的格式(比如yuv/raw等)编码成对应的流媒体数据,从而得到编码后的每路流媒体数据;然后将编码后的所述每路流媒体数据缓存到不同的缓存队列中,以便于在内存消耗和音视频质量中间达到平衡。In this step, since the format of the streaming media data has a great impact on the memory consumption of the terminal, in this embodiment, in order to save memory resources, it can be determined whether the format of the original streaming media data obtained (such as yuv/raw etc.) into corresponding streaming media data, so as to obtain encoded streaming media data of each path; then cache the encoded streaming media data of each path into different cache queues, so as to facilitate the intermediate memory consumption and audio and video quality Achieve balance.
本发明实施例中,还可以根据实际需求,对于不同类型的流媒体选择合适的媒体编码格式,按照选择的媒体编码格式对获取到的每路流媒体数据进行编码压缩,从而减少媒体流数据存储时所占用的内存空间,提高了内存的利用率。In the embodiment of the present invention, it is also possible to select a suitable media encoding format for different types of streaming media according to actual needs, and encode and compress each channel of streaming media data obtained according to the selected media encoding format, thereby reducing the storage of media streaming data The memory space occupied by the system increases the utilization rate of the memory.
可选的,在另一实施例中,该实施在响应于至少一个监控场景触发的缓存请求之后,所述方法还可以包括:在存在与所述至少一个监控场景对应的缓存队列的情况下,执行所述根据每个缓存请求获取对应的流媒体数据的步骤;或者在不存在与所述至少一个监控场景对应的缓存队列的情况下,创建与所述至少一个监控场景对应的缓存队列,执行所述根据每个缓存请求获取对应的流媒体数据的步骤。Optionally, in another embodiment, after the implementation is in response to a cache request triggered by at least one monitoring scenario, the method may further include: if there is a cache queue corresponding to the at least one monitoring scenario, Execute the step of obtaining corresponding streaming media data according to each cache request; or create a cache queue corresponding to the at least one monitoring scene when there is no cache queue corresponding to the at least one monitoring scene, and execute The step of acquiring corresponding streaming media data according to each cache request.
该实施例中,在检测到至少一个监控场景触发的缓存请求的情况下,先判断内存中是否存在与所述至少一个监控场景对应的缓存队列;如果不存在,则创建与所述至少一个监控场景对应的缓存队列,然后根据所述至少一个监控场景中的每个监控场景的缓存请求获取对应的流媒体数据;如果存在,直接根据所述至少一个监控场景中的每个监控场景的缓存请求获取对应的流媒体数据。In this embodiment, in the case of detecting a cache request triggered by at least one monitoring scene, first determine whether there is a cache queue corresponding to the at least one monitoring scene in the memory; if not, create a cache queue corresponding to the at least one monitoring scene The cache queue corresponding to the scene, and then obtain the corresponding streaming media data according to the cache request of each monitoring scene in the at least one monitoring scene; if it exists, directly according to the cache request of each monitoring scene in the at least one monitoring scene Get the corresponding streaming media data.
其中,该实施例中,通常情况下,针对每个监控场景,都会在内存中预先创建与每个监控场景中的流媒体数据对应缓存队列,比如,预先在内存中创建与第一零售门店监控场景对应的两个缓存队列(本实施例两个缓存队列为例),即缓存队列01和缓存队列02。其中,该缓存队列01,用来缓存该监控场景下的音频数据,该缓存队列02,用来缓存该监控场景下的视频数据等。当然,在检测到某个新增加的场景时,需要针对该场景新建对应的缓存队列。Wherein, in this embodiment, usually, for each monitoring scene, a cache queue corresponding to the streaming media data in each monitoring scene will be pre-created in memory, for example, a cache queue corresponding to the first retail store is created in memory in advance The two cache queues corresponding to the monitoring scene (the two cache queues in this embodiment are taken as an example), namely cache queue 01 and cache queue 02. Wherein, the buffer queue 01 is used for buffering audio data in the monitoring scene, and the buffer queue 02 is used for buffering video data in the monitoring scene. Of course, when a newly added scene is detected, a corresponding cache queue needs to be created for the scene.
所以,终端在检测到某个监控场景触发的缓存请求时,会先判断内存中是否存在与该监控场景对应的缓存队列;如果不存在,则创建与该监控场景对应的缓存队列,然后根据该监控场景的缓存请求获取对应的流媒体数据;如果存在,就直接该监控场景的缓存请求获取对应的流媒体数据。Therefore, when the terminal detects a cache request triggered by a monitoring scene, it will first determine whether there is a cache queue corresponding to the monitoring scene in the memory; if not, create a cache queue corresponding to the monitoring scene, and then according to the The cache request of the monitoring scene obtains the corresponding streaming media data; if it exists, the corresponding streaming media data is directly obtained by the cache request of the monitoring scene.
也就是说,本发明实施例中,在检测到监控场景触发的缓存请求,且获取该缓存请求对应的流媒体数据之前,先判断内存中是否存在与该监控场景对应的缓存队列,如果存在,则直接执行获取该缓存请求对应的流媒体数据,然后,将该获取的流媒体数据存储到对应的缓存队列中,如果不存在,就建立与该监控场景对应的缓存列队,然后,获取该缓存请求对应的流媒体数据,并将获取的流媒体数据缓存到创建的所述缓存队列中。That is to say, in the embodiment of the present invention, before the cache request triggered by the monitoring scene is detected and the streaming media data corresponding to the cache request is obtained, it is first judged whether there is a cache queue corresponding to the monitoring scene in the memory, and if so, Then directly execute to obtain the streaming media data corresponding to the cache request, and then store the obtained streaming media data in the corresponding cache queue, if it does not exist, establish a cache queue corresponding to the monitoring scene, and then obtain the cache Request corresponding streaming media data, and cache the obtained streaming media data into the created cache queue.
本发明实施例中,基于不同的监控场景,预先在内存中创建与监控场景对应的缓存队列,以便于在检测到该监控场景的缓存请求时,对该监控场景的流媒体数据进行分类缓存到对应的缓存队列,节省了内存空间,提高了流媒体数据的查找效率。In the embodiment of the present invention, based on different monitoring scenarios, a cache queue corresponding to the monitoring scenario is created in memory in advance, so that when a cache request of the monitoring scenario is detected, the streaming media data of the monitoring scenario is classified and cached to The corresponding cache queue saves memory space and improves the search efficiency of streaming media data.
可选的,在另一实施例中,该实施例在上述实施例的基础上,所述方法还可以包括:在缓存的所述流媒体数据的时间长度超过所述设定缓存时长的情况下,移除所述缓存队列中的头部数据,继续缓存所述流体数据到所述缓存队列的尾部。具体如图2所示,图2为本发明实施例提供的一种按照设定的缓存时长缓存数据的示意图。Optionally, in another embodiment, on the basis of the above embodiment, the method may further include: when the time length of the cached streaming media data exceeds the set cache time length , remove the header data in the cache queue, and continue to cache the fluid data to the end of the cache queue. Specifically, as shown in FIG. 2 , FIG. 2 is a schematic diagram of caching data according to a set cache duration provided by an embodiment of the present invention.
如图2所示,本实施例设定的缓存时长以一分钟为例,即缓存一分钟之前到当前时间的流媒体数据,并将流媒体数据缓存到对应的缓存队列的尾部,并在缓存的过程中,判断缓存的所述流媒体数据的时间长度是否超过一分钟,如果超过一分钟,则移除所述缓存队列中的头部数据,即图中所示的帧数据出的箭头,继续缓存所述流体数据到所述缓存队列的尾部,即图中所示的帧数据进的箭头。As shown in Figure 2, the cache duration set in this embodiment takes one minute as an example, that is, the streaming media data from one minute ago to the current time is cached, and the streaming media data is cached to the tail of the corresponding cache queue, In the process of judging whether the time length of the streaming media data cached exceeds one minute, if it exceeds one minute, then remove the head data in the cache queue, that is, the arrow shown in the frame data shown in the figure, Continue to buffer the fluid data to the end of the buffer queue, that is, the frame data entry arrow shown in the figure.
本发明实施例中缓存队列的缓存结构,可以采用双端队列,其优点是数据可以先进先出,能够让缓存的数据有序化,避免后续取出无序数据导致音视频的合成问题;另外,本实施例能够快速读取到缓存队列中的首尾数据,以便于判断缓存数据的时间长度是否以达到设定缓存长度。The cache structure of the cache queue in the embodiment of the present invention can adopt a double-ended queue, which has the advantage that the data can be first in first out, which can make the cached data orderly, and avoid the problem of audio and video synthesis caused by subsequent unordered data extraction; in addition, This embodiment can quickly read the first and last data in the cache queue, so as to judge whether the time length of the cached data reaches the set cache length.
可选的,在另一实施例中,该实施例在上述实施例的基础上,按照下述步骤确定缓存的流媒体数据的时间长度:确定开始缓存所述媒体流数据的时间戳到结束缓存所述媒体流数据的时间戳之差;将所述时间戳之差作为缓存所述媒体数据流的时间长度。Optionally, in another embodiment, on the basis of the above embodiment, this embodiment determines the time length of the buffered streaming media data according to the following steps: determine the time stamp from the start of buffering the media streaming data to the end of the buffering The time stamp difference of the media stream data; using the time stamp difference as the time length for buffering the media data stream.
本实施例中,缓存流媒体数据的时间长度的计算依赖于音视频帧中的时间戳字段,并且以头尾帧数据时间戳之差来计算存储的流媒体数据是否超过一分钟上限,如果超过一分钟,则移除缓存队列的头部数据,以保证新数据能够正常进该缓存队列的入尾部进行存储。即,本实施例以设定的固定时间长度来缓存流媒体数据。In this embodiment, the calculation of the length of time for buffering streaming media data depends on the timestamp field in the audio and video frame, and calculates whether the stored streaming media data exceeds the upper limit of one minute with the difference between the head and tail frame data timestamps. After one minute, the head data of the cache queue is removed to ensure that new data can be normally stored at the tail of the cache queue. That is, in this embodiment, streaming media data is cached with a set fixed time length.
还请参阅图3,为本发明实施例提供的一种流媒体数据缓存方法的第一应用实例图;该实施例以接收到一个缓存请求为例。但在实际应用中,并并不限于此,可以对接收的到的缓存请求进行并行处理。Please also refer to FIG. 3 , which is a diagram of a first application example of a streaming media data caching method provided by an embodiment of the present invention; this embodiment takes receiving a caching request as an example. However, in practical applications, it is not limited to this, and the received cache requests can be processed in parallel.
步骤301:检测到监控场景触发的缓存请求;Step 301: Detecting a cache request triggered by a monitoring scene;
步骤302:判断内存中是否存在与所述监控场景对应的缓存队列;如果不存在,执行步骤303;否则,执行步骤304;Step 302: Determine whether there is a cache queue corresponding to the monitoring scene in the memory; if not, execute
步骤303:创建与所述监控场景对应的缓存队列;Step 303: Create a cache queue corresponding to the monitoring scene;
步骤304:根据所述缓存请求获取该监控场景的流媒体数据;Step 304: Obtain the streaming media data of the monitoring scene according to the cache request;
步骤305:将获取的该监控场景的流媒体数据开始缓存到对应的缓存队列中;Step 305: Start caching the acquired streaming media data of the monitoring scene into the corresponding cache queue;
步骤306:判断缓存流媒体数据的缓存时长是否超过一分钟(本实施例设定缓存时长以一分钟为例),如果是,执行步骤307:否则,执行步骤308;Step 306: Determine whether the cache duration of the cached streaming media data exceeds one minute (this embodiment sets the cache duration to one minute as an example), if yes, execute step 307: otherwise, execute
步骤307:移除所述缓存队列中的头部数据;Step 307: remove the header data in the cache queue;
步骤308:继续将所述流媒体数据缓存到所述缓存队列的尾部。Step 308: Continue buffering the streaming media data to the end of the buffering queue.
本发明实施例中,在检测到监控场景触发的缓存请求时,先确定内存中是否存在与该监控场景对应的缓存队列,如果存在,则获取该监控场景的流媒体数据,并将获取的流媒体数据开始缓存到对应的缓存队列中,然后,判断缓存流媒体数据的缓存时长是否超过设定的一分钟缓存时长;如果超过,移除所述缓存队列中的头部数据,继续缓存所述流体数据到所述缓存队列的尾部;否则继续缓存所述流体数据到所述缓存队列的尾部。本发明实施例中,在检测到监控场景触发的缓存请求后,可以对突发的监控场景进行记录,并将记录的流媒体数据按照设定缓存时长缓存到对应的缓存队列中,不但节约内存资源,降低设备成本,还提高了监控的灵活性。In the embodiment of the present invention, when a cache request triggered by a monitoring scene is detected, it is first determined whether there is a cache queue corresponding to the monitoring scene in the memory, and if so, the streaming media data of the monitoring scene is obtained, and the obtained stream The media data starts to be cached in the corresponding cache queue, and then, it is judged whether the cache duration of the cache streaming media data exceeds the set one-minute cache duration; if it exceeds, remove the header data in the cache queue, and continue to cache the Fluid data to the tail of the buffer queue; otherwise, continue to buffer the fluid data to the tail of the buffer queue. In the embodiment of the present invention, after the cache request triggered by the monitoring scene is detected, the sudden monitoring scene can be recorded, and the recorded streaming media data can be cached in the corresponding cache queue according to the set cache duration, which not only saves memory resources, reduce equipment costs, and improve monitoring flexibility.
还请参阅图4,为本发明实施例提供的一种流媒体数据缓存方法的另一流程图,该实施例以读取缓存队列中缓存的流媒体数据为例。如图4所示,流媒体数据缓存方法用于终端或服务器中,所述方法包括以下步骤:Please also refer to FIG. 4 , which is another flow chart of a streaming media data caching method provided by an embodiment of the present invention. This embodiment takes reading streaming media data cached in a cache queue as an example. As shown in Figure 4, the streaming media data caching method is used in a terminal or a server, and the method includes the following steps:
步骤401:检测到获取流媒体数据的请求,所述请求包括:请求缓存队列中流媒体数据的请求开始时间和请求结束时间;Step 401: Detecting a request for acquiring streaming media data, the request includes: the request start time and the request end time of the streaming media data in the request cache queue;
该步骤中,由于缓存队列中缓存的流媒体数据是按设定的缓存时长(即固定时间长度)来存储的,因此,在读取该缓存队列中的流媒体数据时,需要在请求中包含请求缓存队列中该流媒体数据的有效的请求开始时间及请求结束时间,用来与流媒体数据中每帧数据的时间戳字段做匹配,以找出符合该时间段的流媒体数据。In this step, since the streaming media data cached in the cache queue is stored according to the set cache duration (that is, the fixed time length), when reading the streaming media data in the cache queue, it is necessary to include in the request The effective request start time and request end time of the streaming media data in the request cache queue are used to match with the timestamp field of each frame of data in the streaming media data, so as to find out the streaming media data matching the time period.
步骤402:根据所述流媒体数据的请求开始时间和请求结束时间,确定所述缓存队列中待获取的流媒体数据;Step 402: Determine the streaming media data to be acquired in the cache queue according to the request start time and request end time of the streaming media data;
该步骤中,先判断所述流媒体数据的请求开始时间和请求结束时间是否为有效时间;若为有效时间,则将所述流媒体数据的请求开始时间和请求结束时间与所述缓存队列中流媒体数据的每帧数据的时间戳从缓存队列的头部依次进行匹配;如果匹配成功,则确定匹配成功的对应时间段内的流媒体数据为待获取的流媒体数据。In this step, first judge whether the request start time and the request end time of the streaming media data are effective time; The timestamps of each frame of media data are sequentially matched from the head of the buffer queue; if the matching is successful, the streaming media data within the corresponding time period of the successful matching is determined to be the streaming media data to be acquired.
步骤403:获取所述缓存队列中待获取的流媒体数据。Step 403: Obtain the streaming media data to be obtained in the cache queue.
该步骤中,从所述缓存队列的头部开始获取对应的流媒体数据;若获取对应的流媒体数据的所述请求结束时间大于或等于当前获取流媒体数据中每帧数据的时间戳或当前请求开始时间,则存储获取的所述流媒体数据;若所述缓存队列中的最后一帧数据的时间戳小于所述请求结束时间,则从所述缓存队列的头部开始获取对应的流媒体数据;若获取对应的流媒体数据的所述请求结束时间小于当前获取流媒体数据中每帧数据的时间戳或当前请求开始时间,或所述缓存队列中的最后一帧数据的时间戳大于或等于所述请求结束时间,则结束获取流媒体数据。In this step, start to obtain the corresponding streaming media data from the head of the cache queue; if the request end time of obtaining the corresponding streaming media data is greater than or equal to the timestamp of each frame of data in the currently obtained streaming media data or the current Request start time, then store the obtained streaming media data; if the timestamp of the last frame data in the cache queue is less than the request end time, start to get the corresponding streaming media from the head of the cache queue data; if the end time of the request to obtain the corresponding streaming media data is less than the timestamp of each frame of data in the currently obtained streaming media data or the current request start time, or the timestamp of the last frame of data in the cache queue is greater than or If it is equal to the request end time, the acquisition of streaming media data ends.
由于缓存队列中的数据一直在更新的,所以,该请求结束时间点可以是未来的某个时间点,当达到设定的缓存时长时,移除缓存队列中的头部数据,以便于将获取到的新数据增加到该缓存队列的尾部,直至尾部新加的数据帧时间戳达到请求结束时间。Since the data in the cache queue is always being updated, the end time of the request can be a certain point in the future. When the set cache duration is reached, the head data in the cache queue will be removed so that the request will be retrieved The new data that arrives is added to the tail of the cache queue until the timestamp of the newly added data frame at the tail reaches the end time of the request.
本发明实施例中,在检测到获取流媒体数据的请求时,根据所述流媒体数据的请求开始时间和请求结束时间,确定所述缓存队列中待获取的流媒体数据;获取所述缓存队列中待获取的流媒体数据。也就是说,本发明实施例中,根据获取流媒体数据的请求中的请求缓存队列中流媒体数据的请求开始时间和请求结束时间,可以根据需求灵活读取缓存队列中缓存的流媒体数据,提高了读取监控数据的灵活度。In the embodiment of the present invention, when a request for acquiring streaming media data is detected, the streaming media data to be acquired in the buffer queue is determined according to the request start time and request end time of the streaming media data; the buffer queue is acquired Streaming media data to be acquired. That is to say, in the embodiment of the present invention, according to the request start time and the request end time of the streaming media data in the request cache queue in the request for obtaining the streaming media data, the streaming media data cached in the cache queue can be flexibly read according to demand, improving It improves the flexibility of reading monitoring data.
可选的,在另一实施例中,该实施例在上述实施例的基础上,当检测到流媒体数据的请求为多个请求时,所述方法还可以包括:在所述多个请求中的请求开始时间或请求结束时间存在交错时间段覆盖的情况下,更新存在交错时间段覆盖的请求中的请求开始时间或请求结束时间,以使更新后的所述请求开始时间或请求结束时间包括更新前的所述请求开始时间或请求结束时间。Optionally, in another embodiment, on the basis of the above embodiment, when detecting that the request for streaming media data is multiple requests, the method may further include: among the multiple requests If the request start time or request end time of the staggered time period overlaps, update the request start time or request end time in the request covered by the staggered time period, so that the updated request start time or request end time includes The request start time or request end time before the update.
也就是说,当检测到流媒体数据的请求为多个请求时,先判断所述多个请求中是否有请求相同时间段内的流媒体数据;如果有,则合并所述获取相同时间段内的流媒体数据的请求为一个请求。That is to say, when it is detected that the request for streaming media data is multiple requests, it is first judged whether there is a request for streaming media data in the same time period among the multiple requests; A request for streaming data is a request.
本发明实施例中,可以支持获取多路流媒体数据的请求的响应,并且采取时间覆盖机制。当检测到同时有多个流媒体数据的请求时,先判断当前新的请求与已存在的请求的请求开始时间和请求请求结束时间是否存在时间段上的覆盖,如果存在,则将两个请求合并成一个请求,以达到缩减资源消耗的目的。In the embodiment of the present invention, the response to the request for obtaining multi-channel streaming media data can be supported, and a time coverage mechanism is adopted. When multiple requests for streaming media data are detected at the same time, it is first judged whether the request start time and request end time of the current new request and the existing request are covered by the time period. If so, the two requests are combined Merge them into one request to reduce resource consumption.
还请参阅图5,为本发明实施例提供的一种流媒体数据缓存方法的第二应用实例图;该实施例以读取多个缓存请求为例。但在实际应用中,并并不限于此。所述方法包括:Please also refer to FIG. 5 , which is a second application example diagram of a streaming media data caching method provided by an embodiment of the present invention; this embodiment takes reading multiple cache requests as an example. But in practical application, it is not limited to this. The methods include:
步骤501:检测到获取流媒体数据的多个请求,每个请求包括:请求缓存队列中流媒体数据的请求开始时间和请求结束时间;Step 501: Multiple requests for obtaining streaming media data are detected, and each request includes: request start time and request end time of streaming media data in the request cache queue;
步骤502:判断内存中是否存在每个请求的缓存队列;如果存在,执行步骤503;否则,执行步骤510;Step 502: Determine whether there is a cache queue for each request in the memory; if so, execute
步骤503:判断每个请求的请求开始时间和请求结束时间是否为有效时间;如果是,执行步骤504;否则,执行步骤509;Step 503: Determine whether the request start time and request end time of each request are valid time; if yes, execute
步骤504:判断所述多个请求中的请求开始时间或请求结束时间是否存在交错时间段覆盖;如果是,执行步骤505;否则,执行步骤506;Step 504: Determine whether the request start time or request end time in the multiple requests is covered by an interleaved time period; if yes, perform
步骤505:更新存在交错时间段覆盖的请求中的请求开始时间或请求结束时间,以使更新后的所述请求开始时间或请求结束时间包括更新前的所述请求开始时间或请求结束时间,并将更新后的所述多个请求合并为一个请求,执行步骤510。Step 505: Update the request start time or request end time in the request covered by the staggered time period, so that the updated request start time or request end time includes the request start time or request end time before the update, and The multiple updated requests are combined into one request, and step 510 is executed.
该步骤504和步骤505中,以具体的示例来说明判断过程,如6所示,图6为本发明实施例提供的一种判断多个请求是否存在时间段覆盖的示意图;如图6所示,该实施例以是三个请求为例,当请求2到来时,首先会判断当前是否为已经存在该请求,并且会判断和已存在的请求开始或结束时间是否存在时间交错;如果存在,则更新请求2的开始或结束时间,以让其将请求1和请求2的开始或结束时间都包含在内;同时,当请求3到来时,依然会做类似的判断,根据判断结果,最后合成一个能够包含之前所有存在时间交错的请求的全新请求,否则,每个请求都当做一个独立的请求,通常该判断,可以有效解决浪费资源消耗的问题,达成最终节约资源CPU、ROM等资源消耗的目的。In
步骤506:从所述缓存队列的头部开始读取未读取的流媒体数据;Step 506: read unread streaming media data from the head of the cache queue;
步骤507:判断所述未读取的流媒体数据的所述请求结束时间是否大于或等于所获取流媒体数据的时间戳,且所获取流媒体数据的时间戳是否大于或等于所述未读取的流媒体数据的请求开始时间;如果是,执行步骤508;否则,执行步骤510;Step 507: Determine whether the request end time of the unread streaming media data is greater than or equal to the timestamp of the acquired streaming media data, and whether the timestamp of the acquired streaming media data is greater than or equal to the unread streaming media data The request start time of the streaming media data; if yes, execute
步骤508:存储获取的所述流媒体数据;Step 508: storing the acquired streaming media data;
步骤509:判断所述缓存队列中最后一帧数据的时间戳是否小于所述未读取的流媒体数据的请求结束时间,如果是,返回执行步骤506;如果否,执行步骤510:Step 509: Determine whether the timestamp of the last frame of data in the cache queue is less than the request end time of the unread streaming media data, if yes, return to step 506; if not, execute step 510:
步骤510:结束获取流媒体数据。Step 510: End obtaining streaming media data.
步骤511:将获取的所述流媒体数据合成音视频文件。Step 511: Synthesize the acquired streaming media data into audio and video files.
本发明实施例中,通过获取流媒体数据的请求中有效的请求开始时间及请求结束时间,与音视频流数据时间戳字段做匹配,以找出符合时间段的流媒体数据。并判断多路请求中是否存储时间段覆盖的请求,如果有,则将其合并为一个请求,以降低各方资源消耗。进一步,在请求流媒体数据结束后,将请求的流媒体数据合成音视频文件,以供其他平台使用。In the embodiment of the present invention, the effective request start time and request end time in the streaming media data request are matched with the timestamp field of the audio and video stream data to find out the streaming media data matching the time period. It is also judged whether the requests covered by the time period are stored in the multi-channel request, and if so, they are merged into one request to reduce the resource consumption of all parties. Further, after the request for streaming media data ends, the requested streaming media data is synthesized into audio and video files for use by other platforms.
进一步,本实施例还可以根据需求对获取的流媒体数据进行编码成想要的格式,然后合成音视频文件等。Further, this embodiment can also encode the acquired streaming media data into a desired format according to requirements, and then synthesize audio and video files and the like.
需要说明的是,对于方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本实施公开并不受所描述的动作顺序的限制,因为依据本发明,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作并不一定是本发明所必须的。It should be noted that, for the method embodiment, for the sake of simple description, it is expressed as a series of action combinations, but those skilled in the art should know that this implementation disclosure is not limited by the described action sequence, because according to In the present invention, certain steps may be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification belong to preferred embodiments, and the actions involved are not necessarily required by the present invention.
图7是本发明实施例提供的一种流媒体数据缓存装置框图。该装置包括:获取模块601和第一缓存模块602,其中,Fig. 7 is a block diagram of a streaming media data caching device provided by an embodiment of the present invention. The device includes: an
该获取模块601,用于响应于至少一个监控场景触发的缓存请求,根据每个缓存请求获取对应的流媒体数据;The acquiring
该第一缓存模块602,用于按照设定缓存时长将获取的每路流媒体数据缓存到不同的缓存队列中。The
可选的,在另一实施例中,该实施例在上述实施例的基础上,所述装置还包括:选择模块和编码模块,其中,Optionally, in another embodiment, on the basis of the above embodiments, the device further includes: a selection module and an encoding module, wherein,
该选择模块,用于在所述第一缓存模块在按照设定缓存时长将获取的每路流媒体数据缓存到不同的缓存队列中之前,选择获取的所述每路流媒体数据对应的媒体编码格式;The selection module is used to select the acquired media encoding corresponding to each channel of streaming media data before the first caching module caches each channel of acquired streaming media data into different cache queues according to the set buffer duration Format;
该编码模块,用于按照选择的所述媒体编码格式分别对获取的所述每路流媒体数据进行编码,得到编码后的每路流媒体数据;The encoding module is used to encode each channel of the acquired streaming media data according to the selected media encoding format to obtain encoded streaming media data of each channel;
所述第一缓存模块,还用于按照设定缓存时长将编码后的所述每路流媒体数据缓存到不同的缓存队列中。The first caching module is further configured to cache the encoded streaming media data of each channel into different cache queues according to the set cache duration.
可选的,在另一实施例中,该实施例在上述实施例的基础上,所述装置还包括:第一判断模块和创建模块,其中,Optionally, in another embodiment, on the basis of the above embodiments, the device further includes: a first judging module and a creating module, wherein,
该第一判断模块,用于在所述响应于至少一个监控场景触发的缓存请求之后,判断是否存在与所述至少一个监控场景对应的缓存队列;The first judging module is configured to judge whether there is a cache queue corresponding to the at least one monitoring scene after the cache request triggered in response to the at least one monitoring scene;
该创建模块,用于在所述第一判断模块判定不存在与所述至少一个监控场景对应的缓存队列的情况下,创建与所述少一个监控场景对应的缓存队列;The creation module is configured to create a cache queue corresponding to the one less monitoring scene when the first judging module determines that there is no cache queue corresponding to the at least one monitoring scene;
所述获取模块,还用于在所述创建模块创建与所述少一个监控场景对应的缓存队列后,根据每个缓存请求获取对应的流媒体数据。The acquisition module is further configured to acquire corresponding streaming media data according to each cache request after the creation module creates a cache queue corresponding to the one less monitoring scene.
可选的,在另一实施例中,该实施例在上述实施例的基础上,所述获取模块,还用于在所述第一判断模块判定存在与所述至少一个监控场景对应的缓存队列的情况下,根据每个缓存请求获取对应的流媒体数据。Optionally, in another embodiment, on the basis of the above embodiment, the acquiring module is further configured to determine in the first judging module that there is a buffer queue corresponding to the at least one monitoring scene In the case of , obtain the corresponding streaming media data according to each cache request.
可选的,在另一实施例中,该实施例在上述实施例的基础上,所述装置还包括:第二判断模块和移除模块,其中,Optionally, in another embodiment, on the basis of the above embodiment, the device further includes: a second judging module and a removing module, wherein,
该第二判断模块,用于判断缓存的所述流媒体数据的时间长度是否超过所述设定缓存时长;The second judging module is used to judge whether the time length of the cached streaming media data exceeds the set cache time length;
该移除模块,用于在所述第二判断模块判定所述缓存时长超过所述设定缓存时长的情况下,移除所述缓存队列中的头部数据;The removal module is configured to remove the header data in the cache queue when the second judging module determines that the cache duration exceeds the set cache duration;
所述第一缓存模块,还用于在所述移除模块移除所述缓存队列中的头部数据后,继续缓存所述流体数据到所述缓存队列的尾部。The first cache module is further configured to continue to cache the fluid data to the end of the cache queue after the removal module removes the head data in the cache queue.
可选的,在另一实施例中,该实施例在上述实施例的基础上,所述装置还包括:差值确定模块,其中,Optionally, in another embodiment, on the basis of the above embodiment, the device further includes: a difference determination module, wherein,
该差值确定模块,用于在所述第二判断模判断缓存的所述流媒体数据的时间长度是否超过所述设定缓存时长之前,确定开始缓存所述媒体流数据的时间戳到结束缓存所述媒体流数据的时间戳之差为缓存所述流媒体数据的时间长度。The difference determination module is used to determine whether the buffering time of the streaming media data exceeds the set buffering duration before the second judging module judges whether the time stamp of the buffering of the media streaming data to the end of the buffering is determined. The difference between the time stamps of the media stream data is the time length for caching the stream media data.
还请参阅图8,为本发明实施例提供的一种流媒体数据缓存装置的另一框图,所述装置包括:检测模块701,确定模块702和获取模块703,其中,Please also refer to FIG. 8, which is another block diagram of a streaming media data caching device provided by an embodiment of the present invention, the device includes: a
该检测模块701,用于检测到获取流媒体数据的请求,所述请求包括:请求缓存队列中流媒体数据的请求开始时间和请求结束时间;The
该确定模块702,用于根据所述流媒体数据的请求开始时间和请求结束时间确定所述缓存队列中待获取的流媒体数据;The determining
该获取模块703,用于获取所述缓存队列中待获取的的流媒体数据。The obtaining
可选的,在另一实施例中,该实施例在上述实施例的基础上,所述确定模块包括:第一判断模块,匹配模块和数据确定模块,其中,Optionally, in another embodiment, based on the above embodiment, the determining module includes: a first judging module, a matching module and a data determining module, wherein,
该第一判断模块,用于判断所述流媒体数据的请求开始时间和请求结束时间是否为有效时间;The first judging module is used to judge whether the request start time and the request end time of the streaming media data are valid time;
该匹配模块,用于在所述第一判断模块判定所述请求开始时间和请求结束时间为有效时间时,将所述流媒体数据的请求开始时间和请求结束时间与所述缓存队列中流媒体数据的每帧数据的时间戳从缓存队列的头部依次进行匹配;The matching module is configured to combine the request start time and request end time of the streaming media data with the streaming media data in the cache queue when the first judging module determines that the request start time and the request end time are valid time The timestamp of each frame of data is sequentially matched from the head of the cache queue;
该数据确定模块,用于在所述匹配模块匹配成功时,确定匹配成功的对应时间段内的流媒体数据为待获取的流媒体数据。The data determination module is configured to determine that the streaming media data within the corresponding time period of the successful matching is the streaming media data to be acquired when the matching module successfully matches.
可选的,在另一实施例中,该实施例在上述实施例的基础上,所述获取模块包括:数据获取模块,存储模块和结束模块,其中,Optionally, in another embodiment, on the basis of the above embodiments, the acquisition module includes: a data acquisition module, a storage module and an end module, wherein,
该数据获取模块,用于从所述缓存队列的头部开始获取未读取的流媒体数据;The data acquisition module is used to acquire unread streaming media data from the head of the cache queue;
该存储模块,用于在所述数据获取模块获取的所述未读取的流媒体数据的所述请求结束时间大于或等于所获取流媒体数据的时间戳,且所获取流媒体数据的时间戳大于或等于所述未读取的流媒体数据的请求开始时间的情况下;存储获取的所述流媒体数据;The storage module is used to obtain the request end time of the unread streaming media data obtained by the data obtaining module, which is greater than or equal to the timestamp of the obtained streaming media data, and the timestamp of the obtained streaming media data When it is greater than or equal to the request start time of the unread streaming media data; store the acquired streaming media data;
所述数据获取模块,还用于在所述缓存队列中最后一帧数据的时间戳小于所述未读取的流媒体数据的请求结束时间的情况下,从所述缓存队列的头部开始获取未读取的流媒体数据;The data acquisition module is further configured to start acquiring from the head of the cache queue when the timestamp of the last frame of data in the cache queue is less than the request end time of the unread streaming media data Unread streaming data;
该结束模块,用于在所述数据获取模块获取的所述未读取的流媒体数据的所述请求结束时间小于所获取流媒体数据的时间戳,且所获取流媒体数据的时间戳小于所述未读取的流媒体数据的请求开始时间,或所述所述缓存队列中最后一帧数据的时间戳大于或等于所述未读取的流媒体数据的请求结束时间的情况下,结束获取流媒体数据。The end module is used for the request end time of the unread streaming media data obtained by the data obtaining module to be less than the time stamp of the obtained streaming media data, and the time stamp of the obtained streaming media data is less than the time stamp of the obtained streaming media data If the request start time of the unread streaming media data, or the timestamp of the last frame data in the cache queue is greater than or equal to the request end time of the unread streaming media data, end the acquisition streaming data.
可选的,在另一实施例中,该实施例在上述实施例的基础上,所述装置还包括:第二判断模块,更新模块和合并模块,其中,Optionally, in another embodiment, on the basis of the above embodiment, the device further includes: a second judging module, an updating module and a merging module, wherein,
该第二判断模块,用于在所述获取模块获取流媒体数据的请求为多个请求的情况下,判断所述多个请求中的请求开始时间或请求结束时间是否存在交错时间段覆盖;The second judging module is used to judge whether the request start time or the request end time in the multiple requests is covered by an interleaved time period when the request of the acquisition module to obtain streaming media data is a plurality of requests;
该更新模块,用于在所述第二判断模块判断存在交错时间段覆盖的情况下,更新存在交错时间段覆盖的请求中的请求开始时间或请求结束时间,以使更新后的所述请求开始时间或请求结束时间包括更新前的所述请求开始时间或请求结束时间;The update module is configured to update the request start time or request end time in the request with interleaved time period coverage in the case that the second judging module judges that there is staggered time period coverage, so that the updated request starts time or request end time includes said request start time or request end time prior to the update;
该合并模块,用于在所述更新模块更新后的所述多个请求合并为一个请求。The merging module is configured to merge the multiple requests updated by the updating module into one request.
关于上述实施例中的装置,其中各个模块执行操作的具体方式已经在有关该方法的实施例中进行了详细描述,此处将不做详细阐述说明。Regarding the apparatus in the foregoing embodiments, the specific manner in which each module executes operations has been described in detail in the embodiments related to the method, and will not be described in detail here.
本发明实施例还提供一种电子设备,包括:The embodiment of the present invention also provides an electronic device, including:
处理器;processor;
用于存储所述处理器可执行指令的存储器;memory for storing said processor-executable instructions;
其中,所述处理器被配置为执行所述指令,以实现如上所述的流媒体数据缓存方法。Wherein, the processor is configured to execute the instructions, so as to implement the streaming media data caching method as described above.
本发明实施例还提供了一种包括计算机可读存储介质,当所述计算机可读存储介质中的指令由电子设备的处理器执行时,使得电子设备能够执行如上所述的流媒体数据缓存方法。可选地,计算机可读存储介质可以是ROM、随机存取存储器(RAM)、CD-ROM、磁带、软盘和光数据存储设备等。The embodiment of the present invention also provides a computer-readable storage medium, when the instructions in the computer-readable storage medium are executed by the processor of the electronic device, the electronic device can execute the streaming media data caching method as described above . Alternatively, the computer readable storage medium may be ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, and the like.
在示例性实施例中,本发明实施例还提供一种计算机程序产品,包括计算机程序或指令,其特征在于,所述计算机程序或指令被处理器执行时实现如上所述的流媒体数据缓存方法。In an exemplary embodiment, an embodiment of the present invention also provides a computer program product, including computer programs or instructions, characterized in that, when the computer program or instructions are executed by a processor, the streaming media data caching method as described above is implemented.
图8是本发明实施例提供的一种电子设备800的框图。例如,电子设备800可以为移动终端也可以为服务器,本发明实施例中以电子设备为移动终端为例进行说明。例如,电子设备800可以是移动电话,计算机,数字广播终端,消息收发设备,游戏控制台,平板设备,医疗设备,健身设备,个人数字助理等。Fig. 8 is a block diagram of an
参照图8,电子设备800可以包括以下一个或多个组件:处理组件802,存储器804,电力组件806,多媒体组件808,音频组件810,输入/输出(I/O)的接口812,传感器组件814,以及通信组件816。8,
处理组件802通常控制电子设备800的整体操作,诸如与显示,电话呼叫,数据通信,相机操作和记录操作相关联的操作。处理组件802可以包括一个或多个处理器820来执行指令,以完成上述的方法的全部或部分步骤。此外,处理组件802可以包括一个或多个模块,便于处理组件802和其他组件之间的交互。例如,处理组件802可以包括多媒体模块,以方便多媒体组件808和处理组件802之间的交互。The
存储器804被配置为存储各种类型的数据以支持在设备800的操作。这些数据的示例包括用于在电子设备800上操作的任何应用程序或方法的指令,联系人数据,电话簿数据,消息,图片,视频等。存储器804可以由任何类型的易失性或非易失性存储设备或者它们的组合实现,如静态随机存取存储器(SRAM),电可擦除可编程只读存储器(EEPROM),可擦除可编程只读存储器(EPROM),可编程只读存储器(PROM),只读存储器(ROM),磁存储器,快闪存储器,磁盘或光盘。The
电源组件806为电子设备800的各种组件提供电力。电源组件806可以包括电源管理系统,一个或多个电源,及其他与为电子设备800生成、管理和分配电力相关联的组件。The
多媒体组件808包括在所述电子设备800和用户之间的提供一个输出接口的屏幕。在一些实施例中,屏幕可以包括液晶显示器(LCD)和触摸面板(TP)。如果屏幕包括触摸面板,屏幕可以被实现为触摸屏,以接收来自用户的输入信号。触摸面板包括一个或多个触摸传感器以感测触摸、滑动和触摸面板上的手势。所述触摸传感器可以不仅感测触摸或滑动动作的边界,而且还检测与所述触摸或滑动操作相关的持续时间和压力。在一些实施例中,多媒体组件808包括一个前置摄像头和/或后置摄像头。当设备800处于操作模式,如拍摄模式或视频模式时,前置摄像头和/或后置摄像头可以接收外部的多媒体数据。每个前置摄像头和后置摄像头可以是一个固定的光学透镜系统或具有焦距和光学变焦能力。The
音频组件810被配置为输出和/或输入音频信号。例如,音频组件810包括一个麦克风(MIC),当电子设备800处于操作模式,如呼叫模式、记录模式和语音识别模式时,麦克风被配置为接收外部音频信号。所接收的音频信号可以被进一步存储在存储器804或经由通信组件816发送。在一些实施例中,音频组件810还包括一个扬声器,用于输出音频信号。The
I/O接口812为处理组件802和外围接口模块之间提供接口,上述外围接口模块可以是键盘,点击轮,按钮等。这些按钮可包括但不限于:主页按钮、音量按钮、启动按钮和锁定按钮。The I/
传感器组件814包括一个或多个传感器,用于为电子设备800提供各个方面的状态评估。例如,传感器组件814可以检测到设备800的打开/关闭状态,组件的相对定位,例如所述组件为电子设备800的显示器和小键盘,传感器组件814还可以检测电子设备800或电子设备800一个组件的位置改变,用户与电子设备800接触的存在或不存在,电子设备800方位或加速/减速和电子设备800的温度变化。传感器组件814可以包括接近传感器,被配置用来在没有任何的物理接触时检测附近物体的存在。传感器组件814还可以包括光传感器,如CMOS或CCD图像传感器,用于在成像应用中使用。在一些实施例中,该传感器组件814还可以包括加速度传感器,陀螺仪传感器,磁传感器,压力传感器或温度传感器。
通信组件816被配置为便于电子设备800和其他设备之间有线或无线方式的通信。电子设备800可以接入基于通信标准的无线网络,如WiFi,运营商网络(如2G、3G、4G或5G),或它们的组合。在一个示例性实施例中,通信组件816经由广播信道接收来自外部广播管理系统的广播信号或广播相关信息。在一个示例性实施例中,所述通信组件816还包括近场通信(NFC)模块,以促进短程通信。例如,在NFC模块可基于射频识别(RFID)技术,红外数据协会(IrDA)技术,超宽带(UWB)技术,蓝牙(BT)技术和其他技术来实现。The
在实施例中,电子设备800可以被一个或多个应用专用集成电路(ASIC)、数字信号处理器(DSP)、数字信号处理设备(DSPD)、可编程逻辑器件(PLD)、现场可编程门阵列(FPGA)、控制器、微控制器、微处理器或其他电子元件实现,用于执行上述所示的流媒体数据缓存方法。In an embodiment, the
本发明实施例还提供了一种计算机可读存储介质,当所述计算机可读存储介质中的指令由电子设备的处理器执行时,使得电子设备800能够执行以上所述的流媒体数据缓存方法。例如,所述计算机可读存储介质可以是ROM、随机存取存储器(RAM)、CD-ROM、磁带、软盘和光数据存储设备等。The embodiment of the present invention also provides a computer-readable storage medium. When the instructions in the computer-readable storage medium are executed by the processor of the electronic device, the
本发明实施例还提供一种计算机程序产品,包括计算机程序或指令,当计算机程序产品中的指令由处理器820执行时,实现如上述所述示的流媒体数据缓存方法。An embodiment of the present invention also provides a computer program product, including computer programs or instructions. When the instructions in the computer program product are executed by the
图9是本发明实施例提供的一种用于流媒体数据缓存的装置900的框图。例如,装置900可以被提供为一服务器。参照图9,装置900包括处理组件922,其进一步包括一个或多个处理器,以及由存储器932所代表的存储器资源,用于存储可由处理组件922的执行的指令,例如应用程序。存储器932中存储的应用程序可以包括一个或一个以上的每一个对应于一组指令的模块。此外,处理组件922被配置为执行指令,以执行上述流媒体数据缓存方法。FIG. 9 is a block diagram of an
装置900还可以包括一个电源组件926被配置为执行装置900的电源管理,一个有线或无线网络接口950被配置为将装置900连接到网络,和一个输入输出(I/O)接口958。装置900可以操作基于存储在存储器932的操作系统,例如Windows ServerTM,Mac OS XTM,UnixTM,LinuxTM,FreeBSDTM或类似。
本领域技术人员在考虑说明书及实践这里公开的发明后,将容易想到本发明的其它实施方案。本申请旨在涵盖本发明的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本发明的一般性原理并包括本发明未公开的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本发明的真正范围和精神由下面的权利要求指出。Other embodiments of the invention will be readily apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any modification, use or adaptation of the present invention, these modifications, uses or adaptations follow the general principles of the present invention and include common knowledge or conventional technical means in the technical field not disclosed in the present invention . The specification and examples are to be considered exemplary only, with a true scope and spirit of the invention being indicated by the following claims.
应当理解的是,本发明并不局限于上面已经描述并在附图中示出的精确结构,并且可以在不脱离其范围进行各种修改和改变。本发明的范围仅由所附的权利要求来限制。It should be understood that the present invention is not limited to the precise constructions which have been described above and shown in the accompanying drawings, and various modifications and changes may be made without departing from the scope thereof. The scope of the invention is limited only by the appended claims.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202210827097.8ACN115348418A (en) | 2022-07-14 | 2022-07-14 | Streaming media data caching method, device, electronic equipment, storage medium and product |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202210827097.8ACN115348418A (en) | 2022-07-14 | 2022-07-14 | Streaming media data caching method, device, electronic equipment, storage medium and product |
| Publication Number | Publication Date |
|---|---|
| CN115348418Atrue CN115348418A (en) | 2022-11-15 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202210827097.8APendingCN115348418A (en) | 2022-07-14 | 2022-07-14 | Streaming media data caching method, device, electronic equipment, storage medium and product |
| Country | Link |
|---|---|
| CN (1) | CN115348418A (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20030081121A1 (en)* | 2001-10-30 | 2003-05-01 | Kirmuss Charles Bruno | Mobile digital video monitoring with pre-event recording |
| US20030080878A1 (en)* | 2001-10-30 | 2003-05-01 | Kirmuss Charles Bruno | Event-based vehicle image capture |
| CN101867786A (en)* | 2009-04-20 | 2010-10-20 | 中兴通讯股份有限公司 | Method and device for monitoring video |
| WO2017107649A1 (en)* | 2015-12-22 | 2017-06-29 | 北京奇虎科技有限公司 | Video transmission method and device |
| CN110324552A (en)* | 2018-03-29 | 2019-10-11 | 沈阳美行科技有限公司 | Grasping means, grasp shoot method, relevant apparatus equipment and the system of audio, video data |
| CN110324698A (en)* | 2018-03-28 | 2019-10-11 | 努比亚技术有限公司 | A kind of video recording method, terminal and computer readable storage medium |
| CN113556485A (en)* | 2021-07-23 | 2021-10-26 | 上海商汤智能科技有限公司 | Video generation method and device, electronic equipment and storage medium |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20030081121A1 (en)* | 2001-10-30 | 2003-05-01 | Kirmuss Charles Bruno | Mobile digital video monitoring with pre-event recording |
| US20030080878A1 (en)* | 2001-10-30 | 2003-05-01 | Kirmuss Charles Bruno | Event-based vehicle image capture |
| CN101867786A (en)* | 2009-04-20 | 2010-10-20 | 中兴通讯股份有限公司 | Method and device for monitoring video |
| WO2017107649A1 (en)* | 2015-12-22 | 2017-06-29 | 北京奇虎科技有限公司 | Video transmission method and device |
| CN110324698A (en)* | 2018-03-28 | 2019-10-11 | 努比亚技术有限公司 | A kind of video recording method, terminal and computer readable storage medium |
| CN110324552A (en)* | 2018-03-29 | 2019-10-11 | 沈阳美行科技有限公司 | Grasping means, grasp shoot method, relevant apparatus equipment and the system of audio, video data |
| CN113556485A (en)* | 2021-07-23 | 2021-10-26 | 上海商汤智能科技有限公司 | Video generation method and device, electronic equipment and storage medium |
| Publication | Publication Date | Title |
|---|---|---|
| CN108737908B (en) | Media playing method, device and storage medium | |
| CN110611829B (en) | Video preloading method and device, electronic equipment and storage medium | |
| RU2624641C2 (en) | Method and device for video quality control based on network environment | |
| CN107454465A (en) | Video playback progress display method, device, and electronic equipment | |
| CN107193678B (en) | Method, device and storage medium for determining cause of freeze | |
| CN107193653B (en) | Bandwidth resource allocation method, device and storage medium | |
| EP2193662A2 (en) | System and method for video coding using variable compression and object motion tracking | |
| EP3185480B1 (en) | Method and apparatus for processing network jitter, and terminal device | |
| CN108093257A (en) | Bit rate control method, electronic equipment and the storage medium of Video coding | |
| EP4007289A1 (en) | Video uploading method and apparatus, electronic device, and storage medium | |
| JP2017503399A (en) | Handling of video frames damaged by camera movement | |
| CN113099272A (en) | Video processing method and device, electronic equipment and storage medium | |
| CN111246278B (en) | Video playing method and device, electronic equipment and storage medium | |
| CN110418209B (en) | An information processing method and terminal device applied to video transmission | |
| CN112530205A (en) | Airport parking apron airplane state detection method and device | |
| CN113225585A (en) | Video definition switching method and device, electronic equipment and storage medium | |
| CN115002402A (en) | event video sequence | |
| CN116257195A (en) | Screen projection method and device, storage medium and electronic equipment | |
| CN105957011A (en) | Picture processing method and device | |
| CN115348418A (en) | Streaming media data caching method, device, electronic equipment, storage medium and product | |
| CN110856196B (en) | WLAN service optimization method, terminal device and storage medium | |
| CN118656355A (en) | A method and device for analyzing events of intelligent devices | |
| CN105245898B (en) | Image data recording method and device | |
| CN109308778B (en) | Mobile detection alarm method, device, acquisition equipment and storage medium | |
| CN112866612B (en) | Frame insertion method, device, terminal and computer-readable storage medium |
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination |