trade2の日記

2008/3/4(火)
ffmpeg奮闘中

この2週間ばかりVLCとFFMPEGのWINDOWS CE用のコンパイルではまって大変だ。

最初はcegccを落としてきてMSYSとMinGWでコンパイルしていたのだが、芳しくなく。Cygwinでもなんかだめで。

で、これはもうLINUXでしょうというので、

Ubuntu
http://www.ubuntulinux.jp/

をインストールすることに。

インターネットサーフィンなどしか使用しないなら日本語版でもいいが、今回はソフトをビルドするので英語版をダウンロード。(ほとんどのソフトの作者さんは日本人ではないので)

デスクトップ版をCD-RWに焼く(半年に一回アップデートするらしいので)
パソコンのCD-ROMにいれて電源落とし、CDからブートさせるとLIVE CDが立ち上がる。問題なく使えるようならパソコンのスペックは大丈夫なのでデスクトップにあるインストールアイコンをダブルクリック。

質問に答えてインストール。

インストールが終わったら、
ネットにつなぐ。
PCカード型の無線LANならドライバが入っている。

バッファローのWLI-CF-S11Gは一発で認識された。

このUbuntu、CDドライブにCD入れてもUSBメモリーをつないでも自動で認識してくれる。面倒なマウント作業がいらない。(アンマウントはいる)すごいなぁ。

ただ、OpenBSDで認識できた、WLI-U2-KG54は認識されなかった。これは


Linux Wireless

http://www.linuxwireless.org/

で、zd1211rwとかいうのをいれるか、カーネルの再コンパイルかなにかがいるらしいが、面倒なのでパス。


システム→システム管理→言語サポートをクリックして日本語を選択するとAnthyなどがインストールされる。うまくいかないときにはOpenOfficeのどれかを開いて言語を日本語にしたりしていろいろいじっているとシステムの言語サポートでAnthyがインストールされる。ここは何回か往復した。

システム→システム管理→synapticを開く
設定のリポジトリを開く
ubuntuのソフトウエアの項で
CD/DVDーROMからインストールのチェックをはずす。これをやらないと

http://www.ubuntu.com/getubuntu/download

の下のほうにある、
Check here if you need the alternate desktop CD. This CD does not include the Live CD, instead it uses a text-based installer.

のCDを毎回ドライブに入れないといけなくて面倒だし、せっかくインストールCDが一枚で収まっているのに、このおかげで2枚必要になる。全部インターネットから直接ダウンロードしてインストールすることにする。

インターネットのダウンロードでソースコード以外のチェックを入れる
ダウンロード元に
その他→日本→ftp.jaist.ac.jpを選ぶ

(パッケージ debであればダブルクリックでインストール可能)











cegccのビルド

ubuntuの端末を開く。ちょうどWindowsのコマンドプロンプトのような画面が開く。

svnのパッケージをインストールする。
sudo apt-get install svn



svn co https://cegcc.svn.sourceforge.net/svnroot/cegcc/trunk/cegcc /home/cegcc

src/build-mingw32.shの指示にしたがって
mkdir build-mingw32ce
cd build-mingw32ce
sudo ../build-mingw32ce.sh

configure.logに足りないパッケージが出てくるので sudo apt-get install でインストール
C++
G77

...etc

その後mingw32ceをビルド。何回もチェックする。

足りないたびに
sudo apt-get install xxx (xxxは チェック リザルトでnoになっている文字。)
でインストールする。
パッケージがないとでるのがあるが、無いものは無いのでそのまま。

いちおう一通りいれたらautomake autoconfをmingw32ceでコンパイルしてみてconfigure.logでたりないパッケージを入れる。

それでも nasmなど引っかからないので気を付ける。








FFMPEGのビルド

svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk /home/ffmpeg

特定のリビジョンを指定したい場合は

svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk -r 9133 /home/ffmpeg







/opt/mingw32ce/arm-mingw32ce/のbin include libをそれぞれ ln -s で/opt/mingw32ce/以下のbin lib include へ シンボリックリンクを張る。

sudo ln -s /opt/mingw32ce/arm-mingw32ce/lib/*.* /opt/mingw32ce/lib

etc


(ffmpegのビルドが終わったらリンクを削除)



cegccのtoolsからerrno.hを、/opt/mingw32ce/lib/gcc/arm-mingw32ce/4.1.0/install-tools/include/へコピー。

/opt/mingw32ce/libにあるシンボリックリンクのlibws2.aから同じフォルダーにws2_32.dllという名前でシンボリックリンクを張る。
これはあとから引っかかるのだが、



pnm_parser.o vc1_parser.o dump_extradata_bsf.o h264_mp4toannexb_bsf.o imx_dump_header_bsf.o mjpega_dump_header_bsf.o movsub_bsf.o mp3_header_compress_bsf.o mp3_header_decompress_bsf.o noise_bsf.o remove_extradata_bsf.o armv4l/dsputil_arm.o armv4l/mpegvideo_arm.o armv4l/jrevdct_arm.o armv4l/simple_idct_arm.o armv4l/dsputil_arm_s.o -L"/home/ubuntuuser/vlc-make/ffmpeg"/libavutil -lavutil -lm -lws2_32
/opt/mingw32ce/lib/gcc/arm-mingw32ce/4.1.0/../../../../arm-mingw32ce/bin/ld: cannot find -lws2_32
collect2: ld returned 1 exit status
make: *** [avcodec-51.dll] エラー 1
ubuntuuser@NEWWIND11ubuntu:~/vlc-make/ffmpeg/libavcodec$



と出るので。
Windows XPのsystem32からコピーしてきてパスの通っているlibフォルダーに入れたが、arm-mingw32ce-gccが理解できないとか言って来たので、そうか、じゃあlibws2.aでいいだろうということで。最後までコンパイルしてみないと、これで正解だったかどうかわからない。




configureの設定は
configureの中身を読むとスイッチの役割が書いてあるのでその通りに指定。
--target-osはmingw32と書いてあるものはmingw32ceだろうがなんだろうがみなmingw32の項目で処理するとかいてあるので、mingw32と指定する。
--archはarmであればみなarmv4lで処理されると書いてある。
--cpuは一応armがスイッチとして候補が挙がっているのだが、configureを読むと
arm*)
add_cflags "-mcpu=$cpu"
と書かれている。これはまずい。arm-mingw32ce-gccは-mcpu=armは理解できない。
Intelのサイトでも
http://www.intel.com/design/intelxscale/

ARMは商標で、CPUの名前はXScaleなんだそうだ。
なので、あとでconfigureでエラーが出るけれど、--cpu=xscaleにする。
ついでにarm-mingw32ce-gccにも-mcpu=xscaleをつける。これをつけないとgenericになって、後でProcessor が対応してないからエラーだとか言われる。

また、VLCの
http://wiki.videolan.org/ARM-XCompile
を参考に--disable-mmxと--enable-sharedを追加。
最初の方で以前のcontribを使って出たエラーを参考に--enable-gpl --enable-ppも追加しておく。


あといろいろなサイトを見て回ってスイッチを追加。




cd ffmpeg

./configure --cross-compile \
--prefix=/usr/local/wince \
--enable-memalign-hack --target-os=mingw32 --arch=armv4l --cpu=xscale \
--disable-mmx --disable-armv5te --enable-static --enable-shared --enable-gpl --enable-pp \
--disable-debug --disable-network \
--disable-vhook --disable-ffserver --disable-ffplay \
--cross-prefix=/opt/mingw32ce/bin/ \
--cc="arm-mingw32ce-gcc -g -D_WIN32_IE=0x0400 -mcpu=xscale" \
--extra-ldflags="-L/opt/mingw32ce/lib" \
--extra-cflags="-g -D_WIN32_IE=0x0400 -I/opt/mingw32ce/include"


make

sudo make install



で、ここまでやったのに、







utils.c:36: warning: 'AVFrac' is deprecated
utils.c:37: warning: 'AVFrac' is deprecated
utils.c: In function 'av_open_input_file':
utils.c:468: error: 'EILSEQ' undeclared (first use in this function)
utils.c:468: error: (Each undeclared identifier is reported only once
utils.c:468: error: for each function it appears in.)
utils.c:475: error: 'EDOM' undeclared (first use in this function)
utils.c: In function 'av_read_frame_internal':
utils.c:857: warning: format '%I64d' expects type 'int', but argument 5 has type 'int64_t'
utils.c:857: warning: format '%I64d' expects type 'int', but argument 6 has type 'int64_t'
utils.c:882: warning: format '%I64d' expects type 'int', but argument 5 has type 'int64_t'
utils.c:882: warning: format '%I64d' expects type 'int', but argument 6 has type 'int64_t'
utils.c: In function 'av_seek_frame_binary':
utils.c:1137: warning: format '%I64d' expects type 'int', but argument 5 has type 'int64_t'
utils.c:1157: warning: 'I' flag used with '%x' printf format
utils.c:1157: warning: format '%I64x' expects type 'unsigned int', but argument 4 has type 'int64_t'
utils.c:1157: warning: format '%I64d' expects type 'int', but argument 5 has type 'int64_t'
utils.c:1173: warning: 'I' flag used with '%x' printf format
utils.c:1173: warning: format '%I64x' expects type 'unsigned int', but argument 4 has type 'int64_t'
utils.c:1173: warning: 'I' flag used with '%x' printf format
utils.c:1173: warning: format '%I64x' expects type 'unsigned int', but argument 5 has type 'int64_t'
utils.c:1173: warning: format '%I64d' expects type 'int', but argument 6 has type 'int64_t'
utils.c: In function 'av_gen_search':
utils.c:1196: warning: format '%I64d' expects type 'int', but argument 5 has type 'int64_t'
utils.c:1242: warning: 'I' flag used with '%x' printf format
utils.c:1242: warning: format '%I64x' expects type 'unsigned int', but argument 4 has type 'int64_t'
utils.c:1242: warning: 'I' flag used with '%x' printf format
utils.c:1242: warning: format '%I64x' expects type 'unsigned int', but argument 5 has type 'int64_t'
utils.c:1242: warning: format '%I64d' expects type 'int', but argument 6 has type 'int64_t'
utils.c:1242: warning: format '%I64d' expects type 'int', but argument 7 has type 'int64_t'
utils.c:1271: warning: format '%I64d' expects type 'int', but argument 4 has type 'int64_t'
utils.c:1271: warning: format '%I64d' expects type 'int', but argument 5 has type 'int64_t'
utils.c:1271: warning: format '%I64d' expects type 'int', but argument 6 has type 'int64_t'
utils.c:1271: warning: format '%I64d' expects type 'int', but argument 7 has type 'int64_t'
utils.c:1271: warning: format '%I64d' expects type 'int', but argument 8 has type 'int64_t'
utils.c:1271: warning: format '%I64d' expects type 'int', but argument 9 has type 'int64_t'
utils.c:1271: warning: format '%I64d' expects type 'int', but argument 10 has type 'int64_t'
utils.c:1271: warning: format '%I64d' expects type 'int', but argument 11 has type 'int64_t'
utils.c:1271: warning: format '%I64d' expects type 'int', but argument 12 has type 'int64_t'
utils.c:1297: warning: 'I' flag used with '%x' printf format
utils.c:1297: warning: format '%I64x' expects type 'unsigned int', but argument 4 has type 'int64_t'
utils.c:1297: warning: format '%I64d' expects type 'int', but argument 5 has type 'int64_t'
utils.c:1297: warning: format '%I64d' expects type 'int', but argument 6 has type 'int64_t'
utils.c:1297: warning: format '%I64d' expects type 'int', but argument 7 has type 'int64_t'
utils.c: In function 'compute_pkt_fields2':
utils.c:2365: warning: format '%I64d' expects type 'int', but argument 4 has type 'int64_t'
utils.c:2365: warning: format '%I64d' expects type 'int', but argument 5 has type 'int64_t'
utils.c: In function 'parse_date':
utils.c:2768: warning: cast discards qualifiers from pointer target type
utils.c: At top level:
utils.c:3058: warning: 'AVFrac' is deprecated
utils.c:3076: warning: 'AVFrac' is deprecated
make[1]: *** [utils.o] エラー 1
make: *** [lib] エラー 2





というエラーが出る。




以前Wince用に出たパッチ

http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2005-December/005398.html


******************************************





Index: configure
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/configure,v
retrieving revision 1.216
diff -u -r1.216 configure
--- configure 29 Nov 2005 21:12:30 -0000 1.216
+++ configure 2 Dec 2005 23:52:42 -0000
@@ -26,6 +26,7 @@
echo " --enable-xvid enable XviD support via xvidcore [default=no]"
echo " --enable-x264 enable H.264 encoding via x264 [default=no]"
echo " --enable-mingw32 enable MinGW native/cross Windows compile"
+echo " --enable-mingwce enable MinGW native/cross WinCE compile"
echo " --enable-a52 enable GPLed A52 support [default=no]"
echo " --enable-a52bin open liba52.so.0 at runtime [default=no]"
echo " --enable-dts enable GPLed DTS support [default=no]"
@@ -199,6 +201,7 @@
pp="no"
shared_pp="no"
mingw32="no"
+mingwce="no"
cygwin="no"
os2="no"
lshared="no"
@@ -534,6 +538,8 @@
;;
--enable-mingw32) mingw32="yes"
;;
+ --enable-mingwce) mingwce="yes"
+ ;;
--enable-shared) lshared="yes"
;;
--disable-debug) debug="no"
@@ -847,7 +855,7 @@
$cc -o $TMPE $TMPC 2> /dev/null || mmi="no"
fi

-if test "$mingw32" = "yes" ; then
+if test "$mingw32" = "yes" -o "$mingwce" = "yes"; then
v4l="no"
bktr="no"
audio_oss="no"
@@ -855,6 +863,9 @@
dc1394="no"
ffserver="no"
network="no"
+if test "$mingw32" = "yes"; then
+ protocols="no"
+fi
SLIBPREF=""
SLIBSUF=".dll"
EXESUF=".exe"
@@ -1621,6 +1632,16 @@
echo "#endif" >> $TMPH
fi

+if test "$mingwce" = "yes" ; then
+ echo "#define CONFIG_WIN32 1" >> $TMPH
+ echo "CONFIG_WIN32=yes" >> config.mak
+ echo "#define CONFIG_WINCE 1" >> $TMPH
+ echo "CONFIG_WINCE=yes" >> config.mak
+ echo "#ifndef __MINGW32__" >> $TMPH
+ echo "#define __MINGW32__ 1" >> $TMPH
+ echo "#endif" >> $TMPH
+fi
+
if test "$os2" = "yes" ; then
echo "#define CONFIG_OS2 1" >> $TMPH
echo "CONFIG_OS2=yes" >> config.mak
Index: libavformat/os_support.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/os_support.c,v
retrieving revision 1.4
diff -u -r1.4 os_support.c
--- libavformat/os_support.c 9 Nov 2004 17:27:33 -0000 1.4
+++ libavformat/os_support.c 2 Dec 2005 23:53:22 -0000
@@ -18,7 +18,8 @@
*/
#include "config.h"
#include "avformat.h"
-#ifdef CONFIG_WIN32
+#if defined(CONFIG_WINCE)
+#elif defined(CONFIG_WIN32)
#include
#include
#elif defined(CONFIG_OS2)
@@ -36,7 +37,9 @@
*/
int64_t av_gettime(void)
{
-#ifdef CONFIG_WIN32
+#if defined(CONFIG_WINCE)
+ return timeGetTime() * int64_t_C(1000);
+#elif defined(CONFIG_WIN32)
struct timeb tb;
_ftime(&tb);
return ((int64_t)tb.time * int64_t_C(1000) + (int64_t)tb.millitm) * int64_t_C(1000);
@@ -47,6 +50,7 @@
#endif
}

+#if !defined(CONFIG_WINCE)
#if !defined(HAVE_LOCALTIME_R)
struct tm *localtime_r(const time_t *t, struct tm *tp)
{
@@ -59,3 +63,4 @@
return tp;
}
#endif /* !defined(HAVE_LOCALTIME_R) */
+#endif /* !defined(CONFIG_WINCE) */
Index: libavformat/utils.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/utils.c,v
retrieving revision 1.168
diff -u -r1.168 utils.c
--- libavformat/utils.c 4 Nov 2005 23:50:11 -0000 1.168
+++ libavformat/utils.c 2 Dec 2005 23:53:26 -0000
@@ -2734,6 +2731,7 @@
* S+[.m...]
* @endcode
*/
+#ifndef CONFIG_WINCE
int64_t parse_date(const char *datestr, int duration)
{
const char *p;
@@ -2841,6 +2839,7 @@
}
return negative ? -t : t;
}
+#endif /* CONFIG_WINCE */

/**
* Attempts to find a specific tag in a URL.
Index: libavutil/common.h
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavutil/common.h,v
retrieving revision 1.154
diff -u -r1.154 common.h
--- libavutil/common.h 1 Dec 2005 18:20:15 -0000 1.154
+++ libavutil/common.h 2 Dec 2005 23:53:26 -0000
@@ -172,6 +172,11 @@

# define snprintf _snprintf
# define vsnprintf _vsnprintf
+
+# ifdef CONFIG_WINCE
+# define perror(a)
+# endif
+
# endif

/* CONFIG_WIN32 end */
@@ -253,6 +258,9 @@
# endif

# endif /* !CONFIG_WIN32 */
+# ifdef CONFIG_WINCE
+# define abort()
+# endif

# define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0)




***********************************************

では、
configure , os_support.c , utils.c ,common.h,

の4つのファイルを手直ししなければならなかったようだ。
今回私がsvnでダウンロードしたリビジョンは12193で、中身が2005年のものとまったく違っているので、多分引数も違うだろうからどうしようもない。多分まだWindowsCE用のパッチが出ていないのだろう。一から自分でコードがかけるんだったら苦労してないし。


warning: 'AVFrac' is deprecated というのをGoogleで検索すると大量に引っかかるが、だれも解決していないようだ。




一応、libavutil と libavcodecは途中エラーを吐きながらも最後までmakeしてavcodec-51.dllと avutil-49.dllはできたのだが、libavformatができないと、次のVLCもできない。


で、今のところここでお手上げ。


うちのGENIO e550DT と CASIO BE-500はまだ動いているんで、何とかWindowsCE用のソフトで有効活用したいなぁと。

フリーのTCPMPをインストールしたらGENIOで長時間の動画がさくさく動いたあの感動ったらない。いまはポッドキャストの動画を入れて持ち歩いているけれどなかなか快適だ。
TCPMPは有料ソフトになってしまったので、配布できなくなったけれど、VLCはまだソースコードが公開されているし。

風呂に入っているときでも電車に乗っているときでもテレビを見たい、っていうんで、防水テレビとかワンセグとか出てきたように、ポッドキャストの動画もいろんなところで見たいわけだ。

で、面倒な手続きとかなしで、スイッチ入れてボタン押したらぱっと動画が流れる。スイッチ切るときもいきなり切ってもいいし。これがWindowsCEのいいところ。
ハードディスクがないから丈夫で長持ちだし。


MSYS+MINGWでこれだけてこずったことが無いので、(ソフトを書く人が配慮してくれているからなんだろうけれど、)なんかcegccでうまくいかないのが奇妙に見えるけれど、なんとか使いこなせるようになって、いろいろPDAでやりたいなあと思う。


関連2008年3月16日の日記

関連2008年2月17日の日記

BACKNUMBER


女の子お絵かき掲示板ナスカiPhone修理