開發ffmpeg/live555常見問題錯誤及解決方法
#include <iostream>using namespace std;extern "C" {#include <libavcodec/avcodec.h> // required headers#include <libavformat/avformat.h>}int main(int argc, char**argv) { av_register_all(); // offending library call return 0;}
ffmpeg 默認是用C文件來編譯的,如果某個CPP文件想引用ffmpeg中的某些函數或者頭文件,有可能出現
‘UINT64_C’ was not declared in this scope的錯誤
情形大概如下
The same issue i'm getting here when compiling chromium with ffmpeg from svn:
In file included from /usr/include/libavutil/avutil.h:81:0,
from /usr/include/libavcodec/avcodec.h:30,
from out/Release/obj.target/geni/ffmpeg_stubs.cc:16:
/usr/include/libavutil/common.h: In function 'int32_t av_clipl_int32(int64_t)':
/usr/include/libavutil/common.h:154:47: error: 'UINT64_C' was not declared in this scope
make: *** [out/Release/obj.target/geni/ffmpeg_stubs.o] Error 1
可以 在cpp文件中加入
extern "C"{
#ifdef __cplusplus
#define __STDC_CONSTANT_MACROS
#ifdef _STDINT_H
#undef _STDINT_H
#endif
# include <stdint.h>
#endif
}
來解決
如果在android下用編譯。在Android.mk加入
LOCAL_CFLAGS := -D__STDC_CONSTANT_MACROS即可
#ifdef __cplusplus extern "C" { #endif void AfterSessionDone(); void openURL(UsageEnvironment& env, char const* progName, char const* rtspURL,Authenticator *authDB,const int Channel); char* h264_decode_buf_prepare(char *sps,int sps_len,char* pps,int pps_len,char* buf_in, char* buf_pre_for_h264_decode,int framesize,const int Channel); #ifdef __cplusplus } #endif
編譯為動態庫時的問題:
/usr/bin/ld: /usr/local/lib/libavcodec.a(avpacket.o): relocation R_X86_64_32S against `av_destruct_packet' can not be used when making a shared object; recompile with -fPIC
修改方法:
./configure --enable-pic && make
如果使用的是虛擬機進行開發live555.需要加入路由表:
route add default gw xxx.xxx.xxx.xxx eth0
編譯ffmpeg后,直接編譯示例不能通過顯示庫不能找到問題解決。
原來,為了讓pkg-config可以得到這些信息,要求庫的提供者,提供一個.pc文件,.pc文件里面存放的是一些頭文件及庫的地址。這些.pc文件默認放在/usr/share/pkgconfig里面,如果你改變了.pc的存放路徑,必須要讓計算機知道,所以需要修改 PKG_CONFIG_PATH 。 假設我的.pc文件放到了/usr/local/lib/pkgconfig下,我需要做如下修改:
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
live555在windows環境編譯vs2010:
Ⅲ 編譯步驟
方法一(Win7下命令方式)
0 綜述:利用genWindowsMakefiles.cmd生成VS可用的makefile
1 修改win32config。打開live\win32config文件,修改如下
TOOLS32 = c:\Program Files\DevStudio\Vc
TOOLS32 = E:\Program Files\Microsoft Visual Studio 10.0\VC
將TOOLS32修改為你的VS2010路徑
LINK_OPTS_0 = $(linkdebug) msvcirt.lib
LINK_OPTS_0 = $(linkdebug) msvcrt.lib
編譯器索要的LINK運行庫不同,原本以為可以改為msvcrt100.lib,但沒找著
2 新增Makefile設定。打開live\groupsock\Makefile.head,修改如下
INCLUDES = -Iinclude -I../UsageEnvironment/include
INCLUDES = -Iinclude -I../UsageEnvironment/include -DNO_STRSTREAM
3 建立makefile
方法:運行live\genWindowsMakefiles.cmd,生成VS能夠編譯的*.mak文件
4 建立build.bat命令
新建live\complie.bat,并添加內容如下:

call "E:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"cd liveMedianmake /B -f liveMedia.makcd ../groupsocknmake /B -f groupsock.makcd ../UsageEnvironmentnmake /B -f UsageEnvironment.makcd ../BasicUsageEnvironmentnmake /B -f BasicUsageEnvironment.makcd ../testProgsnmake /B -f testProgs.makcd ../mediaServernmake /B -f mediaServer.mak

5 開始編譯:(命令行下)執行complie.bat
參考地址:http://www.cnblogs.com/skyseraph/archive/2012/04/11/2442840.html
參考文章:
http://blog.csdn.net/onelight1997/article/details/7528935
live555虛擬機下不能獲取數據問題:
http://blog.csdn.net/wesleyluo/article/details/6204635
http://blog.csdn.net/liushu1231/article/details/9203239
識別I幀P幀B幀。
http://blog.csdn.net/linzhiji/article/details/5393647
解碼流程經典教程:
http://www.360doc.com/content/11/1117/09/8050095_165108638.shtml
ffmpeg時間戳問題匯總
http://www.cnblogs.com/loveclover/archive/2011/03/23/1993065.html
ffmpeg開發SDK介紹
http://blog.sina.com.cn/s/blog_62a8419a01016exv.html
含有B幀時的疑惑
http://bbs.csdn.net/topics/390692774
100行代碼實現最簡單的基于FFMPEG+SDL的視頻播放器
http://blog.csdn.net/leixiaohua1020/article/details/8652605
ffmpeg解碼花屏,碼流丟失問題
http://bbs.rosoo.net/thread-14856-1-1.html
http://blog.csdn.net/howema/article/details/6065441
FFMPEG重要學習官方資料:
RFID管理系統集成商 RFID中間件 條碼系統中間層 物聯網軟件集成