FFMPEG, any tips?
Moderator: General Moderators
-
scarface222
- Forum Contributor
- Posts: 354
- Joined: Thu Mar 26, 2009 8:16 pm
FFMPEG, any tips?
Hey guys, I want to install and use FFMPEG to convert movie files to flash format to be used in a player. I was wondering if anyone had ever done this and had any tips on how to start and implement the method for php, on a linux server or knew of any good tutorials.
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: FFMPEG, any tips?
I did this once. It is actually very simple. Just type 'man ffmpeg' on linux to get available options. Really you just need an input file and an output file, but there are other options for frames per second, sound settings, sizing etc... In PHP you would execute the ffmpeg command with exec(). The most obvious gotchas are that you want to give full file paths and make sure that the input file is readable by the webserver and the output location is writable by the webserver.
Code: Select all
exec("/path/to/ffmpeg -i /path/to/input/video.avi /path/to/output/video.flv");mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
scarface222
- Forum Contributor
- Posts: 354
- Joined: Thu Mar 26, 2009 8:16 pm
Re: FFMPEG, any tips?
ITS MY BOY abra, man you have experience in all these random extensions eh? Appreciate the tip. That sounds really straight forward. Do I need to install FFMPEG to the server or can I just place file and reference its path. Then you set the options, through 'man ffmpeg', I take it through a command console, then all you need to do is run that exec command and then based on the options it will convert your file to the directory?
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: FFMPEG, any tips?
I would install it using the package manager for your linux distro (apt-get, yum, etc...). If not, then you'll have to hunt around for a binary and the install instructions. 'man' is the linux command for 'manual pages'. This will display the manual telling you what the options are. You will use these options in the command you pass to exec().scarface222 wrote:ITS MY BOY abra, man you have experience in all these random extensions eh? Appreciate the tip. That sounds really straight forward. Do I need to install FFMPEG to the server or can I just place file and reference its path. Then you set the options, through 'man ffmpeg', I take it through a command console, then all you need to do is run that exec command and then based on the options it will convert your file to the directory?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
scarface222
- Forum Contributor
- Posts: 354
- Joined: Thu Mar 26, 2009 8:16 pm
Re: FFMPEG, any tips?
My server provider responded by saying they I could install the binary but not the entire suite. What exactly does this mean. Will I have the functions (convert video to flash) that I want with just the binary? This was the reply
If you would only like to install Ffmpeg binary and not the entire suite, you can install this yourself. We have instructions on our forum here:
http://forum.inmotionhosting.com/viewto ... nary#p5994
If you would only like to install Ffmpeg binary and not the entire suite, you can install this yourself. We have instructions on our forum here:
http://forum.inmotionhosting.com/viewto ... nary#p5994
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: FFMPEG, any tips?
Just follow those instructions and it should work fine.scarface222 wrote:My server provider responded by saying they I could install the binary but not the entire suite. What exactly does this mean. Will I have the functions (convert video to flash) that I want with just the binary? This was the reply
If you would only like to install Ffmpeg binary and not the entire suite, you can install this yourself. We have instructions on our forum here:
http://forum.inmotionhosting.com/viewto ... nary#p5994
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
scarface222
- Forum Contributor
- Posts: 354
- Joined: Thu Mar 26, 2009 8:16 pm
Re: FFMPEG, any tips?
I have a question, it simply says point your program to the FFMPEG binary, however, if I want to change options, through man ffmpeg then is that possible with just the binary, because the only directory reference to the binary file I would be making is through the exec function you showed me. So how would the server no where it is if I wanted to change video quality. I assume you access the file through the command line?
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: FFMPEG, any tips?
I answered this already several posts up. 'man' does not set options, it displays the "manual" for the command. All options you set would be in the exec() call.scarface222 wrote:I have a question, it simply says point your program to the FFMPEG binary, however, if I want to change options, through man ffmpeg then is that possible with just the binary, because the only directory reference to the binary file I would be making is through the exec function you showed me. So how would the server no where it is if I wanted to change video quality. I assume you access the file through the command line?
This is a "manpage" http://linux.die.net/man/1/ffmpeg. This (in text form) would be what you would get if you type 'man ffmpeg' in linux (if it is installed).
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
scarface222
- Forum Contributor
- Posts: 354
- Joined: Thu Mar 26, 2009 8:16 pm
Re: FFMPEG, any tips?
Thanks for your time again abra, I just was not sure if the options were passed in exec or not, thanks for clearing that up. I will try it out and let you know.
-
scarface222
- Forum Contributor
- Posts: 354
- Joined: Thu Mar 26, 2009 8:16 pm
Re: FFMPEG, any tips?
ok I tried this command after uploading just the ffmpeg binary as referenced in the instruction. The statement below is basically the one you told me to try except instead of the file directory for the file that hasn't been uploaded, I replaced it with the file itself. In the statement I referenced the binary file.
exec("../ffmpeg/ffmpeg -i ".$_FILES['Filedata']['name']." ../usercontent/$username/video/video.flv")
or die ("Couldn't upload ".$_FILES['Filedata']['name']."\n");
it did not work
Will it work in this manner? Or do I need to upload it to a temporary directory, convert it, and delete the old file...
exec("../ffmpeg/ffmpeg -i ".$_FILES['Filedata']['name']." ../usercontent/$username/video/video.flv")
or die ("Couldn't upload ".$_FILES['Filedata']['name']."\n");
it did not work
Will it work in this manner? Or do I need to upload it to a temporary directory, convert it, and delete the old file...