我正在将ffplay作为后台进程运行,向我的主UI进程提供图像数据。我设置了“SDL_VIDEODRIVER=dummy
”来禁止在SDL窗口中显示ffplay视频。
问题是,在视频输出窗口未显示的情况下,ffplay进程仍会出现为应用程序窗口(Dock、CMD+TAB条目等)。我该如何避免这种情况发生?
对我来说,选项-nodisp
很好用(和-autoexit
一起使用)。
在Ubuntu 18.04、ffmpeg 3.4.6中测试过:
ffplay -f lavfi -i "sine=frequency=1000:duration=5" -autoexit -nodisp
在 Mac 上播放 ffplay
,需要将 dock 条目添加到 SDLMain.m 中(需要编译)。在 SDLMain.m 中注释以下行后,ffplay 将作为无窗口进程运行。
//#ifdef SDL_USE_CPS
// {
// CPSProcessSerNum PSN;
// /* Tell the dock about us */
// if (!CPSGetCurrentProcess(&PSN))
// if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
// if (!CPSSetFrontProcess(&PSN))
// [NSApplication sharedApplication];
// }
//#endif /* SDL_USE_CPS */
/* Set up the menubar */
//[NSApp setMainMenu:[[NSMenu alloc] init]];
//setApplicationMenu();
//setupWindowMenu();
编辑 这只影响 Mac,因为我们在其他平台上不需要 SDLMain.m
包装器来包装 int main()
-nodisp
在Windows 11上也可用。 - Trevor Sullivan