之前已試過在 Linux 的平台上練習 FFmpeg tutorial (見 FFmpeg tutorial practice - tutorial01),接著我想在 Mac OS X 上也做一樣的事。理論上,需要修改的地方應該不多,只是細節要怎麼處理就需要花一點時間試。當我把程式碼從 Linux 平台上放到 Mac OS 的平台上時,一樣先從 tutorial01 開始;當然,我們需要 Mac 版的 FFmpeg,所以需要在 Mac OS 平台上編譯出它的函式庫來用。我算是 Mac OS 平台上的新手,大約一年多的使用經驗,在 Linux 平台上知道怎麼做的事,到 Mac OS 平台上卻不一定知道怎麼處理。不過沒關係,花點時間找一下就可以了。
首先我遇到的是新增函式庫的問題,我使用的 Linux 平台是 Ubuntu,如果少了某某函式庫,可以用很多方式去安裝新的函式庫,Ubuntu 的軟體中心(Ubuntu Software Center)也做的不錯,可以很容易管理你的軟體安裝結果;但在 Mac OS 平台上,是用不同的方式做的,目前我用的是 MacPorts 來管理,因為在編譯 FFmpeg 時,遇到有缺少函式庫的問題,所以我用了 MacPorts 去新增了需要的函式庫。(MacPorts 的使用方法,在這裡就不說了,利用 Google 可以找到很多的說明。)
在編譯完 FFmpeg 之後,接著就是要編譯 tutorial01。直接拿之前在 Linux 平台上編譯過的程式碼來用,當然,一定會有問題的!
ld: library not found for -lrt
collect2: ld returned 1 exit status
make: *** [tutorial01] Error 1
找不找 rt 這個函式庫,那就先把它移除吧!
Undefined symbols for architecture x86_64:
"_BZ2_bzDecompress", referenced from:
_matroska_decode_buffer in libavformat.a(matroskadec.o)
"_BZ2_bzDecompressEnd", referenced from:
_matroska_decode_buffer in libavformat.a(matroskadec.o)
"_BZ2_bzDecompressInit", referenced from:
_matroska_decode_buffer in libavformat.a(matroskadec.o)
"_CFDataCreate", referenced from:
_end_frame in libavcodec.a(vda_h264.o)
_ff_vda_create_decoder in libavcodec.a(vda_h264.o)
"_CFDictionaryCreate", referenced from:
_end_frame in libavcodec.a(vda_h264.o)
"_CFDictionaryCreateMutable", referenced from:
_ff_vda_create_decoder in libavcodec.a(vda_h264.o)
"_CFDictionaryGetValue", referenced from:
_vda_decoder_callback in libavcodec.a(vda_h264.o)
"_CFDictionarySetValue", referenced from:
_ff_vda_create_decoder in libavcodec.a(vda_h264.o)
"_CFNumberCreate", referenced from:
_end_frame in libavcodec.a(vda_h264.o)
_ff_vda_create_decoder in libavcodec.a(vda_h264.o)
"_CFNumberGetValue", referenced from:
_vda_decoder_callback in libavcodec.a(vda_h264.o)
"_CFRelease", referenced from:
_end_frame in libavcodec.a(vda_h264.o)
_ff_vda_create_decoder in libavcodec.a(vda_h264.o)
"_CVPixelBufferGetBaseAddress", referenced from:
_vdadec_decode in libavcodec.a(vda_h264_dec.o)
"_CVPixelBufferGetBaseAddressOfPlane", referenced from:
_vdadec_decode in libavcodec.a(vda_h264_dec.o)
"_CVPixelBufferGetBytesPerRow", referenced from:
_vdadec_decode in libavcodec.a(vda_h264_dec.o)
"_CVPixelBufferGetBytesPerRowOfPlane", referenced from:
_vdadec_decode in libavcodec.a(vda_h264_dec.o)
"_CVPixelBufferGetPixelFormatType", referenced from:
_vda_decoder_callback in libavcodec.a(vda_h264.o)
"_CVPixelBufferGetPlaneCount", referenced from:
_vdadec_decode in libavcodec.a(vda_h264_dec.o)
"_CVPixelBufferIsPlanar", referenced from:
_vdadec_decode in libavcodec.a(vda_h264_dec.o)
"_CVPixelBufferLockBaseAddress", referenced from:
_vdadec_decode in libavcodec.a(vda_h264_dec.o)
"_CVPixelBufferRelease", referenced from:
_release_buffer in libavcodec.a(vda_h264_dec.o)
_ff_vda_release_vda_frame in libavcodec.a(vda_h264.o)
_ff_vda_destroy_decoder in libavcodec.a(vda_h264.o)
"_CVPixelBufferRetain", referenced from:
_vda_decoder_callback in libavcodec.a(vda_h264.o)
"_CVPixelBufferUnlockBaseAddress", referenced from:
_release_buffer in libavcodec.a(vda_h264_dec.o)
"_VDADecoderCreate", referenced from:
_ff_vda_create_decoder in libavcodec.a(vda_h264.o)
"_VDADecoderDecode", referenced from:
_end_frame in libavcodec.a(vda_h264.o)
"_VDADecoderDestroy", referenced from:
_ff_vda_destroy_decoder in libavcodec.a(vda_h264.o)
"_VDADecoderFlush", referenced from:
_end_frame in libavcodec.a(vda_h264.o)
"___CFConstantStringClassReference", referenced from:
CFString in libavcodec.a(vda_h264.o)
"_kCFAllocatorDefault", referenced from:
_end_frame in libavcodec.a(vda_h264.o)
_ff_vda_create_decoder in libavcodec.a(vda_h264.o)
"_kCFCoreFoundationVersionNumber", referenced from:
_vdadec_init in libavcodec.a(vda_h264_dec.o)
"_kCFTypeDictionaryKeyCallBacks", referenced from:
_end_frame in libavcodec.a(vda_h264.o)
_ff_vda_create_decoder in libavcodec.a(vda_h264.o)
"_kCFTypeDictionaryValueCallBacks", referenced from:
_end_frame in libavcodec.a(vda_h264.o)
_ff_vda_create_decoder in libavcodec.a(vda_h264.o)
"_kCVPixelBufferIOSurfacePropertiesKey", referenced from:
_ff_vda_create_decoder in libavcodec.a(vda_h264.o)
"_kCVPixelBufferPixelFormatTypeKey", referenced from:
_ff_vda_create_decoder in libavcodec.a(vda_h264.o)
"_kVDADecoderConfiguration_Height", referenced from:
_ff_vda_create_decoder in libavcodec.a(vda_h264.o)
"_kVDADecoderConfiguration_SourceFormat", referenced from:
_ff_vda_create_decoder in libavcodec.a(vda_h264.o)
"_kVDADecoderConfiguration_Width", referenced from:
_ff_vda_create_decoder in libavcodec.a(vda_h264.o)
"_kVDADecoderConfiguration_avcCData", referenced from:
_ff_vda_create_decoder in libavcodec.a(vda_h264.o)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [tutorial01] Error 1
接著,又出現了找不到 symbol 的訊息。我了解是少了函式庫的關係,但是哪幾個函式庫需要加呢?原來是需要加上下面幾個函式庫
-lbz2 -framework CoreFoundation
-framework CoreVideo -framework VideoDecodeAcceleration
這些問題排除之後,tutorial01 就可以正常地編譯了!
沒有留言:
張貼留言