LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 09-29-2005, 07:44 AM   #1
darkisolde
LQ Newbie
 
Registered: Sep 2005
Posts: 5

Rep: Reputation: 0
Problem executing a linux script from php that runs ffmpeg


Hello,

I created a file called "convnow.sh" that converts multimedia files wmv to mpg and then mpg to avi. I use mencoder to convert wmv to mpg and ffmpeg to convert mpg to avi... so, when I run convnow.sh from console it runs mencoder and ffmpeg ok and converts the files as I want, and if I take commands from .sh file and type them in console one by one they also convert the files fine.

The problem is that if I call this "convnow.sh" file from a PHP page it only executes the mencoder command, the ffmpeg command seems not be executed for some reason. What I don't understand is why mencoder is executed and ffmpeg is not. I made a "ls -l" to see the user group/user name and they are the same "root:root". Another thing that could be important is that It seems that PHP uses user "apache", when I execute a "whoami" command.

Here is the PHP code that calls the "convnow.sh", the mencoder is executed but the ffmpeg isn't:

Quote:

$command1="sh ./convnow.sh";

function syscall($command){
if ($proc = popen("($command)2>&1","r")){
while (!feof($proc)) $result .= fgets($proc, 1000);
pclose($proc);
return $result;
}
}

$results=syscall("$command1");
I tried to execute ffmpeg only from the PHP page but I don't get any result, here is the code:

Quote:

$command1="ffmpeg -i ea.mpg out.avi";


function syscall($command){
if ($proc = popen("($command)2>&1","r")){
while (!feof($proc)) $result .= fgets($proc, 1000);
pclose($proc);
return $result;
}
}

$results=syscall("$command1");
print "$results";
If I use shell_exec it says "It doesn't work" normally it should, because in the command line it does:

Quote:

$command1="ffmpeg -i ea.mpg out.avi";
echo shell_exec($command1) or die("It doesn't work");
Any help would be apreciated.

Regards,
Darkisolde
 
Old 09-29-2005, 11:17 AM   #2
darkisolde
LQ Newbie
 
Registered: Sep 2005
Posts: 5

Original Poster
Rep: Reputation: 0
message from ffmpeg

Hello again!

When the ffmpeg is inside a "conv.sh" file it gives me now a message:

conv.sh: line 1: 16733 Segmentation fault ffmpeg -i ab.mpg out.avi

The php code that calls "conv.sh" is:

Quote:

$command1="sh conv.sh";

function syscall($command){
if ($proc = popen("($command)2>&1","r")){
while (!feof($proc)) $result .= fgets($proc, 1000);
pclose($proc);
return $result;
}
}

$results=syscall("$command1") or die ("Can't execute syscall");
if I replace $command1="ffmpeg -i ab.mpg out.avi" it says that can't execute syscall.

Any help would be apreciated,

Regards,
Darkisolde
 
Old 09-30-2005, 05:06 AM   #3
darkisolde
LQ Newbie
 
Registered: Sep 2005
Posts: 5

Original Poster
Rep: Reputation: 0
Any help, please?

Any help, please?
 
Old 09-30-2005, 08:47 AM   #4
darkisolde
LQ Newbie
 
Registered: Sep 2005
Posts: 5

Original Poster
Rep: Reputation: 0
Question ffmpeg problem

I'm using exec to execute ffmpeg program to convert mpg to avi files like this: exec ("ffmpeg -i /home/httpd/vhosts/zone/uploads/ea.mpg /home/httpd/vhosts/zone/uploads/out.avi 2>&1") or die ("Command died or crashed"); but the command it die/crash for an unknown reason. If I remove the -i option it will execute and shows up this: File '/home/httpd/vhosts/zone/uploads/ea.mpg' already exists. Overwrite ? [y/N] Not overwriting - exiting ffmpeg version 0.4.9-pre1, build 4730, Copyright (c) 2000-2004 Fabrice Bellard configuration: --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu ... could someone tell me why?
 
Old 10-04-2005, 07:43 AM   #5
darkisolde
LQ Newbie
 
Registered: Sep 2005
Posts: 5

Original Poster
Rep: Reputation: 0
Does anyone have any idea what could be causing this problem?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem executing mv command inside shell script pablogosse Linux - General 7 12-16-2009 12:21 PM
cron issue, php script runs fine in browser and cli dtra Linux - Software 1 07-15-2005 05:45 AM
PHP not Executing Sometimes Herbalist Programming 3 06-20-2005 07:41 PM
Executing PHP script- error message vfulco Linux - Newbie 3 07-13-2004 10:55 PM
creating shell script that executes as root regardless of who runs the script? m3kgt Linux - General 13 06-04-2004 10:23 PM


All times are GMT -5. The time now is 09:51 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration