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)


你可能感兴趣的:(vs2010 ffplay 编译总结)