Giter VIP home page Giter VIP logo

go-scrap's Introduction

go-scrap GoDoc

go-scrap is a Go wrapper around the Rust scrap library. It supports reasonably fast capturing of raw screen pixels. The library dependency is only at compile time and statically compiled into the binary. It works on Windows, Linux, and macOS.

Building

Obtain the library, e.g. use go get with -d to not install yet:

go get -d github.com/cretz/go-scrap

Now, the Rust subproject scrap-sys must be compiled which is glue between the Go library and the Rust library. With Rust installed, this can is done by running the following in the scrap-sys/ subdirectory:

cargo build --release

Note: On Windows this must use the same gcc that Cgo would. Go does not support MSVC-compiled libraries yet. The easiest way to ensure this is with rustup by running rustup default stable-x86_64-pc-windows-gnu before building.

Note: On Linux this needs the X11 XCB libraries with the Shm and RandR extensions. On Ubuntu (18.04+ since RandR must be >= 1.12) they are packages named libx11-xcb-dev, libxcb-shm0-dev, and libxcb-randr0-dev respectively.

Now that the dependency is built, the library can be built. For example, take a screenshot:

go run ./example/screenshot

See the Godoc for more documentation and examples.

go-scrap's People

Contributors

cretz avatar notedit avatar rdnt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

go-scrap's Issues

x86_64-w64-mingw32/bin/ld.exe: cannot find -lscrap_sys

Hello.

I have been trying to compile the go-scrap program on windows and I had the following error

go-scrap>go run ./example/screenshot
github.com/cretz/go-scrap
C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lscrap_sys
collect2.exe: error: ld returned 1 exit status.

As far as I can understand, the compiler is looking for the scrap-sys library but can't find it.

How can I do to solve the error?

I have had the same detail compiling the application on Linux.

/go/go-scrap$ go build ./example/screenshot
github.com/cretz/go-scrap
/usr/bin/ld: cannot find -lscrap_sys
collect2: error: ld returned 1 exit status

Thanks

example/video/main.go hangs after 3 frames on macOS only

Hi there,

I'm interested in using this library to record multiple frames (e.g. video from screen). I first tried running the video example on Ubuntu (18.04) and it works correctly, capturing frames continuously until I press enter. This can easily be seen while it's running, since after each frame there is a call to print("."), and you can see .............. continuously in the console as each frame comes in.

However, on macOS (10.13 on my current machine), it captures 3 frames and then stops (i.e. it prints ... and then stops). It appears to never get a frame after that, and constantly returns a wouldBlock from the capturer. The ffplay example from the rust scrap library does not encounter such a problem on OSX, so it seems that this is an issue in the golang implementation, though I'm not really sure where it's going wrong.

Note: I had to manually add the changes from this pull request to get the library working at all on macOS. I also had a couple friends test out the video example on macOS machines and confirmed the same thing (3 frames captured and then nothing).

I understand this library hasn't been touched in a while, so I'm happy to dig through the code if you point me in the right direction. Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.