Welcome Guest, Not a member yet? Register   Sign In
exec in PHP
#11

[eluser]Flemming[/eluser]
It might be worth looking at proc_open - it may not be disabled and allows similar functionality to exec!

http://uk.php.net/manual/en/function.proc-open.php
#12

[eluser]newbie boy[/eluser]
i tried this code...

Code:
if (function_exists(exec('ffmpeg -t 30 -acodec copy -i $inputfile $outputfile'))){

       echo 'function exists';

      } else {

          echo 'function not exists'; }

and the output is always function not exists...

appreciate every little help...
#13

[eluser]cahva[/eluser]
Code:
if (function_exists('exec'))
{
    exec('ffmpeg -t 30 -acodec copy -i $inputfile $outputfile')));
    echo 'function exists';

}
else
{
    echo 'function not exists';
}

You put the whole exec line to the function_exists function and thats why it didnt work.

For the earlier posts, if safe_mode is disabled, it doesnt matter what safe_mode_exec_dir is. It works only in safe mode.

In general, its better to use the whole path to the executable. Commands without path will only be executed if they are in /usr/bin/ (depending on OS used).
#14

[eluser]newbie boy[/eluser]
cahva,

yeah you're right... it's just for testing...

but still this code won't work...

Code:
$inputfile     = $uploadData[$i]['file_name'];
$outputfile = 'preview_' . $inputfile;
                    
$result = exec('ffmpeg -t 30 -acodec copy -i $inputfile $outputfile');    
                    
echo $result;

still no ouput data...
#15

[eluser]cahva[/eluser]
Well exec only return the last line so it can be that the last line is empty. Ofcourse you would still have something in the $outputfile.

Try to use the full path to ffmpeg eg. /usr/bin/ffmpeg

You could also try this:

Code:
ob_start();
$inputfile     = $uploadData[$i]['file_name'];
$outputfile = 'preview_' . $inputfile;
                    
passthru('/usr/bin/ffmpeg -t 30 -acodec copy -i $inputfile $outputfile');

$out = ob_get_contents();
ob_end_clean();

echo $out;
#16

[eluser]newbie boy[/eluser]
cahva,

i re-install ffmpeg again...

in DOS with this code

c:/ffmpeg/ffmpeg.exe –i d:/myfile.mpg d:/myfile.flv /y

i came across with this error

unable to find a suitable output format for ‘ui’

hope you could help me...

by the wat i'm using windows vista...
#17

[eluser]cahva[/eluser]
Im really not an expert with ffmpeg and I dont have it installed on my windowsbox so I dont know how to help you with that.
#18

[eluser]mysoogal[/eluser]
[quote author="newbie boy" date="1247229822"]cahva,

yeah you're right... it's just for testing...

but still this code won't work...

Code:
$inputfile     = $uploadData[$i]['file_name'];
$outputfile = 'preview_' . $inputfile;
                    
$result = exec('ffmpeg -t 30 -acodec copy -i $inputfile $outputfile');    
                    
echo $result;

still no ouput data...[/quote]


Code:
<?php
convertToFlv( "some-video-input.avi", "output.jpg" );

function convertToFlv( $input, $output ) {
   echo "Converting $input to $output<br />";
   $command = "c:\encoder\ffmpeg.exe -v 0 -y -i $input -vframes 1 -ss 5 -vcodec mjpeg -f rawvideo -s 286x160 -aspect 16:9 $output ";
   echo "$command<br />";
   shell_exec( $command );
   echo "Converted<br />";
}
?&gt;

this will get image from some-video-input.avi


Code:
&lt;?php
convertToFlv( "some-input-video.avi", "output.mp4" );

function convertToFlv( $input, $output ) {
   echo "Converting $input to $output<br />";
   $command = "c:\encoder\mencoder.exe $input -o $output -af volume=10 -aspect 16:9 -of avi -noodml -ovc x264 -x264encopts bitrate=500:level_idc=41:bframes=3:frameref=2: nopsnr: nossim: pass=1: threads=auto -oac mp3lame";
   echo "$command<br />";
   shell_exec( $command );
   echo "Converted<br />";
}
?&gt;

mencoder encoding on windows using php, im still learning ! good luck it should work

You will need to have php_ffmpeg.dll installed on your windows server ! check this out

http://poorboyonline.com/?page_id=20




Theme © iAndrew 2016 - Forum software by © MyBB