首先入門級的 編譯寶典:
https://trac.ffmpeg.org/wiki/CompilationGuide/Android
http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/
二進制文件+so庫:
https://github.com/cine-io/android-ffmpeg-with-rtmp
一個利用二進制可執行文件的例子:
https://github.com/vanevery/Android-MJPEG-Video-Capture-FFMPEG
build_android.sh參數配置參考:http://www.cnblogs.com/ohmytime/archive/2013/05/12/ffmpeg-build-help.html
參數參考:http://www.cnblogs.com/ohmytime/archive/2013/05/12/ffmpeg-build-help.html
其次,確定你本地的 ssh正確生成並添加到了你的github的ssh 管理列表中,下面編譯需要使用。
我的rsa:參考:http://blog.csdn.net/wide288/article/details/21003749
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDC/1KQiZR/lTMYOKSUajVK/KRyn3oTOC8sIhNztoxvN36mL/B2u3bx8pUNfaFIoAQ709QDOybfXY54IbeLDr6NVzoqFpkptjB/GSG2hLoOyt4tlkfLMtFLm0OC+QjKa6b4RMdNeKUof5Qx7xvJ6E7dn7yfK4Mzt9y8RE1IF0VxJJW/RIsfgT0i9tUXXPT5Hh2DOzaT/Wza+8PeBY3NfnpoG7Yejjld9xeSV2NLLj6kbmZpBDiPDlJc1DMlcWr90VlrKWURVVEMuMbMgDE7e855hBJJMde5HMeW6xEQwuX8riCbu1rNzQam/awHj/FgMWnaZakllzPyfNdiZZhWdL9r 302940116@qq.com
這個環境的private key 我忙了一晚上 參考:https://help.github.com/articles/error-permission-denied-publickey/(從上到下一個一個驗證就行)
注意點: 1.如果 在生成ssh 的時候 你給的 文件名成不是 id_rsa ,后重命名的 ssh agent 是沒有的,
解決辦法:進行添加
ssh-add $HOME/.ssh/id_rsa
下面讓我們來運行https://github.com/cine-io/android-ffmpeg-with-rtmp的例子
1. 下載壓縮包解壓 (目錄隨意)
2. cd android-ffmpeg-with-rtmp
3.修改build.sh中的幾個參數為你自己的路徑:
#-- try to intelligently determine where the Android NDK is installed
function find_ndk {
ndk_name="android-ndk-r9"//你的ndk存在本地的文件夾名
top_level_paths_to_search="/home/poe"//你的桌面$HOME路徑
found_ndk=""
for d in $top_level_paths_to_search; do
test -d "$d" || continue
found_ndk=$(find $d -name $ndk_name -print)
test "$found_ndk" && break
done
echo "$found_ndk"
}
# create our configuration file if it doesn't yet exist
if [ ! -f "${config_file}" ]; then
# determine OS and architecture
OS_ARCH=$(uname -sm | tr 'A-Z' 'a-z' | sed "s/\ /\-/g")
# find / ask for the NDK
echo "Looking for the NDK ..."
NDK=$(find_ndk)
echo -n "Path to NDK [$NDK]: "
read typed_ndk_root
test "$typed_ndk_root" && NDK="$typed_ndk_root"
# save our configuration
echo "Saving configuration into ${config_file} ..."
echo "OS_ARCH=$OS_ARCH" > ${config_file}
echo "NDK=$NDK" >> ${config_file}
echo "SYSROOT=${NDK}/platforms/android-18/arch-arm" >> ${config_file}//因為我的是ndk-r9 所以沒有android-19此處改為18
echo "TOOLCHAIN=${NDK}/toolchains/arm-linux-androideabi-4.8/prebuilt/${OS_ARCH}" >> ${config_file}
fi
繼續./build.sh
open_ssl編譯通過
open_rtmp編譯通過
open_ffmpeg 不同過,查看 build/build.log 拖到底
patching file configure
Hunk #1 succeeded at 2727 (offset 58 lines).
Package libssl was not found in the pkg-config search path.
Perhaps you should add the directory containing `libssl.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libssl', required by 'librtmp', not found
Package libssl was not found in the pkg-config search path.
Perhaps you should add the directory containing `libssl.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libssl', required by 'librtmp', not found
ERROR: librtmp not found
If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "config.log" produced by configure as this will help
solve the problem.
根據以上提示我們在編譯openssl的時候缺少了libssl.pc這個pkgconfig的文件,
按照提示我們需要把對應的包管理類拷貝到 你的PKG_CONFIG_PATH
(user/lib/pkgconfig)
文件參考這里:http://www.opensource.apple.com/source/OpenSSL098/OpenSSL098-27/pkgconfigs/
把這幾個文件
![]() |
libcrypto.pc | 239 |
![]() |
libssl.pc | 254 |
![]() |
openssl.pc | 264 |
都拷貝到上面路徑。
刪除已經編譯的緩存
$ rm -rf src build .build-config.sh $ ./build.sh
編譯通過!
.
├── bin
│ ├── ffmpeg
│ ├── openssl
│ └── ssltest
└── lib
├── libavcodec-56.so
├── libavdevice-56.so
├── libavfilter-5.so
├── libavformat-56.so
├── libavutil-54.so
├── libcrypto.so
├── librtmp-1.so
├── libssl.so
├── libswresample-1.so
└── libswscale-3.so
通過解壓demo解壓到制定內部文件目錄發現二進制文件ffmpeg只有200k,發現無法運行。
http://blog.csdn.net/sxsj333/article/details/6929487
費解了,直接在 ubuntu系統執行也提示我無法執行,那么肯定是編譯時候的問題了。
仔細研究參數從新編譯:
我只要動態庫,--disable-static \
--enable-shared \
http://www.cnblogs.com/ohmytime/archive/2013/05/12/ffmpeg-build-help.html