Streaming media playing method and deviceTechnical Field
The invention relates to a streaming media playing technology, in particular to a streaming media playing method and a streaming media playing device.
Background
In theory, a continuous stream of audio data and a continuous stream of video data transmitted and played in chronological order are referred to as streaming media. Among them, the network video in the streaming media is very popular with the users due to its convenience and timeliness. Currently, network video playing modes available for users to select are roughly divided into standard definition, high definition and ultrahigh definition. The three modes only have different physical resolutions, the standard definition format resolution is the lowest, the high definition format resolution is slightly higher, and the ultra-high definition resolution is the highest. When the network bandwidth is the same, the video with low resolution ratio is smoother; when the network bandwidth allows, the high-resolution video with better visual experience can meet the watching requirements of users more easily.
In the prior art, a user needs to manually select a network video playing mode; in order to prevent the limited network bandwidth and maintain sufficient fluency of playing, most users will select the standard definition mode when initially selecting the mode; with the playing of the video, the situation that the network bandwidth is increased may exist, and at this time, the video is still played in the standard definition mode, so that although the normal watching of the user can be ensured, the user does not obtain better visual experience, and meanwhile, the network resources are not fully utilized, which causes great waste of the network resources to a certain extent. When a user initially selects a high-definition mode, as the existing playing technology is enough to enable part of high-definition video to be preloaded in the default buffering time, the pause phenomenon does not occur in a period of time for starting playing; in the continuous playing of the video, the situation that the network bandwidth is reduced may exist, and at this time, the high-definition playing mode is still used, so that the phenomena of blocking, waiting for buffering and the like frequently occur, and the normal watching of the user is seriously influenced.
Disclosure of Invention
In view of the above, the main objective of the present invention is to provide a streaming media playing method and apparatus, which can effectively utilize network resources, reduce the waste of bandwidth to the maximum extent, and provide a smoother playing effect.
In order to achieve the purpose, the technical scheme of the invention is realized as follows:
the invention provides a streaming media playing method, which comprises the following steps:
monitoring current network bandwidth information distributed to the streaming media, determining whether the current network bandwidth information of the streaming media is matched with the current playing mode of the streaming media, and adjusting the playing mode of the streaming media according to the current network bandwidth information when the current network bandwidth information of the streaming media is not matched with the current playing mode of the streaming media.
In the foregoing solution, the determining whether the current network bandwidth information of the streaming media matches the current play mode of the streaming media includes:
setting the corresponding relation of each playing mode of the streaming media and the required network bandwidth information;
and determining whether the current network bandwidth information of the streaming media is matched with the current playing mode of the streaming media according to the corresponding relation.
In the above solution, the play mode includes: standard definition play mode, high definition play mode or ultra high definition play mode.
In the above solution, the setting of the corresponding relationship between each play mode of the streaming media and the current network bandwidth information required by the play mode of the streaming media includes:
when the network bandwidth is greater than a set first threshold value, the playing mode of the corresponding streaming media is an ultra-high-definition playing mode;
when the network bandwidth is less than or equal to a set first threshold and greater than a set second threshold, the corresponding streaming media play mode is a high-definition play mode;
when the network bandwidth is less than or equal to a set second threshold value, the playing mode of the corresponding streaming media is a standard definition playing mode;
wherein the first threshold is greater than the second threshold.
In the above scheme, the adjusting the play mode of the streaming media according to the current network bandwidth information when the streaming media is not matched includes:
when the current playing mode is adjusted from a standard definition playing mode to a high definition playing mode or an ultra-high definition playing mode, or when the current playing mode is adjusted from the high definition playing mode to the ultra-high definition playing mode, determining that the difference between the currently loaded time length of the streaming media and the current playing time length of the streaming media is greater than or equal to a preset time threshold, and loading the streaming media from the time length of the sum of the current playing time length of the streaming media and the time threshold according to the data format of the streaming media corresponding to the adjusted playing mode; and when the difference between the current loading time length of the streaming media and the current playing time length of the streaming media is determined to be smaller than a preset time threshold, loading the streaming media from the current loading time length of the streaming media in the data format of the streaming media corresponding to the adjusted playing mode.
In the above scheme, the adjusting the play mode of the streaming media according to the current network bandwidth information when the streaming media is not matched includes:
and when the current play mode is adjusted from the ultra-high-definition play mode to the high-definition play mode or the standard-definition play mode, or the current play mode is adjusted from the high-definition play mode to the standard-definition play mode, loading the streaming media from the current loading time length of the streaming media according to the data format of the streaming media corresponding to the adjusted play mode.
In the foregoing solution, the monitoring current network bandwidth information allocated to the streaming media includes:
and monitoring the network bandwidth information currently allocated to the streaming media when a monitoring instruction is received, or a monitoring period comes, or the playing mode of the streaming media is adjusted.
The invention also provides a streaming media playing device, which comprises: the device comprises a monitoring unit, a determining unit and an adjusting unit; wherein,
the monitoring unit is used for monitoring the current network bandwidth information distributed to the streaming media;
the determining unit is configured to determine whether the current network bandwidth information of the streaming media matches the current playing mode of the streaming media, and trigger the adjusting unit if the current network bandwidth information of the streaming media does not match the current playing mode of the streaming media;
and the adjusting unit is used for adjusting the current playing mode of the streaming media according to the current network bandwidth information.
In the foregoing solution, the determining unit is further configured to determine whether the current network bandwidth information of the streaming media matches the current play mode of the streaming media according to the corresponding relationship; the corresponding relation between each playing mode of the streaming media and the required network bandwidth information is preset.
In the above solution, the play mode includes: standard definition play mode, high definition play mode or ultra high definition play mode.
In the above scheme, the apparatus further comprises: the device comprises a setting unit, a processing unit and a processing unit, wherein the setting unit is used for setting a play mode of the streaming media to be an ultra-high-definition play mode when the network bandwidth is greater than a set first threshold;
when the network bandwidth is less than or equal to a set first threshold value and greater than a set second threshold value, setting the play mode of the streaming media to be a high-definition play mode;
when the network bandwidth is less than or equal to a set second threshold value, setting the play mode of the streaming media as a standard definition play mode;
wherein the first threshold is greater than the second threshold.
In the above scheme, the apparatus further includes a first loading unit and a second loading unit, wherein:
the determining unit is further configured to trigger the first loading unit when the adjusting unit adjusts the current play mode from the standard definition play mode to the high definition play mode or the ultra-high definition play mode, or when the current play mode is adjusted from the high definition play mode to the ultra-high definition play mode, and it is determined that a difference between a currently loaded duration of the streaming media and a currently played duration of the streaming media is greater than or equal to a preset time threshold;
the first loading unit is configured to load the streaming media from a duration of a sum of a current playing duration of the streaming media and the time threshold in accordance with a data format of the streaming media corresponding to the adjusted playing mode;
the determining unit is further configured to trigger the second loading unit when the adjusting unit adjusts the current play mode from the standard definition play mode to the high definition play mode or the ultra-high definition play mode, or when the current play mode is adjusted from the high definition play mode to the ultra-high definition play mode, and it is determined that a difference between a currently loaded duration of the streaming media and a currently played duration of the streaming media is smaller than a preset time threshold;
the second loading unit is configured to load the streaming media from the currently loaded duration of the streaming media in the data format of the streaming media corresponding to the adjusted play mode.
In the above scheme, the apparatus further includes a third loading unit;
the determining unit is further configured to trigger the third loading unit when the adjusting unit adjusts the current play mode from the ultra-high-definition play mode to the high-definition play mode or the standard-definition play mode, or adjusts the current play mode from the high-definition play mode to the standard-definition play mode;
the third loading unit is configured to load the streaming media from the current loading duration of the streaming media according to the data format of the streaming media corresponding to the adjusted play mode.
In the above scheme, the monitoring unit is further configured to monitor current network bandwidth information allocated to the streaming media when a monitoring instruction is received, or a monitoring period comes, or the adjusting unit adjusts the play mode of the streaming media.
The method and the device for playing the streaming media provided by the invention monitor the current network bandwidth information allocated to the streaming media, determine whether the current network bandwidth information of the streaming media is matched with the current playing mode of the streaming media, and adjust the playing mode of the streaming media according to the current network bandwidth information when the current network bandwidth information of the streaming media is not matched with the current playing mode of the streaming media. The invention can realize the effective utilization of network resources, reduce the waste of bandwidth and present smooth video pictures which are not blocked and not waiting for buffering.
Drawings
FIG. 1 is a flow chart of a streaming media playing method according to the present invention;
FIGS. 2(a) to 2(e) are schematic diagrams of loading duration and playing duration;
FIG. 3 is a schematic diagram of a specific embodiment of the streaming media playing method according to the present invention;
fig. 4 is a schematic structural diagram of the streaming media playing apparatus according to the present invention.
Detailed Description
The present invention provides a streaming media playing method, as shown in fig. 1, the method includes:
step 10: monitoring current network bandwidth information allocated to the streaming media;
in this step, when a monitoring period of the network bandwidth information of the streaming media is preset, and when the monitoring period comes, monitoring of the network bandwidth information currently allocated to the streaming media is executed;
or, when the terminal receives a monitoring instruction, such as a monitoring instruction input by a user, the terminal executes monitoring of the current network bandwidth information allocated to the streaming media;
or, after the current play mode of the streaming media is adjusted, monitoring the current network bandwidth information allocated to the streaming media.
In the present invention, the play mode of the streaming media comprises: a standard definition play mode, a high definition play mode and an ultra high definition play mode, but not limited to the above three play modes.
Step 20: and determining whether the current network bandwidth information of the streaming media is matched with the current playing mode of the streaming media, and adjusting the playing mode of the streaming media according to the current network bandwidth information when the current network bandwidth information of the streaming media is not matched with the current playing mode of the streaming media.
Here, the corresponding relation between each playing mode of the streaming media and the required network bandwidth information is preset; and determining whether the network bandwidth information of the streaming media is matched with the playing mode of the streaming media according to the corresponding relation.
Wherein the corresponding relationship comprises: when the network bandwidth is greater than a set first threshold value, setting a playing mode of the corresponding streaming media as an ultra-high-definition playing mode; when the network bandwidth is less than or equal to a set first threshold value and greater than a set second threshold value, setting the corresponding streaming media play mode as a high-definition play mode; when the network bandwidth is less than or equal to a set second threshold value, setting the corresponding streaming media play mode as a standard definition play mode; the first threshold is greater than the second threshold, e.g., 100Kbps kilobits per second, and the second threshold is 60 Kbps. Here, the second threshold value needs to be larger than the lower limit value of the bandwidth required for loading the standard definition streaming media.
Here, the current video splicing technology is adopted when the play mode of the streaming media is adjusted, so that seamless switching between different play modes is realized.
Fig. 3 is a schematic diagram of an embodiment of the present invention, and the monitoring period and the adjustment of the play mode between the high-definition play mode and the standard-definition play mode are taken as examples to further explain the present invention with reference to fig. 2(a) to 2 (e).
For convenience of description, the present invention is further explained by introducing time, loading time, playing time, and the like in fig. 2(a) to 2 (e).
Step 30: preloading a high-definition video stream of a video, and playing the video by using a high-definition mode;
here, the prior art playing technology may preload the high definition video stream at the initial time within a preset buffering time, as shown in fig. 2(a), at the initial time T0, a segment of the high definition video stream is already preloaded; and playing the high-definition video stream by using the high-definition playing mode within the time from T0 to T1 before the monitoring period comes.
Step 31: when the monitoring period comes, starting to monitor the current network bandwidth information of the video, determining that the current network bandwidth information of the video is not matched with the network bandwidth of a preset high-definition play mode and is matched with the network bandwidth of a preset standard definition play mode, adjusting the current play mode of the video to be the standard definition play mode, and then loading the video in a standard definition data format.
Specifically, as shown in fig. 2(b), when it is determined that the current network bandwidth information matches the standard definition play mode at the time T1 when the monitoring period comes, the current loading duration Point1 is recorded; as shown in fig. 2(c), a standard definition video stream of the video is loaded from the current loading duration Point 1.
Step 32: when the monitoring period comes again, starting to monitor the current network bandwidth information of the video, determining that the current network bandwidth information of the video is not matched with the network bandwidth of the preset standard definition play mode and is matched with the network bandwidth of the preset high definition play mode, adjusting the current play mode of the video to be the high definition play mode, and loading the video in a high definition data format.
With reference to fig. 2(d) and fig. 2(e), at a time T2 when the monitoring period comes again, when it is determined that current network bandwidth information matches the network bandwidth of the high definition play mode, recording a currently loaded duration and a currently played duration Point2 of the video, and when it is determined that a difference between the currently loaded duration of the streaming media and the currently played duration Point2 of the streaming media is greater than or equal to a preset time threshold, loading the streaming media from a duration of a sum of the currently played duration of the streaming media and the time threshold in a high definition data format within a time period from T3 to T4; and by analogy, when the monitoring period comes, starting to monitor the current network bandwidth information of the video, and when the network bandwidth information of the video is determined not to be matched with the playing mode of the video, adjusting the playing mode of the video until the video is played.
Wherein the time threshold is preset; the time is usually 1/N of the total length of the video, and N is a natural number, which is determined by the total length of the video, the playing time and the loading time of the video.
Based on the streaming media playing method, the present invention further provides a streaming media playing apparatus, as shown in fig. 4, the apparatus includes: a monitoring unit 31, a determining unit 32, and an adjusting unit 33; wherein,
the monitoring unit 31 is configured to monitor current network bandwidth information allocated to the streaming media;
the determining unit 32 is configured to determine whether the current network bandwidth information of the streaming media matches the current playing mode of the streaming media, and if not, trigger the adjusting unit 33;
the adjusting unit 33 is configured to adjust the play mode of the streaming media according to the current network bandwidth information.
Here, the play mode includes: standard definition play mode, high definition play mode or ultra high definition play mode.
Further, the apparatus further comprises: a setting unit 34; the setting unit 34 is configured to set a corresponding relationship between each play mode of the streaming media and the required network bandwidth information; specifically, when the network bandwidth is greater than a set first threshold, setting the play mode of the streaming media to be an ultra high definition play mode; when the network bandwidth is less than or equal to a set first threshold value and greater than a set second threshold value, setting the play mode of the streaming media to be a high-definition play mode; when the network bandwidth is less than or equal to a set second threshold value, setting the play mode of the streaming media as a standard definition play mode; wherein the first threshold is greater than the second threshold, for example, the first threshold is 100Kbps kbits per second, and the second threshold is 60 Kbps. The second threshold value needs to be larger than the lower limit value of the bandwidth required by loading the standard definition streaming media.
The determining unit 32 determines whether the network bandwidth information of the streaming media matches with the playing mode of the streaming media according to the corresponding relationship.
The monitoring unit 31 is further configured to monitor current network bandwidth information allocated to the streaming media after receiving a monitoring instruction, such as a monitoring instruction input by a user, or a monitoring period comes, or the adjusting unit 33 adjusts a play mode of the streaming media.
The monitoring period is preset and can be set according to the actual condition of the network.
The following describes the present invention in detail by taking an example of adjusting the monitoring period and the play mode between the high definition play mode and the standard definition mode.
The device further comprises: a first loading unit 36 and a second loading unit 37 and a third loading unit 38.
When monitoring that the monitoring period comes, the monitoring unit 31 starts to monitor the current network bandwidth information of the video; the determining unit 32 determines that the current network bandwidth information of the video is not matched with the network bandwidth of the preset high-definition play mode but is matched with the network bandwidth of the preset standard-definition play mode, and then triggers the adjusting unit 33 to adjust the current play mode of the video to be the standard-definition play mode; the determining unit 32 adjusts the current playing mode from the high-definition playing mode to the standard-definition playing mode in the adjusting unit 33, and triggers the third loading unit 38; the third loading unit 38 loads the standard definition video stream of the video in the standard definition data format from the current loading duration;
when monitoring that the monitoring period comes again, the monitoring unit 31 starts to monitor the current network bandwidth information of the video again; the determining unit 32 determines that the current network bandwidth information of the video is not matched with the network bandwidth of the adjusted standard definition play mode but is matched with the network bandwidth of the high definition play mode, and then triggers the adjusting unit 33 to adjust the current play mode of the video to be the high definition play mode; when the adjusting unit 33 adjusts the current play mode from the standard definition play mode to the high definition play mode, and determines that the difference between the currently loaded duration of the streaming media and the currently played duration of the streaming media is greater than or equal to a preset time threshold, the determining unit 32 triggers the first loading unit 36; the first loading unit 36 loads the streaming media from the time length of the sum of the current playing time length of the streaming media and the time threshold;
the determining unit 32 is further configured to trigger the second loading unit 37 when the adjusting unit 33 adjusts the current play mode from the standard definition play mode to the high definition play mode and determines that a difference between a currently loaded duration of the streaming media and a currently played duration of the streaming media is smaller than a preset time threshold;
the second loading unit 37 loads the streaming media from the current loading duration of the streaming media in the adjusted high definition data format.
Wherein the time threshold is preset; the value of the time threshold is determined by the total length of the video, the playing time length and the loading time length of the video.
In the invention, the current play mode is adjusted between a high-definition play mode and a standard-definition play mode; besides, the high-definition playing mode and the ultra-high-definition playing mode or the standard-definition playing mode and the ultra-high-definition playing mode can be adjusted.
The method and the device for playing the streaming media provided by the invention monitor the current network bandwidth information allocated to the streaming media, determine whether the current network bandwidth information of the streaming media is matched with the current playing mode of the streaming media, and adjust the playing mode of the streaming media according to the current network bandwidth information when the current network bandwidth information of the streaming media is not matched with the current playing mode of the streaming media. By using the invention, when the network bandwidth information of the streaming media is determined not to be matched with the network bandwidth corresponding to the play mode of the streaming media, the play mode of the streaming media is adjusted. The invention can reduce the waste of bandwidth, improve the effective utilization of network resources, avoid waiting for buffering by users and present a smooth video image without blockage for the users.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the scope of the present invention.