Install ffmpeg for windows
Step 1
Install xampp, use latest version. After installation there should be a directory C:\xampp
In this example i use C:\xampp as default directory.
Step 2
Check if gd2 is installed, you can do this by using phpinfo() in you script.
Step 3
Download ffmpeg.exe from one of the following links:
http://ffdshow.faireal.net/mirror/ffmpeg/
http://arrozcru.no-ip.org/ffmpeg_builds
http://ffdshow.faireal.net/mirror/ffmpeg/
http://www.paehl.com/open_source/?Convert_Tools:FFMPEG
http://oss.netfarm.it/mplayer-win32.php
Step 4
Unpack the downloaded zip or 7z file, three files should show up namely ffmpeg.exe, ffplay.exe, pthreadGC2.dll .
Step 5
Download the ffmpeg windows dll files:
http://azzerti.free.fr/php_ffmpeg_win32.zip
Step 6
Unpack the downloaded zip file, five dlls should show up namely php_ffmpeg_20050123.dll, php_ffmpeg_20050212.dll, php_ffmpeg_20050618.dll and also avcodec.dll and avformat.dll
Step 7
Copy 1 of 3 dlls which you've unpacked in step 6 into C:\xampp\php\extensions. Rename the dll to php_ffmpeg.dll
Step 8
Open your php.ini file which you find in C:\xampp\php .Add the following line to the list with dlls:
extension=php_ffmpeg.dll
Check also if extension=php_gd2.dll is uncommented. If not then remove the ;
Step 9
Copy the avcodec.dll and avformat.dll which you've unpacked in step 6 to C:\WINDOWS\system32
Step 10
Copy pthreadGC2.dll which was unpacked in step 4 to C:\WINDOWS\system32
Step 11
Restart xampp
Simple Example
Step 12
Create a directory in C:\xampp\htdocs for example www.test.dev\www
C:\xampp\htdocs\www.test.dev\www
Step 13
Open the httpd.conf file, this one you find in C:\xampp\apache\conf
Add under the line
NameVirtualHost localhost:80
the next data
<VirtualHost localhost:80>
ServerName www.test.dev
DocumentRoot C:/xampp/htdocs/www.test.dev/www
</VirtualHost>
Step 14
Find the hosts file on your computer, somewhere in the windows directory and add the following line:
127.0.0.1 www.test.dev
Step 15
Restart xampp
Step 16
Make a php file in the DocumentRoot (C:\xampp\htdocs\www.test.dev\www) for example test.php
Step 17
Add a flv file to the DocumentRoot. In this example i call it wattan.flv.
Step 18
Copy ffmpeg.exe which you've unpacked in step 4 into the DocumentRoot.(C:\xampp\htdocs\www.test.dev\www)
Step 19
Add the following code to the test.php file:
<?php
$ffmpegpath = "ffmpeg.exe";
$input = 'wattan.flv';
$output = 'wattan.jpg';
if (make_jpg($input, $output)){
echo 'success';
}else{
echo 'bah!';
}
function make_jpg($input, $output, $fromdurasec="01") {
global $ffmpegpath;
if(!file_exists($input)) return false;
$command = "$ffmpegpath -i $input -an -ss 00:00:$fromdurasec -r 1 -vframes 1 -f mjpeg -y $output";
@exec( $command, $ret );
if(!file_exists($output)) return false;
if(filesize($output)==0) return false;
return true;
}
?>
Step 19
Open the url http:\\www.test.dev\test.php in firefox.
Step 20
enjoy!
Step 1
Install xampp, use latest version. After installation there should be a directory C:\xampp
In this example i use C:\xampp as default directory.
Step 2
Check if gd2 is installed, you can do this by using phpinfo() in you script.
Step 3
Download ffmpeg.exe from one of the following links:
http://ffdshow.faireal.net/mirror/ffmpeg/
http://arrozcru.no-ip.org/ffmpeg_builds
http://ffdshow.faireal.net/mirror/ffmpeg/
http://www.paehl.com/open_source/?Convert_Tools:FFMPEG
http://oss.netfarm.it/mplayer-win32.php
Step 4
Unpack the downloaded zip or 7z file, three files should show up namely ffmpeg.exe, ffplay.exe, pthreadGC2.dll .
Step 5
Download the ffmpeg windows dll files:
http://azzerti.free.fr/php_ffmpeg_win32.zip
Step 6
Unpack the downloaded zip file, five dlls should show up namely php_ffmpeg_20050123.dll, php_ffmpeg_20050212.dll, php_ffmpeg_20050618.dll and also avcodec.dll and avformat.dll
Step 7
Copy 1 of 3 dlls which you've unpacked in step 6 into C:\xampp\php\extensions. Rename the dll to php_ffmpeg.dll
Step 8
Open your php.ini file which you find in C:\xampp\php .Add the following line to the list with dlls:
extension=php_ffmpeg.dll
Check also if extension=php_gd2.dll is uncommented. If not then remove the ;
Step 9
Copy the avcodec.dll and avformat.dll which you've unpacked in step 6 to C:\WINDOWS\system32
Step 10
Copy pthreadGC2.dll which was unpacked in step 4 to C:\WINDOWS\system32
Step 11
Restart xampp
Simple Example
Step 12
Create a directory in C:\xampp\htdocs for example www.test.dev\www
C:\xampp\htdocs\www.test.dev\www
Step 13
Open the httpd.conf file, this one you find in C:\xampp\apache\conf
Add under the line
NameVirtualHost localhost:80
the next data
<VirtualHost localhost:80>
ServerName www.test.dev
DocumentRoot C:/xampp/htdocs/www.test.dev/www
</VirtualHost>
Step 14
Find the hosts file on your computer, somewhere in the windows directory and add the following line:
127.0.0.1 www.test.dev
Step 15
Restart xampp
Step 16
Make a php file in the DocumentRoot (C:\xampp\htdocs\www.test.dev\www) for example test.php
Step 17
Add a flv file to the DocumentRoot. In this example i call it wattan.flv.
Step 18
Copy ffmpeg.exe which you've unpacked in step 4 into the DocumentRoot.(C:\xampp\htdocs\www.test.dev\www)
Step 19
Add the following code to the test.php file:
<?php
$ffmpegpath = "ffmpeg.exe";
$input = 'wattan.flv';
$output = 'wattan.jpg';
if (make_jpg($input, $output)){
echo 'success';
}else{
echo 'bah!';
}
function make_jpg($input, $output, $fromdurasec="01") {
global $ffmpegpath;
if(!file_exists($input)) return false;
$command = "$ffmpegpath -i $input -an -ss 00:00:$fromdurasec -r 1 -vframes 1 -f mjpeg -y $output";
@exec( $command, $ret );
if(!file_exists($output)) return false;
if(filesize($output)==0) return false;
return true;
}
?>
Step 19
Open the url http:\\www.test.dev\test.php in firefox.
Step 20
enjoy!
gd2 not installed means what we can do ?
ReplyDeleteyou have to install by removing ; in php ini file. it is like this in php ini ;extension=php_gd2.dll
DeleteThis comment has been removed by the author.
ReplyDeleteI want to install ffmpeg on my linux server, please let me know what shold i have to do.
ReplyDeleteThanks
thanks very much it worked 100% thanks again. Keep it up...
ReplyDeletein case of finding host file this link will help you for Windows http://www.tomshardware.com/faq/id-1821155/edit-hosts-file-windows.html
and i think Step 13, 14 are not at all needed
thanks to share this tutorial.
ReplyDeletehey..
ReplyDeleteWhen i restart xampp the computer give me an error called
The program cant be start because avcode-52.dll file is missing from your computer. try to reinstall program..
what can i do to solve it..
It is very possible that your avcodec-52.dll might have been accidentally deleted. Therefore, it is worth checking your Recycle Bin to see if it's there.
Delete1) Simply double-click the Recycle Bin icon.
2) In the upper right-hand corner, search for avcodec-52.dll.
3) If avcodec-52.dll file appears in the search results, select it, and move it to the following directory:
a)Windows 95/98/Me = %PROGRAMFILES%\Steam\bin
b)Windows NT/2000 = %PROGRAMFILES%\Steam\bin
c)Windows XP, Vista, 7, 8, 10 = %PROGRAMFILES%\Steam\bin
d)64-bit Windows = %PROGRAMFILES%\Steam\bin
After moving your avcodec-52.dll file, restart your computer.