How to install FFMPEG in PHP to encode video - php

I want to know how this FFMPEG to integrate in php. I want to encode video. I got this link earlier to refer
http://youtubeclone.wordpress.com/2007/05/26/how-to-convertencode-files-to-flv-using-ffmpeg-php/
but dont know where to point this
$ffmpegPath = "/path/to/ffmpeg";
$flvtool2Path = "/path/to/flvtool2";
here we have to give the path "/path/to/ffmpeg", "/path/to/flvtool2". I am little bit confused what to do or how to integrate ffmpeg, flvtool2 in php

exec("ffmpeg -i /tmp/orig.mov /tmp/output.mp4");
You don't need those $ffmpegPath variables on a properly configured system. Rather than employing pseudo security, you should escape input and output filenames using escapeshellarg().
Conversion options are available in the ffmpeg manual or man page. Google will know more about your flvtool2.

Related

You must have installed FFMPEG in order to use this function

I'm using this script: GitHub Script Link
This script uses FFMPEG to convert MP4 to AVI and from AVI to MP3.
But I always getting the error:
You must have installed FFMPEG in order to use this function
But I have installed FFMPEG on my Linux Server.
This is the output of my CLI (puTTY):
As you can see I have it installed.
I'm sorry the script is to big to post it here but you can take a look.
Thanks for every help!
Run which ffmpeg from your PuTTY console, and see what you get. That's exactly what the script does to detect it:
private function has_ffmpeg() {
$sh = `which ffmpeg`;
return (bool) (strlen(trim($sh)) > 0);
}
It returns false if there's no output from the shell script (i.e. the length of the response is 0).
which only searches through folders defined in your $PATH. If you get no output when you run that command directly, then the script will get the same. This means the script considers that ffmpeg is not installed.
Therefore, as mentioned in the comments already, make sure your $PATH contains the folder in which the ffmpeg executables are stored. http://thegeekstuff.com/2012/07/linux-export-command-examples shows you how to check, and how to add things to it. You can find loads more examples online, for all the various distros.

How to mix/merge 2 mp3 files in PHP?

I need a tool to join 2 mp3 files in 1.
The first file ( background ) will be some sound ( music, submitted by user ),
second file will be a machine (google) speaking text, which was submitted ( by user ).
In output I need a single mp3 file, with background music and speaking robot text playing together.
I can't really find any PHP standalone solution like some library or something like, only shell commands atc.
So are there some libraries?
or there's some unique shell command which works on all OS to combine files?
Or how do I complete the task?
Based off of this question, you should be able to install FFMPEG onto your server (hopefully not a shared host?) and use
//Reduce background volume, assuming it's input2.mp3
shell_exec('ffmpeg -i input2.mp3 -af "volume=0.3" backround.wav');
//Merge the two
shell_exec('ffmpeg -y -i input1.mp3 -i background.wav -filter_complex amerge -c:a libmp3lame -q:a 4 output.mp3');
Then you can simply serve up the output.mp3 file. If this is being performed by PHP running under apache (or other web host, instead of CLI) you'll need to make sure your www-data user has read access to the input files, and write access to the output directory.
All your temporary output, like the background, should be saved as .wav, and only converted back to .mp3 for the final output. Recompressing the audio at each step may result in a very poor final output.
I am making assumptions about how FFMPEG works here, so you may need to consult the documentation for it in order to build a functioning or more efficient set of commands.
You can simply do this
file_put_contents('combined.mp3',
file_get_contents('file1.mp3') .
file_get_contents('file2.mp3'));

Linux Server side php script for audio conversion like 32kbps,48kbps from one bitrate?

I want php script For audio conversion so , that i upload only one format it automatically converts into other formats
Yes you can with php and you need an external program. Good thing its Linux, most audio conversion software is free because its open source.
//Include this in your php script to call it
exec('sox /path/to/audio/files/audio_a.wav /path/to/audio/files/audio_a.mp3');
Make sure you install sox first on your machine and try it on the command line first and check the results and tweak with its arguments to fine tune the auto conversion then use php's exec function to process the entire file. The above example is basic. Here is a full argument list: http://sox.sourceforge.net/sox.html
Install it from: http://sox.sourceforge.net/
You can use git to pull the source.

Decode base64 in array to figure out hackers intents

A WordPress site of a client was recently hacked due to a theme vulnerability and I am now in the process of cleaning up and fortifying. I found guncompress(base64_decoded code. When I decoded it I had more base64 in an array:
$GLOBALS['_1780441916_']=Array(base64_decode('' .'ZXJ' .'yb3Jfc' .'mVwb3J' .'0a' .'W5'.'n'),base64_decode('Y3VybF9pb' .'ml0'),base64_decode('c
How can I decode base64 in an array on my localhost?
Try to using evalhook.so.
You need:
PHP >= 5.2
php5-devel
PHP Zend Optimizer
download source from http://php-security.org/downloads/evalhook-0.1.tar.gz
then unpack and install it
tar xvfz evalhook-0.1.tar.gz
cd evalhook
phpize
./configure
make
sudo make install
and you can use it from console.
php -d extension=evalhook.so encoded_script.php
where encoded_script.php is your encoded script.
every time it ask you
Do you want to allow execution? [y/N]
Type Y if your code after execution have some "base64_decode" in it.
Then when you get something like that
$GLOBALS['_889997777_'] = Array(
...
$GLOBALS['_224568216_'][21]('Xr' . 'x8f7g=')
);
Just run after that var_export($GLOBALS['_889997777_']);die; and you get all functions name, than you can replace it. Here is link that can automate it http://pastebin.com/kBj4iqWh

.mov file to .flv file conversion issue for ffmpeg using PHP

Is there any possible way to convert .mov file to .flv file conversion issue for ffmpeg using PHP. If yes, kindly let me know how to do?
Thanks in advance,
Fero
I agree with Kemo, though following the conventions of Stackoverflow, I'll offer the key bit provided by the link given:
ffmpeg -i <filename.mpg> -deinterlace -ar 44100 -r 25 -qmin 3 -qmax 6 <filename.flv>
I often transcode with ffmpeg and I don't ever bother to give all those flags, so you may find my typical use works well enough for you too:
ffmpeg -i inputFile.mov outputFile.flv
That's supposed to just change container formats and it tries to keep everything else as close as possible. I just did that and it seemed to work fine, though I'm uploading my flv somewhere it I'm having an issue, but that's probably totally unrelated to ffmpeg. Any tips?

Categories