Skip to content
LaurentPerchePublic

About

[CLI script | macOS/Linux] Create video clips from timestamped YouTube URLs.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

ytclip

ytclip is a tiny macOS command line tool for creating video clips from timestamped YouTube URLs.

By default, ytclip optimizes clips for easy sharing in chats and on phones by preferring source video around 480p and producing a compact MP4. Use --hq when you want a higher-quality clip instead.

Why It Exists

ytclip exists to make it easy to grab a short clip from a YouTube video without opening a video editor or manually calculating timestamps.

Requirements

  • macOS
  • Homebrew
  • yt-dlp
  • ffmpeg

Installation

Install dependencies:

brew install yt-dlp ffmpeg

Manual installation:

chmod +x ytclip
sudo cp ytclip /usr/local/bin/ytclip

Install with the included script:

./install.sh

Install from the latest public GitHub release:

brew install yt-dlp ffmpeg
curl -LO https://github.com/LaurentPerche/ytclip/releases/download/v0.3.0/ytclip-v0.3.0.zip
unzip ytclip-v0.3.0.zip
chmod +x ytclip install.sh uninstall.sh
./install.sh

Install from the latest public GitHub release with GitHub CLI:

brew install gh
brew install yt-dlp ffmpeg
gh release download v0.3.0 -R LaurentPerche/ytclip -p 'ytclip-v0.3.0.zip'
unzip ytclip-v0.3.0.zip
chmod +x ytclip install.sh uninstall.sh
./install.sh

Usage

Command format:

ytclip [--hq] <duration_seconds_or_end_timestamp> [youtube_url] [output_file]

Examples:

ytclip 109

ytclip 42:12

ytclip --hq 109

ytclip --hq 42:12

ytclip 109 "https://youtu.be/HGbA6ze0_3M?si=kULAuwqlZvokp0yJ&t=2423"

ytclip 42:12 "https://youtu.be/HGbA6ze0_3M?si=kULAuwqlZvokp0yJ&t=2423"

ytclip 109 "https://www.youtube.com/watch?v=abc123&t=23m32s" "$HOME/Downloads/my_clip.mp4"

Shareable Output

ytclip is optimized for compact, shareable clips by default.

  • It prefers downloading source video at or below roughly 480p when available.
  • It encodes the final clip as a smaller H.264/AAC MP4 for easier sending in chats and messaging apps.
  • It does not upscale lower-resolution source video.

Use high-quality mode when you want the best available source and a less compressed final MP4:

ytclip --hq 109
  • --hq downloads the highest available source instead of capping around 480p.
  • --hq uses a higher-quality encode profile instead of the compact default.
  • --hq keeps the same output format and command flow.

Duration vs Endpoint Mode

Duration mode treats the first argument as the clip length in seconds:

ytclip 109

Endpoint mode treats the first argument as the absolute video timestamp where the clip should end:

ytclip 42:12

If the copied YouTube URL starts at 40:23 and you run ytclip 42:12, ytclip calculates the clip duration as 42:12 - 40:23 = 109 seconds.

Clipboard Mode

If no URL is provided, ytclip reads the YouTube URL from the macOS clipboard using pbpaste.

Default Output Folder

By default, files are saved to:

~/Downloads/

The default filename format is:

youtube_clip_YYYYMMDD_HHMMSS.mp4

The default output is optimized for shareability rather than archival quality. Use --hq when quality matters more than file size.

Troubleshooting

yt-dlp: command not found

  • Install it with brew install yt-dlp

ffmpeg: command not found

  • Install it with brew install ffmpeg

no timestamp found

  • Make sure the YouTube URL includes a timestamp such as ?t=2423, ?t=23m32s, or ?start=2423

endpoint must be after the start timestamp

  • Use an endpoint that comes later than the timestamp embedded in the YouTube URL

Legal Note

Use this tool only for videos you own, have permission to use, or where clipping is permitted by applicable rights and platform terms.

License

MIT

About

[CLI script | macOS/Linux] Create video clips from timestamped YouTube URLs.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages