Php get wav file length


















If you play the resultant file in an audio player, you'll find that is 40 seconds in duration. If you run the code above it also computes the duration to be 40 seconds. So I believe the number of frames is not influenced by the number of channels and the formula above is correct. A very simple method is to use soundfile formerly pysoundfile. To install ffmpeg follow this link. I was trying to get the length of different format of an audio file other than '.

Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more.

Asked 10 years, 2 months ago. Active 2 months ago. Viewed 95k times. Thanks in advance. Improve this question. Pannu Pannu 2, 2 2 gold badges 21 21 silver badges 27 27 bronze badges. Add a comment. Active Oldest Votes. Improve this answer. This is not quite correct The formula posted in my answer computes the duration to be 40s, which jibes with what I see when I play the.

Active Oldest Votes. There is a better way: soxi -D out. Improve this answer. Tim Cooper k 36 36 gold badges silver badges bronze badges. Andrew Kuklewicz Andrew Kuklewicz Unfortunately it returns wrong duration, distinguish from sox output. I have never seen it to be wrong - can you distinguish in what situation this is incorrect? I've cropped the audio with mp3cut. On the other hand sox output. Also windows explorer shows correct duration. I think the two differ in that soxi uses the header info, while sox looks at the body, too.

SO if the header is wrong, the two give different outpu. Why theory? Man directly states it for soxi sox --info : "Displays information from the header of a given audio file or files. Audio is passed unmodified through the SoX processing chain. Show 2 more comments. Use sed to extract the relevant bits: sox out. Latest entries. Top 10 charts.

Recommend this page to a friend! View files Info Example View files 24 Download. February Number 17 PHP provides good file type detection methods using the fileinfo extension.

However, that extension only detect the type of file and does not give much more information. This package provides means to not only detect the file types of audio and video files, but also extract several types of metadata like audio and video length, resolution, etc..

It supports many types of well known video and audio formats. Manuel Lemos. Sergey Vanyushin. How I can get the length of an audio file in php. If it's too hard to do in php then any other way should work alright.

Improve this question. David Basarab Belgin Fish Belgin Fish With any audio format or precise one? Add a comment. Active Oldest Votes. Improve this answer. Stephen Fuhry Stephen Fuhry This is working well for me although it is slow for hundreds of files. Ryan Ryan 19k 26 26 gold badges silver badges bronze badges.

PHP has no standard audio support, you'll have to recompile PHP yourself, or you can use a tool to get the information: You could use ffmpeg.



0コメント

  • 1000 / 1000