obs源码分析
一.obs音视频同步方法
参考:https://blog.csdn.net/liuhengxiao/article/details/83059314
源码在D:\work\obs-studio-jianan\obs-studio\libobs\obs-output.c
static bool prune_interleaved_packets(struct obs_output *output)
{
size_t start_idx = 0;
//先删除超过一个视频帧间隔之前的所有帧
int prune_start = prune_premature_packets(output);
/* prunes the first video packet if it's too far away from audio */
if (prune_start == -1)
return false;
else if (prune_start != 0)
start_idx = (size_t)prune_start;
else
//如果prune_premature_packets没有,找出离视频帧最近的音频帧作为开始
start_idx = get_interleaved_start_idx(output);
if (start_idx)
discard_to_idx(output, start_idx);
return true;
}
一.obs采集与渲染流程
参考:https://www.cnblogs.com/JazzerDaxian/p/8480229.html
摄像头通过dshow来采集的,然后通过obs_source_output_video方法来写入一个队列,然后渲染线程obs_source_video_tick读这个队列的内容来渲染显示咯
网友评论