日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

用minGW编译ffmpeg(供替换opencv中引用的ffmpeg库)

發布時間:2024/9/21 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 用minGW编译ffmpeg(供替换opencv中引用的ffmpeg库) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

在安裝好的opencv文件夾下找到路徑:opencv245\opencv\3rdparty\ffmpeg,此路徑下有一個readme.txt文件,內容例如以下所看到的:

The build script is to be fixed.
Right now it assumes that 32-bit MinGW is in the system path and
64-bit mingw is installed to c:\Apps\MinGW64.


It is important that gcc is used, not g++!
Otherwise the produced DLL will likely be dependent on libgcc_s_dw2-1.dll or similar DLL.
While we want to make the DLLs with minimum dependencies: Win32 libraries + msvcrt.dll.


ffopencv.c is really a C++ source, hence -x c++ is used.


How to update opencv_ffmpeg.dll and opencv_ffmpeg_64.dll when a new version of FFMPEG is release?


1. Install 32-bit MinGW + MSYS from
? ?http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get-inst/
? ?Let's assume, it's installed in C:\MSYS32.
2. Install 64-bit MinGW. http://mingw-w64.sourceforge.net/
? ?Let's assume, it's installed in C:\MSYS64
3. Copy C:\MSYS32\msys to C:\MSYS64\msys. Edit C:\MSYS64\msys\etc\fstab, change C:\MSYS32 to C:\MSYS64.
? ?
4. Now you have working MSYS32 and MSYS64 environments.
? ?Launch, one by one, C:\MSYS32\msys\msys.bat and C:\MSYS64\msys\msys.bat to create your home directories.


4. Download ffmpeg-x.y.z.tar.gz (where x.y.z denotes the actual ffmpeg version).
? ?Copy it to C:\MSYS{32|64}\msys\home\<loginname> directory.


5. To build 32-bit ffmpeg libraries, run C:\MSYS32\msys\msys.bat and type the following commands:


? ?5.1. tar -xzf ffmpeg-x.y.z.tar.gz
? ?5.2. mkdir build
? ?5.3. cd build
? ?5.4. ../ffmpeg-x.y.z/configure --enable-w32threads
? ?5.5. make
? ?5.6. make install
? ?5.7. cd /local/lib
? ?5.8. strip -g *.a


6. Then repeat the same for 64-bit case. The output libs: libavcodec.a etc. need to be renamed to libavcodec64.a etc.


7. Then, copy all those libs to <opencv>\3rdparty\lib\, copy the headers to <opencv>\3rdparty\include\ffmpeg_.


8. Then, go to <opencv>\3rdparty\ffmpeg, edit make.bat
? ?(change paths to the actual paths to your msys32 and msys64 distributions) and then run make.bat


在使用minGW32編譯ffmpeg過程中。遇到了下面幾個問題:

1、 在輸入命令5.4后,出現了提示”yasm is old ...",提示輸入“--disable-yasm”

? ? ? ?事實上是又一次輸入../ffmpeg-x.y.z/configure --enable-w32threads?--disable-yasm。

2、 5.5和5.6的運行過程較長,請耐心等待。

3、 5.7 strip -g *.a 的意思是跳過debug編譯,編譯生成release版本號。

4、 第7步中的編譯好的lib和頭文件,事實上是存放在 local 文件夾下(存放release版本號)。

開始沒注意到。我一個個搜索,復制粘貼過去的,這些是我從"C:\MSYS32\msys\1.0\home\Administrator\bulid" 文件夾下搜索的,而這邊生成的.a庫版本號是debug版本號的。

5、 第8步中改動msys32的路徑就可以,就能夠執行make.dat文件。

? ? ? 或者是在命令行中,轉到”opencv\3rdparty\ffmpeg"這個文件夾下,從gcc處開始”?gcc -Wall -shared -o opencv_ffmpeg.dll -O2 -x c++ -I../include -I../include/ffmpeg_ -I../../modules/highgui/src ffopencv.c -L../lib -lavformat -lavcodec -lavdevice -lswscale -lavutil -lwsock32“ ? 輸入以上語句。執行后會出現

” libiconv“的相關錯誤提示;

?解決方法:在C:\MSYS32 文件夾下找到libiconv.a文件拷貝到 "?opencv\3rdparty\ffmpeg\lib" 文件夾下。

在執行命令時,在后加 -liconv 執行就可以生成文件?opencv_ffmpeg.dll。

6、 ffmpeg-x.y.z.tar.gz的下載地址為:http://www.ffmpeg.org/download.html,在該頁面中選擇最新版本號的Download gzip tarball?這一項下載。

7、在命令行中書寫路徑中,不能用"\", 而用"/"。

8、加yasm編譯:

在1的處理過程中,沒有使用yasm這樣的匯編器。這使得在使用編譯生成的opencv_ffmpeg.dll時。文件編解碼的速度較慢。網上查到說,假設不用yasm編譯的話。速度的確是會變慢的。所以第二次嘗試使用yasm編碼。

處理方法:首先下載yasm的win32版本號的文件,將文件名稱改為yasm.exe。放入C:\MSYS32\bin 文件夾下。運行5.4的原命令。

運行到?5.8. strip -g *.a 時。出現了下面提示:


為了解決問題,又一次下載了strip.exe文件,并覆蓋到相應的文件夾下。

又一次執行該命令,假設本機沒有安裝cygwin的話,會提示缺少cygwin1.dll。所以還需下載安裝cygwin程序,再加入其bin地址到系統環境變量中。再又一次執行5.8命令,就OK了。


如需轉載,請注明文章出處:http://blog.csdn.net/wsbeibei


總結

以上是生活随笔為你收集整理的用minGW编译ffmpeg(供替换opencv中引用的ffmpeg库)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。