當前位置:首頁 » 編程軟體 » macffmpeg編譯代碼

macffmpeg編譯代碼

發布時間: 2022-08-17 12:08:04

❶ 如何在MAC下編譯出32位的ffmpeg庫

你的系統應該是64位的,但是如果你的XCode也是64位的就有可能出錯,XCode3.2以後的版本都是64位的,想編譯成32位的,試試用XCode3.0

❷ ffmpeg configure 腳本是什麼生成的

NDK全稱:Native Development Kit。

1、NDK是一系列工具的集合。
* NDK提供了一系列的工具,幫助開發者快速開發C(或C++)的動態庫,並能自動將so和java應用一起打包成apk。這些工具對開發者的幫助是巨大的。[1]
* NDK集成了交叉編譯器,並提供了相應的mk文件隔離平台、CPU、API等差異,開發人員只需要簡單修改mk文件(指出「哪些文件需要編譯」、「編譯特性要求
」等),就可以創建出so。
* NDK可以自動地將so和Java應用一起打包,極大地減輕了開發人員的打包工作。
2、NDK提供了一份穩定、功能有限的API頭文件聲明。
Google明確聲明該API是穩定的,在後續所有版本中都穩定支持當前發布的API。從該版本的NDK中看出,這些API支持的功能非常有限,包含有:C標准庫(libc
)、標准數學庫(libm)、壓縮庫(libz)、Log庫(liblog)。
3. 利用ndk編譯ffmpeg
ndk自帶的文檔,其中有一篇STANDALONE-TOOLCHAIN.html,裡面涉及了獨立編譯的方法,

A typical use case if invoking the 'configure' script of an open-source library that expects a cross-compiler in the CC environment variable.
那意思很明顯我們可以用這種獨立編譯方法,編譯一些由『configure』腳本生成的開源庫,這篇介紹了把ndk當成普通編譯工具使用,比我我們在linux使用的gcc命令,其實ndk都為我們提供了,甚至ndk還為我們提供了make工具。

此外你還需要了解configure參數,你可以用./configrue --help ->help.txt 生成幫助文件。我的編譯代碼如下:
./configure \
--logfile=FILE \
--prefix='/home/wangping/source/ffmpeg_ndk/release' \
--enable-gpl \
--enable-version3 \
--enable-nonfree \
--disable-doc \
--disable-programs \
--disable-avdevice \
--enable-small \
--cross-prefix='/home/wangping/arm_android14_toolchain/bin/arm-linux-androideabi-' \
--enable-cross-compile \
--target-os=linux \
--extra-cflags='-I/home/wangping/arm_android14_toolchain/sysroot/usr/include' \
--extra-ldflags='-L/home/wangping/arm_android14_toolchain/sysroot/usr/lib' \
--arch=arm \
--disable-symver \
--disable-debug \
--disable-stripping \
--extra-cflags="-fPIC -DANDROID" \

logfile: 是輸出日誌一的文件名

prifix :在運行make install後,他會相應生成的庫文件,及頭文件拷貝的指定文件夾
cross-prefix:是你編譯工具的前綴

extra-cflags:都是編譯時候的選項,你在裡面要提供頭文件的位子
extra-ldflags:是連接時候的選項,要提供你庫文件的件子
這些配置,你要參考 STANDALONE-TOOLCHAIN.htm ,你還可以自成由發揮,只要正確地指定 gcc,等編譯工具和頭文件以及鏈接庫的位子即可, 比如你可以把extra-cflags和extra-ldflags去掉,而加sysroot先項,configure完成後,就運行make了。

❸ ffmpeg 如何指定編譯哪些庫

FFmpeg在Windows系統下的編譯過程,分四步:
如下:
1. 配置編譯環境
2. 下載FFMPEG的代碼
3. 編譯,獲取FFMPEG庫(頭文件,lib,和DLL)
4. 在VC下配置,測試
1. 配置編譯環境
1)安裝MSys
下載文件:
bash-3.1-MSYS-1.0.11-snapshot.tar.bz2
msysCORE-1.0.11-20080826.tar.gz
解壓msysCORE-1.0.11-20080826.tar.gz,比如解壓到X:\msys(以下內容都使用該路徑描述,X為你安裝的盤符)。
解壓bash-3.1-MSYS-1.0.11-snapshot.tar.bz2,產生一個名為bash-3.1的目錄,在該目錄下有一個子目錄名為bin,其他的目錄不需要關心。復制bin目錄中的所有文件到D:\msys\bin,提示是否要覆蓋sh.exe的時候,選擇是。
到「D:\msys\postinstall」目錄下執行pi.bat,在出現的提示中輸入n回車後(這個不搞錯了),按任意鍵退出即可。

❹ 請教ffmpeg在centeOS 64位下的編譯問題

軟體安裝


(1). MinGW+Msys安裝


下載MSYS,解壓到E:/ffmpeg64/msys目錄。


下載MinGW-w64,解到E:/ffmpeg64/msys/mingw64目錄。


啟動msys.bat,打開類似於Linux的終端,並導入mingw64的環境變數。


echo 'export PATH=.:/local/bin:/mingw64/bin:/bin' > .profile

source .profile

(2). SDL安裝


下載SDL1.2.14,解壓到E:/ffmpeg64/SDL-1.2.14目錄。


進入SDL-1.2.14目錄,依次執行:


./configure --host=x86_64-w64-mingw32

make

make install

編譯過程中,出現如下錯誤:

❺ ios 怎麼配置編譯ffmpeg

一、系統環境

MAC OS X Mountain Lion 10.8.3、 XCode 5.1

二、編譯FFMpeg

1、下載ffmpeg2.2.5版本代碼,並解壓。

2、下載並解壓gas-preprocessor.pl (附件中有,zip格式,因網易博客不能上傳zip後綴的文件,故加了個.rar)

在終端中使用cp命令將它復制到 /usr/sbin/目錄,並賦予可執行許可權。

sudo cp -f gas-preprocessor/gas-preprocessor.pl /usr/sbin/chmod +x /usr/sbin/gas-preprocessor.pl

3、在ffmpeg目錄下創建一個config.sh腳本

#!/bin/bash
SDKVERSION="7.1"

ARCHS="armv7 armv7s i386"

DEVELOPER=`xcode-select -print-path`

cd "`dirname "$0"`"
REPOROOT=$(pwd)

# where we will store intermediary builds
INTERDIR="${REPOROOT}/built"
mkdir -p $INTERDIR

########################################
# Exit the script if an error happens

for ARCH in ${ARCHS}
do
if [ "${ARCH}" == "i386" ];
then
PLATFORM="iPhoneSimulator"
EXTRA_CONFIG="--arch=i386 --disable-asm --enable-cross-compile --target-os=darwin --cpu=i386"
EXTRA_CFLAGS="-arch i386"
EXTRA_LDFLAGS="-I${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDKVERSION}.sdk/usr/lib"
else
PLATFORM="iPhoneOS"
EXTRA_CONFIG="--arch=arm --target-os=darwin --enable-cross-compile --cpu=cortex-a9 --disable-armv5te"
EXTRA_CFLAGS="-w -arch ${ARCH}"
fi

mkdir -p "${INTERDIR}/${ARCH}"

./configure --prefix="${INTERDIR}/${ARCH}"
--disable-neon
--disable-armv6
--disable-armv6t2
--disable-ffmpeg
--disable-ffplay
--disable-ffprobe
--disable-ffserver
--disable-iconv
--disable-bzlib
--enable-avresample
--sysroot="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDKVERSION}.sdk"
--cc="${DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
--as='/usr/local/bin/gas-preprocessor.pl'
--extra-cflags="${EXTRA_CFLAGS} -miphoneos-version-min=${SDKVERSION}"
--extra-ldflags="-arch ${ARCH} ${EXTRA_LDFLAGS} -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDKVERSION}.sdk -miphoneos-version-min=${SDKVERSION}" ${EXTRA_CONFIG}
--enable-pic
--extra-cxxflags="$CPPFLAGS -isysroot ${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDKVERSION}.sdk"

make && make install && make clean

done

mkdir -p "${INTERDIR}/universal/lib"

cd "${INTERDIR}/armv7/lib"
for file in *.a
do

cd ${INTERDIR}
xcrun -sdk iphoneos lipo -output universal/lib/$file -create -arch armv7 armv7/lib/$file -arch armv7s armv7s/lib/$file -arch i386 i386/lib/$file
echo "Universal $file created."

done
cp -r ${INTERDIR}/armv7/include ${INTERDIR}/universal/

echo "Done."

SDKVERSION 是XCode的版本,通過`xcode-select -print-path`來獲取XCode的安裝路徑,ARCHS是編譯的三種模式,接下來在終端中cd到ffmpeg目錄,./config.sh執行就可以編譯了。等到編譯完成後,在ffmpeg目錄下會多出一個built目錄,裡面分別是armv7 armv7s i386及三個合並的universal版本了。

❻ 如何把ffmpeg編譯進motion

ffmpeg編譯

首先解壓ffmpeg-0.5.1.tar.bz2,,執行configure命令如下:

[plain] view plain
./configure --cc=arm-linux-gnueabihf-gcc --host-cc=arm-linux-gnueabihf --prefix=/home/***/iWork/common/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux --enable-cross-compile --arch=arm --disable-yasm

編譯:

[plain] view plain
make

出現錯誤如下:

[plain] view plain
arm-linux-gnueabihf-gcc -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -I. -I"/home/***/iWork/lamobo/motion-3.2.12-arm-project/ffmpeg-0.5.1"
-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -std=c99 -fomit-frame-pointer -g -Wdeclaration-after-statement -Wall -Wno-switch -Wdisabled-optimization
-Wpointer-arith -Wrendant-decls -Wno-pointer-sign -Wcast-qual -Wwrite-strings -Wtype-limits -Wundef -O3 -fno-math-errno -fno-signed-zeros -c -o
libavcodec/dsputil.o libavcodec/dsputil.c
/tmp/ccOmDdh7.s: Assembler messages:
/tmp/ccOmDdh7.s:51789: Error: thumb conditional instruction should be in IT block -- `movgt fp,r9'
/tmp/ccOmDdh7.s:51790: Error: thumb conditional instruction should be in IT block -- `movgt r9,r8'
/tmp/ccOmDdh7.s:51792: Error: thumb conditional instruction should be in IT block -- `movle r9,r7'
/tmp/ccOmDdh7.s:51794: Error: thumb conditional instruction should be in IT block -- `movgt fp,r9'
/tmp/ccOmDdh7.s:51889: Error: thumb conditional instruction should be in IT block -- `movgt r9,r8'
/tmp/ccOmDdh7.s:51890: Error: thumb conditional instruction should be in IT block -- `movgt r8,ip'
/tmp/ccOmDdh7.s:51892: Error: thumb conditional instruction should be in IT block -- `movle r8,r6'
/tmp/ccOmDdh7.s:51894: Error: thumb conditional instruction should be in IT block -- `movgt r9,r8'
make: *** [libavcodec/dsputil.o] Error 1
這需要修改~/ffmpeg-0.5.1/config.mak,在OPTFLAGS(line:16)選項中添加:
[plain] view plain
-Wa,-mimplicit-it=thumb
加入這句的意思是在使用Thumb ISA指令編譯時自動產生「IT」指令。 繼續編譯,又報錯:
[plain] view plain
strip: Unable to recognise the format of the input file `ffmpeg'
這是strip沒有使用交叉編譯的版本所致,由於此時我們需要的庫文件已經編成,所以這個錯誤可以忽略不計,修改config.mak中的strip為arm-linux-gnueabihf-strip,繼續讓編譯完成

motion編譯

motion中的ffmpeg.c是對ffmpeg api的封裝,向其他模塊提供功能。如在主程序文件motion.c中

[cpp] view plain
//......

#ifdef HAVE_FFMPEG
/* FFMpeg initialization is only performed if FFMpeg support was found
* and not disabled ring the configure phase.
*/
ffmpeg_init();
#endif /* HAVE_FFMPEG */

//......

這里ffmpeg_init就是ffmpeg.c中封裝的方法:

[cpp] view plain
void ffmpeg_init()
{
motion_log(LOG_INFO, 0, "ffmpeg LIBAVCODEC_BUILD %d LIBAVFORMAT_BUILD %d", LIBAVCODEC_BUILD, LIBAVFORMAT_BUILD);
av_register_all();

#if LIBAVCODEC_BUILD > 4680
av_log_set_callback( (void *)ffmpeg_avcodec_log );
#endif

/* Copy the functions to use for the append file protocol from the standard
* file protocol.
*/
mpeg1_file_protocol.url_read = file_protocol.url_read;
mpeg1_file_protocol.url_write = file_protocol.url_write;
mpeg1_file_protocol.url_seek = file_protocol.url_seek;
mpeg1_file_protocol.url_close = file_protocol.url_close;

/* Register the append file protocol. */
#if LIBAVFORMAT_BUILD >= (52<<16 | 31<<8)
av_register_protocol(&mpeg1_file_protocol);
#else
register_protocol(&mpeg1_file_protocol);
#endif
}
我們需要在motion的Makefile中加入對ffmpeg模塊的編譯,並且打開HAVE_FFMPEG等開關。首先執行configure如下:
[plain] view plain
./configure CC=arm-linux-gnueabihf-gcc --host=arm-linux-gnueabihf --prefix=/home/stewart/iWork/common/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux
生成Makefile,在OBJ選項中添加ffmpeg.o:
[plain] view plain
OBJ = ffmpeg.o motion.o conf.o draw.o jpegutils.o $(VIDEO_OBJ) netcam.o \
netcam_ftp.o netcam_jpeg.o netcam_wget.o track.o \
alg.o event.o picture.o rotate.o webhttpd.o \
webcam.o

在CFLAGS選項中添加-DHAVE_FFMPEG -DFFMPEG_NEW_INCLUDES -DHAVE_FFMPEG_NEW的定義,加入libjpeg頭文件搜索目錄

[plain] view plain
libdir = ${prefix}/lib
incdir = ${prefix}/include

[plain] view plain
CFLAGS = -g -O2 -DHAVE_FFMPEG -DFFMPEG_NEW_INCLUDES -DHAVE_FFMPEG_NEW -D_REENTRANT
-DMOTION_V4L2 -DMOTION_V4L2_OLD -DTYPE_32BIT="int" -DHAVE_BSWAP -Wall
-DVERSION=\"3.2.12\" -Dsysconfdir=\"$( sysconfdir)\"
在LIBS中加入對ffmpeg庫的支持:
[plain] view plain
LIBS = -L${libdir} -static -lavformat -lavcodec -lavutil -ljpeg -lm -lpthread

預備工作完成,make,編譯報錯:

[plain] view plain
motion.h:44:28: fatal error: linux/videodev.h: No such file or directory
compilation terminated.

由於linux-2.4以上的內核已經取消了videodev.h文件,需要安裝libv4l-dev,然後將motion.h,video.h中的

[plain] view plain
#include <linux/videodev.h>

修改為

[cpp] view plain
#include <libv4l1-videodev.h>

繼續,又報錯:

[plain] view plain
track.c: In function 『uvc_center』:
track.c:587:29: error: storage size of 『control_s』 isn』t known
track.c:589:24: error: 『V4L2_CID_PRIVATE_BASE』 undeclared (first use in this function)
track.c:589:24: note: each undeclared identifier is reported only once for each function it appears in
track.c:592:24: error: 『VIDIOC_S_CTRL』 undeclared (first use in this function)
track.c:601:31: error: storage size of 『queryctrl』 isn』t known
track.c:605:24: error: 『VIDIOC_QUERYCTRL』 undeclared (first use in this function)
track.c:601:31: warning: unused variable 『queryctrl』 [-Wunused-variable]
track.c:587:29: warning: unused variable 『control_s』 [-Wunused-variable]
track.c:636:25: error: storage size of 『control_s』 isn』t known
track.c:636:25: warning: unused variable 『control_s』 [-Wunused-variable]
track.c: In function 『uvc_move』:
track.c:724:29: error: storage size of 『control_s』 isn』t known
track.c:726:24: error: 『V4L2_CID_PRIVATE_BASE』 undeclared (first use in this function)
track.c:729:24: error: 『VIDIOC_S_CTRL』 undeclared (first use in this function)
track.c:724:29: warning: unused variable 『control_s』 [-Wunused-variable]
track.c:779:25: error: storage size of 『control_s』 isn』t known
track.c:779:25: warning: unused variable 『control_s』 [-Wunused-variable]
make: *** [track.o] Error 1
在track.c中添加:
[plain] view plain
#include <linux/videodev2.h>
繼續,報錯(怎麼還有啊?):
[plain] view plain
gcc -L/usr/local/lib -o motion motion.o conf.o draw.o jpegutils.o video.o video2.o video_common.o netcam.o netcam_ftp.o netcam_jpeg.o netcam_wget.o track.o alg.o event.o picture.o rotate.o webhttpd.o webcam.o ffmpeg.o -lm -lpthread -ljpeg -L/usr/local/lib -lavformat -lavcodec -lavutil -lm -lz
/usr/local/lib/libavformat.a(file.o):(.data+0x60): multiple definition of `file_protocol'
ffmpeg.o:(.data+0x0): first defined here
collect2: ld returned 1 exit status
原來結構體file_protocol在libavformat.a和ffmpeg.o中重復定義了,分別打開兩個定義:
[cpp] view plain
//libavformat/file.c:85
URLProtocol file_protocol = {
"file",
file_open,
file_read,
file_write,
file_seek,
file_close,
};
[cpp] view plain
//ffmpeg.c
URLProtocol file_protocol = {
"file",
file_open,
file_read,
file_write,
file_seek,
file_close,
#if LIBAVFORMAT_BUILD >= (52<<16 | 31<<8)
NULL,
NULL,
NULL,
#endif
};

將libavformat/file.c中的file_protocol定義注掉,重新編譯一份libavformat.a。然後繼續編譯motion,又報錯:

[plain] view plain
/home/xxx/iWork/Thrid_party/ffmpeg-0.5.1/libavformat/matroskadec.c:917: undefined reference to `BZ2_bzDecompressInit'
/home/xxx/iWork/Thrid_party/ffmpeg-0.5.1/libavformat/matroskadec.c:926: undefined reference to `BZ2_bzDecompress'
/home/xxx/iWork/Thrid_party/ffmpeg-0.5.1/libavformat/matroskadec.c:929: undefined reference to `BZ2_bzDecompressEnd'
這個需要libbz2庫,下載地址http://www.bzip.org/downloads.html
編譯安裝libbz2後將-lbz2加入motion的Makefile的LIBS選項:

[plain] view plain
LIBS = -lpthread -ljpeg -L/usr/lib -lavformat -lavcodec -lavutil -lm -lz -lbz2

❼ 如何在MAC上編譯FFMpeg-CSDN論壇

編譯mac 上基於ffmepg的軟體需要先下載兩個程序:iFrameExractor和ffmpeg
編譯步驟:
1、在終端下: cd /iFrameExtractor/ffmpeg 建議開始就執行 sudo -s (獲取許可權命令)
2、在終端下輸入 ./configure --prefix=/iFrameExtractor/ffmpeg --libdir=iFrameExtractor/ffmpeg/lib --enable-gpl --enable-static --disable-shared --enable-swscale --enable-zlib --enable-bzlib --disable-ffmpeg --disable-ffplay --disable-ffserver --enable-pthreads
3、執行make 這里會有一堆的編譯情況。
註:最好先升級Command Line Tools,避免編譯錯誤
4、執行make install。 (執行完後 到iFrameExtractor/ffmpeg/lib文件上去看看)
出現 libavcodec libavdevice libavformat libavutil libswscale5個.a文件
5、用xcode 打開iFrameExractor工程,確認Header Search Paths里有:"$(SRCROOT)/ffmpeg"路徑。 $(SRCROOT)表示工程路徑。同時可以看到iFrameExractor工程下ffmpeg文件下的.a文件都不是紅色的了。
6、真機上編譯(模擬器上i386,真機上是arm的,真機還分arm6 和arm7

以下是針對arm7的
/configure --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --enable-cross-compile --arch=arm --target-os=darwin --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc --as='gas-preprocessor/gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' -- sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk --cpu=cortex-a8 --extra-cflags='-arch armv7' --extra-ldflags='-arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk' --enable-pic
7、執行 make 和make install 就有上面的幾個.a文件,至此編譯結束。

❽ ios下 怎麼在代碼中調用ffmpeg的命令

ffmpeg是一個多平台多媒體處理工具,處理視頻和音頻的功能非常強大。目前在網上搜到的iOS上使用FFMPEG的資料都比較陳舊,而FFMPEG更新迭代比較快; 且網上的講解不夠詳細,對於初次接觸FFMPEG的新手(例如我)來說確實不太好使用。為了防止忘記,這里對iOS下使用FFMPEG做一個總結。

1. FFMPEG層次結構的簡單理解
要使用FFMPEG,首先需要理解FFMPEG的代碼結構。根據志哥的提示,ffmpeg的代碼是包括兩部分的,一部分是library,一部分是tool。api都是在library裡面,如果直接調api來操作視頻的話,就需要寫c或者c++了。另一部分是tool,使用的是命令行,則不需要自己去編碼來實現視頻操作的流程。實際上tool只不過把命令行轉換為api的操作而已。

2. 預熱-在mac os下使用ffmpeg
在mac os下使用ffmpeg比較簡單,可以直接使用命令行來操作。首先安裝ffmpeg,這里默認系統已經安裝好brew,只需要在終端上輸入:
brew install ffmpeg
等待安裝結束即可。
安裝結束後,嘗試以下命令:
ffmpeg -i input.mp4 output.avi
如果能順利轉換,表明安裝成功

3. 編譯能在iOS下使用的FFMPEG library庫
這一步是編譯1所說的library,編譯好之後可以調用FFMPEG的api。網上有一些方法,但都要自己手動編譯,稍顯復雜而且比較陳舊。按照app store的需求,編譯出來的包還必須支持arm64。我在萬能的github中找到一個能夠"一鍵編譯"的腳本,地址如下:
https://github.com/kewlbear/FFmpeg-iOS-build-script
而且寫這個腳本的歪果仁挺好人,更新很及時,已經更新到了最新的2.5.3版本。下載下來,只有一個build-ffmpeg.sh腳本文件。在終端中轉至腳本的目錄,執行命令:
./build-ffmpeg.sh
腳本則會自動從github中把ffmpeg源碼下到本地並開始編譯。
編譯結束後,文件目錄如下:

其中,ffmpeg-2.5.3是源碼,FFmpeg-iOS是編譯出來的庫,裡面有我們需要的.a靜態庫,一共有7個。
執行命令:
lipo -info libavcodec.a
查看.a包支持的架構,這幾個包都支持了armv7 armv7s i386 x86_64 arm64這幾個架構,這個腳本果真是業界良心啊~~~

4.在xcode中引入FFMPEG library庫
新建工程,把上面編譯好的FFmpeg-iOS拖到xcode工程中,添加一個頭文件引用

#include "avformat.h"
添加一個api語句:

av_register_all();
添加一個空的類,把執行文件.m後綴改為.mm,開啟混編模式。
添加相應的framework,包括avfoundation和coremedia。
運行工程,如果沒有報錯,則表明編譯成功。

5.在xcode項目中使用命令行
執行到第4步,已經可以使用library庫了。但是如果要對視頻進行操作,還是需要手動寫很多代碼去調用api,工作量較大,自然不如直接寫命令行方便。為了命令行能夠在xcode工程中使用,還需要做以下工作:
(1)添加源碼中的tools,具體文件包括:


(2)添加Header Search Paths
在target--build setting中搜索Header Search Paths,並在Header Search Paths下面添加源碼ffmpeg-2.5.3和scratch的路徑。
(3)修改ffmpeg.h和ffmpeg.c源碼

如果此時run這個工程,則會報錯,原因是工程裡面有2個main函數,此時處理方法為:
在ffmpeg.h中添加一個函數聲明:
int ffmpeg_main(int argc, char **argv);
在ffmpeg.c中找到main函數,把main函數改為ffmpeg_main。
(4)調用命令行範例
添加頭文件:#import "ffmpeg.h"
調用命令行
int numberOfArgs = 16;
char** arguments = calloc(numberOfArgs, sizeof(char*));

arguments[0] = "ffmpeg";
arguments[1] = "-i";
arguments[2] = inputPath;
arguments[3] = "-ss";
arguments[4] = "0";
arguments[5] = "-t";
arguments[6] = rationChar;
arguments[7] = "-vcodec";
arguments[8] = "";
arguments[9] = "-acodec";
arguments[10] = "aac";
arguments[11] = "-strict";
arguments[12] = "-2";
arguments[13] = "-b:a";
arguments[14] = "32k";
arguments[15] = outputPath;

int result = ffmpeg_main(numberOfArgs, arguments);
其中inputpath和outputpath是文件路徑。經測試,這兩個路徑不支持asset-library://協議和file:// 協議,所以如果是要用相冊的文件,我目前的解決辦法是把它拷貝到沙盒裡面。

6. 改關閉進程為關閉線程
如果順利進行到了第5步,在app中是能夠用命令行處理視頻了,但會出現一個問題,app會退出。經肖大神提醒,發現了命令行執行完畢之後會退出進程。而iOS下只能啟動一個進程,因此必須改關閉進程為關閉線程,或者直接把關閉進程的方法給注掉。

在ffmpeg.c中可以看到,執行退出進程的方法是exit_program,定位到了cmtils.c中執行了c語言的exit方法。這里我將它改為了pthread_exit(需要添加#include 頭文件)。在xcode項目中使用時,則可以用NSThread來新開一個線程,執行完畢之後,把線程關閉了即可。再使用NSThreadWillExitNotification通知,即可監聽線程退出的情況。

7. 修復ffmpeg.c裡面的一個bug
在實際項目中,可能需要多次調用命令行,但在多次調用命令行的過程中,發現ffmpeg.c的代碼中會訪問空屬性導致程序崩潰。逐步debug後發現,很多指針已經置空了,但它們的計數卻沒有置零,不知道是不是ffmpeg.c的一個bug。修復方法如下:在ffmpeg_cleanup方法下,將各個計數器置零,包括:
nb_filtergraphs
nb_output_files
nb_output_streams
nb_input_files
nb_input_streams
置零之後,重復使用ffmpeg_main方法一切正常。

❾ 如何讓FFmpeg在iOS上完美編譯

編譯mac上基於ffmepg的軟體需要先下載兩個程序:iFrameExractor和ffmpeg編譯步驟:1、在終端下:cd/iFrameExtractor/ffmpeg建議開始就執行sudo-s(獲取許可權命令)2、在終端下輸入./configure--prefix=/iFrameExtractor/ffmpeg--libdir=iFrameExtractor/ffmpeg/lib--enable-gpl--enable-static--disable-shared--enable-swscale--enable-zlib--enable-bzlib--disable-ffmpeg--disable-ffplay--disable-ffserver--enable-pthreads3、執行make這里會有一堆的編譯情況。註:最好先升級CommandLineTools,避免編譯錯誤4、執行makeinstall。(執行完後到iFrameExtractor/ffmpeg/lib文件上去看看)出現個.a文件5、用xcode打開iFrameExractor工程,確認HeaderSearchPaths里有:"$(SRCROOT)/ffmpeg"路徑。$(SRCROOT)表示工程路徑。同時可以看到iFrameExractor工程下ffmpeg文件下的.a文件都不是紅色的了。6、真機上編譯(模擬器上i386,真機上是arm的,真機還分arm6和arm7以下是針對arm7的/configure--disable-doc--disable-ffmpeg--disable-ffplay--disable-ffserver--enable-cross-compile--arch=arm--target-os=darwin--cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc--as='gas-preprocessor/gas-preprocessor.pl/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc'--sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk--cpu=cortex-a8--extra-cflags='-archarmv7'--extra-ldflags='-archarmv7-isysroot/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk'--enable-pic7、執行make和makeinstall就有上面的幾個.a文件,至此編譯結束。

❿ 如何用vc6編譯ffmpeg,並單步調試

目前官方ffmpeg的最新版本為0.9, 我們就以此為例:

1. 下載最新git版本的源代碼(http://ffmpeg.zeranoe.com/builds/, 本例下載的是2011-12-12版本)
2. 放到MSYS環境里配置,生成config.h文件。mingw gcc是能順利編譯通過整個項目的,並生成最新版的ffmpeg。
3. 建立vc6工程,把相關代碼都加入到工程中。由於在vc生成的obj都在一個目錄下,所以需要修改文件名,讓其不重名。
4. 安裝intel compiler 11編譯器,單獨提取其icl.exe及相關include目錄,替換掉vc6自帶的cl.exe, 在工程設置里加上/Qstd=c99,用於支持C99語法。
5. 安裝intel compiler 10編譯器,單獨提取lib目錄,因為此版本調試庫的結構能完美支持vc6的調試信息。
6. 在vc6的options里設置include/exe/lib查找目錄,指向intel編譯器。
7. 開始修改代碼,添加C99的相關linux頭文件, 用於支持vc6, (unistd.h, stdint.h, inttypes.h, getopt.h)
8. 添加C99和linux的相關實現代碼,ffmpeg需要用到: getopt_long, strtoll, gettimeofday, atoll, usleep等
9. 修改windows的相關兼容代碼,GetWindowLongPtr -> GetWindowLong, GWLP_USERDATA
10. 去除硬體加速libavcodec代碼,和依賴庫代碼。選擇所需要的模塊,修改相關的allcodec.c, alldevices.c, allfilters.c, allformats.c
11. 加上鏈接庫,sdl.lib, winmm.lib, dxguid.lib, wsock32.lib
12. 在os_support.c里,把<winsock2.h>移動到文件最前面。
13. 如果是ffmpeg, 已經能順利編譯了。如果是ffplay,還需要編譯靜態sdl, 並鏈接。
14. 等等,音頻運行不正確?有雪花聲?因為還需要替換所有文件里的<math.h>為<mathimf.h>, 默認的rint等數學函數和gcc不兼容。
15. ok, 大功告成,純C版本完美運行。
16. 由於ffmpeg0.9在c文件里,添加了一些intel compiler不支持的mmx語法,所以編譯mmx/sse加速版本時,一小部分.c文件需要依賴mingw gcc編譯成.o文件,再通過vc6的lib.exe工具轉換成lib,讓vc6鏈接上。當然還要加上yasm編譯的很多匯編obj.

熱點內容
androiddomain 發布:2025-02-07 02:46:04 瀏覽:842
埠掃描源碼 發布:2025-02-07 02:31:01 瀏覽:470
androidurl獲取圖片 發布:2025-02-07 02:22:11 瀏覽:482
調用上傳 發布:2025-02-07 02:19:53 瀏覽:84
aix編譯安裝 發布:2025-02-07 02:19:52 瀏覽:906
android界面設計尺寸 發布:2025-02-07 02:16:25 瀏覽:898
zenly安卓為什麼會一直閃 發布:2025-02-07 02:12:02 瀏覽:358
為什麼安卓手機界面總出廣告 發布:2025-02-07 02:10:33 瀏覽:244
plc數據塊怎麼編譯 發布:2025-02-07 02:09:44 瀏覽:98
ct加密 發布:2025-02-07 02:09:03 瀏覽:919