tags:

views:

208

answers:

5

Hi all,

I want to convert a video to flv format. I am using ffmpeg to convert the video. I am using following code.

exec("C:/wamp/www/newtip/ffmpeg/ffmpeg -i C:/wamp/www/newtip/ffmpeg/videos/".$name." -ar 22050 -ab 32 -f flv -s 320x240 C:/wamp/www/newtip/ffmpeg/players/".$name_s.".flv");

It is working correctly in the local system. But in the server it is not working correctly.

In the server i changed the code as below

exec("http://www.mydomain.com/newtip/ffmpeg/ffmpeg -i http://www.mydomain.com/newtip/ffmpeg/videos/".$name." -ar 22050 -ab 32 -f flv -s 320x240 http://www.mydomain.com/newtip/ffmpeg/players/".$name_s.".flv");

In local I have given the Source path as C:/wamp/www/newtip/ But in server i have given the path as http://www.mydomain.com/newtip/ .I think in the server the path is wrong. Can anybody tell me how to give the path in the server?

A: 

Try to specify the correct directory and also specify the document root with:

$path = $_SERVER['DOCUMENT_ROOT'] . "your required folder path here";

Make sure that:

  • Folder has required permissions set, chmod to 755
  • exec is not disabled.
Sarfraz
A: 

You are confusing paths and urls. In place of http://www.mydomain.com/newtip/ffmpeg/ffmpeg, use the full path (something like... /home/username/mydomain.com/newtip/ffmpeg/ffmpeg). As Sarfraz recommends, you can use $_SERVER['DOCUMENT_ROOT'] to find the root for your path.

kingjeffrey
A: 

exec() runs on PHP which runs on the server, so use the path as if you're truly running it on the server with the local paths.

Delan Azabani
A: 

You do not necessarily have to embed full paths in your exec command. Use relative paths on your local and remote servers:

exec("ffmpeg -i ./ffmpeg/videos/{$name} -ar 22050 -ab 32 -f flv -s 320x240 ./ffmpeg/players/{$name_s}.flv");

On windows, the above example assumes that ffmpeg's path is present in Windows' PATH environment variable. If the example does not work on windows or linux, try specifying full path to ffmpeg (C:/Program Files/ffmpeg/ffmpeg.exe on windows, /usr/bin/ffmpeg on linux). Ask your hosting company what is the correct path of ffmpeg binary.

Also make the paths ./ffmpeg/videos and ./ffmpeg/players relative your php script.

Salman A
A: 

i had exact the same problem, it turned out to be the codec.

-acodec mp3 is working on local but the server required -acodec libmp3lame

Herr Kaleun