Method and apparatus for estimating length of audio file

Information

  • Patent Application
  • 20080039965
  • Publication Number
    20080039965
  • Date Filed
    May 17, 2007
    17 years ago
  • Date Published
    February 14, 2008
    16 years ago
Abstract
A method for estimating an audio length of an audio file in an audio player is provided. First, the method generates a predicted audio length based on the average bit rate of some selected audio frames in the audio file, and initializes an adjustable audio length by the predicted audio length. Then, in the process of playing each audio frame of the audio file, the method continuously calculates a latest reference audio length. If the variation between the latest reference audio length and the previous reference audio length is smaller than a predetermined threshold, the method will adjust the adjustable audio length according to the latest reference audio length. Finally, based on the ratio of the played data amount to the total data amount of the audio file, an estimated audio length can be acquired between the adjustable audio length and the reference audio length.
Description

BRIEF DESCRIPTION OF THE APPENDED DRAWINGS


FIG. 1 is a flowchart of using the predictive estimation method to calculate the predicted audio length L0 before the audio file being played according to the invention.



FIG. 2 is a flowchart of calculating an estimated audio length LE(i) when the ith audio frame is played according to the invention.



FIG. 3A shows an example of an adjustable bit rate audio file with the increase of the played audio frames to compare the calculated audio length from the predictive estimation method (L0), the real-time estimation method (LR), and the invention (LE) respectively.



FIG. 3B shows the variation proportion of the ith audio frame R(i) in the embodiment of FIG. 3A with the method of the invention.



FIG. 4 is a flowchart of directly obtaining a predicted audio length L0 based on the file header information before playing the audio file according to the invention.



FIG. 5 is a flowchart of directly calculating a predicted audio length L0 based on the file size before playing the audio file according to the invention.



FIG. 6 is the block diagram of the estimating apparatus according to the invention.





DETAILED DESCRIPTION OF THE INVENTION

A scope of the invention is to provide a method for an audio player to estimate a more accurate audio length before seeking. This method combines the above mentioned predictive estimation method and real-time estimation method. In the beginning of playing an audio file, the audio length estimated by the predictive estimation method is provided, and then the audio length is adjusted to the audio length estimated by the real-time estimation method in the process of playing the audio file.


From a file system relative to the audio file, the total data amount (Stotal) of the audio file can be known. At first, the predictive estimation method is used to calculate a predicted audio length L0 in advance. Afterward, when the audio player of the invention has already played the audio file to the ith audio frame (assume the audio file includes N audio frames, and i is an integer index ranging from 1 to N), the played data amount can be added up as Splayed(i), and the time of the played audio length can be added up as Tplayed(i). The main scope of the invention is to calculate the estimated audio length LE(i) of the ith audio frame according to the above information.



FIG. 1 is a flowchart of using the predictive estimation method to calculate a predicted audio length L0 before the audio file is played according to the invention. Step 100 is to use the predictive estimation method of prior art to calculate a predicted audio length L0. In practical applications, at first, step 101 is to select at least one audio frame as the sample audio frames from the N audio frames. Then, step 102 is to calculate the average bit rate of all sample audio frames. Step 103 is to divide the total data amount Stotal of the audio file by the average bit rate obtained in step 102 to get the predicted audio length L0. Finally, step 110 is to set up an adjustable audio length LA(0) equal to L0.



FIG. 2 is a flowchart of calculating an estimated audio length LE(i) when the ith audio frame is played according to the invention. The estimating method is to perform a procedure when the ith audio frame of the audio file played. In step 200, the reference audio length LR(i) of the ith audio frame is calculated by using the real-time estimation method. In practical applications, according to the method and apparatus of the invention, LR(i) can be calculated according to a first equation represented as:






L
R(i)=[Stotal/Splayed(i)]*Tplayed(i),   (Equation 1)


wherein Stotal is the total data amount of the audio file, Splayed(i) is the sum of data amount of the audio file from the first audio frame to the ith audio frame, Tplayed(i) is the time interval between the time that the audio file is started to be played and the time that the ith audio frame is played.


Step 210 is to calculate the variation ratio of the ith audio frame R(i) according to a second equation and judge whether LR(i) is stable according to whether the variation ratio is smaller than a predetermined threshold. The second equation can be represented as:






R(i)=abs[LR(i)−LR(i−1)]/LR(i),   (Equation 2)


wherein LR(0) is set as 0.


The variation ratio R(i) represents the variation degree between the reference audio length of the ith audio frame LR(i) and the reference audio length of the (i−1)th audio frame LR(i−1). If R(i) is too large, larger than the predetermined threshold, it means that the average bit rate of the audio file is not stable yet, or compared to the bit rate of other audio frames, the bit rate of the ith audio frame has huge variation. The threshold can be determined according to experiment results.


If the judging result of step 210 is YES, it means that the average bit rate of the audio file has already approached the stability. Step 211 is to calculate the adjustable audio length of the ith audio frame LA(i) according to a third equation represented as:






L
A(i)=LA(i−1)*(1−P)+LR(i)*P,   (Equation 3)


wherein P is a predetermined constant, and 0<P<1. This constant can be determined according to experiment results.


As shown in Equation 3, when the average bit rate of the audio file has already approached the stability, the estimating method of the invention is to combine LA(i−1) and the newest reference audio length LR(i) with a fixed proportion to obtain an adjustable audio length of the ith audio frame LA(i). This will make LA(i) gradually approach the stable reference audio length.


If the judging result of step 210 is NO, then step 212 is to calculate the adjustable audio length of the ith audio frame LA(i) according to a fourth equation represented as:






L
A(i)=LA(i−1),   (Equation 4)


As shown in Equation 4, because the average bit rate of the audio file is not stable yet, according to the estimating method of the invention, LA(i) is not adjusted immediately based on the newest reference audio length LR(i), but equals to the former adjustable audio length LA(i−1). In this way, the adjustable audio length can avoid generating huge variation with the temporary bit rate.


In practical conditions, the last few audio frames of certain audio files are silence audio frames. Because the bit rate of these silence audio frames is much smaller than the average bit rate, it induces that the average bit rate drops immediately. Thus, the reference audio length LR(i) will be increased immediately. However, the adjustable audio length LA(i) will not be increased immediately following the reference audio length LR(i). This phenomenon causes that the adjustable audio length LA(i) does not be equal to the correct audio length when the last audio frame is played. According to the estimating method of the invention, the above mentioned problems will be solved by step 220.


Step 220 is to calculate the estimated audio length of the ith audio frame LE(i) which is displayed by the audio player at last according to a fifth equation represented as:






L
E(i)=LA(i)*(1−W)+LR(i)*W,   (Equation 5)


wherein W=[Splayed(i)/Stotal], namely the proportion of data amount of the part which has already been played to the entire audio file.


The Nth estimated audio length LE(N) calculated from Equation 5 must be equal to LR(N), that is to say, the Nth estimated audio length is assumed to converge to the correct audio length of the audio file.


Finally, in step 230, the ith estimated audio length LE(i) calculated from step 220 is stored for further feedback and output when the seeking function is enquired.



FIG. 3A shows an example of an adjustable bit rate audio file with the increase of the played audio frames to compare the calculated audio length from the predictive estimation method (L0), the real-time estimation method (LR), and the invention (LE) respectively. In FIG. 3A, the calculated result of the predictive estimation method (L0) has a deviation from the correct audio length. Moreover, the calculated result of the real-time estimation method (LR) induces a huge deviation at the beginning of playing. Thus, the invention is to provide a method that can estimate a more stable audio length, which is getting more and more accurate. FIG. 3B shows the variation proportion of the ith audio frame R(i) in the embodiment of FIG. 3A in the way of the invention. In FIG. 3B, if R(i) is larger than a threshold (ex., 0.00003), then it means that the average bit rate of the audio frame is not stable yet.


According to the invention, FIG. 4 is a flowchart of directly obtaining an estimated audio length L0 based on a file header information before playing the audio file. Compared to the method of FIG. 1, the following steps are added to the following procedures. First, whether the file header information o the related information of the audio length of the audio file (ex., ID3 or VBRI/Xing Header information) is judged in step 400. If the judging result of step 400 is YES, then step 401 is performed to directly obtain the predicted audio length L0. If the judging result of step 400 is NO, then step 100 is performed to obtain the predicted audio length L0 by using the predictive estimation method of FIG. 1.



FIG. 5 is a flowchart of directly calculating a predicted audio length L0based on the file size before playing the audio file according to the invention. Compared to the method of FIG. 1, the following steps are also added to the method of the invention before performing all the procedures. First, step 500 is to judge whether the total data amount of the audio file Stotal is smaller than a predetermined total amount threshold. If the judging result of step 500 is YES, then step 501 is performed to directly read and calculate the sum of all the audio frames in the audio file to obtain the predicted audio length information L0. If the judging result of step 500 is NO, then step 100 is performed by using the predictive estimation method of FIG. 1. Because the accurate audio length is already obtained directly in the embodiment, it is not necessary to use the real-time estimation method to calculate the estimated audio length in each of audio frames.



FIG. 6 is the block diagram of the estimating apparatus according to the invention. The estimating apparatus 60 includes a processor 62 and a memory 63. The memory 63 is used to store a software program code and an audio file; moreover, it can temporarily save audio length data. The processor 62 performs the software program code stored in the memory. The software program code includes the following steps:


(1) before the audio file is played, calculating a predicted audio length L0 and setting an initial adjustable audio length LA(0) equal to the predicted audio length L0; and


(2) when the ith audio frame of the audio file being played, performing the following sub-steps:


(2a) calculating a reference audio length LR(i) of the ith audio frame;


(2b) calculating a variation ratio R(i) of the ith audio frame according to LR(i) and LR(i−1), and judging whether R(i) is smaller than a predetermined threshold; if YES, performing the sub-step (2c); if NO, performing the sub-step (2d);


(2c) calculating an adjustable audio length LA(i) of the ith audio frame according to LA(i−1) and LR(i), and performing the sub-step (2e);


(2d) setting an adjustable audio length LA(i) of the ith audio frame equal to LA(i−1), and performing the sub-step (2e)


(2e) calculating the estimated audio length LE(i) of the ith audio frame according to LA(i), LR(i), a cumulative played data amount Splayed(i), and a total data amount of the audio file Stotal.;


(2f) storing the estimated audio length of the ith audio frame LE(i) in the memory 63, and feeding back and outputting it when the seeking function is enquired.


It should be noticed that the predictive estimation method can be used to calculate the predicted audio length L0 in the step (1) of the software program code performed by the processor 62, and the predictive estimation method includes the following sub-steps:


(1a) selecting a plurality of audio frames from the audio file;


(1b) calculating an average bit rate of the plurality of selected audio frames; and


(1c) dividing the total data amount Stotal of the audio file by the average bit rate to obtain the predicted audio length L0.


In practical applications, the predicted audio length L0 can be directly obtained according to the file header information in the step (1) of the software program code performed by the processor 62. This method includes the following sub-steps:


(3a) judging whether the file header information of audio file includes audio length related information; if YES, performing the sub-step (3b); if NO, performing the sub-steps (1a), (1b), and (1c) of the predictive estimation method;


(3b) obtaining the predicted audio length L0 directly.


In practical applications, the predicted audio length L0 can be directly calculated according to the audio file size in the step (1) of the software program code performed by the processor 62. This method includes the following sub-steps:


(4a) judging whether the total data amount Stotal of the audio file is smaller than a total amount threshold; if YES, performing the sub-step (4b); if NO, performing the sub-steps (1a), (1b), and (1c) of the predictive estimation method; and


(4b) directly reading and calculating the sum of all audio frames in the audio file to obtain the predicted audio length information L0.


The method and apparatus based on the invention can be used to various audio files coded by the way of audio frames, and it also can provide a stable estimated audio length which is getting more and more accurate. The probability of obtaining the audio frame which is not corresponding to the user-selected time point by the audio player or obtaining no audio frame corresponding to the user-selected time point can be reduced.


With the example and explanations above, the features and spirits of the invention will be hopefully well described. Those skilled in the art will readily observe that numerous modifications and alterations of the device may be made while retaining the teaching of the invention. Accordingly, the above disclosure should be construed as limited only by the metes and bounds of the appended claims.

Claims
  • 1. A method for estimating an audio length of an audio file, the audio file comprising N audio frames, N being a natural number, i being an integer index ranging from 1 to N, said method comprising the steps of: (1) before the audio file is played, calculating a predicted audio length L0 and setting an initial adjustable audio length LA(0) equal to the predicted audio length L0; and(2) when the ith audio frame of the audio file is played, performing the following sub-steps: (2a) calculating a reference audio length LR(i) of the ith audio frame;(2b) calculating a variation ratio R(i) of the ith audio frame according to LR(i) and LR(i−1), judging whether R(i) is smaller than a predetermined threshold; if YES, performing the sub-step (2c); if NO, performing the sub-step (2d);(2c) calculating an ith adjustable audio length LA(i) of the ith audio frame according to LR(i) and an (i−1)th adjustable audio length LA(i−1) of the (i−1)th audio frame in the audio file, performing the sub-step (2e);(2d) setting an adjustable length LA(i) of the ith audio frame equal to an (i−1)th adjustable audio length LA(i−1) of the (i−1)th audio frame in the audio file, and performing the sub-step (2e);(2e) calculating an estimated audio length LE(i) of the ith audio frame according to LA(i), LR(i), a cumulative played data amount Splayed(i), and a total data amount Stotal of the audio file; and(2f) saving the estimated audio length LE(i) of the ith audio frame.
  • 2. The method of claim 1, wherein a prediction method is used to calculate the predicted audio length L0 in the step (1), and the prediction method comprises the following sub-steps: (1a) selecting a plurality of audio frames from the audio file;(1b) calculating an average bit rate of the plurality of selected audio frames; and(1c) dividing the total data amount Stotal of the audio file by the average bit rate to obtain the predicted audio length L0.
  • 3. The method of claim 2, wherein the step (1) further comprises the following sub-steps: (3a) judging whether a file header information of the audio file comprises an audio-length related information of the audio length; if YES, performing the sub-step (3b); if NO, performing the sub-steps (1a), (1b), and (1c); and(3b) obtaining the predicted audio length L0 from the audio-length related information.
  • 4. The method of claim 2, wherein the step (1) further comprises the following sub-steps: (4a) judging whether the total data amount Stotal of the audio file is smaller than a total amount threshold; if YES, performing the sub-step (4b); if NO, performing the sub-steps (1a), (1b), and (1c); and(4b) reading and analyzing all audio frames in the audio file to obtain the predicted audio length L0
  • 5. The method of claim 1, wherein in the sub-step (2a), the reference audio length LR(i) of the ith audio frame is calculated according to a first equation represented as: LR(i)=[Stotal/Splayed(i)]*Tplayed(i)
  • 6. The method of claim 1, wherein in the sub-step (2b), the variation ratio R(i) of the ith audio frame is calculated according to a second equation represented as: R(i)=abs[LR(i)−LR(i−1)]/LR(i).
  • 7. The method of claim 1, wherein in the sub-step (2c), the adjustable audio length LA(i) of the ith audio frame is calculated according to a third equation represented as: LA(i)=LA(i−1)*(1−P)+LR(i)*P,
  • 8. The method of claim 1, wherein in the sub-step (2e), the estimated audio length LE(i) of the ith audio frame is calculated according to a fifth equation represented as: LE(i)=LA(i)*(1−W)+LR(i)*W,
  • 9. An apparatus for estimating audio length in an audio player, comprising: a memory for storing a software program code and an audio file, and for temporarily saving at least one audio length data, the audio file comprising N audio frames, N being a natural number, i being an integer index ranging from 1 to N; anda processor for executing the software program code stored in the memory, the software program code comprising the following steps:(1) before the audio file is played, calculating a predicted audio length L0 and setting an initial adjustable audio length LA(0) equal to the predicted audio length L0; and(2) when the ith audio frame of the audio file is played, performing the following sub-steps: (2a) calculating a reference audio length LR(i) of the ith audio frame;(2b) calculating a variation ratio R(i) of the ith audio frame according to LR(i) and LR(i−1), judging whether R(i) is smaller than a predetermined threshold; if YES, performing the sub-step (2c); if NO, performing the sub-step (2d);(2c) calculating an ith adjustable audio length LA(i) of the ith audio frame according to LR(i) and an (i−1)th adjustable audio length LA(i−1) of the (i−1)th audio frame in the audio file, performing the sub-step (2e);(2d) setting an ith adjustable audio length LA(i) of the ith audio frame equal to an (i−1)th adjustable audio length LA(i−1) of the (i−1)th audio frame in the audio file, and performing the sub-step (2e);(2e) calculating an estimated audio length LE(i) of the ith audio frame according to LA(i), LR(i), a cumulative played data amount Splayed(i), and a total data amount Stotal of the audio file; and(2f) saving the estimated audio length LE(i) of the ith audio frame.
  • 10. The apparatus of claim 9, wherein a prediction method is used to calculate the predicted audio length L0 in the step (1), and the prediction method comprises the following sub-steps: (1a) selecting a plurality of audio frames from the audio file;(1b) calculating an average bit rate of the plurality of selected audio frames; and(1c) dividing the total data amount Stotal of the audio file by the average bit rate to obtain the predicted audio length L0.
  • 11. The apparatus of claim 10, wherein the step (1) of the software program code performed by the processor further comprises the following sub-steps: (3a) judging whether a file header information of the audio file comprises an audio-length related information; if YES, performing the sub-step (3b); if NO, performing the sub-steps (1a), (1b), and (1c); and(3b) obtaining the predicted audio length L0 from the audio-length related information.
  • 12. The method of claim 10, wherein the step (1) further comprises the following sub-steps: (4a) judging whether the total data amount Stotal of the audio file is smaller than a total amount threshold; if YES, performing the sub-step (4b); if NO, performing the sub-steps (1a), (1b), and (1c); and(4b) reading and analyzing all the audio frames in the audio file to obtain the predicted audio length L0.
  • 13. The apparatus of claim 9, wherein the sub-step (2a) of the software program code performed by the processor calculates the reference length LR(i) of the ith audio frame according to a first equation represented as: LR(i)=[Stotal/Splayed(i)]*Tplayed(i).
  • 14. The apparatus of claim 9, wherein the sub-step (2b) of the software program code performed by the processor calculates the variation ratio R(i) of the ith audio frame according to a second equation represented as: R(i)=abs[LR(i)−LR(i−1)]/LR(i).
  • 15. The apparatus of claim 9, wherein the sub-step (2c) of the software program code performed by the processor calculates the adjustable audio length LA(i) of the ith audio frame according to a third equation represented as: LA(i)=LA(i−1)*(1−P)+LR(i)*P,
  • 16. The apparatus of claim 9, wherein the sub-step (2e) of the software program code performed by the processor calculates the ith estimated length LE(i) according to a fifth equation represented as: LE(i)=LA(i)*(1−W)+LR(i)*W,
Priority Claims (1)
Number Date Country Kind
095129681 Aug 2006 TW national