vs2010 ffplay 編譯總結

ffmpeg window vs2010 下 ffplay 可調試版本

今日編譯了windows版本的ffpaly,總結遇到的一些問題

 1 如果要用vs2010進行調試,只能下載window下編譯好的ffmpeg開發庫而不是使用mingw編譯,SDL也一樣
 2 ffpaly的編譯問題相對而言不太多:

2.1 config.h文件可以使用mingw下configure命令生成的,編譯時一些宏報錯可以直接修改

2.2 opinion[]數組報錯是由於vs2010編譯器不支持數組定義時 {.xx=xxxx} 的方式,去掉.xx=即可,
2.3 一些提示找不到的函數(isNAN之類)可以在ffmpeg源碼中找到直接copy過來 
2.4 提示main函數錯誤時註釋掉SDL_main.h文件中的 #define main SDL_main
2.5 重定義無法識別的類型

#define PRIu64       "I64u"

#define PRId64       "I64d"

2.6 ffplay.c文件注意加上#ifdef __cplusplus extern "C"  .....

2.7 生成成功後控制檯提示播放失敗,如果提示“Could not initialize SDL ,(Did you set the DISPLAY variable?)\n")”,註釋下面代碼

#if !defined(__MINGW32__) && !defined(__APPLE__)
   // flags |= SDL_INIT_EVENTTHREAD; /* Not supported on Windows or Mac OS X */
#endif

3 windows下的SDL庫說明 (ver 1.2.15)

3.1 SDL在windows下創建窗口時會先查看用戶有沒有設置環境變量“SDL_WINDOWID”有沒有被設置,有的話就將其值作爲與自己關聯的窗口句柄,沒有則createwindow創建窗口,所以如果你想修改ffplay代碼,是sdl播放窗口與自己的mfc窗口關聯,可以像這樣類似的代碼

<span style="font-size:18px;">	//將CSTATIC控件和sdl顯示窗口關聯 
	HWND hWnd = this->GetDlgItem(IDC_PICURE_CONTROL)->GetSafeHwnd();
	if( hWnd !=NULL)
	{
		char sdl_var[64];    
		sprintf(sdl_var, "SDL_WINDOWID=%d", hWnd);    //主窗口句柄      //這裏一定不能有空格SDL_WINDOWID=%d"
		SDL_putenv(sdl_var);   
		char *myvalue = SDL_getenv("SDL_WINDOWID");   //讓SDL取得窗口ID  
	}</span>


3.2  如果SDL窗口是由內部創建而不是用戶關聯,雖然官方不建議使用破壞跨平臺性質的代碼,但依然給出瞭解決方案,:

You can easily grab the handle of the Window using a single function inside SDL. Please note, I don't recommend you do this unless you really need to do something OS specific. This will almost certainly break cross-platform compatibility.

1
2
3
4
5
6
7
8
9
SDL_SysWMinfo SysInfo; //Will hold our Window information
SDL_VERSION(&SysInfo.version);//Set SDL version
  
if(SDL_GetWMInfo(&SysInfo) <= 0) {
    printf("%s : %d\n", SDL_GetError(), SysInfo.window);
    returnfalse;
}
  
HWNDWindowHandle = SysInfo.window; //There it is, Win32 handle
You can check out the other possible values to grab here:
http://sdl.beuc.net/sdl.wiki/SDL_SysWMInfo

If this is something you want to do, but you still want your game/application to be cross platform, then you can use pre-processor directives:
1
2
3
4
5
#ifdef __WIN32__
HWNDWindowHandle = SysInfo.window; //Win32 window handle
#else
Window WindowHandle = SysInfo.window; //X11 window handle
#endif
Note: This might be useful if you are making an application that you want to sit in the tray, or you want the window to dock (just a few examples).


3.3 ffplay中sdl創建的窗口帶有標題欄,如果想去的當然是可以的,通過給SDL_SetVideoMode的flag標誌傳遞SDL_NOFRAME標記,在ffplay.c中你需要在兩個地方修改 static int video_open(VideoState *is, int force_set_video_mode, VideoPicture *vp)函數與 static void event_loop(VideoState *cur_stream)


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章