Obs使用教程 OBS教程



文章插圖
Obs使用教程 OBS教程

文章插圖
OBS 是一個開源的視頻直播軟件
功能很強大,B站 快手 抖音 直播軟件大都以此為基礎,進行二次開發,或深度借鑒OBS進行開發 。
OBS開發中,會常用到很多內部定義的源,本文將各種源枚舉下,以方便查找 。
OBS很多函數 是以源id為參數的,
id,是定義在源的導出接口中的
比如
struct obs_source_info window_capture_info = {.id= "window_capture",.type= OBS_SOURCE_TYPE_INPUT,.output_flags= OBS_SOURCE_VIDEO | OBS_SOURCE_CUSTOM_DRAW,.get_name= wc_getname,.create= wc_create,.destroy= wc_destroy,.update= wc_update,.video_render= wc_render,.video_tick= wc_tick,.get_width= wc_width,.get_height= wc_height,.get_defaults= wc_defaults,.get_properties = wc_properties};
OBS有哪些源ID呢,在此列舉下:
ID name
image_source 圖像
color_source 色源
slideshow 圖像幻燈片放映
ffmpeg_source 媒體源
text_gdiplus 文本 (GDI+)
text_ft2_source 文本 (FreeType 2)
monitor_capture 顯示器捕獲
window_capture 窗口捕獲
game_capture 游戲捕獲
dshow_input 視頻捕獲設備
wasapi_input_capture 音頻輸入捕獲
wasapi_output_capture 音頻輸出捕獲
img_TransImg 透明圖 —–自定義的
【Obs使用教程 OBS教程】比如 右鍵 添加按鈕,會添加各種源,所用的相關API接口如下:
/*** Enumerates all available inputs source types.**Inputs are general source inputs (such as capture sources, device sources,* etc).*/EXPORT bool obs_enum_input_types(size_t idx, const char **id);
/** Returns the translated display name of a source */EXPORT const char *obs_source_get_display_name(const char *id);
/** Returns capability flags of a source */EXPORT uint32_t obs_source_get_output_flags(const obs_source_t *source);/** Returns capability flags of a source type */EXPORT uint32_t obs_get_source_output_flags(const char *id);
右鍵菜單代碼,遍歷源ID
QMenu *OBSBasic::CreateAddSourcePopupMenu()
const char *type;size_t idx = 0;while (obs_enum_input_types(idx++, &type)) {const char *name = obs_source_get_display_name(type);uint32_t caps = obs_get_source_output_flags(type);//...if (strcmp(type, "image_source") == 0 || strcmp(type, "monitor_capture") == 0 || strcmp(type, "dshow_input") == 0) //...{if ((caps & OBS_SOURCE_DEPRECATED) == 0) {addSource(popup, type, name);//addSource(popup, type, name);}else {addSource(deprecated, type, name);foundDeprecated = true;}foundValues = true;}}