marcelpanse
youtube-guitar-tab-parser
CLI that turns a YouTube guitar-lesson video into a PDF of the guitar tab.
Documentation snapshot
README 快照
翻译暂时拿不到。
机器翻译的项目简介,仅供参考。原文在下方,也可以直接用浏览器自带的整页翻译 (Chrome / Edge 点地址栏右侧的翻译图标,或用右键菜单里的「翻译成中文」)。
下面正文是项目自己的英文 README。想读全文就用浏览器自带的整页翻译: Chrome / Edge 点地址栏右侧的翻译图标,或用右键菜单里的「翻译成中文」; 手机浏览器一般在菜单里。
本页保存的是公开项目资料快照,阅读过程不需要连接 GitHub。
Youtube Guitar Tab Parser
CLI that turns a YouTube guitar-lesson video into a PDF of the guitar tab.
It downloads the video, samples frames, uses Claude vision to locate the tab
region, crops every frame to that region, de-duplicates the crops by the bar
number printed on each line of the score, and stitches the distinct tab lines
vertically into a PDF. It works out of the box with no configuration — the PDF
is written to out/.pdf, with the video title as a heading on the
first page and in the document metadata.
Example
Generated from the YouTube lesson Game of Thrones - Guitar Lesson + TAB:
- 🎬 Source video:
- 📄 Output PDF: examples/Game of Thrones.pdf
Requirements
- Node.js ≥ 20
yt-dlpandffmpegon yourPATH(brew install yt-dlp ffmpeg)- An Anthropic API key
Setup
npm install
npm run build
cp .env.example .env # then put your ANTHROPIC_API_KEY in it
Usage
# with a .env file
node --env-file=.env dist/cli.js "https://www.youtube.com/watch?v=WgU5tDGC-Vc"
# or with the key already exported
export ANTHROPIC_API_KEY=sk-ant-...
node dist/cli.js "https://www.youtube.com/watch?v=WgU5tDGC-Vc"
During development you can skip the build step:
node --env-file=.env --import tsx src/cli.ts ""
The result is written to out/.pdf (its path is also printed to
stdout); progress goes to stderr.
Options
Everything has a sensible default; you normally only need the URL.
-i, --interval screenshot interval (default 2)
--model Claude vision model (default claude-sonnet-5)
--sample frames sampled for tab-region detection (default 6)
--dedup-threshold pre-dedup Hamming distance, cost control (default 12)
--max-height cap download resolution (default 720)
--keep-temp keep intermediate frames/crops
How it works
- Download —
yt-dlpfetches the video (≤--max-height). - Frames —
ffmpegextracts one frame every--intervalseconds. - Detect — two stages, since vision models are reliable at picking labeled
regions but not at precise pixel coordinates:
- A labeled row/column grid is drawn on
--sampleframes and Claude vision reports which rows and columns the sheet music overlaps. The per-edge median across samples gives a coarse box (works whether the tab is a full-width bottom strip or a corner overlay). - That box is then snapped to the actual paper edges with an image mask (sheet music is dark content on a light, unsaturated background, unlike the colourful performer/backdrop), so the crop hugs the tab tightly. If no clear paper region is found (e.g. a dark-themed tab viewer), the vision box is used.
- A labeled row/column grid is drawn on
- Crop —
sharpcrops every frame to that box. - Pre-dedup — a dHash perceptual hash drops near-identical consecutive crops. This is only a cost control to reduce the number of vision calls in the next step.
- Bar-number dedup — Claude reads the measure/bar number printed at the start of each line and whether the crop is real sheet music. The tool keeps exactly one crop per distinct bar number (first appearance wins) and drops non-tab crops (title cards, intros/outros). Because the bar number is constant while the playback cursor sweeps a line and only changes when the score advances, this collapses all the near-identical cursor frames of a line into a single page.
- PDF —
pdf-libstacks the distinct tab lines vertically down A4 pages, in the order they appear in the video. The video title (read fromyt-dlp) becomes the file name, a heading on the first page, and the document metadata title. Output:out/.pdf.
Official distribution
获取与安装
暂未发现可确认的官方软件包地址
当前 README 快照没有出现 npm、PyPI、Crates.io、pub.dev 等官方包页链接。本站不会根据仓库名称猜测下载地址。
本站不托管项目文件;需要安装时,请以项目维护者发布的官方文档为准。
Before installing
使用前核验
本站保存公开资料用于阅读,不代表安全审计或功能背书。安装前请核对许可证、依赖来源和发布签名,不要直接运行来源不明的二进制文件或高权限脚本。