vhs icon indicating copy to clipboard operation
vhs copied to clipboard

feat[playback]: add per-section playback speed control

Open 0xjuanma opened this issue 11 months ago • 2 comments

  • [x] I have read CONTRIBUTING.md.
  • [x] I have created a discussion that was approved by a maintainer (for new features).

Summary

Fixes https://github.com/charmbracelet/vhs/discussions/685 & https://github.com/charmbracelet/vhs/issues/759

Adds new playback speed control feature to VHS, allowing users to vary playback speed at different points in their recordings using the Playback@<speed> command. The value can be either an integer or float with 1 decimal place.

This enables speeding through setup sections while slowing down for important demonstrations, providing more control over the final output than the global Set PlaybackSpeed setting(which defines a single speed for the full GIF). Its effectively a way to set up multiple playback speeds as part of the tape file or commands being run.

To demonstrate this, I used one of my timer packages which makes it very easy to see the playback speed.

Output GIF:

TL;DR: Stage 1 runs at 3x speed, Stage 2 runs at 1x speed, Stage 3 runs at 1x speed(for 10sec) then switches to 3x, finally Stage 4 runs at 1x speed again.

helm-demo3

Here is the demo.tape used to generate the GIF above:

Output helm-demo.gif
Set FontSize 14
Set Width 800
Set Height 500
Set Theme "Darkside"

# Launch Helm(Note: helm is my timer TUI package)
Playback@1
Type "helm"
Enter
Sleep 1s

# Navigate down to show other options
Down
Sleep 500ms
Down
Sleep 500ms

# Pause on current selection
Sleep 500ms

# Select Demo timer
Enter
Sleep 1s

# Start stage(1)
Sleep 1s
Space

# Playback [Stage 1] at 3x speed
[email protected]
Sleep 50s

# Pause
[email protected]
Space
Sleep 1s

# Skip to next stage(2)
Type "n"
Sleep 1s

# Start [Stage 2] at 1x speed
Space
[email protected]
Sleep 30s

# Pause
Space
Sleep 1s

# Start [Stage 3] at 1x speed for 10sec
Type "n"
Space
Sleep 10s


# Update [Stage 3] Playback to 3x speed
[email protected]
Sleep 30s

[email protected]
# Pause
Space
Sleep 1s

# Skip to next [Stage 4] at 1x speed
Type "n"
Sleep 1s
Space
Sleep 20s

# End
Type "q"
Sleep 1s

Updates

  • Added Playback@<speed> command with @ syntax for section-based speed control(follows similar patterns a Type@Xms)
  • Implemented per-section playback speed rendering with FFmpeg filter chain
  • Added tests coverage for lexer, parser, and command execution
  • Documented playback command usage and added syntax highlighting

0xjuanma avatar Dec 09 '25 03:12 0xjuanma

This PR also resolves https://github.com/charmbracelet/vhs/issues/759

0xjuanma avatar Jul 07 '26 01:07 0xjuanma

@meowgorithm @andreynering 👋🏽 hoping to get your eyes on this if you have a second, thanks!

0xjuanma avatar Jul 08 '26 00:07 0xjuanma