I am trying to run this in cakephp
function test()
{
$mainDirectoryPath = WWW_ROOT . "media";
$filePath = "userId_10/vid_1444387525.mp4";
$newPath = "userId_10/Output.mp4";
$value = exec("ffmpeg -i $filePath -s 320x320 -vcodec mpeg4 -acodec aac -strict -2 -ac 2 -ar 44100 -ab 128k $newPath");
$this->jsonOutput($value);
}
i am getting nothing $value is empty,
however in shell if i run this as shell_exec() in a php file it works.
what is wrong above
UPDATE:
Ok now i have created a file with following code
<?php
$mainFile = $_REQUEST['mainFile'];
$newPath = $_REQUEST['newFile'];
echo shell_exec("ffmpeg -i $mainFile -s 320x320 -vcodec mpeg4 -acodec aac -strict -2 -ac 2 -ar 44100 -ab 128k $newPath");
#unlink($mainFile);
?>
If i run this with mainFile and newFile it works.
However when i run it in function as
$val = "php video.php?mainFile=$filePath&newFile=$newPath > /dev/null 2>&1 &";
exec($val);
Nothing happens.
Check php.ini file and disable_functions have not exec comamnd.
For security reason site admin disabled exec command in php.ini.
Remove exec from disable_functions in php.ini file.
Related
When I run exec() through php, I fail to get the output (stderr) into a file.
I've included "2> my_out_put_file.txt" at the end of my command to accomplish this. But when I include this, the command is not executed. However, if I run the command without "2> my_out_put_file.txt" then it works.
The interesting thing is that the whole command, even with "2> my_out_put_file.txt" at the end of the command works if I run directly via shell/promt, but not when I run it through php / apache.
Does not work:
exec("C:/FFmpeg/bin/ffmpeg -i $new_path/$filename_with_ext -f mp4 -vcodec libx264 -preset ultrafast -profile:v main -acodec aac $new_path/$filename.mp4 2> out.txt", $a, $b);
Works:
exec("C:/FFmpeg/bin/ffmpeg -i $new_path/$filename_with_ext -f mp4 -vcodec libx264 -preset ultrafast -profile:v main -acodec aac $new_path/$filename.mp4", $a, $b);
Best regardsNeo
This worked for me:
... 2>&1 >> log.txt
Tested from exec too:
php -r "exec('ffmpeg -version 2>&1 >> log.txt');"
hai i am using ffmpeg command in php exec() for converting any type of video to flv format the command i'm using i sworking fine in the command prompt but when i run the same commend it returns nothing..actully the output is Array( ) and the the third parameter $result is "1"
i've read similar questions like this on stackoverflow but it's not helping
most of the time i noticed that the issue is in path and the safe mode of php
and i have disabled safe mode using .htaccess the syntax is given below and i am using windows 7 os
the directory to the ffmpeg application is c:\ffmpeg\bin\ffmpeg
the full script and output is given below:
the ffmpeg command:
ffmpeg -i c:\xampp\htdocs\video\original\robot.mp4 -c:v libx264 -ar 44100 -crf 17 c:\xampp\htdocs\video\vids\robot.flv
the php script:
echo "starting ffmpeg...<br/>";
echo exec("ffmpeg -i c:\xampp\htdocs\video\original\robot.mp4 -c:v libx264 -ar 44100 -crf 17 c:\xampp\htdocs\video\vids\robot.flv",$out,$r);
var_dump($out);
echo $r."<br/>";
echo "done...<br/>";
?>
the htaccess for switching off the safe mode:
php_value safe_mode "0"
the output:
starting ffmpeg...
array(0) { } 1
done...
Try the below one instead of using exec(ffmpeg -i 'inputfile' 'outputfile');
$cmd = "ffmpeg -i c:\xampp\htdocs\video\original\robot.mp4 -c:v libx264 -ar 44100 -crf 17 c:\xampp\htdocs\video\vids\robot.flv"
ob_start();
passthru($cmd);
$cmd_retr = ob_get_contents();
print_r($cmd_retr);
<?php
echo exec("cmd /c ffmpeg -i c:\\xampp\htdocs\video\original\robot.mp4 -c:v libx264 -ar 44100 -crf 17 c:\\xampp\htdocs\video\vids\robot.flv",$out,$r");
?>
I am trying to create videos from images sequence. I tried all the below code given in $ff_command variable.
$path = dirname(__FILE__);
$ff_command = "ffmpeg -f image2 -i {$path}/img%03d.jpg video.mpg";
$ff_command = "ffmpeg -r 10 -b 1800 -i {$path}/img%03d.jpg test1800.mpg";
$ff_command = "ffmpeg -i {$path}/img%03d.jpg -s 1280x720 -aspect 16:9 -r 24 -vb 20M teste.mp4";
$ff_command = "ffmpeg -f image2 -i {$path}/img%03d.jpg -vcodec mpeg4 -b 800k video.avi";
$ff_command = "ffmpeg -f image2 -i {$path}/img%03d.jpg -vcodec libx264 -b 800k video.avi";
Most of these commands are creating a video file. But when I open that video nothing comes or first image is coming for a split second and nothing after that
Please let me know what I am doing wrong here
I noticed that video is too short to see. Is it possible to increase the video duration so that we can see all the images?
I am trying to get FFMPEG to work in php. I just installed ffmpeg and x264 and ran the following command in my terminal:
$command = 'ffmpeg -i /home/gman/Desktop/cave.wmv -acodec libfaac -aq 100 -vcodec libx264 -preset slow -crf 22 -threads 0 /home/gman/Desktop/newvideo.flv
It worked perfectly and created a new flv video from the inital video, just like I wanted.
Now when I try the same thing in php, nothing happens...
$safe_path = escapeshellarg("/home/gman/Desktop/newvideo.flv");
$command = 'ffmpeg -i /home/gman/Desktop/cave.wmv -acodec libfaac -aq 100 -vcodec libx264 -preset slow -crf 22 -threads 0 ' . $safe_path;
exec($command);
Anyone have any ideas? Can I somehow see what exec is doing and see some sort of output? Would appreciate it.
Usually when you are calling ffmpeg in an exec you need to put in the absolute path to ffmpeg eg:
$safe_path = escapeshellarg("/home/gman/Desktop/newvideo.flv");
$command = '/usr/local/bin/ffmpeg -i /home/gman/Desktop/cave.wmv -acodec libfaac -aq 100 -vcodec libx264 -preset slow -crf 22 -threads 0 ' . $safe_path;
exec($command);
http://blog.codyjung.com/2011/05/29/problems-with-lampp-and-exec/
My solution was to simply copy the ones from /usr/lib/i386-linux-gnu and overwrite the LAMPP ones. Could that cause problems later? Maybe, but I guess we’ll deal with that when it shows up.
On my website I'm using phpmotion to convert videos into FLV files.
What I want to do is that after the successful conversion of any new FLV file add short FLV file at the beginning.
So, I need FFMPEG command in PHP which will join the file 1.flv (intro file) with 2.flv (successful converted file) and as a result create final.flv
I tried with:
ffmpeg -i 1.flv -i 2.flv -vcodec copy -acodec copy final.flv
But without result.
Thanks for any suggestion.
Here is the code, you have to seperate audio and video to raw files at first, join them then again convert back to flv
mkfifo temp1.a
mkfifo temp1.v
mkfifo temp2.a
mkfifo temp2.v
mkfifo all.a
mkfifo all.v
ffmpeg -i 1.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp1.a < /dev/null &
ffmpeg -i 2.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp2.a < /dev/null &
ffmpeg -i 1.flv -an -f yuv4mpegpipe - > temp1.v < /dev/null &
{ ffmpeg -i 2.flv -an -f yuv4mpegpipe - < /dev/null | tail -n +2 > temp2.v ; } &
cat temp1.a temp2.a > all.a &
cat temp1.v temp2.v > all.v &
ffmpeg -f u16le -acodec pcm_s16le -ac 2 -ar 44100 -i all.a \
-f yuv4mpegpipe -i all.v \
-sameq -y output.flv
rm temp[12].[av] all.[av]
I guess you can use mencoder to merge two files.
mencoder -oac copy -ovc copy -o c:\video.flv c:\a.flv c:\b.flv