Re: Calculating total play time

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

 



Janina Sajka <janina@xxxxxxxxxxx> wrote:
> Hi,
> 
> I need to calculate the total playing time of the audio files in a
> particular folder. These are variously encoded--flac, ogg, and even some
> mp3.
> 
> Anyone know how to do this, preferably from the cli? Or, perhaps one of
> the music player apps can provide this datum for a folder?

I like using soxi from sox.  The following should get you started:
(but do not run shell commands without understanding them :)

  find \( -iname '*.flac' -o -iname '*.mp3' -o -iname '*.ogg' \) -print0 | \
    xargs -0 soxi

The find(1) invocation above searches for files with flac, mp3, and ogg
suffixes case-insensitively (-iname) wrapped inside the quoted '()' for
grouping via '-o' ("or").

-print0 in find pairs with the -0 in xargs so it can deal with shell-unfriendly
characters without breaking.

Finally the soxi(1) command does the grunt work of handling all the
command-line arguments for each supported filetype.  You can also
parse and sum the time with the output of "soxi -D" instead of just
"soxi" (which shows output in a human-friendly format).

On Debian-based systems, you'll probably want install sox with all the
formats supported: apt-get install sox libsox-fmt-all

See the section 1 manpages for soxi, find, and xargs for more options
and possibilities.
_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@xxxxxxxxxxxxxxxxxxxx
http://lists.linuxaudio.org/listinfo/linux-audio-user




[Index of Archives]     [Linux Sound]     [ALSA Users]     [Pulse Audio]     [ALSA Devel]     [Sox Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux