プログラミング-ffmpeg導入・足掻き編-

Mingw・MSYSの環境に導入する前にもう少しCygwinで足掻いてみた。

  • 導入に用いたsvn, configureのオプションなどは以下の通り。

$ ffmpeg
FFmpeg version SVN-r19673, Copyright (c) 2000-2009 Fabrice Bellard, et al.
configuration: --disable-shared --enable-static --enable-gpl
libavutil 50. 3. 0 / 50. 3. 0
libavcodec 52.32. 0 / 52.32. 0
libavformat 52.37. 0 / 52.37. 0
libavdevice 52. 2. 0 / 52. 2. 0
libswscale 0. 7. 1 / 0. 7. 1
built on Aug 21 2009 17:44:12, gcc: 3.4.4 (cygming special, gdc 0.12, using dm
d 0.125)
At least one output file must be specified

ちなみに, Cygwinのバージョンは以下の通り。

$ uname -r
1.5.25(0.156/4/2)

http://ffmpeg.org/general.htmlによれば
llrint()の関係でバージョンは1.7を使うようにとあるが, 前回waringですんだため無視することにした。(シェルでffmpegが使えたし。。)

  • サンプルプログラムのmakefileは前回と同じ。

CC = gcc
CFLAGS = -Wall -I/usr/local/include
LDFLAGS = -L/usr/local/bin
LDLIBS = -lavutil -lavformat -lavcodec -lswscale -lavdevice
OBJS = make_thumb.o
make_thumb: $(OBJS)
$(CC) -o $@ $(LDFLAGS) $(OBJS) $(LDLIBS)

  • 上手くmakeできなかったため無理やり, makeに必要だと思われるファイルを同じディレクトリにコピー。

$ cd make_thumb_sample/
$ cp /usr/local/bin/cyg*.dll ../ffmpeg
$ cp ../ffmpeg/*/*.a ./

するとmakeは通った。

  • しかし, 実行すると, エラー?が出現。

sample.jpegは生成されるが, フレームの内容を反映していない。

$ ./make_thumb sample.mov sample.jpeg
Compiler did not align stack variables. Libavcodec has been miscompiled
and may be very slow or crash. This is not a bug in libavcodec,
but in the compiler. You may try recompiling using gcc >= 4.2.
Do not report crashes to FFmpeg developers.

gcc4.3.2で・・
サンプルをmakeしたところ, 変更なし。
configureをして, makeでエラーが発生。

プログラミング-ffmpeg導入・解決編?-

と言うことで, Mingw・MSYSの環境にffmpegを導入することにする。

  • 参考文献

gtaka555さんのページ
http://d.hatena.ne.jp/gtaka555/20080622/p1

[0:環境構築]

  • まずは, Mingw・MSYSの環境をXPで構築する。

http://www.knatech.info/Dev-mingw-install.html
を参考にMingwとMSYSをインストールした。

  • mingw32-makeの導入

http://sourceforge.jp/projects/mingw/releases/35381
からダウンロード。
解凍して, mingw32-make.exeを/c/msys/1.0/binにコピー。

$ mingw32-make --version
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-pc-mingw32

  • gcc4.2の導入

猫科研究所さん
http://up-cat.net/%BA%A3%B9%B9MinGW(5).html
のサイトを参考に導入。

$ gcc -v
Reading specs from C:/MinGW/lib/gcc/mingw32/3.4.5/specs
Target: mingw32
Configured with: ../gcc-4.2.1-2-src/configure --with-gcc --enable-libgomp --host
=mingw32 --build=mingw32 --target=mingw32 --program-suffix=-sjlj --with-arch=i48
6 --with-tune=generic --disable-werror --prefix=/mingw --with-local-prefix=/ming
w --enable-threads --disable-nls --enable-languages=c,c++,fortran,objc,obj-c++,a
da --disable-win32-registry --enable-sjlj-exceptions --enable-libstdcxx-debug --
enable-cxx-flags=-fno-function-sections -fno-data-sections --enable-version-spec
ific-runtime-libs --disable-bootstrap
Thread model: win32
gcc driver version 4.2.1-sjlj (mingw32-2) executing gcc version 3.4.5

[1:ffmpegのインストール]
svnがMSYSでは用意されてなかったので, Cygwinでダウンロードしていたsvn13235を利用。

さっそく, configureを行ったがprコマンドがない。
またまた, 猫科研究所さんのサイト
http://www.up-cat.net/%25BA%25A3%25B9%25B9MinGW%25286%2529.html
を参考にprを導入。

あとは, configureしてmingw32-makeして, install..と思っていたらming32-makeでエラーが発生。

$ mingw32-make
・・・・・・・
-O3 -fno-math-errno -c -o libswscale/options.o libswscale/options.c
In file included from libswscale/options.c:24:
libswscale/swscale_internal.h: In function 'fmt_depth':
libswscale/swscale_internal.h:384: error: 'PIX_FMT_RGB48BE' undeclared (first us
e in this function)
libswscale/swscale_internal.h:384: error: (Each undeclared identifier is reporte
d only once
libswscale/swscale_internal.h:384: error: for each function it appears in.)
libswscale/swscale_internal.h:385: error: 'PIX_FMT_RGB48LE' undeclared (first us
e in this function)
mingw32-make: *** [libswscale/options.o] Error 1

続きはまた明日。