Skip to content

Releases: chromedp/termcast

v0.2.2

Choose a tag to compare

@kenshaw kenshaw released this 05 Oct 22:50

Documentation only. The README lists the example programs that use termcast, and the comment of Stop describes the final frame.

v0.2.1

Choose a tag to compare

@kenshaw kenshaw released this 05 Oct 22:12

termcast supports Go 1.25 and later. It requires chromedp v0.20.0 and cdproto v0.157.8. The CI runs Go 1.25, 1.26 and stable.

v0.2.0

Choose a tag to compare

@kenshaw kenshaw released this 04 Oct 04:23

New option WithElement draws only the element that a chromedp selector finds, and not the whole page. The stream looks the element up again at each frame, so an element that moves or changes its size stays in view. The README also lists the example programs that use termcast.

v0.1.1

Choose a tag to compare

@kenshaw kenshaw released this 04 Oct 03:58

Stop draws a screenshot as the final frame when no screencast frame arrived. A program that ends fast, before the browser sends the first frame, no longer shows an empty final frame.

v0.1.0

Choose a tag to compare

@kenshaw kenshaw released this 04 Oct 03:43

This is the first release of termcast. The package streams the screen of a chromedp page to a terminal that has graphics, with the screencast of the Chrome DevTools Protocol and the package rasterm. It works in Kitty, iTerm2 and Sixel terminals.

var tc termcast.Flags
tc.Register(flag.CommandLine)
flag.Parse()
// ... create the chromedp context ...
s, err := tc.Start(ctx, *verbose)
if err != nil {
	log.Fatal(err)
}
defer s.Stop()
log.SetOutput(s.LogWriter())

What it does

  • Start draws the page at 4 frames per second by default. A WithFPS option or the flag -terminal-fps changes the rate.
  • Each redraw clears the terminal and draws the latest frame. The package uses no alternate screen and does not hide the cursor, so a program that ends with log.Fatal never leaves the terminal in a changed state.
  • The browser sends a frame only when the page changes. The stream keeps the latest frame, so a page that stops changing stays on the screen.
  • Start returns ErrNoGraphics when the terminal has no graphics. The message names the terminals that work and the variable TERM_GRAPHICS that forces a type.
  • Stream.LogWriter holds the log lines of the program while the stream runs, and prints them after a final frame when the stream stops. Every method of *Stream is safe on a nil pointer, so a program can call s.Stop() and s.Fatal(err) whether the stream is on or off.
  • Flags registers -visible-on-terminal and -terminal-fps, and Flags.Start returns ErrVerbose when the stream is on together with -v, because the protocol messages would draw over the frames.
  • The options WithQuality, WithMaxSize, WithOutput, WithLogOutput and WithEncoder change the JPEG quality, the frame size, the writers and the encoder.

Install

go get github.com/chromedp/termcast@v0.1.0

The package needs Go 1.27 or later and chromedp v0.19.0.