I was wondering if anyone had any advice for encoding a user uploaded .wav file to a .mp3 extension. I would like to build a PHP solution if possible. Can I call the command line LAME encoder via PHP once a file has been uploaded? Is there a better option?
Thanks!
Go ahead and call LAME. No chance of a better option existing, even more so if you take the encoder quality into account.
The easiest way to call into an external binary is exec, while for the best integration over the encoding process you might want to use proc_open.
I wrote a wrapper for LAME that provides convenient interface to encode wav file(s). The library is available here: https://github.com/b-b3rn4rd/phplame
I do this, I downloaded and installed ffmpeg with libmp3lame.
In your code do this:
$commandOutput = shell_exec('ffmpeg (or path to your ffmpeg file) -i file.wav file.mp3')
Related
I am trying to generate waveform for mp3 files, and found that it is possible using php code to generate waveform for wav files, but not mp3. I need to convert mp3 to wav, but also it is not possible to install ffmpeg or lame on shared hosting, is there any other solutions like php based conversion?
I don't think this is possible. But you can use a SAAS platform to help you with that. maybe you can try http://www.encoding.com/ or http://aws.amazon.com/elastictranscoder/.
I need to convert AMR audio file to MP3. How can I make it in PHP without FFMPEG (i have no permissions to install it on the server). Please help me.
Use SoX - the Swiss Army knife of sound processing. Very easy to use.
It is a command line tool not a PHP library so to use from PHP you need to execute a shell command and get the result with in your code. I have used it with in few projects.
Example with PHP:
<?php
exec('sox /mypath/my_audio.amr /mypath/my_audio.mp3');
?>
SoX is a cross-platform (Windows, Linux, MacOS X, etc.) command line utility that can convert various formats of computer audio files in to other formats. It can also apply various effects to these sound files, and, as an added bonus, SoX can play and record audio files on most platforms.
SoX is very mature project! Here is the link: http://sox.sourceforge.net/
Here are some examples I googled for you:
http://www.thegeekstuff.com/2009/05/sound-exchange-sox-15-examples-to-manipulate-audio-files/
Just use ffmpeg. You can simply download a binary of ffmpeg (look for "static builds"), and then point your script to the binary. There is no need to install it so there should be no permission issues.
AFAIK there is no way, at least without other command line utilities. You could try using mplayer, but I guess the situation here is the same as with ffmpeg. :)
You could of course upload the executable and run it through PHP if your host's policies allow this (safe mode, SELinux).
Simple answer: You can't convert audio files in pure PHP. I would suggest you to create/ search for a web-service to accomplish that task.
I need to extract the icon (.ico file) out of an executable (.exe).
I need it for PHP on Windows. Any Ideas?
I originally thought that ImageMagick will extract icons from .exe files. However, it seems my memory is failing me.
Instead, since you are prepared to accept the use of exec I think the quickest and easiest solution will be to use a tool like ResHacker. The can be driven in command-line mode. Then if you need to convert from .ico to .png, as per your last question, you can reach for ImageMagick.
How do I determine the length of an FLV file from within PHP or through shell access?
I think a dedicated libraries is available, but I'm really looking for a quicker more direct way.
Read this:
How To Get Video Duration With FFMPEG and PHP
You will need a FLV meta reader and AMF parser.
I have ALWAYS used this :
http://www.tommylacroix.com/2009/06/11/mp4-and-f4v-php-flash-video-meta-data-reader/
:) its really great. It gives lot more things for the FLV. it also allows editing FLV meta
So my host provides ImageMagick on the server, but no MagickWand or IMagick API for PHP. I can do operations with the PHP exec command to manipulate images. But that requires full path file names to work, and I want to pull my images from my MySQL database. Will I have to have pull them out of the database and put them to a file everytime I want to do this? Any recommendations?
One option is to run the imagemagick process using proc_open() and write/read to/from the created process' stdin/stdout.
To have imagemagick read from stdin, you just give a dash '-' as input file. Specify /dev/stdout as the output file. Your call to image magick should look something like:
convert -scale 150x100 - /dev/stdout
Use fwrite and fread on the pipes created by proc_open to write input to imagemagick and read output back.
I haven't tried it, but I guess this should work.
If the only ImageMagick available to you can only operate on files (which is how I read your first sentence), then you will indeed have to make files from your MySQL blobs to use ImageMagick on them (and remember to clean things up afterwards). My recommendation might be to switch to a better hosting service, but I assume you have your reasons to stay with that one.
have you tried phMagick ?