View previous topic :: View next topic |
Author |
Message |
zark n00b
Joined: 27 Mar 2004 Posts: 74 Location: Belgium
|
Posted: Wed Aug 29, 2007 10:22 am Post subject: mp3 to png command line utility |
|
|
Hi
i'm looking for a command line utility that would generate a waveform from a WAVE or ideally MP3 file, and export it to an IMAGE, ideally png
i've searched and searched but could not find
the best i found is a tcl/tk toolkit that has waveform visualisation, but renders it to a tk window ... |
|
Back to top |
|
|
didymos Advocate
Joined: 10 Oct 2005 Posts: 4798 Location: California
|
Posted: Wed Aug 29, 2007 11:36 am Post subject: |
|
|
Well, I don't know of anything like that, but I'd maybe change the subject a bit. I saw "mp3 to png" and thought you had to be drunk or otherwise impaired. Then again, it got me to read it, so maybe that's working in your favor... _________________ Thomas S. Howard |
|
Back to top |
|
|
truc Advocate
Joined: 25 Jul 2005 Posts: 3199
|
Posted: Wed Aug 29, 2007 12:10 pm Post subject: |
|
|
didymos wrote: | so maybe that's working in your favor... |
it is _________________ The End of the Internet! |
|
Back to top |
|
|
cchildress Tux's lil' helper
Joined: 27 May 2004 Posts: 90 Location: Tennessee, United States
|
Posted: Wed Aug 29, 2007 9:56 pm Post subject: |
|
|
What I would do, is look into a png-generating software that can take raw input from a pipe...and use a command-line music player that allows you to pipe out...and combine.
edit:
Upon further investigation, I found GraphicsMagick (http://www.graphicsmagick.org/), which may do exactly what you need it to...not sure, but it's a start |
|
Back to top |
|
|
zark n00b
Joined: 27 Mar 2004 Posts: 74 Location: Belgium
|
Posted: Thu Aug 30, 2007 8:00 am Post subject: |
|
|
well something "surprising" is that classAudioFile (a php class that read id3v2 etc..), can generate waveforms from wave files using GD.
now the problem is that i have *cough* around 100gb of mp3 files to treat
guess i could bash it ...
mp3 --> wav --> classAudioFile --> png
but i doubt i'd be able to pipe the mp3 > wav directly in a php script ... or maybe i could ...
or i could just go hardcore and do it one at a time with a timer so to not kill the server ^^
ps: i'm webprogrammer for a community of young talents uploading their songs in a CreativeCommons licence .
i'd like to have the waveform so it would look nicer in the flash player, also i've been working on a graphic beat recognition program, so that would allow auto-mixing in the flash player |
|
Back to top |
|
|
zark n00b
Joined: 27 Mar 2004 Posts: 74 Location: Belgium
|
Posted: Thu Aug 30, 2007 8:37 am Post subject: |
|
|
okay just did that
sox file1.mp3 file1.wav && php convert.php
resultt : http://zark.be/temp.png
time :
real 0m4.065s
user 0m3.750s
sys 0m0.280s
the file was 6.4Mb
estimations /....
it would take 17hours to convert it all ... not too bad.
maybe i'll stick to that ..
I'll post the final script for those interested. |
|
Back to top |
|
|
Akkara Bodhisattva
Joined: 28 Mar 2006 Posts: 6702 Location: &akkara
|
Posted: Thu Aug 30, 2007 8:38 am Post subject: |
|
|
Very interesting request.
As I was wondering what possibly this might be, I imagined converting mp3 to a image of a phonograph, which could be printed onto a transparency sheet and then used to photo-expose a sheet of vinyl which then is exposed to etchants that eat away a groove, such that it can be played on one of those turntables of yesteryear.
It sounds like you might already have part of your solution, just needing some php expertise in the mix, which I lack, so can't advise about.
What sorts of waveforms would you want to generate? A waveform of the whole thing would be very, very long. Maybe some kind of temporal overlap?
It isn't that hard to roll your own if you feel so inclined, or if the tools don't give what you need.
The basic loop is to read a sample s, plot the point (t,s) and increment the time t, with wrap-around if desired.
To read a sample, use mpg123 with options to cause it to produce "raw" output. Each sample is then 4 bytes: LSB of left, MSB of left, LSB of right, MSB of right. (most .wavs are the same thing after skipping the header (usually 40 or 42 bytes)). Might need to play games with sign-extension of the MSB (if byte-reads are unsigned), or masking the LSB to unsigned (if byte-reads are signed). Then do MSB * 256 + LSB, for left, and for right. Left + right gives the mono sample (or you can plot the L and R waveforms overlaid).
As far as plotting the point (t,s) - look up the "pmn" image format. It is ridiculously easy - just a small ascii header (image size, stuff like that) followed by the rgb pixels (3 bytes each) in left-to-right and up-to-down order. Just declare an array of (r,g,b) triplets in whatever language you're using then dump out the small header followed by the bytes to the file. Then use something like 'convert' to make .png's. |
|
Back to top |
|
|
|