Browse Source

cef_browser: unconditionally write frame, start with transparent frame

master
Shiz 1 year ago
parent
commit
577f35eca3
1 changed files with 8 additions and 5 deletions
  1. +8
    -5
      src/overlay/obs/cef_browser.py

+ 8
- 5
src/overlay/obs/cef_browser.py View File

@ -38,7 +38,7 @@ class CEFBrowserCapturer:
self.dimensions = dimensions
self.url = url
self.outfile = outfile
self.frame = None
self.frame = b'\x00' * 4 * self.dimensions[0] * self.dimensions[1]
self.rate = rate
settings = {
@ -58,20 +58,23 @@ class CEFBrowserCapturer:
window_info.SetAsOffscreen(0)
self.browser = cef.CreateBrowserSync(window_info=window_info, settings=browser_settings, url=self.url)
def __del__(self):
self.browser.CloseBrowser()
cef.Shutdown()
def run_browser(self):
self.browser.SetClientHandler(CEFHandler(self))
self.browser.SendFocusEvent(True)
self.browser.WasResized()
cef.MessageLoop()
cef.Shutdown()
def output_frames(self):
with open(self.outfile, 'wb') as f:
frame_duration = 1.0 / self.rate
while True:
t = time.monotonic()
if self.frame:
f.write(self.frame)
time.sleep(1.0 / self.rate - (time.monotonic() - t))
f.write(self.frame)
time.sleep(max(0.0, frame_duration - (time.monotonic() - t)))
def exit(self, browser=None):
browser = browser or self.browser


Loading…
Cancel
Save