CN110267100B - Code rate switching method and device for FLV (flash video), electronic equipment and storage medium - Google Patents

Code rate switching method and device for FLV (flash video), electronic equipment and storage medium Download PDF

Info

Publication number
CN110267100B
CN110267100B CN201910631959.8A CN201910631959A CN110267100B CN 110267100 B CN110267100 B CN 110267100B CN 201910631959 A CN201910631959 A CN 201910631959A CN 110267100 B CN110267100 B CN 110267100B
Authority
CN
China
Prior art keywords
code rate
current
target
video
switching
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910631959.8A
Other languages
Chinese (zh)
Other versions
CN110267100A (en
Inventor
王涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN201910631959.8A priority Critical patent/CN110267100B/en
Publication of CN110267100A publication Critical patent/CN110267100A/en
Application granted granted Critical
Publication of CN110267100B publication Critical patent/CN110267100B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/25Management operations performed by the server for facilitating the content distribution or administrating data related to end-users or client devices, e.g. end-user or client device authentication, learning user preferences for recommending movies
    • H04N21/266Channel or content management, e.g. generation and management of keys and entitlement messages in a conditional access system, merging a VOD unicast channel into a multicast channel
    • H04N21/2662Controlling the complexity of the video stream, e.g. by scaling the resolution or bitrate of the video stream based on the client capabilities
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/433Content storage operation, e.g. storage operation in response to a pause request, caching operations
    • H04N21/4331Caching operations, e.g. of an advertisement for later insertion during playback
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream, rendering scenes according to MPEG-4 scene graphs
    • H04N21/4402Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream, rendering scenes according to MPEG-4 scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display
    • H04N21/440263Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream, rendering scenes according to MPEG-4 scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display by altering the spatial resolution, e.g. for displaying on a connected PDA
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream, rendering scenes according to MPEG-4 scene graphs
    • H04N21/4402Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream, rendering scenes according to MPEG-4 scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display
    • H04N21/440281Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream, rendering scenes according to MPEG-4 scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display by altering the temporal resolution, e.g. by frame skipping
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/80Generation or processing of content or additional data by content creator independently of the distribution process; Content per se
    • H04N21/85Assembly of content; Generation of multimedia applications
    • H04N21/854Content authoring
    • H04N21/8547Content authoring involving timestamps for synchronizing content

Abstract

The disclosure relates to a code rate switching method, a device, an electronic device and a storage medium for an FLV video, wherein the method comprises the following steps: acquiring the current downloading speed of the FLV video downloaded by the current network; determining a target code rate from a plurality of preset code rates according to the current downloading speed; judging whether code rate switching is needed or not according to whether the target code rate is the same as the current code rate of the FLV video; if the code rate switching is needed, after the current GOP of the current code rate is downloaded, the downloading of the FLV video of the current code rate is stopped, and the current code rate is switched to the target code rate. Therefore, according to the technical scheme provided by the embodiment of the disclosure, in the FLV video playing process, the code rate can be adaptively switched according to the network environment of the user, so that the watching continuity of the user is ensured, and the occurrence of blocking is effectively avoided.

Description

Code rate switching method and device for FLV (flash video), electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of video playing technologies, and in particular, to a method and an apparatus for switching a code rate of an FLV video, an electronic device, and a storage medium.
Background
At present, FLV (Flash Video, streaming media format) gradually becomes the mainstream Video playing mode. The FLV is composed Of a continuous data stream, and the basic unit is GOP (Group Of Picture), in which the duration Of one GOP is fixed, i.e., the time interval between two I frames.
At present, in the related art, the code rate of the FLV video is switched during the playing process, which is manually implemented. The code rate is represented by the definition of video playing, and the manual adjustment of the code rate is the process of manual adjustment of the definition. The general case is: in the process of playing the FLV video according to the definition set by the user, if the FLV video is blocked, the user can manually modify the definition of the player so as to ensure the fluency of video playing. For example: the definition set by a user is high definition, the video playing process of the FLV is blocked, the definition of the player is manually modified into standard definition by the user, and the code rate is reduced to ensure the fluency of video playing. Different code rates of the same video have different download addresses, and the switching code rate is also the switching of the video download addresses.
Therefore, the video code rate switching method in the related art is manually switched after the pause occurs, and the video playing continuity is not high enough.
Disclosure of Invention
The present disclosure provides a method, an apparatus, an electronic device and a storage medium for rate switching of an FLV video, so as to at least solve the problem in the related art that the playing continuity of the FLV video is not high enough. The technical scheme of the disclosure is as follows:
according to a first aspect of the embodiments of the present disclosure, a method for rate switching of an FLV video is provided, including:
acquiring the current downloading speed of the FLV video downloaded by the current network;
determining a target code rate from a plurality of preset code rates according to the current downloading speed;
judging whether code rate switching is needed or not according to whether the target code rate is the same as the current code rate of the FLV video;
if the code rate switching is needed, after downloading the current GOP of the current code rate, the downloading of the FLV video of the current code rate is stopped, and the current code rate is switched to the target code rate.
In a specific embodiment, the step of determining a target code rate from a plurality of preset code rates according to the current downloading speed includes:
and determining the code rate which is smaller than the current downloading speed and has the minimum difference with the current downloading speed as a target code rate.
In a specific embodiment, the step of determining whether to perform rate switching according to whether the target rate is the same as the current rate of the FLV video includes:
judging whether the target code rate is the same as the code rate value of the current code rate of the FLV video or not;
if the target code rate is different from the code rate value of the current code rate of the FLV video, judging whether the currently cached data to be played meets a preset switching condition; if the current cached data to be played meets the preset switching condition, code rate switching is required;
and if the target code rate is the same as the current code rate of the FLV video, code rate switching is not needed.
In a specific embodiment, the preset switching condition is:
when the code rate value of the current code rate is lower than the code rate value of the target code rate, requiring that the playing time of the cached data to be played is greater than or equal to a preset first caching time, wherein the first caching time is greater than the time of a GOP;
and when the code rate value of the current code rate is higher than the code rate value of the target code rate, requiring that the playing time of the cached data to be played is shorter than a preset second caching time, wherein the second caching time is longer than or equal to the time of a GOP and shorter than the first caching time.
In a specific embodiment, before the step of obtaining the current downloading speed of the FLV video downloaded by the current network, the method further includes:
acquiring a configuration file of an FLV video downloaded by a current network; the configuration file comprises: and the code rate value corresponding to each preset code rate in the plurality of code rates and the corresponding relation between the code rate value and the address of the server of the FLV video in which the code rate is stored.
In a specific embodiment, the step of switching the current code rate to the target code rate includes:
acquiring the address of a target server of the FLV video with the target code rate from the configuration file;
acquiring a target time stamp corresponding to the next GOP after the current GOP is finished;
sending a video data downloading request for obtaining a GOP corresponding to the target timestamp to the target server according to the obtained target timestamp, wherein the video data downloading request comprises a code rate value of the target code rate and the target timestamp;
receiving the video data sent by the target server, wherein the video data is video data of an FLV (flash video) downloaded by a current network and with a timestamp of the target timestamp in the target code rate;
and storing the received video data to a cache.
According to a second aspect of the embodiments of the present disclosure, there is provided a rate switching apparatus for an FLV video, including:
the downloading speed acquiring unit is configured to execute acquiring the current downloading speed of the FLV video downloaded by the current network;
the determining unit is configured to determine a target code rate from a plurality of preset code rates according to the current downloading speed;
the judging unit is configured to execute the judgment of whether code rate switching is needed or not according to whether the target code rate is the same as the current code rate of the FLV video;
and the switching unit is configured to execute, when code rate switching is required, after downloading the current GOP of the current code rate, terminate downloading of the FLV video of the current code rate, and switch the current code rate to the target code rate.
In a specific embodiment, the determining unit is configured to perform:
and determining the code rate which is smaller than the current downloading speed and has the minimum difference with the current downloading speed as a target code rate.
In a specific embodiment, the determining unit is configured to perform:
judging whether the target code rate is the same as the code rate value of the current code rate of the FLV video or not;
if the target code rate is different from the code rate value of the current code rate of the FLV video, judging whether the currently cached data to be played meets a preset switching condition; if the current cached data to be played meets the preset switching condition, code rate switching is required;
and if the target code rate is the same as the current code rate of the FLV video, code rate switching is not needed.
In a specific embodiment, the preset switching condition is:
when the code rate value of the current code rate is lower than the code rate value of the target code rate, requiring that the playing time of the cached data to be played is greater than or equal to a preset first caching time, wherein the first caching time is greater than the time of a GOP;
and when the code rate value of the current code rate is higher than the code rate value of the target code rate, requiring that the playing time of the cached data to be played is shorter than a preset second caching time, wherein the second caching time is longer than or equal to the time of a GOP and shorter than the first caching time.
In a specific embodiment, the apparatus for switching bitrate of FLV video further includes:
the configuration file acquisition unit is configured to execute the acquisition of the configuration file of the FLV video downloaded by the current network; the configuration file comprises: and the code rate value corresponding to each preset code rate in the plurality of code rates and the corresponding relation between the code rate value and the address of the server of the FLV video in which the code rate is stored.
In a specific embodiment, the switching unit is configured to perform:
acquiring the address of a target server of the FLV video with the target code rate from the configuration file;
acquiring a target time stamp corresponding to the next GOP after the current GOP is finished;
sending a video data downloading request for acquiring a GOP corresponding to the target timestamp to the target server according to the acquired target timestamp; the video data downloading request comprises a code rate value of the target code rate and the target timestamp;
receiving the video data sent by the target server, wherein the video data is video data of an FLV (flash video) downloaded by a current network and with a timestamp of the target timestamp in the target code rate;
and storing the received video data to a cache.
According to a third aspect of the embodiments of the present disclosure, there is provided an electronic apparatus, including:
a processor;
a memory for storing the processor-executable instructions;
acquiring the current downloading speed of the FLV video downloaded by the current network;
determining a target code rate from a plurality of preset code rates according to the current downloading speed;
judging whether code rate switching is needed or not according to whether the target code rate is the same as the current code rate of the FLV video;
if the code rate switching is needed, after downloading the current GOP of the current code rate, the downloading of the FLV video of the current code rate is stopped, and the current code rate is switched to the target code rate.
According to a fourth aspect of embodiments of the present disclosure, there is provided a computer program product, which, when executed by a processor of an electronic device, enables the electronic device to perform the steps of:
acquiring the current downloading speed of the FLV video downloaded by the current network;
determining a target code rate from a plurality of preset code rates according to the current downloading speed;
judging whether code rate switching is needed or not according to whether the target code rate is the same as the current code rate of the FLV video;
if the code rate switching is needed, after downloading the current GOP of the current code rate, the downloading of the FLV video of the current code rate is stopped, and the current code rate is switched to the target code rate.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects: in the process of playing the FLV video, the code rate is switched in a self-adaptive mode according to the network environment of the user. Due to the technical scheme provided by the embodiment of the disclosure, the high-definition video can be played when the network environment is good according to the self-adaptive switching of the definition of the played video of the current network environment of the user in the video playing process, and the playing definition of the video is automatically switched from the higher definition to the definition adaptive to the current network environment when the network environment is poor, so that the watching continuity of the user is ensured, and the occurrence of blocking is effectively avoided.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure and are not to be construed as limiting the disclosure.
Fig. 1 is a flowchart illustrating a rate switching method for FLV video according to an exemplary embodiment.
Fig. 2 is a flowchart illustrating another rate switching method for FLV video according to an exemplary embodiment.
Fig. 3 is a block diagram illustrating a rate switching apparatus for FLV video according to an exemplary embodiment.
Fig. 4 is a block diagram illustrating another apparatus for rate switching of FLV video according to an exemplary embodiment.
FIG. 5 is a block diagram illustrating an electronic device in accordance with an example embodiment.
Detailed Description
In order to make the technical solutions of the present disclosure better understood by those of ordinary skill in the art, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or otherwise described herein. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
Fig. 1 is a flowchart illustrating a bitrate switching method for an FLV video according to an exemplary embodiment, where the bitrate switching method for the FLV video is used in a client, as shown in fig. 1, and includes the following steps:
in step S101, a current downloading speed of the FLV video downloaded by the current network is obtained.
In practical application, before playing the FLV video, the player downloads the configuration file of the FLV video, obtains a default server address of the FLV video, and starts to download the video data from the server address for playing.
In step S102, a target bitrate is determined from a plurality of preset bitrates according to the current download speed.
In a specific embodiment, the step of determining a target bitrate from a plurality of preset bitrates according to the current downloading speed may include:
and determining the code rate which is smaller than the current downloading speed and has the minimum difference with the current downloading speed as the target code rate.
In step S103, it is determined whether a rate switch is required according to whether the target rate is the same as the current rate of the FLV video.
In a specific embodiment, the step of determining whether to perform rate switching according to whether the target rate is the same as the current rate of the FLV video may include:
judging whether the target code rate is the same as the code rate value of the current code rate of the FLV video;
if the target code rate is different from the code rate value of the current code rate of the FLV video, judging whether the currently cached data to be played meets a preset switching condition; if the current cached data to be played meets the preset switching condition, code rate switching is required;
and if the target code rate is the same as the current code rate of the FLV video, code rate switching is not needed.
In practical applications, the preset switching condition may be:
when the code rate value of the current code rate is lower than the code rate value of the target code rate, requiring that the playing time of the cached data to be played is longer than or equal to a preset first caching time, wherein the first caching time is longer than the time of one GOP;
and when the code rate value of the current code rate is higher than the code rate value of the target code rate, requiring that the playing time of the cached data to be played is shorter than a preset second caching time, wherein the second caching time is longer than or equal to the time of one GOP and shorter than the first caching time.
The playing duration of the cached data to be played may be obtained by calculation according to the data amount of the cached data to be played and the current code rate.
In step S104, if code rate switching is required, after downloading the current GOP of the current code rate, the downloading of the FLV video of the current code rate is terminated, and the current code rate is switched to the target code rate.
In a specific embodiment, the step of switching the current code rate to the target code rate may include:
acquiring the address of a target server of the FLV video with the target code rate from the configuration file;
acquiring a target time stamp corresponding to the next GOP after the current GOP is finished;
sending a video data downloading request of a GOP corresponding to the acquired target timestamp to a target server according to the acquired target timestamp; the video data downloading request comprises a code rate value of a target code rate and a target timestamp;
receiving video data sent by a target server, wherein the video data is video data of an FLV video downloaded by a current network and the time stamp of the FLV video is the target time stamp in the target code rate;
and storing the received video data to a cache.
According to the technical scheme provided by the embodiment of the disclosure, in the process of playing the FLV video, the code rate is adaptively switched according to the network environment of the user. Due to the technical scheme provided by the embodiment of the disclosure, the high-definition video can be played when the network environment is good according to the self-adaptive switching of the definition of the played video of the current network environment of the user in the video playing process, and the playing definition of the video is automatically switched from the higher definition to the definition adaptive to the current network environment when the network environment is poor, so that the watching continuity of the user is ensured, and the occurrence of blocking is effectively avoided.
The following describes a specific embodiment, and further details a rate switching method for an FLV video provided in the embodiments of the present disclosure.
Fig. 2 is a flowchart illustrating another method for rate switching of an FLV video according to an exemplary embodiment, where the method for rate switching of an FLV video, as shown in fig. 2, includes the following steps:
in step S201, a configuration file of the FLV video currently downloaded by the network is acquired.
In this embodiment, the FLV video may be a live video.
In practical applications, before a player acquires an FLV video, a configuration file, specifically a manifest file, is acquired, where the manifest file includes: the method comprises the steps of presetting a code rate value corresponding to each code rate in a plurality of code rates, and corresponding relation between the code rate value and a server address, namely a downloading address, of the FLV video stored with the code rate. Usually, the player selects a default download address to start downloading the FLV video, and the default download address is a download address corresponding to a code rate with the lowest code rate among the preset plurality of code rates.
In step S202, a current download speed of the FLV video downloaded by the current network is obtained.
In a specific embodiment, the method for acquiring the current downloading speed of the FLV video downloaded by the current network may be: and comparing the data volume for downloading the FLV video in the preset time period with the preset time period, and acquiring the current downloading speed of the FLV video downloaded by the current network. Such as: and dividing the data volume of the FLV video downloaded in 5 seconds by 5 seconds to obtain the current downloading speed of the FLV video downloaded by the current network.
In step S203, a target bitrate is determined from a plurality of preset bitrates according to the current downloading speed.
Generally, in a plurality of code rates preset by the same FLV video, the GOP time lengths of all the code rates are the same; the time stamps corresponding to the GOPs of all code rates are the same; the coding formats of the data streams corresponding to all code rates are the same, for example: the GOP time length of all code rates is 3 seconds, and the coding formats of the data streams corresponding to all code rates are all H264 or all H265.
In a specific embodiment, the step of determining a target bitrate from a plurality of preset bitrates according to the current downloading speed may include:
and determining the code rate which is smaller than the current downloading speed and has the minimum difference with the current downloading speed as the target code rate.
In another specific embodiment, the target code rate may be determined from a plurality of preset code rates according to the following steps:
determining a reference downloading speed according to the current downloading speed; wherein the reference download speed is less than the current download speed;
for each code rate, judging whether the difference value obtained by subtracting the code rate from the reference downloading speed and the current ratio of the current downloading speed are within a preset interval range or not;
and if the current ratio is within the preset interval range, determining the code rate as the target code rate.
In practical applications, according to the current download speed, the method for determining the reference download speed may be as follows: and multiplying the current downloading speed by a preset numerical value less than 100% to determine the reference downloading speed. Such as: 80% of the current download speed is determined as the reference download speed.
The ratio can be calculated as:
Figure BDA0002128960830000081
if the ratio is smaller, it indicates that the code rate is closer to the reference download speed. In a specific embodiment, the code rate corresponding to the minimum ratio in the preset range may be determined as the target code rate, and the preset range may be 0 to 10% of the current download speed.
Example 1: the preset code rate comprises the following steps: 4000kpbs, 5000kpbs, 6000kpbs and 7500kpbs, the current code rate is 4000kpbs, and the current downloading speed is 10240 kpbs. The reference download speed is 80% and the current download speed is 8192kpbs, because
Figure BDA0002128960830000082
Therefore, 7500kpbs is determined as the target code rate.
Example 1: the preset code rate comprises the following steps: 4000kpbs, 5000kpbs, 6000kpbs and 7500kpbs, the current code rate is 6000kpbs, and the current download speed is 7000 kpbs. The reference download speed is 80% of the current download speed is 5600kpbs, since
Figure BDA0002128960830000083
Therefore, 5000kpbs is determined as the target code rate.
In step S204, the current bitrate of the FLV video is obtained.
In a specific embodiment, the current bitrate of the FLV video may be obtained before the step of determining the target bitrate from a plurality of preset bitrates according to the current download speed. In another specific embodiment, the current bitrate of the FLV video may also be obtained before obtaining the current downloading speed of the FLV video downloaded by the current network. The embodiment of the present invention does not limit the sequence of the step of obtaining the current bitrate of the FLV video, as long as the current bitrate of the FLV video is obtained before step S205.
In step S205, it is determined whether the code rate values of the current code rate and the target code rate are the same; if the code rate values of the current code rate and the target code rate are not the same, executing step S206; if the code rate values of the current code rate and the target code rate are the same, step S215 is performed.
In step S206, it is determined whether the code rate value of the current code rate is lower than the code rate value of the target code rate; if the code rate value of the current code rate is lower than the code rate value of the target code rate, executing the step S207; if the code rate value of the current code rate is higher than the code rate value of the target code rate, step S208 is executed.
In step S207, determining whether the playing time of the cached data to be played is greater than or equal to a preset first caching time; if the playing time length of the buffered data to be played is greater than or equal to the preset first buffer time length, step S209 is executed, and if the playing time of the buffered data to be played is less than the preset first buffer time length, step S215 is executed, where the first buffer time length is greater than the time length of one GOP.
In step S208, determining whether the playing duration of the cached data to be played is less than a preset second cache duration; if the playing time of the cached data to be played is shorter than the preset second caching time, step S209 is executed, and if the playing time of the cached data to be played is longer than or equal to the preset second caching time, step S215 is executed, where the second caching time is longer than or equal to the time of one GOP and shorter than the first caching time.
Specifically, the playing duration of the cached data to be played is obtained by calculation according to the data amount of the cached data to be played and the current code rate. The buffer duration is set to ensure that the jamming is prevented when the code rate is switched.
The GOP is a basic unit of the FLV video, one GOP is a multimedia data frame, and is composed of an I frame (Intra-coded Picture frame), a plurality of P frames (Predictive-coded Picture frame), and a plurality of B frames (bidirectional-Predictive coded Picture frame), where the I frame is a key frame, the P frame is a forward prediction frame, and the B frame is a bidirectional interpolation frame. The key frame in a multimedia data frame is usually a complete picture, while the P frame and the B frame in a multimedia data frame are mainly used for recording changes relative to the key frame, and the P frame and the B frame cannot be decoded without the key frame.
In practical applications, the duration of a GOP in an FLV video is usually fixed, and is a time interval between two I frames, and the duration of one GOP is usually 2-3 seconds.
In a specific embodiment, the duration of a GOP may be 3 seconds, the first buffering duration may be 4 seconds, and the second buffering duration may be 3 seconds.
In step S209, the address of the target server storing the FLV video with the target bitrate is acquired from the configuration file.
In step S210, a target timestamp corresponding to a next GOP after the end of the current GOP is acquired.
In step S211, according to the acquired target timestamp, sending a video data download request for acquiring a GOP corresponding to the target timestamp to the target server; the video data download request may include a code rate value of the target code rate and a target timestamp.
In practical applications, some GOPs may be missing in the target server, possibly due to data loss, etc. Under a normal condition, if the video data of the GOP corresponding to the target timestamp exists in the target server, the video data of the GOP corresponding to the target timestamp is sent to the client sending the downloading request; and if the video data of the GOP corresponding to the target timestamp does not exist in the target server, sending the video data of the GOP of which the first timestamp is greater than the target timestamp to the client sending the downloading request. Such as: the target time stamp is 2, there is no GOP with time stamp 2 in the target server, the first time stamp larger than the target time stamp 2 in the target server is 3, then the target server will send the video data of GOP with time stamp 3 to the client sending the download request.
In step S212, the video data transmitted by the target server is received.
In step S213, the received video data is stored to the buffer.
In step S214, a code rate corresponding to the video data is identified in the cache; after the player plays the video data downloaded at the previous code rate in the cache, the player can send the decoding information of the video data to the decoder corresponding to the player for decoding according to the code rate corresponding to the video data. The player plays the decoded video data.
In step S215, the FLV video of the current bitrate is continuously downloaded.
Specifically, after the received video data is stored into the video data downloaded at the previous bitrate in the buffer queue according to TAG (frame) as a unit, the corresponding bitrate of the video data is identified in the buffer, that is, index (index) identifying the video data in the buffer is changed, and after the player finishes playing the video data downloaded at the previous bitrate in the buffer queue, the change of the bitrate corresponding to the video data can be known according to the identification in the buffer, so that metadata (metadata) of a new stream, that is, information of height and width of the new stream and the like is notified to the decoder before decoding the new stream data, so as to ensure that the decoder can work normally, and realize seamless switching.
According to the technical scheme provided by the embodiment of the disclosure, in the process of playing the FLV video, the code rate is adaptively switched according to the network environment of the user. Due to the technical scheme provided by the embodiment of the disclosure, the high-definition video can be played when the network environment is good according to the self-adaptive switching of the definition of the played video of the current network environment of the user in the video playing process, and the playing definition of the video is automatically switched from the higher definition to the definition adaptive to the current network environment when the network environment is poor, so that the watching continuity of the user is ensured, and the occurrence of blocking is effectively avoided.
Fig. 3 is a block diagram illustrating a rate switching apparatus for FLV video according to an exemplary embodiment. Referring to fig. 3, the apparatus includes a download speed acquisition unit 301, a determination unit 302, a judgment unit 303, and a switching unit 304.
A download speed obtaining unit 301 configured to perform obtaining a current download speed of the FLV video downloaded by the current network;
a determining unit 302, configured to determine a target code rate from a plurality of preset code rates according to a current downloading speed;
a determining unit 303, configured to perform determining whether code rate switching is required according to whether the target code rate is the same as the current code rate of the FLV video;
the switching unit 304 is configured to execute, when code rate switching is required, after downloading a current GOP of a current code rate, terminating downloading of the FLV video of the current code rate, and switching the current code rate to a target code rate.
In a specific embodiment, the determining unit 302 may be specifically configured to perform:
and determining the code rate which is smaller than the current downloading speed and has the minimum difference with the current downloading speed as the target code rate.
In a specific embodiment, the determining unit 303 is specifically configured to perform:
judging whether the target code rate is the same as the code rate value of the current code rate of the FLV video or not;
if the target code rate is different from the code rate value of the current code rate of the FLV video, judging whether the currently cached data to be played meets a preset switching condition; if the current cached data to be played meets the preset switching condition, code rate switching is required;
and if the target code rate is the same as the current code rate of the FLV video, code rate switching is not needed.
In a specific embodiment, the preset switching condition may be:
when the code rate value of the current code rate is lower than the code rate value of the target code rate, requiring that the playing time of the cached data to be played is greater than or equal to a preset first caching time, wherein the first caching time is greater than the time of a GOP;
and when the code rate value of the current code rate is higher than the code rate value of the target code rate, requiring that the playing time of the cached data to be played is shorter than a preset second caching time, wherein the second caching time is longer than or equal to the time of a GOP and shorter than the first caching time.
Fig. 4 is a block diagram illustrating another apparatus for rate switching of FLV video according to an exemplary embodiment. Referring to fig. 4, the apparatus may further include: a profile acquisition unit 401.
The configuration file acquiring unit 401 is configured to execute acquiring a configuration file of an FLV video currently downloaded through a network; the configuration file comprises: and code rate values corresponding to each preset code rate in a plurality of code rates and the corresponding relation between the code rate values and the address of the server of the FLV video with the stored code rates.
In a specific embodiment, the switching unit 304 may be specifically configured to perform:
acquiring the address of a target server of the FLV video with the target code rate from the configuration file;
acquiring a target time stamp corresponding to the next GOP after the current GOP is finished;
sending a video data downloading request of a GOP corresponding to the acquired target timestamp to a target server according to the acquired target timestamp; the video data downloading request comprises a code rate value of a target code rate and a target timestamp;
receiving video data sent by a target server, wherein the video data is video data of an FLV video downloaded by a current network and the time stamp of the FLV video is the target time stamp in the target code rate;
and storing the received video data to a cache.
With regard to the apparatus in the above-described embodiment, the specific manner in which each unit performs the operation has been described in detail in the embodiment related to the method, and will not be described in detail here.
The device provided by the embodiment of the disclosure realizes the self-adaptive code rate switching according to the network environment of the user in the FLV video playing process. Due to the adoption of the device provided by the embodiment of the disclosure, the high-definition video can be played when the network environment is good according to the self-adaptive switching of the definition of the video of the current network environment of the user in the video playing process, and the playing definition of the video is automatically switched from the higher definition to the definition adaptive to the current network environment when the network environment is poor, so that the watching continuity of the user is ensured, and the occurrence of blocking is effectively avoided.
FIG. 5 is a block diagram illustrating an electronic device in accordance with an example embodiment. Referring to fig. 5, the electronic device may include:
a processor 501, a communication interface 502, a memory 503 and a communication bus 504, wherein the processor 501, the communication interface 502 and the memory 503 are communicated with each other through the communication bus 504,
a memory 503 for storing a computer program;
the processor 501, when executing the program stored in the memory 503, implements the following steps:
acquiring the current downloading speed of the FLV video downloaded by the current network;
determining a target code rate from a plurality of preset code rates according to the current downloading speed;
judging whether code rate switching is needed or not according to whether the target code rate is the same as the current code rate of the FLV video;
if the code rate switching is needed, after the current GOP of the current code rate is downloaded, the downloading of the FLV video of the current code rate is stopped, and the current code rate is switched to the target code rate.
The electronic device provided by the embodiment of the disclosure realizes adaptive code rate switching according to the network environment of the user in the FLV video playing process. Due to the electronic equipment provided by the embodiment of the disclosure, in the process of video playing, according to the definition of the self-adaptive switching playing video of the current network environment of the user, the high-definition video can be played when the network environment is good, and the playing definition of the video is automatically switched from the higher definition to the definition adaptive to the current network environment when the network environment is poor, so that the watching continuity of the user is ensured, and the occurrence of blocking is effectively avoided.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components.
In another embodiment provided by the present disclosure, a computer-readable storage medium is further provided, in which a computer program is stored, and the computer program, when executed by a processor, implements the steps of any of the above methods for rate switching of FLV videos.
In another embodiment provided by the present disclosure, there is also provided a computer program product containing instructions, which when run on a computer, causes the computer to execute any one of the above methods for rate switching of FLV video.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (10)

1. A method for switching code rate of an FLV video is applied to a client, and comprises the following steps:
acquiring the current downloading speed of the FLV video downloaded by the current network;
determining a target code rate from a plurality of preset code rates according to the current downloading speed;
judging whether the target code rate is the same as the code rate value of the current code rate of the FLV video or not;
if the target code rate is different from the code rate value of the current code rate of the FLV video, judging whether the currently cached data to be played meets a preset switching condition; the preset switching conditions are as follows: when the code rate value of the current code rate is lower than the code rate value of the target code rate, requiring that the playing time of the cached data to be played is greater than or equal to a preset first caching time, wherein the first caching time is greater than the time of a GOP; when the code rate value of the current code rate is higher than the code rate value of the target code rate, requiring that the playing time of the cached data to be played is shorter than a preset second caching time, wherein the second caching time is longer than or equal to the time of a GOP and shorter than the first caching time; the playing time of the cached data to be played is obtained by calculation according to the data volume of the cached data to be played and the current code rate;
if the current cached data to be played meets the preset switching condition, code rate switching is required;
if the target code rate is the same as the current code rate of the FLV video, code rate switching is not needed;
if the code rate switching is needed, after downloading the current GOP of the current code rate, the downloading of the FLV video of the current code rate is stopped, and the current code rate is switched to the target code rate.
2. The method for switching the bitrate of the FLV video according to claim 1, wherein the step of determining a target bitrate from a plurality of preset bitrates according to the current download speed comprises:
and determining the code rate which is smaller than the current downloading speed and has the minimum difference with the current downloading speed as a target code rate.
3. The method for switching bitrate of an FLV video according to claim 1, wherein before the step of obtaining the current downloading speed of the FLV video downloaded by the current network, the method further comprises:
acquiring a configuration file of an FLV video downloaded by a current network; the configuration file comprises: and the code rate value corresponding to each preset code rate in the plurality of code rates and the corresponding relation between the code rate value and the address of the server of the FLV video in which the code rate is stored.
4. The method for switching bitrate of an FLV video according to claim 3, wherein the step of switching the current bitrate to the target bitrate comprises:
acquiring the address of a target server of the FLV video with the target code rate from the configuration file;
acquiring a target time stamp corresponding to the next GOP after the current GOP is finished;
sending a video data downloading request for obtaining a GOP corresponding to the target timestamp to the target server according to the obtained target timestamp, wherein the video data downloading request comprises a code rate value of the target code rate and the target timestamp;
receiving the video data sent by the target server, wherein the video data is video data of an FLV (flash video) downloaded by a current network and with a timestamp of the target timestamp in the target code rate;
and storing the received video data to a cache.
5. An apparatus for switching bitrate of an FLV video, comprising:
the downloading speed acquiring unit is configured to execute acquiring the current downloading speed of the FLV video downloaded by the current network;
the determining unit is configured to determine a target code rate from a plurality of preset code rates according to the current downloading speed;
a determination unit configured to perform: judging whether the target code rate is the same as the code rate value of the current code rate of the FLV video or not; if the target code rate is different from the code rate value of the current code rate of the FLV video, judging whether the currently cached data to be played meets a preset switching condition; if the current cached data to be played meets the preset switching condition, code rate switching is required; if the target code rate is the same as the current code rate of the FLV video, code rate switching is not needed; the preset switching conditions are as follows: when the code rate value of the current code rate is lower than the code rate value of the target code rate, requiring that the playing time of the cached data to be played is greater than or equal to a preset first caching time, wherein the first caching time is greater than the time of a GOP; when the code rate value of the current code rate is higher than the code rate value of the target code rate, requiring that the playing time of the cached data to be played is shorter than a preset second caching time, wherein the second caching time is longer than or equal to the time of a GOP and shorter than the first caching time; the playing time of the cached data to be played is obtained by calculation according to the data volume of the cached data to be played and the current code rate;
and the switching unit is configured to execute, when code rate switching is required, after downloading the current GOP of the current code rate, terminate downloading of the FLV video of the current code rate, and switch the current code rate to the target code rate.
6. The apparatus for switching bitrate of FLV video according to claim 5, wherein the determining unit is configured to perform:
and determining the code rate which is smaller than the current downloading speed and has the minimum difference with the current downloading speed as a target code rate.
7. The apparatus for switching bitrate of an FLV video according to claim 6, further comprising:
the configuration file acquisition unit is configured to execute the acquisition of the configuration file of the FLV video downloaded by the current network; the configuration file comprises: and the code rate value corresponding to each preset code rate in the plurality of code rates and the corresponding relation between the code rate value and the address of the server of the FLV video in which the code rate is stored.
8. The apparatus for switching bitrate of FLV video according to claim 7, wherein the switching unit is configured to perform:
acquiring the address of a target server of the FLV video with the target code rate from the configuration file;
acquiring a target time stamp corresponding to the next GOP after the current GOP is finished;
sending a video data downloading request for acquiring a GOP corresponding to the target timestamp to the target server according to the acquired target timestamp; the video data downloading request comprises a code rate value of the target code rate and the target timestamp;
receiving the video data sent by the target server, wherein the video data is video data of an FLV (flash video) downloaded by a current network and with a timestamp of the target timestamp in the target code rate;
and storing the received video data to a cache.
9. An electronic device, comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the rate switching method of the FLV video according to any one of claims 1 to 4.
10. A storage medium in which instructions, when executed by a processor of an electronic device, enable the electronic device to perform the bitrate switching method of FLV video according to any one of claims 1 to 4.
CN201910631959.8A 2019-07-12 2019-07-12 Code rate switching method and device for FLV (flash video), electronic equipment and storage medium Active CN110267100B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910631959.8A CN110267100B (en) 2019-07-12 2019-07-12 Code rate switching method and device for FLV (flash video), electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910631959.8A CN110267100B (en) 2019-07-12 2019-07-12 Code rate switching method and device for FLV (flash video), electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN110267100A CN110267100A (en) 2019-09-20
CN110267100B true CN110267100B (en) 2022-01-25

Family

ID=67926063

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910631959.8A Active CN110267100B (en) 2019-07-12 2019-07-12 Code rate switching method and device for FLV (flash video), electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110267100B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111726642B (en) * 2019-03-19 2023-05-30 北京京东尚科信息技术有限公司 Live broadcast method, apparatus and computer readable storage medium
CN110913245A (en) * 2019-11-08 2020-03-24 网宿科技股份有限公司 Method and device for controlling video transcoding code rate
CN113141524B (en) 2020-01-17 2023-09-29 北京达佳互联信息技术有限公司 Resource transmission method, device, terminal and storage medium
CN113141541B (en) * 2020-01-17 2022-06-10 北京达佳互联信息技术有限公司 Code rate switching method, device, equipment and storage medium
CN112019873A (en) * 2020-09-08 2020-12-01 北京金山云网络技术有限公司 Video code rate adjusting method and device and electronic equipment
CN113905257A (en) * 2021-09-29 2022-01-07 北京字节跳动网络技术有限公司 Video code rate switching method and device, electronic equipment and storage medium
CN113891155B (en) * 2021-09-29 2024-04-05 百果园技术(新加坡)有限公司 Video playing gear determining method, video playing method and related devices
CN115396731A (en) * 2022-08-10 2022-11-25 北京势也网络技术有限公司 Panoramic video playing method and device, electronic equipment and readable storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102957672A (en) * 2011-08-25 2013-03-06 中国电信股份有限公司 Method, client side and system for self-adaptive playing of FLV (flash video) media streams
CN105744342A (en) * 2016-01-28 2016-07-06 腾讯科技(深圳)有限公司 Data transmission method and device for mobile terminal
CN105898403A (en) * 2015-11-16 2016-08-24 乐视云计算有限公司 Online media service code stream self-adaptive method and system
CN107438202A (en) * 2016-05-26 2017-12-05 中兴通讯股份有限公司 A kind of method and device for realizing code check switching
CN108668146A (en) * 2017-03-27 2018-10-16 华为技术有限公司 A kind of method and apparatus of adjustment streaming media bit rate
CN109769125A (en) * 2018-12-06 2019-05-17 北京东方广视科技股份有限公司 Dynamic adjusting method, media server and the transcoding server of streaming media bit rate
CN109862403A (en) * 2019-02-19 2019-06-07 未来电视有限公司 Self-adaption code rate switching method, device, electronic equipment and storage medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060143678A1 (en) * 2004-12-10 2006-06-29 Microsoft Corporation System and process for controlling the coding bit rate of streaming media data employing a linear quadratic control technique and leaky bucket model
CN103002272A (en) * 2011-09-15 2013-03-27 上海聚力传媒技术有限公司 Method, device and equipment for switching code rate of audio and video information
CN103945245A (en) * 2014-04-16 2014-07-23 上海交通大学 DASH code rate conversion method and rapid video starting method
CN107135411B (en) * 2016-02-26 2020-04-24 掌赢信息科技(上海)有限公司 Method for adjusting video code rate and electronic equipment
CN107071529B (en) * 2017-03-29 2018-10-26 咪咕视讯科技有限公司 A kind of HLS video broadcasting methods, terminal and server
CN108063955B (en) * 2017-12-15 2020-02-11 重庆邮电大学 State machine based code rate switching method for dynamic self-adaptive video transmission

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102957672A (en) * 2011-08-25 2013-03-06 中国电信股份有限公司 Method, client side and system for self-adaptive playing of FLV (flash video) media streams
CN105898403A (en) * 2015-11-16 2016-08-24 乐视云计算有限公司 Online media service code stream self-adaptive method and system
CN105744342A (en) * 2016-01-28 2016-07-06 腾讯科技(深圳)有限公司 Data transmission method and device for mobile terminal
CN107438202A (en) * 2016-05-26 2017-12-05 中兴通讯股份有限公司 A kind of method and device for realizing code check switching
CN108668146A (en) * 2017-03-27 2018-10-16 华为技术有限公司 A kind of method and apparatus of adjustment streaming media bit rate
CN109769125A (en) * 2018-12-06 2019-05-17 北京东方广视科技股份有限公司 Dynamic adjusting method, media server and the transcoding server of streaming media bit rate
CN109862403A (en) * 2019-02-19 2019-06-07 未来电视有限公司 Self-adaption code rate switching method, device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN110267100A (en) 2019-09-20

Similar Documents

Publication Publication Date Title
CN110267100B (en) Code rate switching method and device for FLV (flash video), electronic equipment and storage medium
US10638169B2 (en) Codec techniquest for fast switching without a synchronization frame
AU2014223523B2 (en) Adaptive streaming techniques
CN110636346B (en) Code rate self-adaptive switching method and device, electronic equipment and storage medium
US20160073106A1 (en) Techniques for adaptive video streaming
US9571827B2 (en) Techniques for adaptive video streaming
US10542288B2 (en) Random access in a video bitstream
CN110198495B (en) Method, device, equipment and storage medium for downloading and playing video
US10491964B2 (en) Assisted acceleration for video streaming clients
US20180351868A1 (en) Multicast abr flow prioritization using error detection thresholds in the receiver
EP2993911A1 (en) Method and client terminal for receiving a multimedia content split into at least two successive segments, and corresponding computer program product and computer-readable medium
US11563990B2 (en) Method and apparatus for automatic HLS bitrate adaptation
US11563962B2 (en) Seamless content encoding and transmission
EP2963896A1 (en) Method for operating a cache arranged along a transmission path between client terminals and at least one server, and corresponding cache
CN114245196B (en) Screen recording and stream pushing method and device, electronic equipment and storage medium
CN110062003B (en) Video data transmitting method, video data transmitting device, electronic equipment and storage medium
US20230291913A1 (en) Methods, systems, and apparatuses for improved adaptation logic and content streaming
CN114745590A (en) Video frame encoding method, video frame encoding device, electronic device, and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant