player

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package player turns a YouTube stream into raw RGB frames (via ffmpeg) and ANSI half-block text, so video plays directly inside the terminal.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	VideoURL string
	AudioURL string // empty disables audio
	FPS      int
}

Config describes the media sources for one playback session.

type Frame

type Frame struct {
	Data  []byte
	Index int // frame number since the last Play, for position tracking
}

Frame is one decoded video frame in packed RGB24, W×H pixels.

type Pipeline

type Pipeline struct {
	// contains filtered or unexported fields
}

Pipeline manages the ffmpeg (video) and ffplay (audio) processes for one playback session. Play/Stop may be called repeatedly (pause, seek, resize all restart the pipeline at a new position).

func New

func New(cfg Config) *Pipeline

func (*Pipeline) Play

func (p *Pipeline) Play(parent context.Context, pos time.Duration, w, h int) (<-chan Frame, error)

Play starts decoding at pos into w×h pixel frames and returns a channel of wall-clock-paced frames. Frames that fall behind schedule are dropped so audio and video stay aligned. The channel closes at end of stream.

func (*Pipeline) Stop

func (p *Pipeline) Stop()

Stop kills the current playback processes, if any.

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

Renderer converts RGB24 frames into ANSI true-color half-block text.

Each terminal cell shows two vertical pixels using the upper-half-block character '▀': the glyph (foreground) color is the top pixel and the cell background is the bottom pixel — doubling vertical resolution.

func (*Renderer) Render

func (r *Renderer) Render(buf []byte, w, h int) string

Render returns frame buf (w×h pixels, packed RGB) as terminal text. h must be even; rows come out as h/2 lines.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL