Help! Mac script: first 10 sec of audio

Index » 喫茶店 (Koohii Lounge)

  • 1
 
Mesqueeb Member
From: Japan Registered: 2008-10-14 Posts: 253 Website

So I need to make a script that will be able to easily extract the first 10 seconds of audio from an audio file.
I found this on the web, after looking for "extract first 10 seconds of audio"
but it doesn't work, since it's for Ti.Media (whatever that is):

var sound = Ti.Media.createSound({
    sound: file,
    duration: 10
});

→ error: couldn't write the class name after this identifier.

I want to extract the first 10 seconds of classical songs, and be able to recognize the composer and title in Anki. ^^

Anyone has any knowledge about scripts?
Cheers!

-Mesqueeb

Last edited by Mesqueeb (2011 December 16, 2:39 am)

cangy Member
From: 平安京 Registered: 2006-12-13 Posts: 372 Website

sox trim (seems to be in mac ports and fink)

Last edited by cangy (2011 December 16, 5:18 am)

Mesqueeb Member
From: Japan Registered: 2008-10-14 Posts: 253 Website

Hello, I downloaded Sox and it is a certain folder. However even after I have the folder on my computer I cannot use the command.

The command I need I found here:
http://billposer.org/Linguistics/Comput … ml#extract

sox Input.wav  Half1.wav trim 0 30:00
in my case:
sox Input.mp3  output.mp3 trim 0 10

However. "sox" is not recognized by Terminal. ><
Could you help me out a little bit in how to make sox active? Thanks!

Advertising (register and sign in to hide this)
JapanesePod101 Sponsor
 
Mesqueeb Member
From: Japan Registered: 2008-10-14 Posts: 253 Website

Went into the sox folder and I got a bit closer I think.

Mesqueebiator:sox-14.3.2 Mesqueeb$ ./sox 1.mp3  2.mp3 trim 0 10
./sox FAIL util: Unable to load MAD decoder library (libmad).
./sox FAIL formats: can't open input file `1.mp3':


meaning I need to install MAD decoder? I'll google it and come report back in a second.

But do I really need to copy the mp3 file in the sox folder each time? =.=

Mesqueeb Member
From: Japan Registered: 2008-10-14 Posts: 253 Website

It's all a big hassle, I need to install mac dev tools and such...

Is there a really easy way to extract the first 10 seconds of audio?

cangy Member
From: 平安京 Registered: 2006-12-13 Posts: 372 Website

you'll want to install it using mac ports or fink

Mesqueeb Member
From: Japan Registered: 2008-10-14 Posts: 253 Website

But I need to install xCode, which is like 2 gb and I only have 60 gb on my Mac... >< Contstantly fighting against my limit. Truth is, I have no idea how to open up another 2gb...
><
Maybe I'll just use the mic and record the first few seconds...

Is there like a program that records desktop, and sound output? (not including sound input like mic.) If that would exist I could record 10 seconds my desktop, and afterwards convert it to mp3. ^^

Blahah Member
From: Cambridge, UK Registered: 2008-07-15 Posts: 715 Website

I use a program called Fission by Rogue Amoeba to do this. You have to pay but there's a free trial, so if you only need to do it a couple of times it will work.

Alternatively you could do it with python. If you have a mac python should be installed. You could try PyMP3Cut.

bombpersons Member
From: UK Registered: 2008-10-08 Posts: 907 Website

I've never used a mac in my life, but, is there not a mac version of FFMPEG? Is there no package manager at all for installing stuff like that?

Mesqueeb Member
From: Japan Registered: 2008-10-14 Posts: 253 Website

when i did an update of a mac app called all2mp3 they asked me to install ffmpeg, and like practically did it for me! ^^
Is there a command I would be able to use now? To like easily cut the first 10 seconds of a piece of audio?

bombpersons Member
From: UK Registered: 2008-10-08 Posts: 907 Website

try this

Code:

ffmpeg -i MyInputFile -ss 00:00:00 -t 00:00:10 MyOutputFile.mp3

That should get you the first 10 seconds of an audio file (well, any format ffmpeg supports actually)

I tested this on a random mkv file and it worked fine.

Reply #12 - 2012 January 05, 2:23 pm
Mesqueeb Member
From: Japan Registered: 2008-10-14 Posts: 253 Website

bombpersons wrote:

try this

Code:

ffmpeg -i MyInputFile -ss 00:00:00 -t 00:00:10 MyOutputFile.mp3

That should get you the first 10 seconds of an audio file (well, any format ffmpeg supports actually)

I tested this on a random mkv file and it worked fine.

-bash: ffmpeg: command not found

Reply #13 - 2012 January 05, 4:01 pm
Mesqueeb Member
From: Japan Registered: 2008-10-14 Posts: 253 Website

It's ok! I have found the perfect solution!
'Adapter' for mac!
You can drag a whole folder into it and batch convert to ten seconds each!
Muhahahaha!

  • 1