ubuntu 在 R40e 上 還有 Debian 在 Sempron 2600 上

2009年9月7日 星期一

build ffmpeg sample in mingw

光是一個 av_register_all( ),就噓要 link 4 個 library:
gcc testffmpeg.c -lavformat -lavcodec -lavutil -lz

* 而且要按照這個次序..!!!!

至於那個 sample file,最後還要加一個library : lswscale

google 了一下: ffmpeg static library link order

發現有說明,因為ffmpeg 的各個 library 裡有重複的 object file,所以link order 很重要。

如果要做出一個單一的 library 包含現在的 library,好像要 --enable-gpl,同時 disable 一些 codec。


log -ffmpeg install

$ make install
install -d "/mingw/lib"
install -m 644 libavfilter/libavfilter.a "/mingw/lib"
ranlib "/mingw/lib/libavfilter.a"
install -d "/mingw/lib"
install -m 644 libavdevice/libavdevice.a "/mingw/lib"
ranlib "/mingw/lib/libavdevice.a"
install -d "/mingw/lib"
install -m 644 libavformat/libavformat.a "/mingw/lib"
ranlib "/mingw/lib/libavformat.a"
install -d "/mingw/lib"
install -m 644 libavcodec/libavcodec.a "/mingw/lib"
ranlib "/mingw/lib/libavcodec.a"
install -d "/mingw/lib"
install -m 644 libavutil/libavutil.a "/mingw/lib"
ranlib "/mingw/lib/libavutil.a"
install -d "/mingw/lib"
install -m 644 libswscale/libswscale.a "/mingw/lib"
ranlib "/mingw/lib/libswscale.a"
install -d "/mingw/include/libavfilter"
install -d "/mingw/lib/pkgconfig"
install -m 644 "/c/ffmpeg/ffmpeg-export-2009-09-02/libavfilter"/avfilter.h "/mingw/include/libavfilter"
install -m 644 "/c/ffmpeg/build"/libavfilter/libavfilter.pc "/mingw/lib/pkgconfig"
install -d "/mingw/include/libavdevice"
install -d "/mingw/lib/pkgconfig"
install -m 644 "/c/ffmpeg/ffmpeg-export-2009-09-02/libavdevice"/avdevice.h "/mingw/include/libavdevice"
install -m 644 "/c/ffmpeg/build"/libavdevice/libavdevice.pc "/mingw/lib/pkgconfig"
install -d "/mingw/include/libavformat"
install -d "/mingw/lib/pkgconfig"
install -m 644 "/c/ffmpeg/ffmpeg-export-2009-09-02/libavformat"/avformat.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavformat"/
avio.h "/mingw/include/libavformat"
install -m 644 "/c/ffmpeg/build"/libavformat/libavformat.pc "/mingw/lib/pkgconfig"
install -d "/mingw/include/libavcodec"
install -d "/mingw/lib/pkgconfig"
install -m 644 "/c/ffmpeg/ffmpeg-export-2009-09-02/libavcodec"/avcodec.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavcodec"/opt
.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavcodec"/vdpau.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavcodec"/xvmc.h "/mingw/in
clude/libavcodec"
install -m 644 "/c/ffmpeg/build"/libavcodec/libavcodec.pc "/mingw/lib/pkgconfig"
install -d "/mingw/include/libavutil"
install -d "/mingw/lib/pkgconfig"
install -m 644 "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/adler32.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/avstr
ing.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/avutil.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/base64.h "/c/ff
mpeg/ffmpeg-export-2009-09-02/libavutil"/common.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/crc.h "/c/ffmpeg/ffmpeg-exp
ort-2009-09-02/libavutil"/fifo.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/intfloat_readwrite.h "/c/ffmpeg/ffmpeg-expor
t-2009-09-02/libavutil"/log.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/lzo.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libav
util"/mathematics.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/md5.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/mem.
h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/pixfmt.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/rational.h "/c/ffmp
eg/ffmpeg-export-2009-09-02/libavutil"/sha1.h "/mingw/include/libavutil"
install -m 644 "/c/ffmpeg/build"/libavutil/libavutil.pc "/mingw/lib/pkgconfig"
install -d "/mingw/include/libswscale"
install -d "/mingw/lib/pkgconfig"
install -m 644 "/c/ffmpeg/ffmpeg-export-2009-09-02/libswscale"/swscale.h "/mingw/include/libswscale"
install -m 644 "/c/ffmpeg/build"/libswscale/libswscale.pc "/mingw/lib/pkgconfig"
gcc -DHAVE_AV_CONFIG_H -I. -I"/c/ffmpeg/ffmpeg-export-2009-09-02" -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -D_FILE_OFFSET_B
ITS=64 -D_LARGEFILE_SOURCE -std=c99 -fno-common -fomit-frame-pointer -g -Wdeclaration-after-statement -Wall -Wno-switch -Wdi
sabled-optimization -Wpointer-arith -Wredundant-decls -Wno-pointer-sign -Wcast-qual -Wwrite-strings -Wundef -O3 -fno-math-er
rno -fno-tree-vectorize        -MMD -MF ffmpeg.d -MT ffmpeg.o -c -o ffmpeg.o /c/ffmpeg/ffmpeg-export-2009-09-02/ffmpeg.c
gcc -L"/c/ffmpeg/build"/libavcodec -L"/c/ffmpeg/build"/libavdevice -L"/c/ffmpeg/build"/libavfilter -L"/c/ffmpeg/build"/libav
format -L"/c/ffmpeg/build"/libavutil -L"/c/ffmpeg/build"/libpostproc -L"/c/ffmpeg/build"/libswscale -Wl,--warn-common -Wl,--
as-needed -Wl,-rpath-link,"/c/ffmpeg/build"/libpostproc -Wl,-rpath-link,"/c/ffmpeg/build"/libswscale -Wl,-rpath-link,"/c/ffm
peg/build"/libavfilter -Wl,-rpath-link,"/c/ffmpeg/build"/libavdevice -Wl,-rpath-link,"/c/ffmpeg/build"/libavformat -Wl,-rpat
h-link,"/c/ffmpeg/build"/libavcodec -Wl,-rpath-link,"/c/ffmpeg/build"/libavutil -Wl,-Bsymbolic -o ffmpeg_g.exe ffmpeg.o cmdu
tils.o -lavfilter -lavdevice -lavformat -lavcodec -lavutil -lswscale -lz -lm  -lvfw32
cp -p ffmpeg_g.exe ffmpeg.exe
strip ffmpeg.exe
install -d "/mingw/bin"
install -c -m 755 ffmpeg.exe ffplay.exe "/mingw/bin"
install -d "/mingw/share/ffmpeg"
install -m 644 /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-baseline.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffp
resets/libx264-default.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-fastfirstpass.ffpreset /c/ffmpeg/ffmpeg
-export-2009-09-02/ffpresets/libx264-hq.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-ipod320.ffpreset /c/ff
mpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-ipod640.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-lossle
ss_fast.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-lossless_max.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-
02/ffpresets/libx264-lossless_medium.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-lossless_slow.ffpreset /c
/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-lossless_slower.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/lib
x264-lossless_ultrafast.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-main.ffpreset /c/ffmpeg/ffmpeg-export-
2009-09-02/ffpresets/libx264-max.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-normal.ffpreset /c/ffmpeg/ffm
peg-export-2009-09-02/ffpresets/libx264-slowfirstpass.ffpreset "/mingw/share/ffmpeg"

2009年9月6日 星期日

bookmark - ffmpeg and SDL tutorial

ffmpeg and SDL tutorial : 這個就是有名的 "How to write a video player in 1000 lines".


順便寫一下,這個也有說明 ffmpeg 的 source code architecture

www.wiki.multimedia.cx

其實這些link 在 ffmpeg 的主站就有link

bookmark : video sample site - mplayer

mplayer 的網站有放很多壓縮格式的 sample file:

2009年9月4日 星期五

SDL programming - draw pixel

SDL library 裝完後,就可以試試SDL。 先從 SDL 手動繪圖 (描點) 來看 : 參考的是 Linux Journal : a crash course in SDL 還有 SDL Wiki 看起來 SDL 的用發跟 DirectDraw 類似。 也是以 Surface 為操作主體。 在使用之前,要 作 initialize: SDL_Init(SDL_INIT_VIDEO);然後create 一個你要的 surface,可以任意指定這個 video surface 的 format (color depth, color space(?), dimension): SDL_Surface *screen; screen = SDL_SetVideoMode(640,480,16,SDL_FULL_SCREEN); 接下來就跟 DirectDraw 很像.. surface 的 structure 中包含 surface 的 raw data arrary (就像是 framebuffer一樣),可以直接作read/write pixel 的動作。 但是在操作之前,要lock surface,操作完後 unlock: Uint16 *raw_pixels; SDL_LockSurface(screen); raw_pixels = (Uint16 *)screen->pixels; 要"填寫" raw pixel value,可以利用 screen structure 中另一個資訊:format。 format 包涵 color bit 的 有效bit和 bit 位置的資料: 在 example program 可以看出來: Uint value; value = ((red >>fmt->Rloss) <<fmt->Rshift) + .... R.G.B 三色分別有對應的無效 bit 數 (Xloss) 和位置(Xshift) 還有 raw_pixels[] array 的 x, y 對應,可以依照 screen structure 的 pitch 的資料。 pitch 代表 一條 y line 的 byte 數。 example code 中,填寫 (x,y) 點的 offset 是:
screen->pitch/2 * y + 1
-- 因為 raw_pixels 是 Uint16,所以要/2。 畫完圖後SDL_Unlock(screen)。 再call SDL_UpdateRect(screen,0,0,0,0) 把 surface update 到真正的螢幕上。
完整code: #include "SDL.h" Uint16 CreateHicolorPixel(SDL_PixelFormat *fmt, Uint8 red, Uint8 green, Uint8 blue) { Uint16 value; value = ((red >>fmt->Rloss) << fmt->Rshift) + ((green>>fmt->Gloss) << fmt->Gshift) + ((blue >>fmt->Bloss) << fmt->Bshift); return value; } int main(int argc,char* argv[]) { SDL_Surface *screen; Uint16 *raw_pixels; int x,y; SDL_Init(SDL_INIT_VIDEO); atexit(SDL_Quit); screen = SDL_SetVideoMode(640,480,16,SDL_FULLSCREEN); SDL_LockSurface(screen); raw_pixels = (Uint16*)screen->pixels; for(x=0;x<256;x++){ for(y=0;y<256;y++){ Uint16 pixel_color; int offset; pixel_color=CreateHicolorPixel(screen->format,x,0,y); offset=(screen->pitch/2 *y+x); raw_pixels[offset]=pixel_color; } } SDL_UnlockSurface(screen); SDL_UpdateRect(screen,0,0,0,0); SDL_Delay(3000); return 0; } build command 可以利用 sdl-config 吐出 build optin:
gcc sdl1.c -o sdl1 `sdl-config --cflags --libs`

2009年9月3日 星期四

ffplay in gdb & ffmpeg library

試試在 gdb 裡面 run ffmpeg。
首先要build none-strip 版本。
先 configure --help 列出 configure option。其中有:
Developer options (useful when working on FFmpeg itself):
--disable-debug          disable debugging symbols
--enable-debug=LEVEL     set the debug level []
--enable-gprof           enable profiling with gprof []
--disable-optimizations  disable compiler optimizations
--enable-extra-warnings  enable more compiler warnings
--disable-stripping      disable stripping of executables and shared libraries
所以重新configuer,加上 --disable-optimizations --disable-stripping。
然後就可以開始make
gdb 的話,我是用 gdb-6.8-mingw-3 這個版本 (一樣,download bz2 解開,覆蓋 mingw 下)。
先照著 Tetralet 這一篇 作一次,了解 gdb 的使用方式。
還有 study area 這一篇 也是 step by step,也照著作一下。

ffplay.c 是ffmpeg 附的播放程式。可以從這邊開始 run,看 ffmpeg decode 的程序。
ffplay.c 的 decode 是在 open_stream( ) 中 create 的 decode_thread( ) 作得。
其中 libavformat/utils.c : av_read_frame_internal( ) 負責從 stream 中解出 frame。

follow 這一篇(http://ffmpeg.arrozcru.org/wiki/index.php?title=Static)的 ffmpeg build 步驟,ffmpeg include 和 lib 會被 install 在
/usr/local/include
/usr/local/lib
所以compile 的時候要加上 -I/usr/local/include -L/usr/local/lib -lavdevice -lavformat -lavcodec -lavutil -lswscale

如果在config ffmpeg 時指定 --prefix=/mingw ,就不用 額外 寫明 -I, -L path。

2009年9月2日 星期三

msys, mingw

follow 這個link 安裝 msys + mingw 時要知道的事:
msys 和 mingw 是兩個不一樣的東西。
msys 和 mingw 都有自己的 file hierarchy (bin, usr, lib,...)。
所以,當自己 download msys, mingw 的 package 下來安裝 (其實也就是解開-copy 覆蓋)時。
  • 屬於 msys 的 package,就要 copy 到 msys 的 folder root。
  • 屬於 mingw 的 package,就要 copy 到 mingw 的 folder root。
link 中,build ffplay 安裝 SDL lib 時,有一個地方好像寫錯:
Copy all the files from the lib folder to C:\msys\mingw\lib\.
Copy the SDL folder from the include folder to C:\msys\mingw\include\.
Copy all the files from the bin folder to C:\msys\mingw\bin\.
其中的 path 應該是
C:\mingw\lib\.
C:\mingw\include\.
C:\mingw\bin\.
因為follow default setting 的話, minGW 是 install 在 c:\mingw。
而且mingw 比 msys 先安裝,要怎樣 install 到 msys 的 folder 中呢?
這一篇有圖文並茂的 msys, mingw的安裝教學 (我沒看 )

標籤

網誌存檔