2013年1月29日 星期二

FFMPEG -- Compile FFPLAY on MAC

FFMPEG won't compile ffplay be default. Below list the procedure to compile ffplay correctly.

1. Install MacPorts (v2.1.2)
Download from http://www.macports.org/,Choose the Mac OS version of your platform,download the dmg file and install.  After installed, we should update MacPorts to latest version, run below command.
$sudo port -fvds selfupdate
2. Understand MacPorts usage
Reference http://guide.macports.org/,Chapter 3 introduce 18 commands. Here I only list two most common command.
$sudo port install libsdl
$sudo port uninstall libsdl

3. Install pkg-config (version 0.27)
http://www.freedesktop.org/wiki/Software/pkg-config/
$sudo port install pkgconfig

4. Install SDL (1.2.15)
http://www.libsdl.org/download-1.2.php,download the source code and build myself.
$./configure --x-libraries=/usr/X11/lib
$ make
or you can just install the compiled library 
$sudo port install libsdl
$sudo port install libsdl_gfx libsdl_image libsdl_mixer libsdl_ttf
5. Install yasm
$sudo port install yasm

6. Compile ffplay, change directory the ffmpeg, and run
$./configure
$ make
7. Execute ffplay
$./ffplay  rtsp://192.168.0.2:554/livestream
Note: If you only need ffplay executable file, you can run "sudo port install ffmpeg +gpl +lame +x264 +xvid" without compile file.


FAQ:

1. When I run ffplay, some error log shows.
ffplay version N-49398-g51e9d2d Copyright (c) 2003-2013 the FFmpeg developers
  built on Jan 28 2013 22:28:56 with llvm-gcc 4.2.1 (LLVM build 2336.11.00)
  configuration:
  libavutil      52. 17.100 / 52. 17.100
  libavcodec     54. 91.100 / 54. 91.100
  libavformat    54. 61.104 / 54. 61.104
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 34.101 /  3. 34.101
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
Could not initialize SDL - No available video device
(Did you set the DISPLAY variable?)
USE "export SDL_VIDEODRIVER=xxx" can solve this problem. For example,
"export SDL_VIDEODRIVER=x11"
Aftern install XQuartz, ffplay can display image correctly.
  • Download XQuartz from http://xquartz.macosforge.org/landing/ and install
  • Execute the xterm of XQuartz
  • run command 
  • "$ffplay  rtsp://192.168.0.10:554/livestream/


2. VLC can be a streaming server if you don't have one.
Reference http://wiki.videolan.org/Documentation:Streaming_HowTo/Easy_Streaming

Reference
  • https://github.com/rubygame/rubygame/wiki/Mac-Install-Guide
  • http://www.chenjunlu.com/2011/03/understanding-pkg-config-tool/
  • http://www.libsdl.org/docs/html/sdlenvvars.html
  • http://www.sajithmr.me/install-ffmpeg-in-mac