{"id":13842150,"url":"https://github.com/kirides/screencapture","last_synced_at":"2025-07-11T14:30:48.956Z","repository":{"id":45863915,"uuid":"365306938","full_name":"kirides/screencapture","owner":"kirides","description":"This repository has been moved to https://github.com/kirides/go-d3d","archived":true,"fork":false,"pushed_at":"2022-12-27T09:32:01.000Z","size":49,"stargazers_count":54,"open_issues_count":0,"forks_count":8,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-08-05T17:30:40.625Z","etag":null,"topics":["com-interop","d3d11","go","golang","idxgioutputduplication","screen-capture","screen-sharing","windows"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kirides.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-07T17:27:54.000Z","updated_at":"2024-02-29T01:37:02.000Z","dependencies_parsed_at":"2023-01-31T03:01:02.538Z","dependency_job_id":null,"html_url":"https://github.com/kirides/screencapture","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirides%2Fscreencapture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirides%2Fscreencapture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirides%2Fscreencapture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirides%2Fscreencapture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kirides","download_url":"https://codeload.github.com/kirides/screencapture/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225729869,"owners_count":17515180,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["com-interop","d3d11","go","golang","idxgioutputduplication","screen-capture","screen-sharing","windows"],"created_at":"2024-08-04T17:01:28.227Z","updated_at":"2024-11-21T12:30:56.907Z","avatar_url":"https://github.com/kirides.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# Screencapture\n\nThis repository has been moved to https://github.com/kirides/go-d3d\n\n## Motivation\n\nI wanted to learn more about `COM` interop with Go and create a somewhat usable screen sharing tool\n\n## Libaries used\n\nThis application uses D3D11 `IDXGIOutputDuplication` to create a somewhat _realtime_ desktop presentation\n\n- `github.com/mattn/go-mjpeg` for mjpeg streaming\n- `github.com/kbinani/screenshot` for comparison with GDI `BitBlt` (slightly modified source, to support re-using `image.RGBA`)\n- `golang.org/x/exp/shiny/driver/internal/swizzle` for faster BGRA -\u003e RGBA conversion (see [shiny LICENSE](./swizzle/LICENSE))\n- `github.com/pixiv/go-libjpeg/jpeg` for fast jpeg encoding\n  - enable with `go build -tag jpegturbo`\n\n## Demo\n\nJust build the application and run it.\nIt should serve all your monitors on an URL like `http://127.0.0.1:8023/watch?screen=N`  \nwhere `screen=N \u003c- N` is the monitor index, starting at zero (`0`).\n\nBy changing the lines in `cmd/example/main.go` regarding the streaming, you can switch between GDI `BitBlt` or `IDXGIOutputDuplication`\n\n```go\n// ...\nframerate := 10\nfor i := 0; i \u003c n; i++ {\n    // ...\n    // streamDisplay(ctx, i, framerate, stream)  // \u003c= USE GDI BitBlt\n    streamDisplayDXGI(ctx, i, framerate, stream) // \u003c= USE IDXGIOutputDuplication\n    // captureScreenTranscode(ctx, i, desiredFps)\n    http.HandleFunc(fmt.Sprintf(\"/mjpeg%d\", i), stream.ServeHTTP)\n}\n// ...\n```\n\n### screen recording with ffmpeg\n\nThe code contains the function `captureScreenTranscode` which allows you to record the\nselected screen directly into ffmpeg and transcode it to h264 in an mp4 container.\n\n## Performance\n\nPerformance _is not_ optimized to 100%, there are still thing that could be improved.\n\n- only copying the dirty-rectangles (less GPU\u003c-\u003eCPU communication)\n- faster swizzle implementation using AVX/2 (less time for converting the BGRA texture)\n- _profile ... profile ... profile_\n\nOverall the current implementation is about 2-5x faster than GDI `BitBlt` (depending on the resolution, \nthe higher the bigger the difference) and uses a lot less resources for cases where there arent any changes to the screen.\n\n## app.manifest\n\nTo make use of `IDXGIOutput5::DuplicateOutput1`, an application has to provide support for `PerMonitorV2` DPI-Awareness (Windows 10 1703+)\nThis is usually done by providing an my-executable.exe.manifest file either next to the executable, or as an embedded resource.\n\nIn this application there are calls to `IsValidDpiAwarenessContext` and `SetThreadDpiAwarenessContext` which circumvent the requirement.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkirides%2Fscreencapture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkirides%2Fscreencapture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkirides%2Fscreencapture/lists"}