CN117425034A - Video playing method and device, electronic equipment and computer readable storage medium - Google Patents

Video playing method and device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN117425034A
CN117425034A CN202311442913.4A CN202311442913A CN117425034A CN 117425034 A CN117425034 A CN 117425034A CN 202311442913 A CN202311442913 A CN 202311442913A CN 117425034 A CN117425034 A CN 117425034A
Authority
CN
China
Prior art keywords
video
capacity
storage space
data
video data
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.)
Pending
Application number
CN202311442913.4A
Other languages
Chinese (zh)
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.)
Shenzhen TCL New Technology Co Ltd
Original Assignee
Shenzhen TCL New 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 Shenzhen TCL New Technology Co Ltd filed Critical Shenzhen TCL New Technology Co Ltd
Priority to CN202311442913.4A priority Critical patent/CN117425034A/en
Publication of CN117425034A publication Critical patent/CN117425034A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/433Content storage operation, e.g. storage operation in response to a pause request, caching operations
    • 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/4335Housekeeping operations, e.g. prioritizing content for deletion because of storage space restrictions

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Television Signal Processing For Recording (AREA)

Abstract

The embodiment of the application discloses a video playing method, a video playing device, electronic equipment and a computer readable storage medium, wherein the method comprises the following steps: storing video data obtained after decoding the video file into a storage space, wherein the storage space is configured with an initial capacity, and the initial capacity is used for limiting the data amount of the video data stored in the storage space; reading video data from the storage space, and playing video according to the read video data; and according to the residual data amount of the video data in the storage space and the size relation of the initial capacity, adjusting the initial capacity to obtain a target capacity, and controlling the storage of the video data in the storage space according to the target capacity. Through optimizing the capacity of the storage space, the adjustment of the capacity of the storage space is tried continuously while smooth video playing is ensured, the utilization rate of the storage space can be improved, and the waste of resources is reduced.

Description

Video playing method and device, electronic equipment and computer readable storage medium
Technical Field
The embodiment of the application relates to the field of computers, in particular to a video playing method, a video playing device, electronic equipment and a computer readable storage medium.
Background
At present, the existing video playing technology is that a player decodes a video file, then stores the video file in a storage space, obtains decoded video data from the storage space, converts the decoded video data into image signals, transmits the image signals to a client, and renders the image signals to a canvas by the client.
The size of the storage space is a key for smooth video playing, and when the storage space is large enough, enough decoded video data can be stored, so that smooth generation of image signals can be ensured, and further, the fluency of the video is ensured.
However, the larger the storage space is, the better, and when the storage space is too large, the storage space cannot be fully utilized due to the influence of the speed of reading the decoded video data from the storage space, so that the utilization rate is low, and the resource waste is caused.
Disclosure of Invention
The embodiment of the application provides a video playing method, a video playing device, electronic equipment and a computer readable storage medium, which can optimize the storage space for storing decoded video data, improve the utilization rate of the storage space and reduce the resource waste.
The embodiment of the application provides a video playing method, which comprises the following steps:
storing video data obtained after decoding a video file into a storage space, wherein the storage space is configured with an initial capacity, and the initial capacity is used for limiting the data amount of the video data stored in the storage space;
Reading the video data from the storage space, and playing the video according to the read video data;
and according to the residual data amount of the video data in the storage space and the size relation of the initial capacity, adjusting the initial capacity to obtain a target capacity, and controlling the storage of the video data in the storage space according to the target capacity.
Correspondingly, the embodiment of the application also provides a video playing device, which comprises:
the storage module is used for storing video data obtained after decoding the video file into a storage space, wherein the storage space is configured with an initial capacity, and the initial capacity is used for limiting the data volume of the video data stored in the storage space;
the playing module is used for reading the video data from the storage space and playing the video according to the read video data;
and the control module is used for adjusting the initial capacity according to the relation between the residual data volume of the video data in the storage space and the initial capacity to obtain a target capacity, and controlling the storage of the video data in the storage space according to the target capacity.
Optionally, in some embodiments of the present application, the control module includes:
the first adjusting unit is used for adjusting the initial capacity according to a first preset adjusting amplitude to obtain a target capacity if the residual data amount of the video data in the storage space is larger than or equal to the initial capacity, wherein the initial capacity is larger than the target capacity;
and the second adjusting unit is used for adjusting the initial capacity according to a second preset adjusting amplitude to obtain a target capacity if the residual data amount of the video data in the storage space is smaller than or equal to a first reference capacity, wherein the initial capacity is smaller than the target capacity, the first reference capacity is calculated based on a first preset ratio and the initial capacity, and the first reference capacity is smaller than the initial capacity.
Wherein, in some embodiments of the present application, the first adjusting unit includes:
a calculating subunit, configured to calculate a target capacity corresponding to the initial capacity according to a first preset adjustment amplitude;
a control subunit configured to stop storing the video data into the storage space;
and the adjustment subunit is used for adjusting the initial capacity of the storage space to the target capacity when the residual data amount of the video data in the storage space is smaller than the target capacity.
Wherein, in some embodiments of the present application, the apparatus further comprises a re-control module, the re-control module comprising:
a calculating unit, configured to calculate a second reference capacity corresponding to the target capacity based on a second preset ratio, where the second reference capacity is smaller than the target capacity;
a third adjustment unit, configured to adjust the target capacity according to a third preset adjustment range to obtain a new target capacity if the remaining data amount of the video data in the storage space is less than or equal to the second reference capacity, where the target capacity is less than the new target capacity;
and the control unit is used for controlling the storage of the video data by the storage space based on the new target capacity.
In some embodiments of the present application, the storage space includes a data link table, and the storage module includes:
the first decoding unit is used for decoding the video file through at least two video decoding threads to obtain video data;
the first inserting unit is used for inserting the video data into the data link list according to the head node of the data link list;
the play module comprises:
and the first reading unit is used for reading the video data from the tail node of the data link list through a video playing thread.
Wherein, in some embodiments of the present application, the apparatus further comprises an encoding control module, the encoding control module comprising:
the first coding control unit is used for stopping the video decoding thread from decoding the video file if the data volume of the video data stored in the data linked list exceeds the initial capacity, and calculating a third reference capacity corresponding to the initial capacity based on a third preset ratio, wherein the third reference capacity is smaller than the initial capacity;
the second coding control unit is used for starting the video decoding thread to decode the video file if the data volume of the video data in the data linked list is smaller than the third reference capacity, so as to obtain video data;
and the storage unit is used for inserting the video data into the data link list.
In some embodiments of the present application, the storage space includes a data link table, and the storage module includes:
the second decoding unit is used for decoding the video file through at least two video decoding threads to obtain video data;
the second inserting unit is used for inserting the video data into the data link list according to the tail node of the data link list;
The play module comprises:
and the second reading unit is used for reading the video data through a video playing thread according to the head node of the data linked list.
In a third aspect, an embodiment of the present application further provides an electronic device, where the electronic device includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor, and the computer program when executed by the processor implements the steps in the video playing method described above.
In a fourth aspect, embodiments of the present application further provide a computer readable storage medium, where a computer program is stored, where the computer program when executed by a processor implements the steps in the video playing method described above.
According to the embodiment of the application, video data obtained after decoding the video file is stored in a storage space, the storage space is configured with an initial capacity, the initial capacity is used for limiting the data amount of the video data stored in the storage space, the video data are read from the storage space, video playing is carried out according to the read video data, the initial capacity is adjusted according to the residual data amount of the video data in the storage space and the relation between the residual data amount and the initial capacity, so that a target capacity is obtained, and the storage of the video data by the storage space is controlled according to the target capacity. The storage and the reading of the decoded data are both from the storage space, so that the residual data amount of the video data in the storage space reflects the decoding speed of the file and the reading speed of the data, namely, when the residual data amount exists or is higher, the decoding speed is higher than the reading speed, otherwise, when the residual data amount does not exist, the decoding speed is lower than the reading speed, and therefore, the initial capacity is adjusted according to the residual data amount, so that the adjusted storage space can meet the storage and reading requirements, and meanwhile, the capacity adjustment can be tried, the capacity of the storage space is optimized, and the utilization rate of the storage space is improved.
The relation between the residual data quantity and the initial capacity reflects the utilization condition of the storage space, if the residual data quantity is higher than the initial capacity, the reading speed is lower than the decoding speed, and the capacity of the storage space can be reduced, so that the capacity of the storage space can be properly reduced, and the utilization rate of the storage space can be improved; conversely, if the amount of remaining data is smaller, it indicates that the reading speed is higher, so in order to ensure smooth reading of the decoded video data, it may be attempted to increase the capacity of the storage space, so as to expect more decoded video data to be stored in the storage space.
In sum, according to the embodiment of the application, through optimizing the capacity of the storage space, the smooth playing of the video is ensured, and meanwhile, the adjustment of the capacity of the storage space is continuously tried, so that the utilization rate of the storage space can be improved, and the waste of resources is reduced.
Drawings
In order to more clearly illustrate the technical solutions of the present application, the drawings that are needed in the description of the embodiments will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic view of a video playing method according to an embodiment of the present application;
fig. 2 is a flow chart of a video playing method according to an embodiment of the present application;
fig. 3 is another flow chart of a video playing method according to an embodiment of the present application;
FIG. 4 is a schematic diagram of a change in storage space capacity according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of a video playing device according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to fall within the scope of the invention.
The embodiment of the application provides a video playing method, a video playing device, electronic equipment and a computer readable storage medium. Specifically, the embodiment of the application provides a video playing device suitable for electronic equipment, wherein the electronic equipment comprises terminal equipment, and the terminal equipment comprises, but is not limited to, desktop computers, notebook computers, tablet computers, mobile phones and other equipment.
Referring to fig. 1, fig. 1 is a schematic view of a scenario in which a terminal device performs the video playing method according to the embodiment of the present application, where a specific implementation procedure of the terminal device performing the video playing method is as follows:
after receiving the video file to be played, the terminal device 10 decodes the video file to obtain video data, and then stores the video data in a storage space, where the storage space is configured with an initial capacity, and the initial capacity is used to limit the data amount of the video data stored in the storage space.
Subsequently, the terminal device 10 reads video data from the storage space, and performs video playback based on the read video data.
When the storage space stores video data and video data to be read, the initial capacity is adjusted to obtain a target capacity based on the relation between the residual data amount of the video data in the storage space and the initial capacity, and the storage of the video data by the storage space is controlled according to the target capacity.
It should be noted that, the storage space is a storage space with adjustable storage capacity, and according to the relation between the residual data amount and the initial capacity of the video data in the storage space, the embodiment of the application adjusts the initial capacity of the storage space, so that the storage space can dynamically adjust the capacity based on the actual condition of the residual data amount in the storage space on the basis of satisfying the balance between storage and reading, thereby being beneficial to realizing the utilization rate of the storage space and reducing the resource waste.
The following will describe in detail. It should be noted that the following description order of embodiments is not a limitation of the priority order of embodiments.
Referring to fig. 2, fig. 2 is a flowchart of a video playing method according to an embodiment of the present application. The video playing method comprises the following specific processes:
101. and storing video data obtained after decoding the video file into a storage space, wherein the storage space is configured with an initial capacity, and the initial capacity is used for limiting the data volume of the video data stored in the storage space.
It may be understood that the video file is a file to be played, and the format may include AVI, MP4, etc., and the video file may be a file downloaded from a web page, or a file obtained by receiving transmission from another terminal, or may be a video file obtained by shooting with a camera.
The storage space is a space for temporarily storing decoded video data in a video playing process, the initial capacity is a capacity configured for the storage space, and the capacity of the storage space can be dynamically adjusted, that is, in a video playing process, the capacity can be adjusted, and further, the storage control of the video data is performed based on the adjusted capacity, for example, the size of the initial capacity is adjusted, so that the control of the data amount which can be stored in the storage space is realized, wherein the storage space comprises, but is not limited to, a storage space formed by a data link list.
In this embodiment of the present application, the frame number of the video file that can be stored is used as the capacity of the storage space, for example, the initial capacity is determined based on the frame rate of the video that is played, for example, if the frame rate is 30 frames/second, the initial capacity may be determined to be 30 frames.
It can be understood that the video file is generally played by first decoding, then storing the decoded video data in a storage space, then reading the decoded video data from the storage space, converting the image data, and finally rendering the image data into a canvas to form the video playing on the terminal interface. The size of the storage space influences smooth playing of the video, when the storage space is large enough, more decoded video data can be stored in the storage space, and accordingly, video data can be read continuously from the storage space and then rendered continuously.
However, when the storage space is too large, the storage space cannot be fully utilized due to the limitation of the reading speed, so that the utilization rate is low and resources are wasted. Therefore, in order to promote the utilization ratio of the storage space while the video is smoothly played, the embodiment of the application configures the storage space with dynamically adjustable capacity for the storage space with fixed capacity, and tries to find the smaller capacity value when the video is smoothly played through the dynamic adjustment of the capacity of the storage space so as to promote the utilization ratio of the storage space.
102. And reading the video data from the storage space, and playing the video according to the read video data.
By reading the decoded video data from the storage space, video playing can be performed based on the video data, for example, the video data is read, the video data is subjected to image data conversion, then the image data is rendered on a canvas to form image display on a screen, and a plurality of corresponding video data are rendered for a plurality of times, so that a smoothly played video is obtained.
103. And according to the residual data amount of the video data in the storage space and the size relation of the initial capacity, adjusting the initial capacity to obtain a target capacity, and controlling the storage of the video data in the storage space according to the target capacity.
The storage and the reading of the decoded data are both from the storage space, so that the residual data amount of the video data in the storage space reflects the decoding speed of the file and the reading speed of the data, namely, when the residual data amount exists or is higher, the decoding speed is higher than the reading speed, otherwise, when the residual data amount does not exist, the decoding speed is lower than the reading speed, and therefore, the initial capacity is adjusted according to the residual data amount, so that the adjusted storage space can meet the storage and reading requirements, and meanwhile, the capacity adjustment can be tried, the capacity of the storage space is optimized, and the utilization rate of the storage space is improved.
The relation between the residual data quantity and the initial capacity reflects the utilization condition of the storage space, if the residual data quantity is higher than the initial capacity, the reading speed is slower than the decoding speed, and the capacity of the storage space can be reduced, so that the capacity of the storage space can be properly reduced, and the utilization rate of the storage space can be improved; conversely, if the amount of remaining data is smaller, it indicates that the reading speed is higher, so in order to ensure smooth reading of the decoded video data, it may be attempted to increase the capacity of the storage space, so as to expect more decoded video data to be stored in the storage space.
For example, the decoding speed is affected by environmental factors such as network and hardware, so that the decoding speed has fluctuation, if the data amount of the video data stored in the storage space is smaller, the capacity of the storage space can be tried to be enlarged, so that the video data with more data amount can be stored as much as possible when the environmental factors affect less, the defect that the readable video data is lack in the storage space due to the influence of the environmental factors is overcome, and further smooth playing of the video is ensured.
In sum, according to the embodiment of the application, through optimizing the capacity of the storage space, the smooth playing of the video is ensured, and meanwhile, the adjustment of the capacity of the storage space is continuously tried, so that the utilization rate of the storage space can be improved, and the waste of resources is reduced.
Optionally, in the embodiment of the present application, in order to improve accuracy of capacity adjustment, whether to perform adjustment on an initial capacity may be determined according to whether an amount of data in a storage space exceeds an initial capacity, that is, optionally, in some embodiments of the present application, the step of "adjusting, according to a remaining amount of data of the video data in the storage space and a size relationship between the initial capacity, the initial capacity to obtain a target capacity" includes:
if the residual data amount of the video data in the storage space is larger than or equal to the initial capacity, the initial capacity is adjusted according to a first preset adjustment range to obtain a target capacity, wherein the initial capacity is larger than the target capacity;
and if the residual data amount of the video data in the storage space is smaller than or equal to a first reference capacity, adjusting the initial capacity according to a second preset adjustment range to obtain a target capacity, wherein the initial capacity is smaller than the target capacity, the first reference capacity is calculated based on a first preset ratio and the initial capacity, and the first reference capacity is smaller than the initial capacity.
The data amount in the storage space exceeds the initial capacity, which means that the video data reading speed is relatively slow, so that more video data can be retained in the storage space, and therefore, in order to improve the utilization rate of the storage space and reduce the resource waste, an attempt can be made to reduce the initial capacity of the storage space.
On the contrary, if the amount of data in the storage space is smaller, it indicates that the reading speed of the video data is close to the storing speed, so that in order to avoid the fluctuation of the decoding speed caused by the influence of environmental factors and ensure smooth playing of the video, the initial capacity of the storage space is increased, so that more video data can be expected to be stored when the decoding speed is higher, and the reading requirement of the video data is ensured.
The first reference capacity is calculated to be smaller than the initial capacity, so as to realize that the first reference capacity is used as a judging standard of whether the data amount in the storage space is smaller or not, correspondingly, the value of the first reference capacity can be adjusted based on actual requirements, namely, the value of the first reference capacity is adjusted by adjusting a first preset ratio, the specific value of the first preset ratio is not limited, for example, the first preset ratio can be 1/2, and correspondingly, if the initial capacity is 30 frames, the first reference capacity is 15 frames.
The first preset adjustment amplitude and the second preset adjustment amplitude are the amplitude of capacity adjustment, which may be the same or different, where in this embodiment of the present application, the adjustment amplitude may be in a ratio or a proportional form, for example, the initial capacity is adjusted to be 1/2 or 3/4 of the original capacity, for example, the first preset adjustment amplitude may be 3/4, the initial capacity is 30 frames, and the target capacity obtained after the initial capacity is adjusted based on the first preset adjustment amplitude is 23 (22.5 is obtained by rounding and rounding) frames; for another example, if the second preset adjustment amplitude is 2 and the initial capacity is 30 frames, the target capacity obtained after the initial capacity is adjusted based on the second preset adjustment amplitude is 60 frames.
Optionally, in order to ensure accuracy of video data in the storage space, and avoid that the adjustment capacity causes loss of video data, the capacity of the storage space may be adjusted when the amount of data in the storage space is small, that is, optionally, in some embodiments of the present application, the step of "adjusting the initial capacity according to the first preset adjustment amplitude to obtain the target capacity" includes:
calculating a target capacity corresponding to the initial capacity according to a first preset adjustment amplitude;
Stopping storing the video data into the storage space;
and when the residual data amount of the video data in the storage space is smaller than the target capacity, adjusting the initial capacity of the storage space to the target capacity.
When the data amount of the video data in the storage space is large, if the storage space is directly reduced, part of the data in the storage space is lost, so that the adjusted target capacity can be calculated first, and when the data amount of the video data stored in the storage space is smaller than the target capacity, the initial capacity is updated.
Wherein, since the initial capacity is used for limiting the data amount of the stored video data in the storage space, when the data amount remained in the storage space after storage and reading reaches the target capacity, the storage of the video data in the storage space can be stopped, for example, a decoding thread of the video file is suspended, the decoding of the video file is stopped, and the data amount of the video data stored in the storage space is reduced through reading of the video file.
For example, when the data amount of video data in the storage space reaches 30 frames of initial capacity, the decoding thread of the video file is suspended, only the reading thread is kept awake, the video data is read from the storage space by the reading thread until 23 frames of target capacity are reached, and after the initial capacity of the storage space reaches 30 frames, the initial capacity of the storage space is adjusted to 23 frames. In order to avoid the influence of other factors such as untimely suspension of the decoding thread or interruption of the reading thread, the embodiment of the application can adjust the initial capacity from 30 frames to 23 frames with the target capacity after the number of video data in the storage space reaches half (15 frames) of the initial capacity.
Optionally, in the embodiment of the present application, the adjustment of the capacity of the storage space is a cyclic process, after the first adjustment to obtain the target capacity, the adjustment of the target capacity may be further performed according to the comparison between the data amount of the video data in the storage space and the target capacity, so as to obtain a new target capacity, so as to realize dynamic adjustment of the capacity of the storage space in the storage process of the video data, that is, optionally, in some embodiments of the present application, after the step of "controlling the storage of the video data by the storage space according to the target capacity", the method further includes:
calculating a second reference capacity corresponding to the target capacity based on a second preset ratio, wherein the second reference capacity is smaller than the target capacity;
if the residual data amount of the video data in the storage space is smaller than or equal to the second reference capacity, the target capacity is adjusted according to a third preset adjustment range to obtain a new target capacity, wherein the target capacity is smaller than the new target capacity;
and controlling the storage of the video data by the storage space based on the new target capacity.
The method comprises the steps of adjusting the adjusted target capacity again to ensure that the storage space has enough available space, avoiding the problem of video playing and blocking caused by small adjustment, for example, when the data volume of video data in the storage space is adjusted to be smaller than the target capacity due to exceeding the initial capacity, if the data volume of the video data in the storage space is detected to be smaller than the target capacity, indicating that the video data in the storage space has risk of being not read, namely blocking of video playing can be caused, and therefore, the storage space can be enlarged to expect to quickly decode a certain amount of video data under good hardware or network environment, so as to meet the requirement of video data reading.
The second preset ratio is selected in the same manner as the first preset ratio, so that the explanation and the example of the first preset ratio can be referred to for understanding, and the description is omitted herein.
Accordingly, for capacity adjustment, a corresponding adjustment condition may be generated according to a relationship between the data amount of video data in the storage space and the capacity before adjustment, and the capacity adjustment operation is indicated based on the adjustment condition, for example, the data amount of video data in the storage space reaches the initial capacity as a first condition, the data amount of video data in the storage space is less than half of the initial capacity as a second condition, the data amount of video data in the storage space is less than half of the target capacity (capacity after adjustment based on the initial capacity) as a third condition, after the first condition and the second condition are met, the adjustment of the initial capacity is triggered to obtain the target capacity, and after the second condition and the third condition are met, the adjustment of the target capacity is triggered to obtain the new target capacity.
Optionally, in this embodiment of the present application, the storage space may be a storage space provided by a data link table, that is, video data obtained after decoding a video file is stored in the data link table, and storage control of the video data is implemented by using a feature of adjustable capacity of the data link table, so as to solve a problem of low utilization rate of the storage space, that is, optionally, in some embodiments of the present application, the storage space includes the data link table, and the step of storing the video data obtained after decoding the video file into the storage space includes:
Decoding the video file through at least two video decoding threads to obtain video data;
inserting the video data into the data link list according to the head node of the data link list;
the reading the video data from the storage space includes:
and reading the video data from the tail node of the data link list through a video playing thread.
The video file is decoded by a plurality of video decoding threads, so that the problem that a single video decoding thread cannot meet the video playing requirements of high resolution and high frame rate during decoding is solved.
The linked list (linked list) is a non-continuous and non-sequential storage structure on a physical storage unit, and the logical sequence of data elements is implemented by a pointer linking sequence in the linked list, for example, the data linked list includes joints, the nodes include data fields and pointer fields, a pointing relationship between the nodes is established through the pointer fields, and the order of the nodes is maintained, so that the video data stored in each data field can be read once through the pointers.
When video data is inserted into the data link list, new video data can be inserted into the node obtained after the node is inserted based on the position of the node, namely, a new node is inserted, the node is kept to be positioned behind the node, and the pointer of the node points to the new node.
When the video data is inserted based on the head of the data link table, the video data may be read based on the tail of the data link table, for example, the video data may be read from the tail node of the data link table.
It will be appreciated that when it is desired to stop inserting decoded video data into the data link list, the video decoding thread may be suspended, the decoding of the video file may be suspended, i.e. the generation of decoded video data is stopped, and correspondingly, when the insertion of video data into the data link list is started, the decoding thread may be woken up, the video file may be decoded by the decoding thread, and the decoded video data may be inserted into the data link list,
the step of waking up the video decoding thread may be determined based on the data amount of the video data stored in the data link table, for example, when the data amount reaches half of the initial capacity, that is, optionally, in some embodiments of the present application, the step of inserting the video data into the data link table according to the head node of the data link table includes:
if the data amount of the video data stored in the data linked list exceeds the initial capacity, stopping decoding the video file by the video decoding thread, and calculating a third reference capacity corresponding to the initial capacity based on a third preset ratio, wherein the third reference capacity is smaller than the initial capacity;
If the data amount of the video data in the data linked list is smaller than the third reference capacity, starting the video decoding thread to decode the video file to obtain the video data;
and inserting the video data into the data link list.
When the data quantity exceeds the initial capacity, the control of the data quantity stored in the data link list is realized, and when the video decoding thread is suspended, the data quantity in the data link list is continuously reduced along with the reading processing of the video reading thread, so when the third reference capacity is reached, the video decoding thread can be awakened again, and the control of the data quantity of the video data stored in the data link list is performed.
The third preset ratio is similar to the first preset ratio and the second preset ratio, and can be understood with reference to descriptions of the first preset ratio and the second preset ratio, for example, the third preset ratio may be 1/2, that is, when the data amount of the video data in the data link table is less than half of the initial capacity,
optionally, in the embodiment of the present application, the inserting of the video data may also be performed based on the tail portion of the data link table, and then the reading of the video data may be performed according to the head portion of the data link table, that is, optionally, in some embodiments of the present application, the step of storing the video data obtained after decoding the video file into the storage space includes:
Decoding the video file through at least two video decoding threads to obtain video data;
inserting the video data into the data link list according to the tail node of the data link list;
the reading the video data from the storage space includes:
and reading the video data according to the head node of the data linked list through a video playing thread.
The method for inserting video data from the tail node of the data link table is the same as the method for inserting data from the head node of the data link table, and correspondingly, the method can read data according to the head node of the data link table based on the condition that the video data is inserted by the tail node.
In sum, according to the embodiment of the application, the capacity of the data link table is adjusted according to the comparison result of the data quantity stored in the data link table and the capacity of the data link table, the storage of the data link table is controlled based on the adjusted capacity, dynamic adjustment of the capacity according to actual storage conditions is facilitated, and the utilization rate of the data link table is improved while smooth video playing is guaranteed.
When the capacity adjustment is judged to be needed, the data quantity is waited to be reduced to half of the capacity of the linked list and then adjusted, so that the loss of the data in the linked list can be avoided, and the integrity of the video data is protected.
The method comprises the steps of adjusting the capacity of the linked list by continuously comparing the residual data quantity with the capacity in the linked list after adjustment, and realizing that the capacity of the linked list can be reduced as much as possible and the utilization rate of the storage space of the linked list can be improved while the smooth playing of video is met by means of dynamic adjustment.
The video file is decoded through a plurality of video decoding threads, so that smooth playing of the video with high resolution and high frame rate is realized.
Since the capacity of the storage space is a dynamic adjustment process, the video data is stored in a data link table, and the dynamic process of capacity adjustment is embodied in a cyclic manner, specifically, referring to fig. 3, fig. 3 is another flow chart of the video playing method provided in the embodiment of the present application, specifically:
121. determining a data link list for storing video data;
122. initializing the capacity of the data link list to obtain initial capacity;
123. starting a video decoding thread and a video reading thread, decoding a video file through the video decoding thread to obtain video data, storing the video data into a data linked list, reading the video data from the data linked list through the video reading thread, and playing the video based on the read video data;
In order to meet the video playing requirements of high resolution and high frame rate, a plurality of video decoding threads are adopted to decode the video file in the embodiment of the application.
After the video data are read, the video data are converted into image data, and then the image data are rendered on a canvas to finish the playing of the video.
124. Judging whether the data amount of the video data stored in the data linked list exceeds the initial capacity, if so, executing step 125, otherwise, returning to execute step 123;
125. suspending the video decoding thread;
after the video decoding thread is suspended, the video reading thread still continues to read the video data in the data link list, so that the data amount of the video data in the data link list starts to decrease.
126. Judging whether the data amount of the video data in the data link list is less than half of the initial capacity, if so, executing step 127;
127. waking up a video decoding thread, and adjusting the initial capacity to be three quarters of the original capacity to obtain a target capacity;
and controlling the storage of the video data in the data link list according to the target capacity.
128. Judging whether the data amount of the video data in the data link list is less than half of the target capacity, if so, executing step 129;
129. The target capacity is adjusted to be twice of the original target capacity, a new target capacity is obtained, and the step 123 is executed again until the decoding of the video file is completed;
wherein the storing of video data in the data link list is controlled based on the new target capacity.
In summary, the embodiment of the application continuously compares the data volume of the video data stored in the data linked list with the capacity of the data linked list, continuously adjusts the capacity of the data linked list according to the comparison result, and achieves the scheme of continuously and dynamically optimizing the capacity in the video playing process, so that the capacity of the data linked list can be reduced as much as possible while smooth video playing is ensured, the utilization rate of the data linked list is improved, and resource waves are reduced.
For example, as shown in fig. 4, fig. 4 is a schematic diagram of a change in storage space capacity provided in an embodiment of the present application, where a curve a is a capacity change curve in a capacity-fixed design in the related art, and a curve B is a capacity change curve in a dynamic adjustment in an embodiment of the present application, as can be seen from fig. 4, in the embodiment of the present application, the capacity of the storage space of video data is continuously adjusted, and based on the adjustment result, the capacity of the storage space is always smaller than the capacity in the capacity-fixed design in the playing process of the video, and the smaller storage capacity has a higher utilization rate, so that the waste of resources can be reduced.
In order to facilitate better implementation of the video playing method, the application also provides a video playing device based on the video playing method. The meaning of the nouns is the same as that in the video playing method, and specific implementation details can be referred to the description in the method embodiment.
Referring to fig. 5, fig. 5 is a schematic structural diagram of a video playing device according to an embodiment of the present application, where the video playing device may specifically be as follows:
a storage module 301, configured to store video data obtained after decoding a video file into a storage space, where the storage space is configured with an initial capacity, where the initial capacity is used to limit a data amount of the video data stored in the storage space;
a playing module 302, configured to read the video data from the storage space, and play video according to the read video data;
and the control module 303 is configured to adjust the initial capacity according to a relationship between the remaining data amount of the video data in the storage space and the initial capacity to obtain a target capacity, and control storage of the video data in the storage space according to the target capacity.
Optionally, in some embodiments of the present application, the control module 303 includes:
The first adjusting unit is used for adjusting the initial capacity according to a first preset adjusting amplitude to obtain a target capacity if the residual data amount of the video data in the storage space is larger than or equal to the initial capacity, wherein the initial capacity is larger than the target capacity;
and the second adjusting unit is used for adjusting the initial capacity according to a second preset adjusting amplitude to obtain a target capacity if the residual data amount of the video data in the storage space is smaller than or equal to a first reference capacity, wherein the initial capacity is smaller than the target capacity, the first reference capacity is calculated based on a first preset ratio and the initial capacity, and the first reference capacity is smaller than the initial capacity.
Wherein, in some embodiments of the present application, the first adjusting unit includes:
a calculating subunit, configured to calculate a target capacity corresponding to the initial capacity according to a first preset adjustment amplitude;
a control subunit configured to stop storing the video data into the storage space;
and the adjustment subunit is used for adjusting the initial capacity of the storage space to the target capacity when the residual data amount of the video data in the storage space is smaller than the target capacity.
Wherein, in some embodiments of the present application, the apparatus further comprises a re-control module, the re-control module comprising:
a calculating unit, configured to calculate a second reference capacity corresponding to the target capacity based on a second preset ratio, where the second reference capacity is smaller than the target capacity;
a third adjustment unit, configured to adjust the target capacity according to a third preset adjustment range to obtain a new target capacity if the remaining data amount of the video data in the storage space is less than or equal to the second reference capacity, where the target capacity is less than the new target capacity;
and the control unit is used for controlling the storage of the video data by the storage space based on the new target capacity.
Wherein, in some embodiments of the present application, the storage space includes a data linked list, and the storage module 301 includes:
the first decoding unit is used for decoding the video file through at least two video decoding threads to obtain video data;
the first inserting unit is used for inserting the video data into the data link list according to the head node of the data link list;
the play module 302 includes:
and the first reading unit is used for reading the video data from the tail node of the data link list through a video playing thread.
Wherein, in some embodiments of the present application, the apparatus further comprises an encoding control module, the encoding control module comprising:
the first coding control unit is used for stopping the video decoding thread from decoding the video file if the data volume of the video data stored in the data linked list exceeds the initial capacity, and calculating a third reference capacity corresponding to the initial capacity based on a third preset ratio, wherein the third reference capacity is smaller than the initial capacity;
the second coding control unit is used for starting the video decoding thread to decode the video file if the data volume of the video data in the data linked list is smaller than the third reference capacity, so as to obtain video data;
and the storage unit is used for inserting the video data into the data link list.
Wherein, in some embodiments of the present application, the storage space includes a data linked list, and the storage module 301 includes:
the second decoding unit is used for decoding the video file through at least two video decoding threads to obtain video data;
the second inserting unit is used for inserting the video data into the data link list according to the tail node of the data link list;
The play module 302 includes:
and the second reading unit is used for reading the video data through a video playing thread according to the head node of the data linked list.
In this embodiment, the storage module 301 stores video data obtained after decoding a video file into a storage space, where the storage space is configured with an initial capacity, where the initial capacity is used to limit a data amount of the video data stored in the storage space, then the playing module 302 reads the video data from the storage space and plays the video according to the read video data, and meanwhile, the control module 303 adjusts the initial capacity according to a relationship between a remaining data amount of the video data in the storage space and the initial capacity to obtain a target capacity, and controls the storage of the video data in the storage space according to the target capacity.
According to the embodiment of the application, through optimizing the capacity of the storage space, the smooth playing of the video is ensured, and meanwhile, the adjustment of the capacity of the storage space is continuously tried, so that the utilization rate of the storage space can be improved, and the waste of resources is reduced.
In addition, the present application further provides an electronic device, as shown in fig. 6, which shows a schematic structural diagram of the electronic device according to the present application, specifically:
The electronic device may include one or more processing cores 'processors 401, one or more computer-readable storage media's memory 402, power supply 403, and input unit 404, among other components. It will be appreciated by those skilled in the art that the electronic device structure shown in fig. 6 is not limiting of the electronic device and may include more or fewer components than shown, or may combine certain components, or a different arrangement of components. Wherein:
the processor 401 is a control center of the electronic device, connects various parts of the entire electronic device using various interfaces and lines, and performs various functions of the electronic device and processes data by running or executing software programs and/or modules stored in the memory 402, and calling data stored in the memory 402, thereby performing overall monitoring of the electronic device. Optionally, 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 processes an operating system, a user interface, an application program, etc., and the modem processor mainly processes wireless communication. It will be appreciated that the modem processor described above may not be integrated into the processor 401.
The memory 402 may be used to store software programs and modules, and the processor 401 executes various functional applications and data processing by executing the software programs and modules stored in the memory 402. The memory 402 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program (such as a sound playing function, an image playing function, etc.) required for at least one function, and the like; the storage data area may store data created according to the use of the electronic device, etc. In addition, memory 402 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic 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.
The electronic device further comprises a power supply 403 for supplying power to the various components, preferably the power supply 403 may be logically connected to the processor 401 by a power management system, so that functions of managing charging, discharging, and power consumption are performed by the power management system. The power supply 403 may also include one or more of any of a direct current or alternating current power supply, a recharging system, a power device commissioning circuit, a power converter or inverter, a power status indicator, etc.
The electronic device may further comprise an input unit 404, which input unit 404 may be used for receiving input digital or character information and generating keyboard, mouse, joystick, optical or trackball signal inputs in connection with user settings and function control.
Although not shown, the electronic device may further include a display unit or the like, which is not described herein. In particular, in this embodiment, the processor 401 in the electronic device loads executable files corresponding to the processes of one or more application programs into the memory 402 according to the following instructions, and the processor 401 executes the application programs stored in the memory 402, so as to implement the steps in any video playing method provided in the embodiments of the present application.
According to the embodiment of the application, video data obtained after decoding the video file is stored in a storage space, the storage space is configured with an initial capacity, the initial capacity is used for limiting the data amount of the video data stored in the storage space, the video data are read from the storage space, video playing is carried out according to the read video data, the initial capacity is adjusted according to the residual data amount of the video data in the storage space and the relation between the residual data amount and the initial capacity, so that a target capacity is obtained, and the storage of the video data by the storage space is controlled according to the target capacity.
The storage space capacity is optimized, so that smooth video playing is ensured, and meanwhile, the adjustment of the storage space capacity is continuously tried, the utilization rate of the storage space can be improved, and the waste of resources is reduced.
The specific implementation of each operation above may be referred to the previous embodiments, and will not be described herein.
Those of ordinary skill in the art will appreciate that all or a portion of the steps of the various methods of the above embodiments may be performed by instructions, or by instructions controlling associated hardware, which may be stored in a computer-readable storage medium and loaded and executed by a processor.
To this end, the present application provides a computer readable storage medium having stored thereon a computer program that can be loaded by a processor to perform the steps of any of the video playback methods provided herein.
The specific implementation of each operation above may be referred to the previous embodiments, and will not be described herein.
Wherein the computer-readable storage medium may comprise: read Only Memory (ROM), random access Memory (RAM, random Access Memory), magnetic or optical disk, and the like.
Because the instructions stored in the computer readable storage medium can execute the steps in any video playing method provided in the present application, the beneficial effects that can be achieved by any video playing method provided in the present application can be achieved, and detailed descriptions of the foregoing embodiments are omitted herein.
The foregoing has described in detail a video playing method, apparatus, electronic device and computer readable storage medium provided in the present application, and specific examples have been applied to illustrate the principles and embodiments of the present invention, and the above examples are only used to help understand the method and core idea of the present invention; meanwhile, as those skilled in the art will vary in the specific embodiments and application scope according to the ideas of the present invention, the present description should not be construed as limiting the present invention in summary.
It should be noted that, in the specific embodiment of the present application, a video file to be played, a storage space for storing video data of the video file after decoding, and data related to a capacity of the storage space and an actually stored data amount, etc. are referred to, when the above embodiment of the present application is applied to a specific product or technology, permission or consent of a user needs to be obtained, and collection, use and processing of related data need to comply with related laws and regulations and standards of related countries and regions.

Claims (10)

1. A video playing method, comprising:
storing video data obtained after decoding a video file into a storage space, wherein the storage space is configured with an initial capacity, and the initial capacity is used for limiting the data amount of the video data stored in the storage space;
reading the video data from the storage space, and playing the video according to the read video data;
and according to the residual data amount of the video data in the storage space and the size relation of the initial capacity, adjusting the initial capacity to obtain a target capacity, and controlling the storage of the video data in the storage space according to the target capacity.
2. The video playing method according to claim 1, wherein the adjusting the initial capacity according to the remaining data amount of the video data in the storage space and the size relation of the initial capacity to obtain the target capacity includes:
if the residual data amount of the video data in the storage space is larger than or equal to the initial capacity, the initial capacity is adjusted according to a first preset adjustment range to obtain a target capacity, wherein the initial capacity is larger than the target capacity;
And if the residual data amount of the video data in the storage space is smaller than or equal to a first reference capacity, adjusting the initial capacity according to a second preset adjustment range to obtain a target capacity, wherein the initial capacity is smaller than the target capacity, the first reference capacity is calculated based on a first preset ratio and the initial capacity, and the first reference capacity is smaller than the initial capacity.
3. The method of claim 2, wherein the adjusting the initial capacity according to the first preset adjustment range to obtain the target capacity includes:
calculating a target capacity corresponding to the initial capacity according to a first preset adjustment amplitude;
stopping storing the video data into the storage space;
and when the residual data amount of the video data in the storage space is smaller than the target capacity, adjusting the initial capacity of the storage space to the target capacity.
4. The video playback method as recited in claim 3, wherein after said controlling the storage of the video data by the storage space in accordance with the target capacity, the method further comprises:
Calculating a second reference capacity corresponding to the target capacity based on a second preset ratio, wherein the second reference capacity is smaller than the target capacity;
if the residual data amount of the video data in the storage space is smaller than or equal to the second reference capacity, the target capacity is adjusted according to a third preset adjustment range to obtain a new target capacity, wherein the target capacity is smaller than the new target capacity;
and controlling the storage of the video data by the storage space based on the new target capacity.
5. The video playing method according to claim 1, wherein the storage space includes a data link table, and the storing the video data obtained after decoding the video file into the storage space includes:
decoding the video file through at least two video decoding threads to obtain video data;
inserting the video data into the data link list according to the head node of the data link list;
the reading the video data from the storage space includes:
and reading the video data from the tail node of the data link list through a video playing thread.
6. The video playback method of claim 5, wherein after inserting the video data into the data link list according to the head point of the data link list, the method further comprises:
If the data amount of the video data stored in the data linked list exceeds the initial capacity, stopping decoding the video file by the video decoding thread, and calculating a third reference capacity corresponding to the initial capacity based on a third preset ratio, wherein the third reference capacity is smaller than the initial capacity;
if the data amount of the video data in the data linked list is smaller than the third reference capacity, starting the video decoding thread to decode the video file to obtain the video data;
and inserting the video data into the data link list.
7. The video playing method according to claim 1, wherein the storage space includes a data link table, and the storing the video data obtained after decoding the video file into the storage space includes:
decoding the video file through at least two video decoding threads to obtain video data;
inserting the video data into the data link list according to the tail node of the data link list;
the reading the video data from the storage space includes:
and reading the video data according to the head node of the data linked list through a video playing thread.
8. A video playback device, comprising:
the storage module is used for storing video data obtained after decoding the video file into a storage space, wherein the storage space is configured with an initial capacity, and the initial capacity is used for limiting the data volume of the video data stored in the storage space;
the playing module is used for reading the video data from the storage space and playing the video according to the read video data;
and the control module is used for adjusting the initial capacity according to the relation between the residual data volume of the video data in the storage space and the initial capacity to obtain a target capacity, and controlling the storage of the video data in the storage space according to the target capacity.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps in the video playback method as claimed in any one of claims 1 to 7 when the computer program is executed.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements the steps of the video playback method as claimed in any one of claims 1 to 7.
CN202311442913.4A 2023-10-31 2023-10-31 Video playing method and device, electronic equipment and computer readable storage medium Pending CN117425034A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311442913.4A CN117425034A (en) 2023-10-31 2023-10-31 Video playing method and device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311442913.4A CN117425034A (en) 2023-10-31 2023-10-31 Video playing method and device, electronic equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN117425034A true CN117425034A (en) 2024-01-19

Family

ID=89522539

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311442913.4A Pending CN117425034A (en) 2023-10-31 2023-10-31 Video playing method and device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN117425034A (en)

Similar Documents

Publication Publication Date Title
US6968468B2 (en) Digital computer utilizing buffer to store and output data to play real time applications enabling processor to enter deep sleep state while buffer outputs data
WO2018082412A1 (en) Electronic equipment control method, device and electronic equipment
US10509588B2 (en) System and method for controlling memory frequency using feed-forward compression statistics
KR101846397B1 (en) System and method of dynamically throttling cpu frequency for gaming workloads
CN102402454B (en) Method for regulating memory operation frequency and electronic device
JP2013542491A (en) Mobile device and method for publishing and managing a set of performance scaling algorithms
CN110583018B (en) System and method for intelligent data/frame compression in a system-on-chip
CN103399802A (en) Method and device for preloading of picture
CN110521208B (en) System and method for intelligent data/frame compression in a system-on-chip
CN106960054B (en) Data file access method and device
JP2013545158A (en) System and method for optimizing the composition of a set of performance scaling algorithms
US20110099404A1 (en) Electronic device, method of controlling an electronic device, and system-on-chip
CN111538678A (en) Data buffering method, device and computer readable storage medium
CN114217759A (en) Screen projection method and device, storage medium and electronic equipment
TWI632816B (en) Continuous data delivery with energy conservation
US20150220362A1 (en) Multi-core processor system, electrical power control method, and computer product for migrating process from one core to another
WO2023193527A1 (en) Thread execution method and apparatus, electronic device, and computer-readable storage medium
CN117425034A (en) Video playing method and device, electronic equipment and computer readable storage medium
US20210320890A1 (en) Method and device for displaying text and video in two threads
CN113918002A (en) Frequency modulation method, frequency modulation device, storage medium and electronic equipment
JP2005038198A (en) Information processor
CN110457392B (en) Copy reading and writing method and device
CN113765886A (en) Multimedia playing method, device, storage medium and electronic equipment
WO2022206153A1 (en) Electronic device control method and apparatus, and storage medium and electronic device
CN117173275A (en) Animation drawing method and related equipment

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