ffmpeg sample code
![]()
Install ffmpeg library in your server first.
Place a video file of any type on current directory (or anywhere), here it is clock.avi .
Click more for source code:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
extension_loaded('ffmpeg') or die('Error in loading ffmpeg');
$ffmpegInstance = new ffmpeg_movie('clock.avi');
echo "getDuration: " . $ffmpegInstance->getDuration() .
"getFrameCount: " . $ffmpegInstance->getFrameCount() .
"getFrameRate: " . $ffmpegInstance->getFrameRate() .
"getFilename: " . $ffmpegInstance->getFilename() .
"getComment: " . $ffmpegInstance->getComment() .
"getTitle: " . $ffmpegInstance->getTitle() .
"getAuthor: " . $ffmpegInstance->getAuthor() .
"getCopyright: " . $ffmpegInstance->getCopyright() .
"getArtist: " . $ffmpegInstance->getArtist() .
"getGenre: " . $ffmpegInstance->getGenre() .
"getTrackNumber: " . $ffmpegInstance->getTrackNumber() .
"getYear: " . $ffmpegInstance->getYear() .
"getFrameHeight: " . $ffmpegInstance->getFrameHeight() .
"getFrameWidth: " . $ffmpegInstance->getFrameWidth() .
"getPixelFormat: " . $ffmpegInstance->getPixelFormat() .
"getBitRate: " . $ffmpegInstance->getBitRate() .
"getVideoBitRate: " . $ffmpegInstance->getVideoBitRate() .
"getAudioBitRate: " . $ffmpegInstance->getAudioBitRate() .
"getAudioSampleRate: " . $ffmpegInstance->getAudioSampleRate() .
"getVideoCodec: " . $ffmpegInstance->getVideoCodec() .
"getAudioCodec: " . $ffmpegInstance->getAudioCodec() .
"getAudioChannels: " . $ffmpegInstance->getAudioChannels() .
"hasAudio: " . $ffmpegInstance->hasAudio(); |
//___________________________________Code end here_____________________________________
I also can be used for file format conversion
Eg: exec(‘ffmpeg -i ‘.$SourcePath.’ ‘.$Destination);
Here $SourcePath any file of any format , and destionation also another format.
eg: exec(‘ffmpeg -i saji.3gp saji.flv’);


Hi,
I’m seaching how to transcode various videos type to .flv.
Do you know where can I find informations about all parameters to use in the exec (ffmpeg…)
thank your for your help
best regards
Michel
Does anyone know the command to implement the water mark feature. I’ve installed eveything and it works fine i just need to know how to use the water mark feature.
thanks
friend, i am using a pre compiled ffmpeg in my shared server(RHEL) and the output flv that i got has no audio(libmp3lame.so is missing).
Since i dont have shell access to the server i asked our hosting team to install it for us.The installation path looks like usr/local/bin .. and /lib for libraries..all the required files are there but i am not able to execute ffmpeg within my php program.
can u please suggest a solution for this.
The installation of ffmpeg is pretty crap. You need to compile the ffmpeg with libmp3lame enabled. Since you didnt have root access, its more difficult, and your hosting solution provider may not aware of this installation procedure. So instead of ffmpeg, you can use mencoder. Tell them to install mencoder in your server. The usage of mencoder can be found from this blog itself. http://www.sajithmr.com/mencoder-video-convertion-tool/
Hi
Thanks for ur reply.
Can we get a ffmpeg exectable binary which also contain libmp3lame.Which means it will b a single exectable library.
Hello Naveen
You can get ffmpeg executables for windows. But for linux machine you need to install it after proper compilation. Since it is utter configurable and flexible, you need to MAKE it for your own use. FFMPEG Sound problem is a big problem in various linux os. Download full ffmpeg from source forge and compile it by enabling all the options. Since you did nt have root access, it is depending with your provider. More over application like ffmpeg , mencoder etc, root accessed server is a must !!!
hello sajith,
do u know how to create an html thumbnail view , provided an url as input in php or javascript.Similar to a screen shot .
We are trying it on a linux server.
These links may help you:
http://pcwin.com/software/Html_To_Jpeg/index-1.htm
http://www.guangmingsoft.net/htmlsnapshot/html2image.htm
http://www.filetransit.com/files.php?name=Html_To_Jpeg
http://www.amazon.com/gp/browse.html?node=236156011
Hello Sajith,
While uploading my small files are convert into flv with out any issue..
But with big files (>1MB) is not converting.. please help me..
This is my code…
$srcWidth = “320″;
$srcHeight = “240″;
$srcAB = “32″;
$srcAR = “22050″;
exec($ffmpegPath . ” -i ” . $srcFile . ” -ar ” . $srcAR . ” -ab ” . $srcAB . ” -f flv -s ” . $srcWidth . “x” . $srcHeight . ” ” . $destFile . ” | ” . $flvtool2Path . ” -U stdin ” . $destFile);
Thanks in advance
I dont think size of file is a problem for ffmpeg. Instead checking through your web browser with exec command, go to shell / command prompt and check using ffmpeg function call directly.
I think your problem is web server’s file uploading, see your webserver’s uploading file size limit in configuration . Do unit testing , means test one by one, first convertion on multiple type/size files using ffmpeg command directly, and if everything works fine, test with php library. OKay
(you can use mencoder also for video convertion)
http://www.sajithmr.com/mencoder-video-convertion-tool/
Thanks
Sajith
Thanks sajith,
I tried it all that way.. I changed webserver’s uploading file size limit to 10M
1. Files 1MB moves to the desired folder but when it comes to the converted folder size seems to 0kb
That means it’s not get converted , am i right?
Please help me!!!
You can see the error message while you apply the command ffmpeg direclty from command prompt. see the error log or messages arrive when you try to convert big file.
I repeat , never try it through php or apache , try directly from command prompt to see what actually happening behind. if there is a convertion, it shows result like input:thisfile.3gp output: thatfile.flv etc etc audio: video: etc. Okay
Thanks
Sajith
Sajith,
Undefined method ‘timestamp’ for nil:Nillclass
and alist of errors…
help me..
Sorry Chanchel, I am not familiar with this error
And when i googled it , nothing listed. Try some other files , i dont think it’s compilation error of ffmpeg, or try mencoder.
Hi Mr Sajith,
Im wondering if you can point out much clearer on how to convert videos using ffmpeg through php script. Ive been trying to do this for a week and still no progress. I tried:
exec(“ffmpeg -i ‘inputFile.avi’ ‘outputFile.flv’”);
but to no effect. Is there a problem with exec() function in PHP in converting this videos? I tried using your tutorial and I managed to run it properly but converting them is really painful.
Need some help.
Hi Jonathan,
ffmpeg is not a php function or script to convert video files. It is an application. Before you convert files from php, you have to check the ffmpeg binary working from your command prompt(windows) or shell (linux) , by typing
ffmpeg -i ‘inputFile.avi’ ‘outputFile.flv
For its 100% working , you have to install ffmpeg properly with libamr, lame etc support for all file format including 3gp (if you want). If it works fine in shell, your ffmpeg is okay. Exec is only a php function for executing shell commands. So if the former settings are okay, the rest will work without any error.
i use win xp run ffmpeg successfuly in dos but in php exec not working plz help me
I have tried working with ffmpeg on a shell client, command prompt to be more specific and it is working fine on a command line. What I need to do is to access ffmpeg through php script. I have a webserver which records a video and I need to convert those videos to other formats.
Thanks.
And when i tried ffmpeg in windows, everything worked very well. But when i tried in linux everything ok except the audio for flv output. When we convert some files into flv , there was no audio output. Since our server for mobshare was linux, i installed all the libraries for sound (mp3lame, amrlib etc).
On that time, i got mencoder, another video converting tool in linux (Backend of mplayer), and it worked very well with all format. So in our site http://www.mobshare.in , we are using mencoder for video conversion . See my post on mencoder from
http://www.sajithmr.com/mencoder-video-convertion-tool/
Hi Jonathan,
Then you are using windows os in your php server. Then you have to do some more security thing with apache configuration. You have to change the safe_mode option in httpd.conf file for executing exec commmand from php script. If there is any antivirus etc running , these all affect the execution of exec command.
When safe mode is enabled, you can only execute executables within the safe_mode_exec_dir
See this: http://in.php.net/function.exec
And do the needful for windows security configuration
Regards
Sajith
Sorry If I havent informed the situation very well. The webserver is running on Debian Linux. I used red5 server to accomplish the Record and Audio Capture things. Now what I need to do is to convert the files recorded to other formats using ffmpeg through php classes/scripts.
I have checked the phpinfo(); of the site and the safe mode is turned to off. I am wondering what I could be missing in here. Is my exec(); line command enough or is there something I might have not include? Shall I use flvtool2 too? Like I have seen others have done after converting a file? if so, how would it be?
If the ffmpeg is working well through shell, your ffmpeg installation and configuration is okay. Now from your comment, i got that, you could not initiate or execute same thing via php code. And your exec is not working as you expected, right ?
try $result = exec(“whoami”); and echo the $result
When you run exec from php, the user of linux will be apache (not all time, commonly apache) and when you try this using command prompt, the user will be root or some other else. Here also the permission problem.
anyway echo the result of exec, sothat you can see what is the error. place the files to be converted under apache’s web root and give needful permissions. (try with 777)
Some simple debugging can solve your problem. Please be patient and check apache’s error log after call exec function. if error log is disabled, enable it from httpd.conf and point a file to show error log.
In another terminal , open that error file using tale command ( http://www.sajithmr.com/tail/ ) so that you can see the live error reporting.
From these , i am damn sure, you can solve your exec ffmpeg issue. Be confident and go on
Regards
Sajith
Thank you and I will try what you have advised. I will inform you the progress as I go along and thanks for the help. Also, the cheering helps.
Jonathan
Hi mr Sajith,
I tried executing ffmpeg via SSH client. When i type ‘ffmpeg’ an error occurs which says:
“ffmpeg: error while loading shared libraries: libvorbisenc.so.2: cannot open shared object file: No such file or directory”.
Does it mean I didnt compile libvorbis or other stuffs the way it should be? If so.. What should I do so that ffmpeg can detect it?
Thanks in advance.
Jonathan
At last you found your ffmpeg is not working properly from ssh. This is what i am telling from the beginning. This is called atomic testing. Test one by one before testing the whole system. So make sure to compile ffmpeg by enabling all the libraries.
The compilation process is not that much simple. You need to compile it very carefully.
Do I have to do the ‘./configure && make && make install’ to each and everyone again? FFmpeg seems to be trying to open a file from the shared libraries which is called libvorbisenc.so.2. I dont know where to start, Im thinking what folder is the shared libraries and if I can just put the file which ffmpeg is searching for?
a single line can enable all the libraries … like
–enable mp3laame -enable lib etc
See this link: http://groups.google.com/group/ffmpeg-php/web/installing-ffmpeg-and-ffmpeg-php-on-centos
It might be a useful one for you.
Use google properly for perfect installation. when ever an error comes, paste the exact sentence on google. it will lead you to the exact page.
Regards
Sythoos
Hi,
I used this command on my shell ldd ‘which ffmpeg’ and it gives me this output:
linux-gate.so.1 => (0xffffe000)
libavdevice.so.52 => /usr/lib/libavdevice.so.52 (0x4001d000)
libavformat.so.52 => /usr/lib/libavformat.so.52 (0×40024000)
libavcodec.so.51 => /usr/lib/libavcodec.so.51 (0x400bd000)
libavutil.so.49 => /usr/lib/libavutil.so.49 (0x4054d000)
libm.so.6 => /lib/libm.so.6 (0x4055c000)
libc.so.6 => /lib/libc.so.6 (0×40581000)
libz.so.1 => /usr/lib/libz.so.1 (0x4069c000)
libdl.so.2 => /lib/libdl.so.2 (0x406b0000)
libmp3lame.so.0 => /usr/lib/libmp3lame.so.0 (0x406b4000)
/lib/ld-linux.so.2 (0×40000000)
libvorbisenc.so.2 => not found
libvorbis.so.0 => not found
It seems that the last two files were missing, and I just want to ask/confirm that if I just get this files and just put it inside the ‘/usr/lib’ folder, does it have any possibility of solving the problem? I tried recompiling the libvorbis but to no effect. Thanks
I dont know linux libraries in deep. In my case i used ubuntu. All were in a simple step using apt-get install ffmpeg … So it is working fine there.
http://wiki.kartbuilding.net/index.php/Ffmpeg
The manual configuration sometimes become very crap. And in my radhat server i used mencoder for video conversion.
Once the ffmpeg installed well, i can help you in php part. But all the minimum thing needed is, set the ffmpeg RUN
Hi,
Finally ffmpeg run through shell command and now I can execute it via php script. Im just thinking and maybe you can help me out. Here is the situation:
The thing is I am recording a video via red5 server and it automatically saves the video to a .flv file. I converted a lot of .flv video via ffmpeg but the video recorded through the server is different. Along with the flv file it has its .meta file.
I dont know what it was but all I know if I have for example a ‘test.flv’ along with it is ‘test.flv.meta’ and when i try to convert it via ffmpeg it says unsuported format. Do you have any ideas what should be done or is it possible for ffmpeg to convert it?
Hi Jonathan,
I have no experience with red server. From my bare knowledge , i guess the following things:
If there is a meta file with .flv , it will be an xml format file or something to save the extra attribute of .flv file. It might be latest flash player’s settings. In new flash players (8) the meta file also load with the flv file and retrieve attributes from that meta and plays . The process is called flv meta injector.
And ffmpeg conversion problem. Since ffmpeg is an opensource and its development is still on, latest flv version might not be supported. These all are my guess, not from real knowledge. Check your red server configuration for recording video in older flv format , or without meta injection or something.
And for which website, you are doing these things ? If it is private, need not to mention. Just asked.
Anyway
Go on
Sajith
Its me again,
I just wanted to ask if it is possible to join two audio file in ffmpeg or mencoder.. I’ve successfully joined two video file through mencoder but I cant find a possible command to join two audio file. I tried something like:
copy audio1.mp3 audio2.mp3 > final.mp3
But it just create a file that has 1Kb.
Is there a way to join audio files using this applications??
Hi Sajith,
I have requrment to to record a video file from remote client machine’s webcam(from browser) to the server machine.Is it possible by using ffmpeg.Iam using PHP and apache server for my development.Is it possible by using ffmpeg.any idea.
Thanks,
VKS.
Hi Jonathan,
One question, how u use the RED server from PHP.I think it is running in JAVA, is it possible to use from PHP?
Thanks,
VKS
Hi Jonathan, i did nt try audio joining yet.
And please clear the doubt of VKS in this thread regarding red server.
Thanks
Sajith
Hi VKS, regarding your question, I am running it via Macromedia Flash, Flash connects through red5 server that is how web recording is achieved. Anyway, I didnt use PHP in web recording, but if I would, I believe Flash would stand as a middleman between PHP and Red5. But I do not have enough knowledge as of now, Im still exploring it.
And by the way, Sajith, I have achieved audio concatenation/joining through mencoder.
But do you have any idea if mencoder can join two audio and play them together, like overlaying an audio to another audio? That they would play together at the very start of the track?
Joathan, from these thread i got the info that you are a very good programmer, and regarding this mencoder merging, might be you are the apt person to solve this audio merging b’cause i stopped all the mencoder works when my video to flv conversion done
Anyway, was a good discussion with you .
I see.. Anyway I just want to let you know that I appreciate what you contributed and it really helped me from the very start. Thanks and this thread is awesome.
Hello sajith,
do u know any free tools that can be used to convert pdf to swf .if u have done any flick magazine app before in flash and php please let me know the issues come under it.
thanks
I have no idea about PDF to SWF (FLASH) Conversion. Sorry naveen
Holo
I want to use the information from exec(‘ffmpeg -i file1 file2′,$output,$return_var);
If I run the ffmpeg command from shell it is OK a lot of information is dispayed after, echo return_var is 0 so it is OK but the $output is always empty in PHP.
Any ideeas?
ovidiu
Hi Sajith,
I converted video files into flv in cmd prompt successfully .But when i try to use to convert this in my php file by using exec command
it wont be converted.can u plaese help me about this.Here is my code. The exec for “hello World” is executed successfully.But the 2nd
exec command could not be executed.
$in = “../FFmpeg/monkeydog.wmv”;
$out = “../FFmpeg/mn.flv”;
$ffmpegPath = “../FFmpeg/ffmpeg”;
echo exec(‘echo Hello World!’);
exec(‘$ffmpegPath -i $in -ar 22050 -ab 32 -f flv $out’);
Hi Sajith,
i want to convert wmv file to flv but i am not success.
please help to this conversion.
ffmpeg is already installed on server
please open the iduce.com/test.php
from here you can download the file and check what is the mistake and you can also check my server inf at given bottom link
thanks
and regards
how to keep play,stop,pause buttons for swf file.
please help me
Hello Sajith!
Don’t worry I am not going to ask you any questions, not yet…
I just got started to read about ffmpeg, I am considering it as one of my strong options for a project I am doing.
So while I was doing my search I stumbled on this form.
I was both amazed and surprised by how you don’t only have the knowledge but also share it freely! I like went through all the question and answers… Lots of details and crystal clear answers.
So to sum it up I just want to say “GREAT JOB”
And thank you!
All the best,
Tamer Qtaish
Thank you Tamer, Ideas and knowledge are always for sharing… it grows as you share it… don’t let anyone to re-invent the same wheel , so share
Why you do not use fflib.net? Try http://www.intuitive.sk/fflib/
i have done flv conversion in command prompt.But once i tried with php script,conversion has not been done
hi sajith i have doubt first i want to know spouse i host my website and ffmpeg not installed can i install or i have to contact webhosting service and how i can change mov,avi in flv with specific resolution
i am the newbie for ffmpeg,i want to know it is a script or application,where can i run this file in my local server(mypc)
give basic idea,i am using windows,i need reply from u brother
i hate linux and i hate those who built this stupid ffmpeg only for linux ! fuck you geek
It seems as if you need to get a web host that has the ffmpeg library for php so that you can execute the ffmpeg commands with exec(). I found documentation of ffmpeg: http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html that helped out a lot. I assume that the exec() function requires parameters that can be found in the ffmpeg documentation such as:
exec(ffmpeg -f oss -i /dev/dsp -f video4linux2 -i /dev/video0 /tmp/out.mpg)
Question I am trying to solve is this. We have flash based property tour tool that takes photos of property listings and displays them in sequence. Is there a way to take the swf that is displayed typically in a browser window and capture 30 seconds of it and convert to mpg using ffmpeg? Thanks in advance.
or please let me know if there is another way to accomplish this… thanks.
Hi,
first of all i would thank you every one, i have learn lot from this discussion.
i’m having the same problem exec(‘ffmpeg ..’) is not working on my server. i have read all the previous comments & tried those actions
but the problem is still remaining. ffmpeg is working fine in my terminal & not working through my php code with exec(‘ ‘)
i have check error_log file; it’s saying(also tried with whoami..)
sh: /whoami: No such file or directory
sh: /pwd: No such file or directory
sh: /ffmpeg: No such file or directory
the file path is correct & it has this file permissions(i hv tried with chmod -R 777 filename)
-rwxrwxrwx 1 apache
please help me to solve this!
my server details are:
Linux and OS is Fedora ,Apache/2.2.3 (Fedora),PHP Version 5.2.6
Hey
I have implemented the ffmpeg in the site, But it is not working well, Problem is the it takes too much time to upload the videos.can any one tells me how i can make it fast
hi
how do i strip a certain section of a video(m3). say to post 5-10 sec audio to listen b4 some1 dwnloads it.. using ffmpeg
thanx
vasu
@Rohit
To work the uploading fast, do a queuing machanism for converting videos. See the implementation in mobshare.in
Register there and upload a pic, it wont come that time, instead a processing symbol will be shown. The real image will be displayed after a little bit time of processing
Hey
Thanks for reply me. This is my site link http://www.iceageadultvideo.com.Please register here and upload any video. I am facing two problems in this site.One it takes too much time in uploading the videos and second in flash player i wanna fast speed flash player. I will be very thankful to you if u can help me in this
Hey
when i enter the above like this
extension_loaded(‘ffmpeg’) or die(‘Error in loading ffmpeg’);
$ffmpegInstance = new ffmpeg_movie(‘http://iceageadultvideo.com/flvideo/102.flv‘);
echo “getDuration: ” . $ffmpegInstance->getDuration() .
“getFrameCount: ” . $ffmpegInstance->getFrameCount() .
“getFrameRate: ” . $ffmpegInstance->getFrameRate() .
“getFilename: ” . $ffmpegInstance->getFilename() .
“getComment: ” . $ffmpegInstance->getComment() .
“getTitle: ” . $ffmpegInstance->getTitle() .
“getAuthor: ” . $ffmpegInstance->getAuthor() .
“getCopyright: ” . $ffmpegInstance->getCopyright() .
“getArtist: ” . $ffmpegInstance->getArtist() .
“getGenre: ” . $ffmpegInstance->getGenre() .
“getTrackNumber: ” . $ffmpegInstance->getTrackNumber() .
“getYear: ” . $ffmpegInstance->getYear() .
“getFrameHeight: ” . $ffmpegInstance->getFrameHeight() .
“getFrameWidth: ” . $ffmpegInstance->getFrameWidth() .
“getPixelFormat: ” . $ffmpegInstance->getPixelFormat() .
“getBitRate: ” . $ffmpegInstance->getBitRate() .
“getVideoBitRate: ” . $ffmpegInstance->getVideoBitRate() .
“getAudioBitRate: ” . $ffmpegInstance->getAudioBitRate() .
“getAudioSampleRate: ” . $ffmpegInstance->getAudioSampleRate() .
“getVideoCodec: ” . $ffmpegInstance->getVideoCodec() .
“getAudioCodec: ” . $ffmpegInstance->getAudioCodec() .
“getAudioChannels: ” . $ffmpegInstance->getAudioChannels() .
“hasAudio: ” . $ffmpegInstance->hasAudio();
in my site of one video. It gives me following description.please tell me how i can get excellent quality video from this which will buffer too much
getDuration: 14.89getFrameCount: 445getFrameRate: 29.9166660309getFilename: http://iceageadultvideo.com/flvideo/102.flvgetComment: getTitle: getAuthor: getCopyright: getArtist: getGenre: getTrackNumber: 0getYear: 0getFrameHeight: 1200getFrameWidth: 1600getPixelFormat: yuv420pgetBitRate: 64000getVideoBitRate: getAudioBitRate: 64000getAudioSampleRate: 22050getVideoCodec: flvgetAudioCodec: mp3getAudioChannels: 2hasAudio: 1
Hey
Any one tell me which is best bit rate in ffmpeg so videos will low in buffering in video player
@ Rohit…. `best` is such a subjective term. Low quality bitrates are less than 300k, but then your video will get pixelated. If you use the -sameq switch in your ffmpeg command, then the quality will be as high as the original, but then it could stream slowly depending upon your server, the bandwidth coming out of it, the bandwidth of your users, and their machine spec’s. I like 500k bitrates, personally.
@Sajith: Thanks for the function list. Now I can make my encoding engine smarter.
Hey
Any one can tell me solution of pixlated video.Please see this link http://www.iceagevideo.com.In this video is pixlated. I am using ffmpeg to convert the video format to flv.I am also using -sameq in the ffmpeg command. Any one tell me solution then video will be clear
hi.
thanks for your work. i am happy. I hope you will work better in coming days.
Narayana
kathmandu
Nepal
Please help me
How can I join two flv files ?
iam looking for ffmpeg php windows dll files, how to setup ffmpeg in wamp could you please help in this regard.
hi,
i have windows sever, i am using php for developing any video to flv using ffmpeg. please provide the php code for converstion any video to flv on fly.
thank you.
hi,
i need conversion of any video to ‘.flv’ using FFMPeg on fly in php code. this is need to done by uploading a video
thank you.
Hello Expert,
I am trying to convert into .flv file from other format.
i am using this command
$srcFile = “/home/amitadut/public_html/gallery_video/robot.avi”;
$destFile = “/home/amitadut/public_html/gallery_video/robot.flv”;
$ffmpegPath = “/usr/local/bin/ffmpeg”;
$flvtool2Path = “/usr/local/bin/flvtool2″;
// Create our FFMPEG-PHP class
$ffmpegObj = new ffmpeg_movie($srcFile);
// Save our needed variables
$srcWidth = makeMultipleTwo($ffmpegObj->getFrameWidth());
$srcHeight = makeMultipleTwo($ffmpegObj->getFrameHeight());
$srcFPS = $ffmpegObj->getFrameRate();
$srcAB = intval($ffmpegObj->getAudioBitRate()/1000);
$srcAR = $ffmpegObj->getAudioSampleRate();
// Call our convert using exec()
exec($ffmpegPath . ” -i ” . $srcFile . ” -ar ” . $srcAR . ” -ab ” . $srcAB . ” -f flv -s ” . $srcWidth . “x” . $srcHeight . ” ” . $destFile . ” | ” . $flvtool2Path . ” -U stdin ” . $destFile);
But file is creating with 0 kb filesize.
can you tell me why 0 kb is creating??????????/
i have also print some propeties of ffmpeg for you
srcWidth: 160
srcHeight: 112
srcFPS: 25
srcAB: 32
srcAR: 32000
getDuration: 9.60000038147
getFrameCount: 240
getFrameRate: 25
getFilename: /home/amitadut/public_html/gallery_video/robot.avi
getComment:
getTitle:
getAuthor:
getCopyright:
getArtist:
getGenre:
getTrackNumber: 0
getYear: 0
getFrameHeight: 112
getFrameWidth: 160
getPixelFormat: yuv420p
getBitRate: 183948
getVideoBitRate: 104857200
getAudioBitRate: 32000
getAudioSampleRate: 32000
getVideoCodec: mpeg1video
getAudioCodec: mp2
getAudioChannels: 1
hasAudio: 1
Hi Sajith,
New to use this FFmpeg. and to linux also.
I installed ffmpeg and trying to use the Library of the ffmpeg.
#include “libavcodec/avcodec.h”
#include “libavformat/avformat.h”
I am using simple sample code ,which takes vedio stream ,and convert it to someformat.
I am facing problem is when i wrote the C Code .
I complied it which is not the problem,but linking is getting problem.
It is giving like this
test.c:(.text+0xf6): undefined reference to `av_register_all’
test.c:(.text+0x12b): undefined reference to `av_open_input_file’
test.c:(.text+0×146): undefined reference to `av_find_stream_info’
test.c:(.text+0×183): undefined reference to `dump_format’
test.c:(.text+0x1f6): undefined reference to `avcodec_find_decoder’
test.c:(.text+0×242): undefined reference to `avcodec_open’
test.c:(.text+0×257): undefined reference to `avcodec_alloc_frame’
test.c:(.text+0x25f): undefined reference to `avcodec_alloc_frame’
test.c:(.text+0×294): undefined reference to `avpicture_get_………
Means it is unable to link with the contents of the header files ..
Please do guide me ..what is the worng thing i am doing.
i want to run ffmpeg in my system but its not run properly
and error msg are comming
“Error in loading ffmpeg”
pls help me
Hi folk,
Currently I come to work with FFMPEG to convert video stream into flv in php. Can anyone give how could i do this using php? Does anybody has class or source code for that?
A little help appreciate…
Web-Farmer
http://www,letsnurture.com
Hello!
I want to resize jpeg image. Already resized but problem is image quality not good. i.e. Original image size is 640*480. After resize 200* auto. Resize image not looking same as original image. Anybody give an idea..
i’m installing ffmpeg and did this code
c:/ffmpeg/ffmpeg.exe –i d:/myfile.mpg d:/myfile.flv /y
on the DOS and then came this error
unable to find a suitable output format for ‘ui’
how can i solve this?
i’m using windows xp by the way.
thanks.
I downloaded ffmpeg.exe from some site.. i placed that exe file in server. after that i executed above code..Then i got an error msg like this
“Error in loading ffmpeg..
what sholud i do?
output : fail
Is there a problem with exec().
I have checked the phpinfo(); and ffmpeg turn on
I use ubuntu 10.04. Please help.
extension_loaded(‘ffmpeg’) or die(‘error in loading ffmpeg’);
if(exec(‘ffmpeg -i saman600.flv saman6001.avi’))
echo”success”;
else
echo”fail”;
output : fail
Hey Sajith thanks a lot for the successful script.
I think you have not mentioned users that they should buy ffmpeg supported domain.
Actually cpanels don’t provide support for ffmpeg, because it is RAM consuming application. For this, you have to buy ffmpeg supported domain.
I am using Citrex Domain, its working 100% perfectly.
Exec is a system call, which is made in Linux C, and it is used for launching or initiating any proces, so you have to run this application and this function is also available in php.
exec(‘ffmpeg -i abc.3gp abc.flv’);
Buy domain from some ffmpeg supported domain e.g Citrex and enjoy.
Regards
Atif
hi,
thank you so much for your help to manage videos with ffmpeg.
please write a command to grab the image in jpg,png or gif for that converted flv video.
thanks in advance
hello, I try to get thumbnail from certain part of video but doesn’t work, I got error “Fatal error: Call to a member function toGDImage() on a non-object”
I try everything but nothing, my code is
getFrameCount() / 4);
$frame = $movie->GetFrame( $thumbnailOf );
$image = $frame->toGDImage();
$name_of_image = ‘my_pics.jpg’;
imagejpeg($image, $video_path.$name_of_image, 100);
echo ”;
Can someone help me !?
This is the code:
$file = $video_path.$video["video"];
$movie = new ffmpeg_movie($file);
$thumbnailOf = (int) round($movie->getFrameCount() / 4);
$frame = $movie->GetFrame( $thumbnailOf );
$image = $frame->toGDImage();
$name_of_image = ‘my_pics.jpg’;
imagejpeg($image, $video_path.$name_of_image, 100);
echo ”;
$file = $video_path.$video["video"];
$movie = new ffmpeg_movie($file);
$thumbnailOf = (int) round($movie->getFrameCount() / 4);
$frame = $movie->GetFrame( $thumbnailOf );
$image = $frame->toGDImage();
$name_of_image = ‘my_pics.jpg’;
imagejpeg($image, $video_path.$name_of_image, 100);
echo "";
@Sajith M.R
Is there a way to find if FFMPEG library file exist in linux and windows using PHP ?
Thanks
Praveen
Search for ffmpeg.exe in Windows, and in linux type ‘whereis ffmpeg’ in command prompt
Hi Sajith,
Am new to ffmpeg, we are working in both windows and linux.
Development is in windows where as in house server is in linux.
So we have to configure in both windows and linux, first i have to install in windows then convert any video format to .flv format and capture image to display in home page.
I have install in windows and got ffmpeg section in phpinfo().
With the help of ffmpeg am able to get video attributes only, how to convert video format and capture image.
If possible explain step wise to capture completely.
Thanks in advance
The way i have install ffmpeg as follows,
1. Copied avcodec-51.dll, avformat-51.dll, avutil-49.dll and pthreadGC2.dll to windows/system32 directory.
2. Copied php_ffmpeg.dll to /php/ext directory.
3. Downloaded ffmpeg.exe and ffplay.exe and copied in a directory.
4. Added following code in php.ini.
extension=php_ffmpeg.dll
then restarted apache.
Above install is it enough for video format conversion.
Please guide me to complete my project ( Video library management )
Thanks in advance
Dear Sajith,
We are developing video website in house. We have video player that support only .flv file. so, we find out php script to convert all other format video file to .FLV and its running nice if, the .avi. mpg etc file size is small. Once, i try to upload big files like 50 mb, 80 mb then its not convert.
We can upload only 10 MB not more then. Please help soon.
Can you please help me here?
Thanks,
Dear Sajith,
We are developing video website in house. We have video player that support only .flv file. so, we find out php script to convert all other format video file to .FLV and its running nice if, the .avi. mpg etc file size is small. Once, i try to upload big files like 50 mb, 80 mb then its not convert.
If, you want to see the php script then please let us know.
We can upload only 10 MB not more then. Please help soon.
Can you please help me here?
Thanks,
Hi Mr.Sajith,
I a newbie to ffmpeg after a long battle i have successfully installed ffmepg in my linux server, but now i need to join two or more flv video files using ffmpeg (by using php coding not in command prompt), can you please guide me to do this activity?
Thanks in advance, looking forward to hear from you.
Thanks & Regards,
Muthuraj S
bhai sajit M.R thanks for the code but this procedure is only for linux. this is not work in php hwo to convert file in php ?? any user ask abt that question u dont reply it . why ??? if u have no idea abt that simple says i have no idea . but u dont reply it becuase u feel u r a loser …………………………
@ Nilesh
Edit your php.ini configuration file
;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;
max_execution_time = 6000 ; Maximum execution time of each script, in seconds
max_input_time = 6000 ; Maximum amount of time each script may spend parsing request data
memory_limit = 99M ; Maximum amount of memory a script may consume (16MB)
;;;;;;;;;;;;;;;;;
; Data Handling ;
;;;;;;;;;;;;;;;;;
; Maximum size of POST data that PHP will accept.
post_max_size = 1024M
;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;
; Maximum allowed size for uploaded files.
upload_max_filesize = 1024M
Hi Sajith M.R,
My project is working fine locally on windows. But when I run the project on linux dedicated server, the converted flv video has no sound. And when I add the “-acodec mp3″ line in ffmpeg command, ffmpeg coverts no video. ffmpeg only converts the video with no audio when there is no -vcodec and -acodec lines present in commands. I contacted my hosting company, they says that libmp3lame is enabled. Can you tell me what is the problem, why there is no audio in converted video. And also why ffmpeg doesn’t generates the output flv, if there is -acodec line present in ffmpeg command.
Your help is highly appreciated! THanks
Hai Mr.Sajith. I successfully installed ffmpeg libraries in my windows machine. It is working in my command prompt but the problem is when i’m trying to access it via php it shows error ‘like error in loading ffmpeg while executing the below line. plz help me
extension_loaded(‘ffmpeg’) or die(‘Error in loading ffmpeg’);
While running form PHP you need to provide full path, eg: C:/Windows/ffmpeg.exe rather than just exec(‘ffmpeg ‘)