help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Estimating track length


From: Jeff Clough
Subject: Re: Estimating track length
Date: Wed, 08 Dec 2010 15:26:17 -0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

tossel@gmail.com writes:

> 2010/8/25 Ivan Kanis <expire-by-2010-08-30@kanis.fr>:
>> tossel@gmail.com wrote:
>>
>>> Hello, everybody! I need to estimate length of audio file in seconds
>>> from emacs. Is such function already implemented in some package? One
>>> obvious candidate is EMMS, but I couldn't find information about how
>>> to do it. I'd be grateful for any suggestions.
>>
>> What kind of file? Emacs won't tell you the track length of a file. You
>> will need to call a separate process which will output the information
>> you want.
>
> mp3, ogg, wav, wma etc. - the more formats the better.
> It's a good idea to find an external program to do this task, but
> could not find any either. And if I'll have to develop it myself, it
> can be implemented in elisp as well as in any other language.

You can do this with mplayer.  The magic I've found:

mplayer -ao null -identify -frames 0 foo.mp3 2>&1 | grep ID_LENGTH

The incantations for mplayer have always been a source of mystery and
terror for me.  I googled this a while back and kept it around in case
it was needed.  It will pump the time out for you in seconds, and I
*believe* it will work for multiple formats, but YMMV.

The other way I know works is the Hard Way.  I have a music player I
hacked out in elisp that grovels through the ID3 tags of a target mp3
trying to get the various info to be found there.  Given the
proliferation of things that call themselves ID3, and how little they
resemble each other, this is some seriously hideous code that breaks if
you look at it funny*.  Once you add in ogg, wav, wma et al, your level
of shafted probably approaches infinity.

So, yeah, "find an external program to do this task" is almost certainly
the sanest option.

* To be fair to myself, though, this was pretty much my first
  programming project using elisp.

Jeff

-- 
web:  http://www.chaosphere.com
Author of Genesys, a Free Universal Paper and Pencil RPG.
http://www.chaosphere.com/genesys/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]