Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

屏幕录制的代码好像是基于linux的,可以写个在windows上运行的demo吗? #5

Open
SHI1992 opened this issue Sep 3, 2024 · 3 comments

Comments

@SHI1992
Copy link

SHI1992 commented Sep 3, 2024

谢谢

@codematrixer
Copy link
Owner

暂时没有Windows的电脑,欢迎提PR

@hxb396
Copy link

hxb396 commented Sep 13, 2024

改这个几个地方:

    import imageio                                                         # 引入依赖

    def _video_writer(self):                                               # 修改实现
        """Write frames to video file."""
        writer = None
        try:
            writer = imageio.get_writer("ohos.mp4", fps=10)
            while not self.stop_event.is_set():
                data = self.jpeg_queue.get()
                if data is not None:
                    image = imageio.imread(bytes(data))
                    writer.append_data(image)
            writer.close()
            time.sleep(1)
        finally:
            if writer is not None and not writer.closed:
                writer.close()

    def stop(self):
        """Stop screen recording."""
        try:
            self.stop_event.set()
            self.jpeg_queue.put(None)                                          # 新增
            for t in self.threads:
                t.join()

            if self.sock:
                self._send_message("stopCaptureScreen", [])
                self._recv_mesaage(1024, decode=True)
                self.sock.close()
        except Exception as e:
            print(f"An error occurred: {e}")

@codematrixer
Copy link
Owner

codematrixer commented Sep 14, 2024

谢谢

已适配windows 53293e9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants