Install FFMPEG-PHP

Submitted by joezine on Sat, 12/19/2009 - 10:29

กว่าจะ Install ได้บน Redhat แทบตาย! เพราะไม่มี Package ให้เลือกติดตั้งแบบสบายๆ ต้องทำการ Compile และติดปัญหาหลายๆอย่าง ตั้งแต่ Source ของ Library ผิด ต้องงมๆกันไป จนสำเร็จขึ้นมาจนได้

จดไว้ดีกว่าเป็นข้อมูลให้กับคนอื่น

สำหรับการติดตั้งครั้งนี้ ใช้ Redhat ES5 32 bit สิ่งที่จำเป็นมีดังต่อไปนี้

สิ่งที่ต้องทำมีดังต่อไปนี้

ติดตั้ง FFMPEG

เซ็งมาก!! เพราะไม่สามารถ Download File มาได้ ต้อง Checkout จาก Trunk มาก่อน (ต้องลง svn อีก)

#yum install subversion

หลังจากนั้นทำการ Checkout Sourcecode ออกมา

#svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg

และให้เข้าไปยัง /path/to/ffmpeg ตามด้วยติดตั้ง

#cd /path/to/ffmpeg   
#./configure --enable-shared --prefix=/usr  
#make clean && make  
#make install

เป็นอันเสร็จสิ้นสำหรับการติดตั้ง FFMPEG

ติดตั้ง FFMPEG-PHP

หลังจาก Download File แล้วให้ Extract ไปที่ /path/to/php_sources/ext

#tar -xjf ffmpeg-php.X.x.x.tbz2 -C /path/to/php_sources/ext/

และเข้าไป /path/to/php_sources/ext/ เพื่อทำการ Compile

#cd /path/to/php_sources/ext/  
#./configure && make  
#make clean && make

ให้ทำการ Add extension เข้าไปใน php.ini เพื่อให้ Load Module อัตโนมัติ

extension=ffmpeg.so

และ Restart Webserver

#service httpd restart

เป็นอันเสร็จสิ้นพิธี

ถ้าหากใช้งานได้ลองเขียน phpinfo จะแสดงรายละเอียดตามด้านล่าง

System => Linux testffmpeg 2.6.18-164.9.1.el5 #1 SMP Wed Dec 9 03:29:54 EST 2009 i686
ffmpeg
ffmpeg-php version => 0.6.0-svn
ffmpeg-php built on => Dec 19 2009 09:00:00
ffmpeg-php gd support  => enabled
ffmpeg libavcodec version => Lavc52.43.0
ffmpeg libavformat version => Lavf52.44.0
ffmpeg swscaler version => SwS0.7.2
ffmpeg.allow_persistent => 0 => 0
ffmpeg.show_warnings => 0 => 0
HOSTNAME => testffmpeg
_SERVER["HOSTNAME"] => testffmpeg
_ENV["HOSTNAME"] => testffmpeg

การแสดงข้อความด้านบนใช้

php -r 'phpinfo();' | grep "ffmpeg"

ปัญหาต่างๆ

SELinux

ต้อง Disabled SElinux ด้วย หากไม่ Disabled จะมี Error ตามด้านล่าง

PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/modules/ffmpeg.so’ - /usr/local/lib/libavutil.so.50: cannot restore segment prot after reloc: Permission denied in Unknown on line 0

error: ‘PIX_FMT_RGBA32′ undeclared

เกิด Error แบบนี้

/path/to/php_sources/ext/ffmpeg-php.X.x.x/ffmpeg_frame.c:495: error: ‘PIX_FMT_RGBA32′ undeclared (first use in this function) make: *** [ffmpeg_frame.lo] Error 1

ให้ทำตามนี้

เปิด File /path/to/php_sources/ext/ffmpeg-php.X.x.x/ffmpeg_frame.c ด้วย vi

#vi /path/to/php_sources/ext/ffmpeg-php.X.x.x/ffmpeg_frame.c

Execute Command นี้

:%s/PIX_FMT_RGBA32/PIX_FMT_RGB32

จากนั้น save และลอง Compile อีกครั้ง

error:swscale.h: No such file or directory

ให้ทำตามนี้

เปิด File /path/to/php_sources/ext/ffmpeg-php.X.x.x/ffmpeg-php.c ด้วย vi

#/path/to/php_sources/ext/ffmpeg-php.X.x.x/ffmpeg-php.c

ทำการแก้ไข Locate ของ Library swscale ใหม่ จาก

include <swscale.h>

เป็น

include <libswscale/swscale.h>

เป็นอันเสร็จสมบูรณ์

Link

ด้านล่างเป็น Link ข้อมูลการติดตั้งและการแก้ไข

Tags: | »

ket (not verified) Says:
Wed, 06/09/2010 - 04:03

ช่วยสอนวิธีติดตั้ง FFMPEG บน local คอมพิวเตอร์ หน่อยครับ อยากทดสอบการใช้งานจริงก่อนอัพขึ้นเว็บครับ

เริ่มจากหลังจากดาวน์โหลดมาแล้วนะครับ ไม่รู้จะทำยังไง ประมาณโง่อ่ะ

ผมใช้ WAMPSERVER ครับตอนนี้ จะติดตั้ง FFMPEG ยังไง ผมอยากทำเว็บวีดีโอสำหรับคนไทยแข่งกะยูทู้บ

ช่วยตอบด้วยครับ

joezine Says:
Sat, 06/12/2010 - 10:43

ผมคิดว่า link นี้สามารถให้คำตอบได้นะครับ

http://www.ehow.com/how_4716678_install-ffmpeg-windows.html

วิธีการคล้ายกันเลย ลองดูครับผม

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You can use Markdown syntax to format and style the text. Also see and Markdown Extra for tables, footnotes, and more.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

More information about formatting options