新聞中心

        EEPW首頁 > 嵌入式系統 > 設計應用 > 移植 ffmpeg 到 ARM 平臺

        移植 ffmpeg 到 ARM 平臺

        作者: 時間:2016-11-09 來源:網絡 收藏
        一、下載yasm:

        到http://www.tortall.net/projects/yasm/wiki/Download下載yasm0.7.2(x264需要用到的匯編編譯器)

        本文引用地址:http://www.104case.com/article/201611/317672.htm

        for x86:

        ./configure --enable-shared --prefix=/usr/local
        make
        make install

        for arm:
        ./configure --enable-shared --prefix=/usr/local/ --host=arm-linux
        make
        make install

        下載安裝x264

        到 ftp://ftp.videolan.org/pub/videolan/x264/snapshots/ 下載x264庫
        for x86:
        ./configure --enable-shared --prefix=/usr/local
        make
        make install
        for arm:
        ./configure --enable-shared
        修改config.mak文件,將其中的CC=gcc,AS=yasm修改成CC=arm-linux-gcc,AS=arm-linux-as。—>make。之后便生成了可執行文件X264。
        這里會出錯,解決辦法:將解壓文件夾下的common文件夾下的cpu.c中的#elif defined(SYS_LINUX) unsigned int bit; int np; cpu_set_t p_aff; memset( &p_aff, 0, sizeof(p_aff) );sched_getaffinity( 0, sizeof(p_aff), &p_aff );for( np = 0;bit = 0; bit < sizeof(p_aff); bit++ );np += (((uint8_t *)&p_aff)[bit / 8] >> (bit % 8)) & 1;return np;
        改成了:#elif defined(SYS_LINUX)
        return 1 ;
        二、下載安裝xvid庫
        到 http://downloads.xvid.org/downloads/xvidcore-1.1.3.tar.gz下載xvid
        for x86:
        cd build/generic
        ./configure --prefix=/usr/local
        make
        make install
        for arm:
        #./configure --prefix=/usr/local/ --host=arm-linux --target=arm-linux
        ./configure --prefix=/usr/local/ --host=arm-hismall-linux --target=arm-hismall-linux
        make
        make install
        三、下載ffmpeg
        http://download.chinaunix.net/download.php?id=5532&ResourceID=2990在這個網址上下載了ffmpeg-0.4.9-p20051120.tar.bz2,然后解壓。
        (1)修改configure文件,要修改的如下
        prefix="/usr/local/ffmpeg-arm"
        cross_prefix="/usr/local/arm/3.3.2/bin/"
        cc="arm-linux-gcc"
        ar="arm-linux-ar"
        ranlib="arm-linux-ranlib"
        strip="arm-linux-strip"
        cpu="armv41"
        由于cc、ar、ranlib、strip都是交叉編譯環境中的執行文件,也可以這樣配置
        prefix="/usr/local/ffmpeg-arm"
        cross_prefix="/usr/local/arm/3.3.2/bin/arm-linux-"
        cpu="armv41"
        (2)執行
        ./configure --enable-shared --disable-strip
        說明:如果不加--disable-strip,那么在編譯之后,動態鏈接庫會有問題。在運行程序鏈接該三個鏈接庫的時候,會出現"skippingincompatible"錯誤。我猜想是在安裝動態庫之前,利用了strip對其進行了處理,而不是調用arm-linux-strip,所以造成了動態庫的損壞。(比如gcc編譯得到的動態庫,利用arm-linux-gcc去鏈接該動態庫,當然會出現"skippingincompatible"錯誤)。
        (3)編譯并安裝
        make
        make install
        安裝完成后,在/usr/local/ffmpeg-arm文件下有三個文件夾,分別為頭文件夾include、動態庫文件夾lib和執行文件夾bin。
        由于是利用動態鏈接庫,bin目錄下的執行文件需要lib下的動態庫的支持。在實驗箱上運行ffmpeg,必須把lib下的動態庫燒寫到/usr/lib或者/lib目錄下。
        (4)測試
        把include文件夾下的ffmpeg文件夾到/usr/local/arm/3.3.2/include目錄下。那么在測試程序中的包含文件可以這樣寫#include
        編譯:arm-linux-gcc -o test test.c -L/usr/local/ffmpeg-arm/lib-lavformat -lavcodec
        -lavutil
        在實驗箱運行測試程序,必須把動態庫文件燒寫到/usr/lib或者/lib下。

        (5)ffmpeg+ffserver構建視頻服務器(攝像頭作為視頻采集端口,通過ffmpeg進行mpeg4編碼,然后通過ffserver使用rtp協議傳輸視頻!)
        首先啟動ffserver。啟動ffserver之前必須先配置好ffserver。配置文件如下
        Port 8090

        BindAddress 0.0.0.0
        #最大鏈接數
        MaxClients 1000
        #帶寬上限
        MaxBandwidth 10000
        CustomLog -
        NoDaemon
        #配置緩沖文件

        #緩沖文件所在目錄
        File /tmp/feed1.ffm
        #緩沖大小
        FileMaxSize 1M
        #允許鏈接的地址
        ACL allow 127.0.0.1

        #配置視頻文件的參數

        Feed feed1.ffm
        Format asf
        NoAudio
        VideoCodec mpeg4
        VideoFrameRate 15
        VideoSize 320x240
        VideoBitRate 256
        VideoBufferSize 40
        VideoGopSize 30
        #AudioBitRate 64
        StartSendOnKey
        ACL allow 192.168.0.0 192.168.255.255

        這樣就可以啟動ffserver了,使用格式如下:./ffserver -f test.conf
        然后再啟動ffmpeg,使用方法:ffmpeg -f video4linux -s 320*240 -r 15 -i /dev/video0 http://localhost:8090/feed1.ffm
        這樣服務器端就OK了,客戶端不知道為什么怎么也不行!
        郁悶!!!!!!!!!!!!!!!!!!!!!!11

        二、ffmpeg在VC下使用
        首先下載一個ffmpeg SDK,現在最新版本3.2,下載地址:http://www.bairuitech.com/html/ruanjianxiazai/ffmpeg/20080414/89.html,然后解壓后,將庫文件和頭文件加到VC中去,將動態鏈接庫文件拷貝到自己的工程目錄下。如果出現各種找不到可以解析的外部函數名,一般都是由于沒有將相應的頭文件和庫文件加入的原因!!!!!!!!!!!


        關鍵詞: 移植ffmpegARM平

        評論


        技術專區

        關閉
        主站蜘蛛池模板: 高雄市| 高雄县| 尼勒克县| 怀安县| 千阳县| 林甸县| 潮州市| 永平县| 桑日县| 赣榆县| 离岛区| 滨州市| 中江县| 永寿县| 长阳| 吴桥县| 威海市| 远安县| 安图县| 庐江县| 临清市| 凌海市| 高碑店市| 昌都县| 达孜县| 卢氏县| 杭锦后旗| 买车| 洛川县| 漳平市| 汪清县| 潞西市| 赞皇县| 永德县| 黑龙江省| 宜宾市| 环江| 浦城县| 赤壁市| 惠来县| 桐梓县|