Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Dec 27, 2022. It is now read-only.
/screencapturePublic archive

This repository has been moved tohttps://github.com/kirides/go-d3d

License

NotificationsYou must be signed in to change notification settings

kirides/screencapture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repository has been moved tohttps://github.com/kirides/go-d3d

Motivation

I wanted to learn more aboutCOM interop with Go and create a somewhat usable screen sharing tool

Libaries used

This application uses D3D11IDXGIOutputDuplication to create a somewhatrealtime desktop presentation

  • github.com/mattn/go-mjpeg for mjpeg streaming
  • github.com/kbinani/screenshot for comparison with GDIBitBlt (slightly modified source, to support re-usingimage.RGBA)
  • golang.org/x/exp/shiny/driver/internal/swizzle for faster BGRA -> RGBA conversion (seeshiny LICENSE)
  • github.com/pixiv/go-libjpeg/jpeg for fast jpeg encoding
    • enable withgo build -tag jpegturbo

Demo

Just build the application and run it.It should serve all your monitors on an URL likehttp://127.0.0.1:8023/watch?screen=N
wherescreen=N <- N is the monitor index, starting at zero (0).

By changing the lines incmd/example/main.go regarding the streaming, you can switch between GDIBitBlt orIDXGIOutputDuplication

// ...framerate:=10fori:=0;i<n;i++ {// ...// streamDisplay(ctx, i, framerate, stream)  // <= USE GDI BitBltstreamDisplayDXGI(ctx,i,framerate,stream)// <= USE IDXGIOutputDuplication// captureScreenTranscode(ctx, i, desiredFps)http.HandleFunc(fmt.Sprintf("/mjpeg%d",i),stream.ServeHTTP)}// ...

screen recording with ffmpeg

The code contains the functioncaptureScreenTranscode which allows you to record theselected screen directly into ffmpeg and transcode it to h264 in an mp4 container.

Performance

Performanceis not optimized to 100%, there are still thing that could be improved.

  • only copying the dirty-rectangles (less GPU<->CPU communication)
  • faster swizzle implementation using AVX/2 (less time for converting the BGRA texture)
  • profile ... profile ... profile

Overall the current implementation is about 2-5x faster than GDIBitBlt (depending on the resolution,the higher the bigger the difference) and uses a lot less resources for cases where there arent any changes to the screen.

app.manifest

To make use ofIDXGIOutput5::DuplicateOutput1, an application has to provide support forPerMonitorV2 DPI-Awareness (Windows 10 1703+)This is usually done by providing an my-executable.exe.manifest file either next to the executable, or as an embedded resource.

In this application there are calls toIsValidDpiAwarenessContext andSetThreadDpiAwarenessContext which circumvent the requirement.


[8]ページ先頭

©2009-2025 Movatter.jp