LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to know audio file lenght? (https://www.linuxquestions.org/questions/linux-software-2/how-to-know-audio-file-lenght-345948/)

RomanG 07-23-2005 05:49 AM

How to know audio file lenght?
 
Does anyone know how to know audio file lenght in shell command line without opening it in audioplayer?
I need it for a shell script. Files are in this formats: wav, wav49, mp3, ogg, gsm.
Please help me. Thank you.
:study: :study: :study:

mad4linux 07-23-2005 07:46 AM

you can calculate the file length from the file size if it`s not a strongly compressed format like mp3.
A WAV File has a bitwidth (mostly 16 bit) and a sample rate (mostly 44 kHz). This two values determine the filesize (plus some header data which you`ll have to find out by comparing the result of the calculation with the actual file sizes) in this way:
length of the sound (in s) = Size of the file (in MByte) / 44100 / 16 * 8 * 1024 * 1024 (if a Byte has 8 Bit (is so in 99.9999999% of the cases :-) ))

I`ve never tried this out, it`s just theory, so please counter check before using productivly.


All times are GMT -5. The time now is 01:46 PM.