[go: up one dir, main page]

HK40051647B - A video definition switching method, device, electronic equipment and storage medium - Google Patents

A video definition switching method, device, electronic equipment and storage medium Download PDF

Info

Publication number
HK40051647B
HK40051647B HK42021040723.5A HK42021040723A HK40051647B HK 40051647 B HK40051647 B HK 40051647B HK 42021040723 A HK42021040723 A HK 42021040723A HK 40051647 B HK40051647 B HK 40051647B
Authority
HK
Hong Kong
Prior art keywords
video
keyframe
switched
switching
currently playing
Prior art date
Application number
HK42021040723.5A
Other languages
Chinese (zh)
Other versions
HK40051647A (en
Inventor
梁鑫
Original Assignee
腾讯科技(深圳)有限公司
Filing date
Publication date
Application filed by 腾讯科技(深圳)有限公司 filed Critical 腾讯科技(深圳)有限公司
Publication of HK40051647A publication Critical patent/HK40051647A/en
Publication of HK40051647B publication Critical patent/HK40051647B/en

Links

Description

一种视频清晰度的切换方法、装置、电子设备以及存储介质A method, apparatus, electronic device, and storage medium for switching video resolution.

技术领域Technical Field

本申请涉及计算机技术领域,具体涉及一种视频清晰度的切换方法、装置、电子设备以及存储介质。This application relates to the field of computer technology, and specifically to a method, apparatus, electronic device, and storage medium for switching video resolution.

背景技术Background Technology

随着网络技术的发展,用户可以使用终端上网观看视频。网上一个视频源所提供的视频一般会有分有多种码率,不同码率的视频有着不同的清晰度。当用户在观看视频时,可以根据观看需求手动选择所观看视频的码率。With the development of internet technology, users can now watch videos online using their devices. Videos from a single online source typically come in multiple bitrates, each offering different levels of clarity. Users can manually select the bitrate they wish to watch based on their viewing needs.

目前,视频清晰度的切换方案主要基于实时流媒体协议(HTTP Live Streaming,HLS),即首先将视频文件进行分片,在切换清晰度时,以分片为基础重新加载,然而,目前的切换方案会存在跳帧播放的问题,进而耗费很多流量。Currently, the main solution for switching video resolution is based on the real-time streaming media protocol (HTTP Live Streaming, HLS). This means that the video file is first divided into segments, and when switching resolutions, the segments are reloaded. However, the current switching solution has the problem of frame skipping, which consumes a lot of bandwidth.

发明内容Summary of the Invention

本发明实施例提供一种视频清晰度的切换方法、装置、电子设备以及存储介质,可以解决跳帧播放的问题,进而减少流量消耗。This invention provides a method, apparatus, electronic device, and storage medium for switching video resolution, which can solve the problem of frame skipping playback and thus reduce data consumption.

本发明实施例提供了一种视频清晰度的切换方法,包括:This invention provides a method for switching video resolution, including:

获取当前播放的视频,得到当前播放视频;Get the currently playing video;

当接收到用户触发的视频清晰度的切换请求时,获取与当前播放视频的内容一致的待切换视频,所述当前播放视频的码率与待切换视频的码率不同;When a user-triggered request to switch video resolution is received, a video to be switched that is identical to the content of the currently playing video is obtained, wherein the bitrate of the currently playing video is different from that of the video to be switched.

加载所述待切换视频对应的索引数据;Load the index data corresponding to the video to be switched;

提取当前播放视频当前的关键帧,得到当前关键帧;Extract the current keyframe of the currently playing video to obtain the current keyframe;

根据当前关键帧以及索引数据确定待切换视频中与当前关键帧对应的关键帧,得到切换关键帧;Based on the current keyframe and index data, determine the keyframe in the video to be switched that corresponds to the current keyframe, and obtain the switching keyframe.

基于当前关键帧、切换关键帧以及索引数据,将当前播放视频切换为所述待切换视频。Based on the current keyframe, the switching keyframe, and the index data, the currently playing video is switched to the video to be switched.

相应的,本发明实施例还提供了一种视频清晰度的切换装置,包括:Accordingly, embodiments of the present invention also provide a video resolution switching device, comprising:

第一获取模块,用于获取当前播放的视频,得到当前播放视频;The first acquisition module is used to acquire the currently playing video and obtain the currently playing video.

第二获取模块,用于当接收到用户触发的视频清晰度的切换请求时,获取与当前播放视频的内容一致的待切换视频,所述当前播放视频的码率与待切换视频的码率不同;The second acquisition module is used to acquire a video to be switched that is consistent with the content of the currently playing video when a user-triggered video resolution switching request is received, wherein the bitrate of the currently playing video is different from the bitrate of the video to be switched.

加载模块,用于加载所述待切换视频对应的索引数据;A loading module is used to load the index data corresponding to the video to be switched.

提取模块,用于提取当前播放视频当前的关键帧,得到当前关键帧;The extraction module is used to extract the current keyframe of the currently playing video and obtain the current keyframe.

确定模块,用于根据当前关键帧以及索引数据确定待切换视频中与当前关键帧对应的关键帧,得到切换关键帧;The determination module is used to determine the key frame in the video to be switched that corresponds to the current key frame based on the current key frame and index data, and obtain the switching key frame.

切换模块,用于基于当前关键帧、切换关键帧以及索引数据,将当前播放视频切换为所述待切换视频。The switching module is used to switch the currently playing video to the video to be switched based on the current keyframe, the switching keyframe, and index data.

可选的,在本发明的一些实施例中,所述确定模块包括:Optionally, in some embodiments of the present invention, the determining module includes:

获取子模块,用于从所述当前播放视频获取所述当前关键帧所在的视频数据,得到第一视频数据;The acquisition submodule is used to acquire the video data where the current keyframe is located from the currently playing video to obtain the first video data;

确定子模块,用于根据第一视频数据、当前关键帧以及索引数据在所述待切换视频中选择满足预设条件的关键帧,得到切换关键帧。The determination submodule is used to select key frames that meet preset conditions in the video to be switched based on the first video data, the current key frame, and index data, and obtain the switching key frame.

可选的,在本发明的一些实施例中,所述确定子模块包括:Optionally, in some embodiments of the present invention, the determining submodule includes:

获取单元,用于获取当前关键帧在所述第一视频数据中的位置,得到当前关键帧对应的位置信息;The acquisition unit is used to acquire the position of the current keyframe in the first video data and obtain the position information corresponding to the current keyframe.

选择单元,用于根据所述索引数据在待切换视频中选择满足预设条件的关键帧,得到切换关键帧。The selection unit is used to select key frames that meet preset conditions in the video to be switched according to the index data, so as to obtain the switching key frames.

可选的,在本发明的一些实施例中,所述选择单元包括:Optionally, in some embodiments of the present invention, the selection unit includes:

加载子单元,用于基于所述索引数据加载所述待切换视频对应的视频数据,得到第二视频数据;A loading subunit is used to load the video data corresponding to the video to be switched based on the index data to obtain the second video data;

选择子单元,用于在所述第二视频数据中选择与所述位置信息匹配的关键帧,得到切换关键帧。The selection sub-unit is used to select a key frame that matches the location information in the second video data to obtain a switching key frame.

可选的,在本发明的一些实施例中,所述获取子单元具体用于:Optionally, in some embodiments of the present invention, the acquisition subunit is specifically used for:

提取当前关键帧对应的时间戳,得到第一时间戳,以及Extract the timestamp corresponding to the current keyframe to obtain the first timestamp, and

提取所述第二视频数据中各关键帧对应的时间戳,得到多个第二时间戳;Extract the timestamps corresponding to each keyframe in the second video data to obtain multiple second timestamps;

将第二时间戳与第一时间戳一致的关键帧确定为与所述当前关键帧对应的关键帧,得到切换关键帧。The key frame whose second timestamp matches the first timestamp is determined as the key frame corresponding to the current key frame, thus obtaining the switching key frame.

可选的,在本发明的一些实施例中,所述切换模块具体用于:Optionally, in some embodiments of the present invention, the switching module is specifically used for:

根据当前关键帧确定所述当前播放视频已播放的视频数据;Determine the video data that has been played in the currently playing video based on the current keyframe;

通过当前关键帧、已播放的视频数据以及索引数据计算所述待切换视频需要加载的视频数据;The video data that needs to be loaded for the video to be switched is calculated using the current keyframe, the already played video data, and the index data.

通过需要加载的视频数据对预设视频数据缓冲区进行更新,得到更新后缓冲区;The preset video data buffer is updated by the video data to be loaded, resulting in the updated buffer;

以所述切换关键帧为起始点,基于需要加载的视频数据以及更新后缓冲区,将当前播放视频切换为所述待切换视频。Starting from the switching keyframe, based on the video data to be loaded and the updated buffer, the currently playing video is switched to the video to be switched.

可选的,在本发明的一些实施例中,还包括删除模块,所述删除模块具体用于:删除更新后缓冲区中当前播放视频对应的视频数据。Optionally, in some embodiments of the present invention, a deletion module is further included, which is specifically used to delete the video data corresponding to the currently playing video in the updated buffer.

可选的,在本发明的一些实施例中,还包括构建模块,所述构建模块具体用于:Optionally, in some embodiments of the present invention, a construction module is further included, the construction module being specifically used for:

构建视频数据缓冲区;Construct a video data buffer;

在所述视频数据缓冲区中加载当前播放视频对应的视频数据。The video data corresponding to the currently playing video is loaded into the video data buffer.

本发明实施例在获取当前播放的视频,得到当前播放视频后,当接收到用户触发的视频清晰度的切换请求时,获取与当前播放视频的内容一致的待切换视频,所述当前播放视频的码率与待切换视频的码率不同,然后,加载所述待切换视频对应的索引数据,接着,提取当前播放视频当前的关键帧,得到当前关键帧,再然后,根据当前关键帧以及索引数据确定待切换视频中与当前关键帧对应的关键帧,得到切换关键帧,最后,基于当前关键帧、切换关键帧以及索引数据,将当前播放视频切换为所述待切换视频。因此,该方案可以解决跳帧播放的问题,进而减少流量消耗。In this embodiment of the invention, after obtaining the currently playing video, when a user-triggered request to switch video resolution is received, a video to be switched to with content identical to the currently playing video is obtained, provided that the bitrate of the currently playing video is different from that of the video to be switched to. Then, the index data corresponding to the video to be switched to is loaded. Next, the current keyframe of the currently playing video is extracted to obtain the current keyframe. Then, based on the current keyframe and the index data, the keyframe in the video to be switched that corresponds to the current keyframe is determined to obtain the switching keyframe. Finally, based on the current keyframe, the switching keyframe, and the index data, the currently playing video is switched to the video to be switched to. Therefore, this solution can solve the problem of frame skipping during playback, thereby reducing data consumption.

附图说明Attached Figure Description

为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

图1a是本发明实施例提供的视频清晰度的切换方法的场景示意图;Figure 1a is a schematic diagram of a scenario for the video resolution switching method provided in an embodiment of the present invention;

图1b为本发明实施例提供的视频清晰度的切换方法的流程示意图;Figure 1b is a flowchart illustrating the video resolution switching method provided in an embodiment of the present invention;

图2a是本发明实施例提供的视频清晰度的切换方法的另一流程示意图;Figure 2a is another flowchart illustrating the video resolution switching method provided in an embodiment of the present invention;

图2b是本发明实施例提供的视频清晰度的切换方法中显示当前播放视频对应的显示页面的示意图;Figure 2b is a schematic diagram of the display page corresponding to the currently playing video in the video clarity switching method provided in the embodiment of the present invention;

图2c是本发明实施例提供的视频清晰度的切换方法中一帧视频帧的示意图;Figure 2c is a schematic diagram of a video frame in the video resolution switching method provided in the embodiment of the present invention;

图2d是本发明实施例提供的视频清晰度的切换方法中切换播放待切换视频的示意图;Figure 2d is a schematic diagram of switching the video to be switched in the video clarity switching method provided in the embodiment of the present invention;

图3a是本发明实施例提供的视频清晰度的切换装置的第一种实施方式的结构示意图;Figure 3a is a schematic diagram of the first embodiment of the video resolution switching device provided in this invention;

图3b是本发明实施例提供的视频清晰度的切换装置的第二种实施方式的另一结构示意图;Figure 3b is another structural schematic diagram of a second embodiment of the video resolution switching device provided in this invention;

图3c是本发明实施例提供的视频清晰度的切换装置的第三种实施方式的结构示意图;Figure 3c is a structural schematic diagram of a third embodiment of the video resolution switching device provided in this invention;

图4是本发明实施例提供的电子设备的结构示意图。Figure 4 is a schematic diagram of the structure of the electronic device provided in an embodiment of the present invention.

具体实施方式Detailed Implementation

下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

本发明实施例提供一种视频清晰度的切换方法、装置、电子设备和存储介质。This invention provides a method, apparatus, electronic device, and storage medium for switching video resolution.

其中,该视频清晰度的切换装置具体可以集成在终端中,终端可以包括手机、平板电脑或个人计算机(PC,Personal Computer)。Specifically, the video resolution switching device can be integrated into the terminal, which may include a mobile phone, tablet computer, or personal computer (PC).

请参阅图1a,本发明实施例提供一种视频清晰度的切换系统(以下简称切换系统),该切换系统可以包括终端、服务器以及用户,以该视频清晰度的切换装置集成在个人计算机为例,该个人计算机可以安装有客户端,该客户端可以是任一能够提供视频播放服务的客户端,例如基于浏览器的网页客户端,该视频播放服务可以支持用户通过浏览器观看视频,在观看视频的过程中,用户还可以针对同一视频进行视频清晰度的切换,比如,当用户需要对当前播放的视频进行视频清晰度的切换时,获取与当前播放视频的内容一致的待切换视频,该待切换视频的码率与当前播放视频的码率不同,然后,加载待切换视频对应的索引数据,接着,提取当前播放视频当前的关键帧,得到当前关键帧,再然后,根据当前关键帧以及索引数据确定待切换视频中与当前关键帧对应的关键帧,得到切换关键帧,最后,基于当前关键帧、切换关键帧以及索引数据,将当前播放视频切换为待切换视频。Please refer to Figure 1a. This embodiment of the invention provides a video resolution switching system (hereinafter referred to as the switching system). The switching system may include a terminal, a server, and a user. Taking the video resolution switching device integrated into a personal computer as an example, the personal computer may have a client installed. The client may be any client that can provide video playback services, such as a browser-based web client. The video playback service can support users to watch videos through a browser. During the video viewing process, users can also switch the video resolution of the same video. For example, when a user needs to switch the video resolution of the currently playing video, a video to be switched with the same content as the currently playing video is obtained. The bitrate of the video to be switched is different from that of the currently playing video. Then, the index data corresponding to the video to be switched is loaded. Next, the current keyframe of the currently playing video is extracted to obtain the current keyframe. Then, based on the current keyframe and the index data, the keyframe in the video to be switched that corresponds to the current keyframe is determined to obtain the switching keyframe. Finally, based on the current keyframe, the switching keyframe, and the index data, the currently playing video is switched to the video to be switched.

由于该方案是根据当前关键帧以及索引数据在待切换视频中确定与当前关键帧对应的关键帧(即切换关键帧),然后,再基于当前关键帧、切换关键帧以及索引数据,将当前播放视频切换为待切换视频,也就是说,在本方案中,是基于关键帧进行视频清晰度切换的,因此,可以解决现有的方案中存在的跳帧播放的问题,进而减少流量消耗。This solution determines the corresponding keyframe (i.e., the switching keyframe) in the video to be switched based on the current keyframe and index data. Then, based on the current keyframe, the switching keyframe, and index data, the currently playing video is switched to the video to be switched. In other words, this solution switches video clarity based on keyframes. Therefore, it can solve the problem of frame skipping in existing solutions and reduce bandwidth consumption.

以下分别进行详细说明。需说明的是,以下实施例的描述顺序不作为对实施例优先顺序的限定。The following sections provide detailed descriptions of each example. It should be noted that the order in which the embodiments are described is not intended to limit the priority of the embodiments.

一种视频清晰度的切换方法,包括:获取当前播放的视频,得到当前播放视频,当接收到用户触发的视频清晰度的切换请求时,获取与当前播放视频的内容一致的待切换视频,加载待切换视频对应的索引数据,提取当前播放视频当前的关键帧,得到当前关键帧,根据当前关键帧以及索引数据确定待切换视频中与当前关键帧对应的关键帧,得到切换关键帧,基于当前关键帧、切换关键帧以及索引数据,将当前播放视频切换为待切换视频。A method for switching video resolution includes: acquiring the currently playing video; when receiving a video resolution switching request triggered by a user, acquiring a video to be switched that has the same content as the currently playing video; loading the index data corresponding to the video to be switched; extracting the current keyframe of the currently playing video; determining the keyframe in the video to be switched that corresponds to the current keyframe based on the current keyframe and the index data; obtaining the switching keyframe; and switching the currently playing video to the video to be switched based on the current keyframe, the switching keyframe, and the index data.

请参阅图1b,图1b为本发明实施例提供的视频清晰度的切换方法的流程示意图。该视频清晰度的切换方法的具体流程可以如下:Please refer to Figure 1b, which is a flowchart illustrating the video resolution switching method provided in an embodiment of the present invention. The specific flow of this video resolution switching method can be as follows:

101、获取当前播放的视频,得到当前播放视频。101. Get the currently playing video.

其中,获取当前播放的视频的途径可以有多种,比如,可以从互联网和/或指定数据库中进行获取,具体可以根据实际应用的需求而定,当前播放视频可以包括电视剧、电影以及用户录制的视频等等。There are several ways to obtain the currently playing video. For example, it can be obtained from the Internet and/or a specified database. The specific method depends on the actual application requirements. The currently playing video can include TV series, movies, and user-recorded videos, etc.

需要说明的是,在视频切换之前,可以构建一个视频数据缓冲区,该视频数据缓冲区可以用于存放以及管理视频源数据片段,即,可选的,步骤“获取当前播放的视频,得到当前播放视频”之前,具体还可以包括:It should be noted that before switching videos, a video data buffer can be constructed. This buffer can be used to store and manage video source data segments. Optionally, before the step "obtain the currently playing video," the following additional steps may be included:

(11)构建视频数据缓冲区;(11) Construct a video data buffer;

(12)在视频数据缓冲区中加载当前播放的视频对应的视频数据。(12) Load the video data corresponding to the currently playing video into the video data buffer.

比如,在视频切换之前,当前播放的视频为视频A,那么视频数据缓冲区中则可以加载视频A对应的视频数据。For example, if the currently playing video is video A before the video switch, then the video data buffer can load the video data corresponding to video A.

102、当接收到用户触发的视频清晰度的切换请求时,获取与当前播放视频的内容一致的待切换视频。102. When a user-triggered request to switch video resolution is received, obtain the video to be switched that is consistent with the content of the currently playing video.

其中,当前播放视频的码率与待切换视频的码率不同,码率就是数据传输时单位时间传输的数据位数,单位为kbps(千比特每秒),也就是取样率,单位时间内取样率越大,精度就越高,处理出来的文件就越接近原始文件,码率越高越清晰,反之则画面粗糙。The bitrate of the currently playing video is different from the bitrate of the video to be switched. Bitrate is the number of bits of data transmitted per unit time during data transmission, and the unit is kbps (kilobits per second). It is also called sampling rate. The higher the sampling rate per unit time, the higher the accuracy, and the closer the processed file is to the original file. The higher the bitrate, the clearer the picture, and vice versa.

比如,当接收到用户触发的视频清晰度的切换请求时,该切换请求指示将视频A切换为视频B,即,视频A为当前播放视频,视频B为待切换视频,其中,视频A的内容与视频B的内容一致,视频A的码率与视频B的码率不同。For example, when a user triggers a video resolution switching request, the switching request instructs that video A be switched to video B. That is, video A is the currently playing video, and video B is the video to be switched to. The content of video A is the same as that of video B, but the bitrate of video A is different from that of video B.

103、加载待切换视频对应的索引数据。103. Load the index data corresponding to the video to be switched.

在本发明实施例中,视频播放过程中终端与服务器之间遵循视频传输协议,该传输协议可包括:实时消息传输协议(Real Time Messaging Protocol,RTMP)以及HLS(HTTPLive Streaming)协议等等。除特别说明外,本发明后续实施例均以HLS协议为例,HLS协议是一种流媒体解决方案,其包括视频索引以及视频分片,视频索引里面包含了该视频流的很多基础信息,用户通过终端播放视频时,并不是直接播放视频索引,而是对视频索引进行解析,获取各视频分片的索引,并根据索引找到相应的视频分片的URL进行播放,其中,每个视频分片为待播放视频的一段视频内容,其包括了关键帧的时间戳以及该时间戳对应的视频内容等数据,比如,当前播放视频和待切换视频的格式均为第四代动态图像专家组(Moving Picture Experts Group 4,MP4)格式,对于一个MP4文件而言,其最重要的就是索引数据,索引数据(又称头文件)记录了后续所有音频帧和视频帧的解码信息、时间戳以及位置等数据,当然,基于其他流媒体协议切换当前播放视频的清晰度也是如此,在此不再赘述。In this embodiment of the invention, during video playback, the terminal and the server follow a video transmission protocol, which may include Real Time Messaging Protocol (RTMP) and HLS (HTTP Live Streaming) protocol, etc. Unless otherwise specified, the following embodiments of the present invention will use the HLS protocol as an example. The HLS protocol is a streaming media solution that includes a video index and video segments. The video index contains a lot of basic information about the video stream. When a user plays a video through a terminal, the video index is not played directly, but the video index is parsed to obtain the index of each video segment, and the URL of the corresponding video segment is found and played according to the index. Each video segment is a segment of video content to be played, which includes data such as the timestamp of the key frame and the video content corresponding to the timestamp. For example, the format of the currently playing video and the video to be switched is the Moving Picture Experts Group 4 (MP4) format. For an MP4 file, the most important thing is the index data. The index data (also known as the header file) records the decoding information, timestamps, and positions of all subsequent audio and video frames. Of course, the same applies to switching the clarity of the currently playing video based on other streaming media protocols, which will not be elaborated here.

104、提取当前播放视频当前的关键帧,得到当前关键帧。104. Extract the current keyframe of the currently playing video to obtain the current keyframe.

其中,视频帧可以包括关键帧(I帧)、向前预测帧(P帧)以及双向预测帧(B帧),I帧是内部编码帧,是每个图像的第一个帧,是一个完整的画面;P帧是前向预测帧,记录的是相对于I帧或相邻前一个P帧的变化;B帧是双向内插帧,与P帧的区别在于,它既可以参考I帧或相邻前一个帧,也可以参考相邻后一个帧,即P帧记录的是相对于相邻前后帧的变化,也就是说要播放一小段画面,必须找到I帧,然后才能顺利解码相应的B帧和P帧,需要说明的是,对步骤103和步骤104的先后顺序不作限定。The video frames can include keyframes (I-frames), forward prediction frames (P-frames), and bidirectional prediction frames (B-frames). I-frames are internally encoded frames, the first frame of each image, and a complete picture. P-frames are forward prediction frames, which record changes relative to I-frames or the adjacent previous P-frame. B-frames are bidirectional interpolated frames. The difference between B-frames and P-frames is that B-frames can refer to I-frames or the adjacent previous frame, or they can refer to the adjacent next frame. That is, P-frames record changes relative to adjacent frames. In other words, to play a short segment of the picture, I-frames must be found, and then the corresponding B-frames and P-frames can be decoded successfully. It should be noted that the order of steps 103 and 104 is not limited.

105、根据当前关键帧以及索引数据确定待切换视频中与当前关键帧对应的关键帧,得到切换关键帧。105. Based on the current keyframe and index data, determine the keyframe in the video to be switched that corresponds to the current keyframe, and obtain the switching keyframe.

由于当前播放视频的内容与待切换视频是一致的,即,这两个视频所记录的图像张数是相同的,因此,这两个视频对应的关键帧的数量也是一致的,也就是说,待切换视频中的每一个关键帧,在当前播放视频中都有与其对应的关键帧,在本发明实施例中,可以根据当前关键帧以及索引数据确定待切换视频中与当前关键帧对应的关键帧,其区别在于两个视频帧的状态不同,比如,当接收到用户针对视频A触发的视频清晰度的切换请求时,该切换请求指示切换视频B,此时,视频A的关键帧I1正在播放,则确定该视频帧I1为当前关键帧,根据视频帧I1以及索引数据确定视频B中与视频帧I1对应的关键帧为关键帧I2,那么则确定关键帧I2为切换关键帧。Since the content of the currently playing video is the same as the video to be switched, that is, the number of images recorded in the two videos is the same, the number of keyframes corresponding to the two videos is also the same. In other words, every keyframe in the video to be switched has a corresponding keyframe in the currently playing video. In this embodiment of the invention, the keyframe corresponding to the current keyframe in the video to be switched can be determined based on the current keyframe and index data. The difference lies in the different states of the two video frames. For example, when a user receives a request to switch the video clarity triggered by video A, the switching request indicates to switch to video B. At this time, keyframe I1 of video A is playing, so video frame I1 is determined to be the current keyframe. Based on video frame I1 and index data, the keyframe corresponding to video frame I1 in video B is determined to be keyframe I2, and then keyframe I2 is determined to be the switching keyframe.

比如,可以从当前播放视频中获取当前关键帧所在的视频数据,基于该视频数据、当前关键帧以及索引数据确定待切换视频中与当前关键帧对应的关键帧,即,可选的,在一些实施例中,步骤“根据当前关键帧以及索引数据确定待切换视频中与当前关键帧对应的关键帧,得到切换关键帧”,具体可以包括:For example, video data containing the current keyframe can be obtained from the currently playing video. Based on this video data, the current keyframe, and index data, the keyframe corresponding to the current keyframe in the video to be switched can be determined. That is, optionally, in some embodiments, the step "determining the keyframe corresponding to the current keyframe in the video to be switched based on the current keyframe and index data, and obtaining the switching keyframe" can specifically include:

(21)从当前播放视频中获取当前关键帧所在的视频数据,得到第一视频数据;(21) Obtain the video data of the current keyframe from the currently playing video to obtain the first video data;

(22)根据第一视频数据、当前关键帧以及索引数据在待切换视频中选择满足预设条件的关键帧,得到切换关键帧。(22) Select a key frame that meets the preset conditions in the video to be switched based on the first video data, the current key frame and the index data to obtain the switching key frame.

比如,可以根据第一视频数据、当前关键帧以及索引数据,在待切换视频中选择与当前关键帧的图像内容一致的关键帧,得到切换关键帧,具体可以采用神经网络模型对当前关键帧的图像内容、以及对待切换视频中各关键帧对应的图像内容进行识别。For example, based on the first video data, the current keyframe, and the index data, a keyframe whose image content is consistent with the current keyframe can be selected in the video to be switched to obtain the switching keyframe. Specifically, a neural network model can be used to identify the image content of the current keyframe and the image content corresponding to each keyframe in the video to be switched.

又比如,可以获取当前关键帧在第一视频数据中的位置,再根据该位置以及索引数据确定待切换视频中与当前关键帧对应的关键帧,,然后,再根据该位置以及索引数据确定待切换视频中与当前关键帧对应的关键帧,得到切换关键帧,即,可选的,步骤“根据第一视频数据、当前关键帧以及索引数据在待切换视频中选择满足预设条件的关键帧,得到切换关键帧”,具体可以包括:For example, the position of the current keyframe in the first video data can be obtained, and then the keyframe corresponding to the current keyframe in the video to be switched can be determined based on the position and index data. Then, the keyframe corresponding to the current keyframe in the video to be switched can be determined again based on the position and index data to obtain the switching keyframe. That is, optionally, the step "selecting keyframes that meet preset conditions in the video to be switched based on the first video data, the current keyframe, and the index data to obtain the switching keyframe" can specifically include:

(31)获取当前关键帧在第一视频数据中的位置,得到当前关键帧对应的位置信息;(31) Obtain the position of the current keyframe in the first video data and get the position information corresponding to the current keyframe;

(32)根据索引数据在待切换视频中选择位置信息满足预设条件的关键帧,得到切换关键帧。(32) Select key frames whose location information meets the preset conditions in the video to be switched based on the index data to obtain the switching key frames.

比如,具体的,获取到当前关键帧在第一视频数据中的位置,该位置指示当前关键帧处于第一视频数据中第8帧的位置,然后,再基于索引数据加载待切换视频对应的视频数据,并在待切换视频对应的视频数据中选择第8帧关键帧,得到切换关键帧,即,可选的,在一些实施例中,步骤“根据位置信息以及索引数据确定待切换视频中与当前关键帧对应的关键帧,得到切换关键帧”,具体可以包括:For example, specifically, the position of the current keyframe in the first video data is obtained, indicating that the current keyframe is at the position of the 8th frame in the first video data. Then, the video data corresponding to the video to be switched is loaded based on the index data, and the 8th frame keyframe is selected from the video data corresponding to the video to be switched to obtain the switching keyframe. That is, optionally, in some embodiments, the step "determine the keyframe corresponding to the current keyframe in the video to be switched based on the position information and the index data, and obtain the switching keyframe" may specifically include:

(41)基于索引数据加载待切换视频对应的视频数据,得到第二视频数据;(41) Load the video data corresponding to the video to be switched based on the index data to obtain the second video data;

(42)在第二视频数据中选择与所述位置信息匹配的关键帧,得到切换关键帧。(42) Select the key frame that matches the location information in the second video data to obtain the switching key frame.

比如,具体的,对索引数据进行解析,基于解析结果加载待切换视频对应的视频数据,得到第二视频数据,然后,再从第二视频数据中获取与当前关键帧对应的关键帧,得到切换关键帧,其中,从第二视频数据中获取与当前关键帧对应的关键帧,得到切换关键帧可以有两种方式:For example, specifically, the index data is parsed, and the video data corresponding to the video to be switched is loaded based on the parsing result to obtain the second video data. Then, the keyframe corresponding to the current keyframe is obtained from the second video data to obtain the switching keyframe. There are two ways to obtain the switching keyframe from the second video data:

第一种方式:可以根据当前关键帧的位置信息,从第二视频数据中获取与当前关键帧对应的关键帧,得到切换关键帧,比如,当前关键帧为第8帧的数据,那么可以将第二视频数据中的第8帧确定为与当前关键帧对应的关键帧,得到切换关键帧。The first method is to obtain the keyframe corresponding to the current keyframe from the second video data based on the position information of the current keyframe, and then obtain the switching keyframe. For example, if the current keyframe is the data of the 8th frame, then the 8th frame in the second video data can be determined as the keyframe corresponding to the current keyframe, and the switching keyframe can be obtained.

第二种方式:可以根据当前关键帧对应的时间戳以及第二视频数据中各关键帧对应的时间戳,在第二视频数据中选择与当前关键帧对应的关键帧,即,可选的,在一些实施例中,步骤“在第二视频数据中获取与当前关键帧对应的关键帧,得到切换关键帧”,具体可以包括:The second method: Based on the timestamp corresponding to the current keyframe and the timestamps corresponding to each keyframe in the second video data, a keyframe corresponding to the current keyframe can be selected from the second video data. Optionally, in some embodiments, the step "obtaining the keyframe corresponding to the current keyframe in the second video data to obtain the switching keyframe" may specifically include:

(51)提取当前关键帧对应的时间戳,得到第一时间戳,以及提取第二视频数据中各关键帧对应的时间戳,得到多个第二时间戳;(51) Extract the timestamp corresponding to the current key frame to obtain the first timestamp, and extract the timestamp corresponding to each key frame in the second video data to obtain multiple second timestamps;

(52)将多个第二时间戳与第一时间戳一致的关键帧确定为与当前关键帧对应的关键帧,得到切换关键帧。(52) Determine the key frames whose second timestamps are consistent with the first timestamps as the key frames corresponding to the current key frame to obtain the switching key frame.

比如,当前播放视频和待切换视频均为100秒的视频,当前关键帧的时间戳指示当前关键帧为第10秒的关键帧,那么,可以将第二视频数据中第10秒的关键帧确定为与当前关键帧对应的关键帧,得到切换关键帧,在得到切换关键帧后,可以执行步骤106。For example, if both the currently playing video and the video to be switched are 100 seconds long, and the timestamp of the current keyframe indicates that the current keyframe is the 10th second keyframe, then the 10th second keyframe in the second video data can be determined as the keyframe corresponding to the current keyframe to obtain the switching keyframe. After obtaining the switching keyframe, step 106 can be executed.

106、基于当前关键帧、切换关键帧以及索引数据,将当前播放视频切换播放待切换视频。106. Based on the current keyframe, the switching keyframe, and the index data, switch the currently playing video to the video to be switched.

比如,具体的,可以根据当前关键帧、切换关键帧以及索引数据,计算待切换视频需要加载的视频数据,然后,再基于切换关键真以及需要加载的视频数据,将当前播放视频切换播放待切换视频,即,可选的,在一些实施例中,步骤“基于当前关键帧、切换关键帧以及索引数据,将当前播放视频切换播放待切换视频”,具体可以包括:For example, specifically, the video data that needs to be loaded for the video to be switched can be calculated based on the current keyframe, the switching keyframe, and the index data. Then, based on the switching keyframe and the video data to be loaded, the currently playing video is switched to play the video to be switched. That is, optionally, in some embodiments, the step "based on the current keyframe, the switching keyframe, and the index data, the currently playing video is switched to play the video to be switched" may specifically include:

(61)根据当前关键帧确定当前播放视频已播放的视频数据;(61) Determine the video data that has been played in the current video based on the current keyframe;

(62)通过当前关键帧、已播放的视频数据以及索引数据计算待切换视频需要加载的视频数据;(62) Calculate the video data that needs to be loaded for the video to be switched using the current keyframe, the video data that has been played, and the index data;

(63)通过需要加载的视频数据对预设视频数据缓冲区进行更新,得到更新后缓冲区;(63) Update the preset video data buffer with the video data to be loaded to obtain the updated buffer;

(64)以切换关键帧为起始点,基于切换关键帧以及更新后缓冲区,将当前播放视频切换播放待切换视频。(64) Starting from the switching keyframe, based on the switching keyframe and the updated buffer, switch the currently playing video to the video to be switched.

比如,具体的,若当前关键帧为第3帧关键帧时,可以根据该当前关键帧确定当前播放视频已播放的视频数据包括:第1帧的视频数据、第2帧的视频数据以及第3帧的视频数据,然后,可以基于索引数据获取待切换视频的视频数据,并通过当前关键帧以及已播放的视频数据计算待切换视频需要加载的视频数据,紧接着,通过当前播放视频已播放的视频数据和需要加载的视频数据反向计算需要加载的视频数据缓冲区的大小,即,可以通过当前播放视频已播放的视频数据和需要加载的视频数据对预设视频数据缓冲区进行更新,最后基于切换关键帧以及需要加载的视频数据,将当前播放视频切换为待切换视频。For example, specifically, if the current keyframe is the 3rd keyframe, the video data already played in the currently playing video can be determined based on this keyframe, including the video data of the 1st frame, the 2nd frame, and the 3rd frame. Then, the video data of the video to be switched can be obtained based on the index data, and the video data to be loaded for the video to be switched can be calculated using the current keyframe and the already played video data. Next, the size of the video data buffer to be loaded can be calculated in reverse using the already played video data and the video data to be loaded. That is, the preset video data buffer can be updated using the already played video data and the video data to be loaded. Finally, based on the switching keyframe and the video data to be loaded, the currently playing video is switched to the video to be switched.

为了避免了不必要的流量浪费,将当前播放视频切换为待切换视频之后,还可以将更新后缓冲区中前一个视频的视频数据,比如,将视频A切换为视频B后,可以删除更新后缓冲区中视频A的视频数据,也即,在一些实施中,步骤“以切换关键帧为起始点,基于需要加载的视频数据以及更新后缓冲区,将当前播放视频切换为待切换视频之后”,还可以包括:删除更新后缓冲区中当前播放视频对应的视频数据。To avoid unnecessary bandwidth waste, after switching the currently playing video to the video to be switched, the video data of the previous video in the updated buffer can be deleted. For example, after switching video A to video B, the video data of video A in the updated buffer can be deleted. That is, in some implementations, the step "starting from the switching keyframe, based on the video data to be loaded and the updated buffer, after switching the currently playing video to the video to be switched", can also include: deleting the video data corresponding to the currently playing video in the updated buffer.

本发明实施例首先获取当前播放的视频,得到当前播放视频,当接收到用户触发的视频清晰度的切换请求时,获取与当前播放视频的内容一致的待切换视频,然后,加载待切换视频对应的索引数据,接着,提取当前播放视频当前的关键帧,得到当前关键帧,再然后,根据当前关键帧以及索引数据确定待切换视频中与当前关键帧对应的关键帧,得到切换关键帧,最后,基于当前关键帧、切换关键帧以及索引数据,将当前播放视频切换为待切换视频。相较于现有的视频清晰度的切换方案而言,本发明的视频清晰度的切换方法可以根据当前关键帧以及索引数据在待切换视频中确定与当前关键帧对应的关键帧,得到切换关键帧,然后,再基于当前关键帧、切换关键帧以及索引数据,将当前播放视频切换播放待切换视频,也就是说,在本方案中,是基于关键帧进行视频清晰度切换的,因此,可以解决现有的方案中存在的跳帧播放的问题,进而减少流量消耗。This invention first acquires the currently playing video. When a user-triggered video resolution switching request is received, a video to be switched to, identical in content to the currently playing video, is acquired. Then, the index data corresponding to the video to be switched to is loaded. Next, the current keyframe of the currently playing video is extracted. Then, based on the current keyframe and the index data, the corresponding keyframe in the video to be switched is determined, resulting in the switching keyframe. Finally, based on the current keyframe, the switching keyframe, and the index data, the currently playing video is switched to the video to be switched. Compared to existing video resolution switching schemes, this invention's method can determine the corresponding keyframe in the video to be switched based on the current keyframe and the index data, obtaining the switching keyframe. Then, based on the current keyframe, the switching keyframe, and the index data, the currently playing video is switched to the video to be switched. In other words, this scheme performs video resolution switching based on keyframes, thus solving the frame skipping problem in existing schemes and reducing bandwidth consumption.

根据实施例所述的方法,以下将举例进一步详细说明。The method described in the embodiments will be further described in detail below with examples.

在本实施例中将以该视频清晰度的切换装置具体集成在终端中为例进行说明。In this embodiment, the video resolution switching device will be specifically integrated into the terminal as an example for explanation.

请参阅图2a,一种视频清晰度的切换方法,具体流程可以如下:Please refer to Figure 2a, which illustrates a method for switching video resolution. The specific process is as follows:

201、终端获取当前播放的视频,得到当前播放视频。201. The terminal obtains the currently playing video and gets the currently playing video.

其中,终端可以获取当前播放的视频的途径可以有多种,比如,可以从互联网和/或指定数据库中进行获取,具体可以根据实际应用的需求而定,当前播放视频可以包括电视剧、电影以及用户录制的视频等等。There are several ways for a terminal to obtain the currently playing video. For example, it can obtain it from the Internet and/or a specified database. The specific method depends on the actual application requirements. The currently playing video can include TV series, movies, and user-recorded videos, etc.

需要说明的是,在视频切换之前,终端可以构建一个视频数据缓冲区,该视频数据缓冲区可以用于存放以及管理视频源数据片段,即,可选的,在一些实施例中,终端具体可以构建视频数据缓冲区,然后,终端在视频数据缓冲区中加载当前播放的视频对应的视频数据。It should be noted that before switching videos, the terminal can construct a video data buffer, which can be used to store and manage video source data segments. That is, optionally, in some embodiments, the terminal can specifically construct a video data buffer, and then the terminal loads the video data corresponding to the currently playing video into the video data buffer.

202、终端当接收到用户触发的视频清晰度的切换请求时,获取与当前播放视频的内容一致的待切换视频。202. When the terminal receives a video resolution switching request triggered by the user, it obtains the video to be switched that is consistent with the content of the currently playing video.

其中,当前播放视频的码率与待切换视频的码率不同,例如,具体的,请参阅图2b,终端可以安装有客户端,该客户端可以是任一能够提供视频播放服务的客户端,终端的显示屏上可以显示有与该当前播放视频对应的显示页面,该显示页面可以包括切换控件A、切换控件B以及切换控件C,终端当接收到用户触发的视频清晰度的切换请求时,如终端检测到用户针对切换控件C的选择操作时,获取与当前播放视频的内容一致,且清晰度与切换控件C对应的待切换视频。In this scenario, the bitrate of the currently playing video differs from that of the video to be switched. For example, as shown in Figure 2b, the terminal may have a client installed, which can be any client capable of providing video playback services. The terminal's display screen may show a display page corresponding to the currently playing video. This display page may include switching controls A, B, and C. When the terminal receives a video clarity switching request triggered by the user, such as when the terminal detects the user's selection operation on switching control C, it obtains the video to be switched that has the same content as the currently playing video and a clarity corresponding to switching control C.

203、终端加载待切换视频对应的索引数据。203. The terminal loads the index data corresponding to the video to be switched.

对于一个MP4文件而言,其最重要的就是索引数据,索引数据记录了后续所有音频帧和视频帧的解码信息、时间戳以及位置等数据,当然,基于其他流媒体协议切换当前播放视频的清晰度也是如此,在此不再赘述。For an MP4 file, the most important part is the index data. The index data records the decoding information, timestamps, and positions of all subsequent audio and video frames. Of course, the same applies to switching the resolution of the currently playing video based on other streaming media protocols, which will not be elaborated on here.

204、终端提取当前播放视频当前的关键帧,得到当前关键帧。204. The terminal extracts the current keyframe of the currently playing video and obtains the current keyframe.

其中,视频帧可以包括关键帧(I帧)、向前预测帧(P帧)以及双向预测帧(B帧),I帧是内部编码帧,是每个图像的第一个帧,是一个完整的画面;P帧是前向预测帧,记录的是相对于I帧或相邻前一个P帧的变化;B帧是双向内插帧,与P帧的区别在于,它既可以参考I帧或相邻前一个帧,也可以参考相邻后一个帧,即P帧记录的是相对于相邻前后帧的变化,如图2c所示,视频播放可以理解成是由连续的画面帧依次渲染而完成的,但是视频要想传输,必须进行编码压缩,每一小段视频都由一个I帧与多个B帧,P帧组成,其中B帧和P帧依赖I帧进行压缩编码,每一段视频片段中I帧始终是第一帧,也就是说想要播放这一小段画面,一定要先找到I帧,然后才能顺利解码相应的B帧和P帧,需要说明的是,对步骤203和步骤204的先后顺序不作限定。The video frames can include keyframes (I-frames), forward prediction frames (P-frames), and bidirectional prediction frames (B-frames). I-frames are internally encoded frames, the first frame of each image, and a complete picture. P-frames are forward prediction frames, recording changes relative to I-frames or the adjacent previous P-frame. B-frames are bidirectional interpolated frames, which differ from P-frames in that they can reference either I-frames or the adjacent previous frame, or the adjacent next frame. That is, P-frames record changes relative to adjacent frames, as shown in Figure 2c. Video playback can be understood as being completed by rendering consecutive picture frames in sequence. However, for video to be transmitted, it must be encoded and compressed. Each small video segment consists of one I-frame and multiple B-frames and P-frames. B-frames and P-frames rely on I-frames for compression encoding. In each video segment, the I-frame is always the first frame. That is to say, to play this small segment, the I-frame must be found first, and then the corresponding B-frames and P-frames can be decoded successfully. It should be noted that the order of steps 203 and 204 is not limited.

205、终端根据当前关键帧以及索引数据确定待切换视频中与当前关键帧对应的关键帧,得到切换关键帧。205. The terminal determines the key frame in the video to be switched that corresponds to the current key frame based on the current key frame and the index data, and obtains the switching key frame.

由于当前播放视频的内容与待切换视频是一致的,即,这两个视频所记录的图像张数是相同的,因此,这两个视频对应的关键帧的数量也是一致的,也就是说,待切换视频中的每一个关键帧,在当前播放视频中都有与其对应的关键帧,比如,终端获取当前播放视频的视频数据,得到第一视频数据,然后,终端根据第一视频数据、当前关键帧以及索引数据确定待切换视频中与当前关键帧对应的关键帧,得到切换关键帧,进一步的,比如,具体的,终端获取到当前关键帧在第一视频数据中的位置,该位置指示当前关键帧处于第一视频数据中第8帧的位置,然后,终端再基于索引数据加载待切换视频对应的视频数据,终端并根据该位置信息在待切换视频对应的视频数据获取与当前关键帧对应的关键帧,得到切换关键帧。Since the content of the currently playing video is identical to that of the video to be switched, meaning the two videos record the same number of images, the number of keyframes corresponding to these two videos is also identical. In other words, every keyframe in the video to be switched has a corresponding keyframe in the currently playing video. For example, the terminal obtains the video data of the currently playing video to get the first video data. Then, the terminal determines the keyframe in the video to be switched that corresponds to the current keyframe based on the first video data, the current keyframe, and the index data, thus obtaining the switching keyframe. Further, for example, specifically, the terminal obtains the position of the current keyframe in the first video data, indicating that the current keyframe is at frame 8 in the first video data. Then, the terminal loads the video data corresponding to the video to be switched based on the index data, and the terminal obtains the keyframe corresponding to the current keyframe in the video data corresponding to the video to be switched based on this position information, thus obtaining the switching keyframe.

206、终端基于当前关键帧、切换关键帧以及索引数据,将当前播放视频切换为待切换视频。206. Based on the current keyframe, the switching keyframe, and the index data, the terminal switches the currently playing video to the video to be switched.

具体的,终端可以根据当前关键帧、切换关键帧以及索引数据,计算待切换视频需要加载的视频数据,然后,终端再基于切换关键真以及需要加载的视频数据,将当前播放视频切换播放待切换视频。Specifically, the terminal can calculate the video data that needs to be loaded for the video to be switched based on the current keyframe, the switching keyframe, and the index data. Then, based on the switching keyframe and the video data to be loaded, the terminal switches the currently playing video to the video to be switched.

比如,请参阅图2d,若当前关键帧为第3帧关键帧时,终端可以根据该当前关键帧确定当前播放视频已播放的视频数据包括:第1帧的视频数据、第2帧的视频数据以及第3帧的视频数据,然后,终端可以基于索引数据获取待切换视频的视频数据,终端通过当前关键帧以及已播放的视频数据计算待切换视频需要加载的视频数据,最后,终端基于切换关键帧以及需要加载的视频数据,将当前播放视频切换播放待切换视频,比如,如图所示,可以在第三帧I帧处进行视频切换,又比如,为了提高视频播放的流畅性,可以在切换关键帧的下一帧切换视频,即,可以在第四帧I帧处切换,具体根据实际情况进行设置。For example, referring to Figure 2d, if the current keyframe is the 3rd keyframe, the terminal can determine the video data already played in the currently playing video, including the video data of the 1st frame, the 2nd frame, and the 3rd frame. Then, the terminal can obtain the video data of the video to be switched based on the index data. The terminal calculates the video data that needs to be loaded for the video to be switched based on the current keyframe and the already played video data. Finally, the terminal switches the currently playing video to the video to be switched based on the switching keyframe and the video data to be loaded. For example, as shown in the figure, the video can be switched at the 3rd frame (I-frame). Or, to improve the smoothness of video playback, the video can be switched in the next frame after the switching keyframe, that is, at the 4th frame (I-frame). The specific settings depend on the actual situation.

可选的,在一些实施例中,终端在切换播放待切换视频之后,可以删除视频数据缓冲区中当前播放视频对应的视屏数据Optionally, in some embodiments, after switching to play the video to be switched, the terminal may delete the video data corresponding to the currently playing video from the video data buffer.

由上可知,本发明的终端首先获取当前播放的视频,得到当前播放视频,当接收到用户触发的视频清晰度的切换请求时,终端获取与当前播放视频的内容一致的待切换视频,然后,终端加载待切换视频对应的索引数据,接着,终端提取当前播放视频当前的关键帧,得到当前关键帧,再然后,终端根据当前关键帧以及索引数据确定待切换视频中与当前关键帧对应的关键帧,得到切换关键帧,最后,终端基于当前关键帧、切换关键帧以及索引数据,将当前播放视频切换播放待切换视频。相较于现有的视频清晰度的切换方案而言,本发明的终端可以根据当前关键帧以及索引数据在待切换视频中确定与当前关键帧对应的关键帧,得到切换关键帧,然后,终端再基于当前关键帧、切换关键帧以及索引数据,将当前播放视频切换播放所述待切换视频,也就是说,在本方案中,终端是基于关键帧进行视频清晰度切换的,因此,可以解决现有的方案中存在的跳帧播放的问题,进而减少流量消耗。As described above, the terminal of this invention first obtains the currently playing video. When it receives a user-triggered request to switch video resolution, the terminal obtains a video to be switched that is identical to the currently playing video. Then, the terminal loads the index data corresponding to the video to be switched. Next, the terminal extracts the current keyframe of the currently playing video. Then, the terminal determines the keyframe in the video to be switched that corresponds to the current keyframe based on the current keyframe and the index data. Finally, the terminal switches the currently playing video to play the video to be switched based on the current keyframe, the switching keyframe, and the index data. Compared to existing video resolution switching schemes, the terminal of this invention can determine the keyframe corresponding to the current keyframe in the video to be switched based on the current keyframe and the index data. Then, the terminal switches the currently playing video to play the video to be switched based on the current keyframe, the switching keyframe, and the index data. In other words, in this scheme, the terminal switches video resolution based on keyframes. Therefore, it can solve the problem of frame skipping in existing schemes, thereby reducing data consumption.

为便于更好的实施本发明实施例的视频清晰度的切换方法,本发明实施例还提供一种基于上述视频清晰度的切换装置(简称切换装置)。其中名词的含义与上述视频清晰度的切换方法中相同,具体实现细节可以参考方法实施例中的说明。To facilitate better implementation of the video resolution switching method of the present invention, the present invention also provides a video resolution switching device (hereinafter referred to as the switching device). The meanings of the terms are the same as in the video resolution switching method described above, and specific implementation details can be found in the description of the method embodiments.

请参阅图3a,图3a为本发明实施例提供的视频清晰度的切换装置的第一种实施方式的结构示意图,其中该切换装置可以包括第一获取模块301、第二获取模块302、加载模块303、提取模块304、确定模块305以及切换模块306,具体可以如下:Please refer to Figure 3a, which is a schematic diagram of the first embodiment of the video resolution switching device provided in this invention. The switching device may include a first acquisition module 301, a second acquisition module 302, a loading module 303, an extraction module 304, a determination module 305, and a switching module 306, as follows:

第一获取模块301,用于获取当前播放的视频,得到当前播放视频。The first acquisition module 301 is used to acquire the currently playing video and obtain the currently playing video.

其中,第一获取模块301可以获取当前播放的视频的途径可以有多种,比如,可以从互联网和/或指定数据库中进行获取,具体可以根据实际应用的需求而定,当前播放视频可以包括电视剧、电影以及用户录制的视频等等。The first acquisition module 301 can acquire the currently playing video in various ways, such as from the Internet and/or a specified database. The specific method can be determined according to the actual application requirements. The currently playing video can include TV series, movies, and user-recorded videos, etc.

第二获取模块302,用于当接收到用户触发的视频清晰度的切换请求时,获取与当前播放视频的内容一致的待切换视频。The second acquisition module 302 is used to acquire the video to be switched that is consistent with the content of the currently playing video when a user-triggered video resolution switching request is received.

其中,当前播放视频的码率与待切换视频的码率不同,码率就是数据传输时单位时间传输的数据位数,单位为kbps(千比特每秒),也就是取样率,单位时间内取样率越大,精度就越高,处理出来的文件就越接近原始文件,码率越高越清晰,反之则画面粗糙。The bitrate of the currently playing video is different from the bitrate of the video to be switched. Bitrate is the number of bits of data transmitted per unit time during data transmission, and the unit is kbps (kilobits per second). It is also called sampling rate. The higher the sampling rate per unit time, the higher the accuracy, and the closer the processed file is to the original file. The higher the bitrate, the clearer the picture, and vice versa.

加载模块303,用于加载待切换视频对应的索引数据。Loading module 303 is used to load the index data corresponding to the video to be switched.

在本发明实施例中,视频播放过程中终端与服务器之间遵循视频传输协议,该传输协议可包括:实时消息传输协议(Real Time Messaging Protocol,RTMP)以及HLS(HTTPLive Streaming)协议等等。除特别说明外,本发明后续实施例均以HLS协议为例,HLS协议是一种流媒体解决方案,其包括视频索引以及视频分片,视频索引记录了各视频分片的索引,用户通过终端播放视频时,并不是直接播放视频索引,而是对视频索引进行解析,获取各视频分片的索引,并根据索引找到相应的视频分片的URL进行播放,其中,每个视频分片为待播放视频的一段视频内容,其包括了时间戳以及该时间戳对应的视频内容等数据,比如,当前播放视频和待切换视频的格式均为第四代动态图像专家组(Moving PictureExperts Group 4,MP4)格式,对于一个MP4文件而言,其最重要的就是索引数据,索引数据记录了后续所有音频帧和视频帧的解码信息、时间戳以及位置等数据,当然,基于其他流媒体协议切换当前播放视频的清晰度也是如此,在此不再赘述。In this embodiment of the invention, during video playback, the terminal and the server follow a video transmission protocol, which may include Real Time Messaging Protocol (RTMP) and HLS (HTTP Live Streaming) protocol, etc. Unless otherwise specified, the following embodiments of the present invention all use the HLS protocol as an example. The HLS protocol is a streaming media solution that includes a video index and video segments. The video index records the index of each video segment. When a user plays a video through a terminal, the video index is not played directly. Instead, the video index is parsed to obtain the index of each video segment, and the URL of the corresponding video segment is found and played according to the index. Each video segment is a segment of video content to be played, which includes data such as a timestamp and the video content corresponding to that timestamp. For example, the format of the currently playing video and the video to be switched is both Moving Picture Experts Group 4 (MP4) format. For an MP4 file, the most important thing is the index data. The index data records the decoding information, timestamps, and positions of all subsequent audio and video frames. Of course, the same applies to switching the clarity of the currently playing video based on other streaming media protocols, which will not be elaborated here.

提取模块304,用于提取当前播放视频当前的关键帧,得到当前关键帧。Extraction module 304 is used to extract the current keyframe of the currently playing video and obtain the current keyframe.

确定模块305,用于根据当前关键帧以及索引数据确定待切换视频中与当前关键帧对应的关键帧,得到切换关键帧。The determination module 305 is used to determine the key frame in the video to be switched that corresponds to the current key frame based on the current key frame and index data, and obtain the switching key frame.

由于当前播放视频的内容与待切换视频是一致的,即,这两个视频所记录的图像张数是相同的,因此,这两个视频对应的关键帧的数量也是一致的,也就是说,待切换视频中的每一个关键帧,在当前播放视频中都有与其对应的关键帧,在本发明实施例中,确定模块305可以根据当前关键帧以及索引数据确定待切换视频中与当前关键帧对应的关键帧。Since the content of the currently playing video is the same as that of the video to be switched, that is, the number of images recorded in the two videos is the same, the number of keyframes corresponding to the two videos is also the same. In other words, every keyframe in the video to be switched has a corresponding keyframe in the currently playing video. In this embodiment of the invention, the determining module 305 can determine the keyframe in the video to be switched that corresponds to the current keyframe based on the current keyframe and the index data.

可选的,在一些实施例中,确定模块305具体可以包括:Optionally, in some embodiments, the determining module 305 may specifically include:

获取子模块,用于从当前播放视频获取当前关键帧所在的视频数据,得到第一视频数据;The acquisition submodule is used to obtain the video data of the current keyframe from the currently playing video, and obtain the first video data;

确定子模块,用于根据第一视频数据、当前关键帧以及索引数据在待切换视频中选择满足预设条件的关键帧,得到切换关键帧。The determination submodule is used to select keyframes that meet preset conditions from the video to be switched based on the first video data, the current keyframe, and the index data, and obtain the switching keyframes.

可选的,在一些实施例中,确定子模块具体可以包括:Optionally, in some embodiments, determining a submodule may specifically include:

获取单元,用于获取当前关键帧在第一视频数据中的位置,得到当前关键帧对应的位置信息;The acquisition unit is used to acquire the position of the current keyframe in the first video data and obtain the position information corresponding to the current keyframe.

选择单元,用于根据索引数据选择在待切换视频中选择满足预设条件的关键帧,得到切换关键帧。The selection unit is used to select key frames that meet preset conditions from the video to be switched based on the index data, and obtain the switching key frames.

可选的,在一些实施例中,选择单元具体可以包括:Optionally, in some embodiments, the selection unit may specifically include:

加载子单元,用于基于索引数据加载待切换视频对应的视频数据,得到第二视频数据;The loading subunit is used to load the video data corresponding to the video to be switched based on the index data, so as to obtain the second video data.

选择子单元,用于在第二视频数据中选择与当前关键帧位置信息匹配的关键帧,得到切换关键帧。The selection sub-unit is used to select a keyframe that matches the current keyframe position information in the second video data, thereby obtaining the switching keyframe.

可选的,在一些实施例中,获取子单元具体可以用于:提取当前关键帧对应的时间戳,得到第一时间戳,以及提取第二视频数据中各关键帧对应的时间戳,得到多个第二时间戳,将第二时间戳与第一时间戳一致的关键帧确定为与当前关键帧对应的关键帧,得到切换关键帧。Optionally, in some embodiments, the acquisition subunit may be specifically used to: extract the timestamp corresponding to the current key frame to obtain a first timestamp, and extract the timestamps corresponding to each key frame in the second video data to obtain multiple second timestamps, and determine the key frame whose second timestamp is consistent with the first timestamp as the key frame corresponding to the current key frame to obtain the switching key frame.

切换模块306,用于基于当前关键帧、切换关键帧以及索引数据,将当前播放视频切换为待切换视频。The switching module 306 is used to switch the currently playing video to the video to be switched based on the current keyframe, the switching keyframe, and the index data.

比如,具体的,可以根据当前关键帧、切换关键帧以及索引数据,计算待切换视频需要加载的视频数据,然后,再基于切换关键真以及需要加载的视频数据,将当前播放视频切换播放待切换视频。For example, specifically, the video data that needs to be loaded for the video to be switched can be calculated based on the current keyframe, the switching keyframe, and the index data. Then, based on the switching keyframe and the video data that needs to be loaded, the currently playing video can be switched to play the video to be switched.

可选的,在一些实施例中,切换模块306具体可以用于:根据当前关键帧确定当前播放视频已播放的视频数据,通过当前关键帧、已播放的视频数据以及索引数据计算待切换视频需要加载的视频数据,通过需要加载的视频数据对预设视频数据缓冲区进行更新,得到更新后缓冲区,以切换关键帧为起始点,基于需要加载的视频数据以及更新后缓冲区,将当前播放视频切换播放所述待切换视频。Optionally, in some embodiments, the switching module 306 may be specifically used to: determine the video data already played in the currently playing video based on the current keyframe; calculate the video data to be loaded for the video to be switched using the current keyframe, the already played video data, and index data; update the preset video data buffer using the video data to be loaded to obtain the updated buffer; and, starting from the switching keyframe, switch the currently playing video to play the video to be switched based on the video data to be loaded and the updated buffer.

可选的,在一些实施例中,请参阅图3b,还包括删除模块307,删除模块307具体用于删除更新后缓冲区中当前播放视频对应的视频数据。Optionally, in some embodiments, please refer to Figure 3b, a deletion module 307 is also included, which is specifically used to delete the video data corresponding to the currently playing video in the updated buffer.

可选的,在一些实施例中,请参阅图3c,还包括构建模块308,构建模块308具体可以用于:构建视频数据缓冲区,在视频数据缓冲区中加载当前播放的视频对应的视频数据。Optionally, in some embodiments, please refer to FIG3c, a construction module 308 is also included. The construction module 308 may be specifically used to: construct a video data buffer and load the video data corresponding to the currently playing video into the video data buffer.

可见,本发明实施例的视频清晰度的切换装置中的第一获取模块301获取当前播放的视频,得到当前播放视频后,第二获取模块302当接收到用户触发的视频清晰度的切换请求时,获取与当前播放视频的内容一致的待切换视频,然后,加载模块303加载待切换视频对应的索引数据,接着,提取模块304提取当前播放视频当前的关键帧,得到当前关键帧,再然后,确定模块305根据当前关键帧以及索引数据确定待切换视频中与当前关键帧对应的关键帧,得到切换关键帧,最后,切换模块306基于当前关键帧、切换关键帧以及索引数据,将当前播放视频切换播放待切换视频。相较于现有的视频清晰度的切换方案而言,本发明的确定模块305可以根据当前关键帧以及索引数据在待切换视频中确定与当前关键帧对应的关键帧,得到切换关键帧,然后,切换模块306再基于当前关键帧、切换关键帧以及索引数据,将当前播放视频切换为待切换视频,也就是说,在本方案中,是基于关键帧进行视频清晰度切换的,因此,可以解决现有的方案中存在的跳帧播放的问题,进而减少流量消耗。As can be seen, in the video clarity switching device of this embodiment, the first acquisition module 301 acquires the currently playing video. After acquiring the currently playing video, when the second acquisition module 302 receives a video clarity switching request triggered by the user, it acquires the video to be switched that is consistent with the content of the currently playing video. Then, the loading module 303 loads the index data corresponding to the video to be switched. Next, the extraction module 304 extracts the current keyframe of the currently playing video to obtain the current keyframe. Then, the determination module 305 determines the keyframe in the video to be switched that corresponds to the current keyframe based on the current keyframe and the index data to obtain the switching keyframe. Finally, the switching module 306 switches the currently playing video to play the video to be switched based on the current keyframe, the switching keyframe, and the index data. Compared to existing video resolution switching schemes, the determining module 305 of this invention can determine the keyframe corresponding to the current keyframe in the video to be switched based on the current keyframe and index data, and obtain the switching keyframe. Then, the switching module 306 switches the currently playing video to the video to be switched based on the current keyframe, the switching keyframe, and the index data. In other words, in this scheme, video resolution switching is based on keyframes. Therefore, it can solve the problem of frame skipping in existing schemes and reduce data consumption.

此外,本发明实施例还提供一种电子设备,如图4所示,其示出了本发明实施例所涉及的电子设备的结构示意图,具体来讲:Furthermore, this invention also provides an electronic device, as shown in FIG4, which illustrates a structural schematic diagram of the electronic device involved in this invention. Specifically:

该电子设备可以包括一个或者一个以上处理核心的处理器401、一个或一个以上计算机可读存储介质的存储器402、电源403和输入单元404等部件。本领域技术人员可以理解,图4中示出的电子设备结构并不构成对电子设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。其中:The electronic device may include components such as a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will understand that the electronic device structure shown in FIG4 does not constitute a limitation on the electronic device, and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein:

处理器401是该电子设备的控制中心,利用各种接口和线路连接整个电子设备的各个部分,通过运行或执行存储在存储器402内的软件程序和/或模块,以及调用存储在存储器402内的数据,执行电子设备的各种功能和处理数据,从而对电子设备进行整体监控。可选的,处理器401可包括一个或多个处理核心;优选的,处理器401可集成应用处理器和调制解调处理器,其中,应用处理器主要处理操作系统、用户界面和应用程序等,调制解调处理器主要处理无线通信。可以理解的是,上述调制解调处理器也可以不集成到处理器401中。The processor 401 is the control center of the electronic device. It connects various parts of the electronic device via various interfaces and lines. By running or executing software programs and/or modules stored in the memory 402, and by calling data stored in the memory 402, it performs various functions and processes data, thereby providing overall monitoring of the electronic device. Optionally, the processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 401.

存储器402可用于存储软件程序以及模块,处理器401通过运行存储在存储器402的软件程序以及模块,从而执行各种功能应用以及数据处理。存储器402可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序(比如声音播放功能、图像播放功能等)等;存储数据区可存储根据电子设备的使用所创建的数据等。此外,存储器402可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。相应地,存储器402还可以包括存储器控制器,以提供处理器401对存储器402的访问。The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 402 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.

电子设备还包括给各个部件供电的电源403,优选的,电源403可以通过电源管理系统与处理器401逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。电源403还可以包括一个或一个以上的直流或交流电源、再充电系统、电源故障检测电路、电源转换器或者逆变器、电源状态指示器等任意组件。The electronic device also includes a power supply 403 that supplies power to the various components. Preferably, the power supply 403 can be logically connected to the processor 401 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 403 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.

该电子设备还可包括输入单元404,该输入单元404可用于接收输入的数字或字符信息,以及产生与用户设置以及功能控制有关的键盘、鼠标、操作杆、光学或者轨迹球信号输入。The electronic device may also include an input unit 404, which can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.

尽管未示出,电子设备还可以包括显示单元等,在此不再赘述。具体在本实施例中,电子设备中的处理器401会按照如下的指令,将一个或一个以上的应用程序的进程对应的可执行文件加载到存储器402中,并由处理器401来运行存储在存储器402中的应用程序,从而实现各种功能,如下:Although not shown, the electronic device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 401 in the electronic device loads the executable files corresponding to the processes of one or more applications into the memory 402 according to the following instructions, and the processor 401 runs the applications stored in the memory 402 to realize various functions, as follows:

获取当前播放的视频,得到当前播放视频,当接收到用户触发的视频清晰度的切换请求时,获取与当前播放视频的内容一致的待切换视频,加载待切换视频对应的索引数据,提取当前播放视频当前的关键帧,得到当前关键帧,根据当前关键帧以及索引数据确定待切换视频中与当前关键帧对应的关键帧,得到切换关键帧,基于当前关键帧、切换关键帧以及索引数据,将当前播放视频切换为待切换视频。The system retrieves the currently playing video. When a user-triggered video resolution switching request is received, it retrieves the video to be switched, which is identical to the currently playing video. It loads the index data corresponding to the video to be switched, extracts the current keyframe of the currently playing video, and determines the corresponding keyframe in the video to be switched based on the current keyframe and the index data. Based on the current keyframe, the switching keyframe, and the index data, it switches the currently playing video to the video to be switched.

以上各个操作的具体实施可参见前面的实施例,在此不再赘述。For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

本发明实施例首先获取当前播放的视频,得到当前播放视频,当接收到用户触发的视频清晰度的切换请求时,获取与当前播放视频的内容一致的待切换视频,然后,加载待切换视频对应的索引数据,接着,提取当前播放视频当前的关键帧,得到当前关键帧,再然后,根据当前关键帧以及索引数据确定待切换视频中与当前关键帧对应的关键帧,得到切换关键帧,最后,基于当前关键帧、切换关键帧以及索引数据,将当前播放视频切换播放待切换视频。相较于现有的视频清晰度的切换方案而言,本发明的视频清晰度的切换方法可以根据当前关键帧以及索引数据在待切换视频中确定与当前关键帧对应的关键帧,得到切换关键帧,然后,再基于当前关键帧、切换关键帧以及索引数据,将当前播放视频切换播放待切换视频,也就是说,在本方案中,是基于关键帧进行视频清晰度切换的,因此,可以解决现有的方案中存在的跳帧播放的问题,进而减少流量消耗。This invention first acquires the currently playing video. When a user-triggered video resolution switching request is received, a video to be switched to, identical in content to the currently playing video, is acquired. Then, the index data corresponding to the video to be switched to is loaded. Next, the current keyframe of the currently playing video is extracted. Then, based on the current keyframe and the index data, the corresponding keyframe in the video to be switched is determined, resulting in the switching keyframe. Finally, based on the current keyframe, the switching keyframe, and the index data, the currently playing video is switched to play the video to be switched. Compared to existing video resolution switching schemes, this invention's method can determine the corresponding keyframe in the video to be switched based on the current keyframe and the index data, obtaining the switching keyframe. Then, based on the current keyframe, the switching keyframe, and the index data, the currently playing video is switched to play the video to be switched. In other words, this scheme switches video resolution based on keyframes, thus solving the frame skipping problem in existing schemes and reducing bandwidth consumption.

本领域普通技术人员可以理解,上述实施例的各种方法中的全部或部分步骤可以通过指令来完成,或通过指令控制相关的硬件来完成,该指令可以存储于一计算机可读存储介质中,并由处理器进行加载和执行。Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.

为此,本发明实施例提供一种存储介质,其中存储有多条指令,该指令能够被处理器进行加载,以执行本发明实施例所提供的任一种视频清晰度的切换方法中的步骤。例如,该指令可以执行如下步骤:To this end, embodiments of the present invention provide a storage medium storing a plurality of instructions that can be loaded by a processor to execute steps in any of the video resolution switching methods provided in the embodiments of the present invention. For example, the instructions can execute the following steps:

获取当前播放的视频,得到当前播放视频,当接收到用户触发的视频清晰度的切换请求时,获取与当前播放视频的内容一致的待切换视频,加载待切换视频对应的索引数据,提取当前播放视频当前的关键帧,得到当前关键帧,根据当前关键帧以及索引数据确定待切换视频中与当前关键帧对应的关键帧,得到切换关键帧,基于当前关键帧、切换关键帧以及索引数据,将当前播放视频切换为待切换视频。The system retrieves the currently playing video. When a user-triggered video resolution switching request is received, it retrieves the video to be switched, which is identical to the currently playing video. It loads the index data corresponding to the video to be switched, extracts the current keyframe of the currently playing video, and determines the corresponding keyframe in the video to be switched based on the current keyframe and the index data. Based on the current keyframe, the switching keyframe, and the index data, it switches the currently playing video to the video to be switched.

以上各个操作的具体实施可参见前面的实施例,在此不再赘述。For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

其中,该存储介质可以包括:只读存储器(ROM,Read Only Memory)、随机存取记忆体(RAM,Random Access Memory)、磁盘或光盘等。The storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

由于该存储介质中所存储的指令,可以执行本发明实施例所提供的任一种视频清晰度的切换方法中的步骤,因此,可以实现本发明实施例所提供的任一种视频清晰度的切换方法所能实现的有益效果,详见前面的实施例,在此不再赘述。Since the instructions stored in the storage medium can execute the steps in any of the video resolution switching methods provided in the embodiments of the present invention, the beneficial effects that any of the video resolution switching methods provided in the embodiments of the present invention can achieve can be realized, as detailed in the preceding embodiments, and will not be repeated here.

以上对本发明实施例所提供的一种视频清晰度的切换方法、装置、电子设备以及存储介质进行了详细介绍,本文中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法及其核心思想;同时,对于本领域的技术人员,依据本发明的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本发明的限制。The foregoing has provided a detailed description of a video resolution switching method, apparatus, electronic device, and storage medium provided by embodiments of the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims (6)

1.一种视频清晰度的切换方法,其特征在于,包括:1. A method for switching video resolution, characterized in that it includes: 获取当前播放的视频,得到当前播放视频;Get the currently playing video; 当接收到用户触发的视频清晰度的切换请求时,获取与当前播放视频的图像张数相同的待切换视频,所述当前播放视频的清晰度与待切换视频的清晰度不同,所述当前播放视频与待切换视频对应的关键帧的数量一致;When a user-triggered video resolution switching request is received, a video to be switched is obtained with the same number of images as the currently playing video. The resolution of the currently playing video is different from that of the video to be switched, and the number of keyframes corresponding to the currently playing video and the video to be switched is the same. 加载所述待切换视频对应的索引数据,所述索引数据包括所述待切换视频中音频帧和视频帧的解码信息、时间戳以及位置;Load the index data corresponding to the video to be switched, the index data including the decoding information, timestamps and positions of the audio frames and video frames in the video to be switched; 提取当前播放视频当前的关键帧,得到当前关键帧;Extract the current keyframe of the currently playing video to obtain the current keyframe; 从所述当前播放视频中获取所述当前关键帧所在的视频数据,得到第一视频数据;Obtain the video data containing the current keyframe from the currently playing video to obtain the first video data; 获取当前关键帧在所述第一视频数据中的位置,得到当前关键帧对应的位置信息;Obtain the position of the current keyframe in the first video data to obtain the position information corresponding to the current keyframe; 基于所述索引数据加载所述待切换视频对应的视频数据,得到第二视频数据;Based on the index data, the video data corresponding to the video to be switched is loaded to obtain the second video data; 在所述第二视频数据中选择与所述位置信息匹配的关键帧,得到切换关键帧,包括:提取当前关键帧对应的时间戳,得到第一时间戳,提取所述第二视频数据中各关键帧对应的时间戳,得到多个第二时间戳;将所述多个第二时间戳中与第一时间戳一致的关键帧确定为与所述当前关键帧对应的关键帧,得到切换关键帧;其中,所述切换关键帧包括基于所述当前关键帧所在的视频数据、所述当前关键帧以及所述索引数据,确定所述待切换视频对应的视频数据中与当前关键帧对应的时间戳或图像内容一致的关键帧;Selecting a keyframe that matches the location information from the second video data to obtain a switching keyframe includes: extracting the timestamp corresponding to the current keyframe to obtain a first timestamp; extracting the timestamps corresponding to each keyframe in the second video data to obtain multiple second timestamps; determining the keyframe among the multiple second timestamps that matches the first timestamp as the keyframe corresponding to the current keyframe to obtain a switching keyframe; wherein, the switching keyframe includes determining a keyframe in the video data corresponding to the video to be switched that matches the timestamp or image content of the current keyframe based on the video data where the current keyframe is located, the current keyframe, and the index data; 基于当前关键帧、切换关键帧以及索引数据,确定所述待切换视频需要加载的视频数据,并根据需要加载的视频数据对视频数据缓冲区进行更新,基于更新后缓冲区中的视频数据,将当前播放视频切换为所述待切换视频,包括:根据当前关键帧确定所述当前播放视频已播放的视频数据;通过当前关键帧、已播放的视频数据以及索引数据计算所述待切换视频需要加载的视频数据;通过需要加载的视频数据对预设视频数据缓冲区进行更新,得到更新后缓冲区;以所述切换关键帧为起始点,基于需要加载的视频数据以及更新后缓冲区,将当前播放视频切换为所述待切换视频。Based on the current keyframe, the switching keyframe, and index data, the video data that needs to be loaded for the video to be switched is determined, and the video data buffer is updated according to the video data to be loaded. Based on the video data in the updated buffer, the currently playing video is switched to the video to be switched. This includes: determining the video data that has been played in the currently playing video according to the current keyframe; calculating the video data that needs to be loaded for the video to be switched using the current keyframe, the played video data, and index data; updating the preset video data buffer using the video data to be loaded to obtain the updated buffer; and switching the currently playing video to the video to be switched, starting from the switching keyframe and based on the video data to be loaded and the updated buffer. 2.根据权利要求1所述的方法,其特征在于,所述以所述切换关键帧为起始点,基于需要加载的视频数据以及更新后缓冲区,将当前播放视频切换为所述待切换视频之后,还包括:2. The method according to claim 1, characterized in that, after switching the currently playing video to the video to be switched based on the video data to be loaded and the updated buffer, using the switching keyframe as the starting point, the method further includes: 删除更新后缓冲区中当前播放视频对应的视频数据。Delete the video data corresponding to the currently playing video in the updated buffer. 3.根据权利要求1所述的方法,其特征在于,在获取当前播放的视频,得到当前播放视频之前,还包括:3. The method according to claim 1, characterized in that, before obtaining the currently playing video, it further includes: 构建视频数据缓冲区;Construct a video data buffer; 在所述视频数据缓冲区中加载当前播放视频对应的视频数据。The video data corresponding to the currently playing video is loaded into the video data buffer. 4.一种视频清晰度的切换装置,其特征在于,包括:4. A video resolution switching device, characterized in that it comprises: 第一获取模块,用于获取当前播放的视频,得到当前播放视频;The first acquisition module is used to acquire the currently playing video and obtain the currently playing video. 第二获取模块,用于当接收到用户触发的视频清晰度的切换请求时,获取与当前播放视频的图像张数相同的待切换视频,所述当前播放视频的清晰度与待切换视频的清晰度不同,所述当前播放视频与待切换视频对应的关键帧的数量一致;The second acquisition module is used to acquire a video to be switched with the same number of images as the currently playing video when a user-triggered request to switch video resolution is received. The resolution of the currently playing video is different from that of the video to be switched, and the number of keyframes corresponding to the currently playing video and the video to be switched is the same. 加载模块,用于加载所述待切换视频对应的索引数据,所述索引数据包括所述待切换视频中音频帧和视频帧的解码信息、时间戳以及位置;The loading module is used to load the index data corresponding to the video to be switched. The index data includes the decoding information, timestamps and positions of the audio frames and video frames in the video to be switched. 提取模块,用于提取当前播放视频当前的关键帧,得到当前关键帧;The extraction module is used to extract the current keyframe of the currently playing video and obtain the current keyframe. 确定模块,用于根据当前关键帧以及索引数据确定待切换视频中与当前关键帧对应的关键帧,得到切换关键帧;其中,所述切换关键帧包括基于所述当前关键帧所在的视频数据、所述当前关键帧以及所述索引数据,确定所述待切换视频对应的视频数据中与当前关键帧对应的时间戳或图像内容一致的关键帧;The determination module is used to determine the key frame in the video to be switched that corresponds to the current key frame based on the current key frame and index data, and obtain the switching key frame; wherein, the switching key frame includes a key frame in the video data corresponding to the video to be switched that is consistent with the timestamp or image content corresponding to the current key frame based on the video data where the current key frame is located, the current key frame and the index data. 切换模块,用于基于当前关键帧、切换关键帧以及索引数据,确定所述待切换视频需要加载的视频数据,并根据需要加载的视频数据对视频数据缓冲区进行更新,基于更新后缓冲区中的视频数据,将当前播放视频切换为所述待切换视频,包括:根据当前关键帧确定所述当前播放视频已播放的视频数据;通过当前关键帧、已播放的视频数据以及索引数据计算所述待切换视频需要加载的视频数据;通过需要加载的视频数据对预设视频数据缓冲区进行更新,得到更新后缓冲区;以所述切换关键帧为起始点,基于需要加载的视频数据以及更新后缓冲区,将当前播放视频切换为所述待切换视频;The switching module is used to determine the video data that needs to be loaded for the video to be switched based on the current keyframe, the switching keyframe, and index data, and to update the video data buffer as needed. Based on the video data in the updated buffer, the currently playing video is switched to the video to be switched. This includes: determining the video data already played in the currently playing video based on the current keyframe; calculating the video data that needs to be loaded for the video to be switched using the current keyframe, the already played video data, and index data; updating the preset video data buffer using the video data to be loaded to obtain an updated buffer; and switching the currently playing video to the video to be switched, starting from the switching keyframe and based on the video data to be loaded and the updated buffer. 其中,所述确定模块包括:The determining module includes: 获取子模块,用于从所述当前播放视频中获取所述当前关键帧所在的视频数据,得到第一视频数据;The acquisition submodule is used to acquire the video data where the current keyframe is located from the currently playing video to obtain the first video data; 确定子模块,用于根据第一视频数据、当前关键帧以及索引数据在所述待切换视频中选择满足预设条件的关键帧,得到切换关键帧;The determination submodule is used to select key frames that meet preset conditions in the video to be switched based on the first video data, the current key frame and the index data, and obtain the switching key frame. 所述确定子模块包括:The determining submodule includes: 获取单元,用于获取当前关键帧在所述第一视频数据中的位置,得到当前关键帧对应的位置信息;The acquisition unit is used to acquire the position of the current keyframe in the first video data and obtain the position information corresponding to the current keyframe. 选择单元,用于根据所述索引数据在待切换视频中选择满足预设条件的关键帧,得到切换关键帧;The selection unit is used to select key frames that meet preset conditions in the video to be switched according to the index data, and obtain the switching key frames. 所述选择单元包括:The selection unit includes: 加载子单元,用于基于所述索引数据加载所述待切换视频对应的视频数据,得到第二视频数据;A loading subunit is used to load the video data corresponding to the video to be switched based on the index data to obtain the second video data; 选择子单元,用于在所述第二视频数据中选择与所述位置信息匹配的关键帧,得到切换关键帧,包括:提取当前关键帧对应的时间戳,得到第一时间戳,提取所述第二视频数据中各关键帧对应的时间戳,得到多个第二时间戳;将所述多个第二时间戳中与第一时间戳一致的关键帧确定为与所述当前关键帧对应的关键帧,得到切换关键帧。The selection subunit is used to select a key frame that matches the location information in the second video data to obtain a switching key frame. The subunit includes: extracting the timestamp corresponding to the current key frame to obtain a first timestamp; extracting the timestamps corresponding to each key frame in the second video data to obtain multiple second timestamps; and determining the key frame that matches the first timestamp among the multiple second timestamps as the key frame corresponding to the current key frame to obtain a switching key frame. 5.一种电子设备,包括存储器,处理器及存储在存储器上并可在处理器上运行的计算机程序,其中,所述处理器执行所述程序时实现如权利要求1-3任一项所述视频清晰度的切换方法的步骤。5. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the video resolution switching method as described in any one of claims 1-3. 6.一种存储介质,其特征在于,其上存储有计算机程序,其中,所述计算机程序被处理器执行时实现如权利要求1-3任一项所述视频清晰度的切换方法的步骤。6. A storage medium, characterized in that it stores a computer program thereon, wherein the computer program, when executed by a processor, implements the steps of the video resolution switching method as described in any one of claims 1-3.
HK42021040723.5A 2021-10-19 A video definition switching method, device, electronic equipment and storage medium HK40051647B (en)

Publications (2)

Publication Number Publication Date
HK40051647A HK40051647A (en) 2022-01-14
HK40051647B true HK40051647B (en) 2024-10-10

Family

ID=

Similar Documents

Publication Publication Date Title
KR101737325B1 (en) Method and apparatus for reducing decreasing of qualitly of experience in a multimedia system
KR102039778B1 (en) Method and apparatus for adaptively providing multiple bit rate stream media in server
US8407747B1 (en) Adaptive trick play streaming
CN113225585B (en) Video definition switching method and device, electronic equipment and storage medium
CN112839238B (en) Screen projection playing method and device and storage medium
US9521470B2 (en) Video delivery system configured to seek in a video using different modes
US9769546B2 (en) Preview image processing using a bundle of preview images
CN103686411A (en) Method for playing video and multimedia device
TW201644269A (en) Content reproduction system, content reproduction apparatus, program, content reproduction method, and providing content server
CN114268830B (en) Cloud guide synchronization method, device, equipment and storage medium
JP4294933B2 (en) Multimedia content editing apparatus and multimedia content reproducing apparatus
WO2019149066A1 (en) Video playback method, terminal apparatus, and storage medium
KR20100002536A (en) Method and system for playing a same motion picture among heterogeneity terminal
US9633694B2 (en) Full fidelity remote video editing
WO2018028547A1 (en) Channel switching method and device
JP4526294B2 (en) STREAM DATA TRANSMITTING DEVICE, RECEIVING DEVICE, RECORDING MEDIUM CONTAINING PROGRAM, AND SYSTEM
CN113382278A (en) Video pushing method and device, electronic equipment and readable storage medium
JP6397341B2 (en) Reception device, buffer management method, and program
HK40051647B (en) A video definition switching method, device, electronic equipment and storage medium
CN112866745B (en) Streaming media video data processing method, device, computer equipment and storage medium
CN115408554A (en) Video processing method and device, storage medium and electronic equipment
CN116170633A (en) Decoding method, device, terminal, storage medium and program product
WO2022173504A1 (en) Playback of media content during dual mode trick play operations
KR20240008319A (en) Switch between delivery of custom content and pre-written media content
HK40051647A (en) A video definition switching method, device, electronic equipment and storage medium