Communitygithub.com

eternova/long-video-course-notes

Claude Code skill: 把长视频课程自动化生成图文飞书文档笔记。video→canvas 抓帧 + AI 识别 + lark-cli 推送。

long-video-course-notes 是什么?

long-video-course-notes is a Claude Code agent skill that claude Code skill: 把长视频课程自动化生成图文飞书文档笔记。video→canvas 抓帧 + AI 识别 + lark-cli 推送。.

兼容平台✓Claude Code~Codex CLI✓Cursor
npx skills add eternova/long-video-course-notes

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

预览

来自技能 README

placeholder-frame-XXXXs.jpg

文档

Long Video Course Illustrated Notes Skill

When to Use

  • The user provides a long video URL (>30 minutes) and wants a textual summary instead of watching the entire video.
  • The video is a live replay / online course / lecture primarily consisting of slides and instructor commentary (not short entertainment clips).
  • The output destination is Feishu Doc (default) or a local Markdown file.
  • The video platform supports any website that uses the HTML5 <video> element (XiaoeTech, Shengcaiyoushu, Bilibili, NetEase Cloud Classroom, Douyin Education, etc.).

When Not to Use

  • The video uses Flash / Silverlight / a proprietary player (no HTML5 video element).
  • The video is shorter than 15 minutes (it's faster to just watch it through).
  • The video content is pure entertainment (music, vlog, animation) — frame capture provides no value.
  • The user wants to keep the spoken transcript — this skill does not perform ASR; use Whisper or Feishu Minutes instead.

Core Principle (Why This Works)

Video streams are typically HLS / MPEG-DASH with token authentication — direct ffmpeg download will return a 403 error. However, the browser's video element has already decrypted the stream into a frame buffer. Using canvas.drawImage(video, ...), you can grab PNGs at any timestamp, bypassing the entire copyright chain.

Video element (after DRM-free decryption) → canvas.drawImage → toDataURL → local jpg

Overall Flow

Step 1: Assess video accessibility (login status / HTML5 video present)
Step 2: Probe — get duration / resolution / src
Step 3: Coarse sampling (one frame every 8-10 minutes)
Step 4: AI classifies frames (slide vs talking head vs editor vs Q&A)
Step 5: Densify sampling in slide-heavy regions
Step 6: Write Markdown article
Step 7: Push to Feishu (create folder + create document + insert images)

Step 1: Login / Accessibility Check

Open the video URL using the Playwright MCP browser:

mcp__playwright__browser_navigate(url=VideoURL)

Check:

  • If redirected to a login page → proceed to "Login Strategy" below.
  • If the course page is displayed directly → jump to Step 2.

Login Strategy (by priority)

A. Already logged in on the platform (most common, no action needed) — The Playwright MCP browser session retains cookies. If the user recently visited the same domain via Playwright and logged in, cookies persist. Just try navigating directly.

B. User logged in via their own Chrome → import cookies — Use the cookie-import-browser tool from ~/.claude/skills/gstack/browse:

cd ~/.claude/skills/gstack/browse
bun run src/cli.ts goto "https://target.com/"  # Must visit target domain first
bun run src/cli.ts cookie-import-browser chrome --domain target.com

⚠️ Common failure cause: cookies in the user's Chrome have expired (check the expires_utc field).

C. Unattended login infeasible → ask the user to do it — CAPTCHAs, sliders, WeChat QR codes can never be automated. Simply ask the user to log in:

  • Give one clear instruction sentence: "Open X in Chrome, log in, then tell me."
  • Do not write more than 2 paragraphs; do not offer 4 options.

Never get stuck in an infinite loop: try logging in → cookie expires → switch tools → tool breaks → switch again. At most try twice, then downgrade to Plan B (user sends me screenshots directly).

Step 2: Video Element Probe

After opening the video page, run:

() => {
  const v = document.querySelector('video');
  if (!v) return {error: 'no video element'};
  return {
    src: v.src || v.currentSrc,
    duration: v.duration,
    width: v.videoWidth,
    height: v.videoHeight,
    paused: v.paused,
    readyState: v.readyState,
    title: document.title,
    url: location.href
  };
}

Judgment:

  • duration > 0 and readyState >= 3 → frame capture is feasible.
  • src is a blob:... URL → MSE is being used, which is exactly what we want.
  • videoWidth >= 720 → frame quality is adequate.
  • readyState < 3 → the video hasn't loaded; you may need to click the play button to trigger loading (skip muted autoplay for better stability).

Step 3: Coarse Sampling Time Points

For an N-minute video, first sample ceil(N/8) frames (one frame every 8 minutes) to cover the overall pacing:

async () => {
  const v = document.querySelector('video');
  v.pause(); v.muted = true;
  
  const duration = v.duration;
  const interval = 480; // 8 minutes
  const targets = [];
  for (let t = 30; t < duration - 30; t += interval) targets.push(Math.floor(t));
  
  const seekTo = (t) => new Promise((resolve) => {
    const onSeeked = () => { v.removeEventListener('seeked', onSeeked); resolve(); };
    v.addEventListener('seeked', onSeeked);
    v.currentTime = t;
    setTimeout(() => { v.removeEventListener('seeked', onSeeked); resolve(); }, 8000);
  });
  
  const canvas = document.createElement('canvas');
  canvas.width = v.videoWidth;
  canvas.height = v.videoHeight;
  const ctx = canvas.getContext('2d');
  
  window.__frames = window.__frames || {};
  const out = [];
  for (const t of targets) {
    await seekTo(t);
    v.pause();
    await new Promise(r => setTimeout(r, 800)); // Wait for frame buffer
    ctx.drawImage(v, 0, 0, canvas.width, canvas.height);
    window.__frames[t] = canvas.toDataURL('image/jpeg', 0.8);
    out.push({t: v.currentTime, target: t, kb: (window.__frames[t].length / 1024) | 0});
  }
  return out;
}

Key Details:

  • v.muted = true: prevents autoplay detection from blocking.
  • v.pause() is called again after each seek (some players auto-resume after seeking).
  • 800ms wait: the seeked event fires before the frame is rendered; give the GPU buffer some time, otherwise you might capture a frame from a previous timestamp.
  • All frames are stashed in window.__frames to avoid returning a huge 30MB base64 payload at once.

Step 4: Extract Base64 and Save to Disk

Each evaluate call can return at most ~5MB of JSON. Process in batches:

() => {
  const keys = Object.keys(window.__frames).sort((a,b) => +a - +b);
  const out = {};
  for (const k of keys.slice(START, START+4)) {
    out[k] = window.__frames[k].split(',')[1]; // Remove data:image/jpeg;base64,
  }
  return out;
}

Use the filename parameter of mcp__playwright__browser_evaluate to write the JSON to ~/.playwright-mcp/ or ~/. Cannot write directly to /tmp (sandbox restriction).

Save script:

import json, base64, os
os.makedirs(os.path.expanduser("~/course-frames"), exist_ok=True)
for batch in glob("~/course-frames/batch*.json"):
    d = json.load(open(batch))
    for t, b64 in d.items():
        secs = int(t)
        fn = f"frame-{secs:04d}s-{secs//60:03d}m{secs%60:02d}s.jpg"
        open(f"~/course-frames/{fn}", "wb").write(base64.b64decode(b64))

Step 5: AI Classifies Frames + Densifies Sampling

Use the Read tool to view frames one by one (images will be displayed to you automatically). Label each frame:

  • slide — contains PPT text, readable → must capture
  • editor — Cursor / VS Code / terminal → capture (useful for demo scenarios)
  • talking_head — only the instructor's face → skip
  • qa / chat — bullet comments interaction → select 1-2 frames as Q&A representatives

Dense resampling: If two consecutive frames are 8 minutes apart but contain completely different content (e.g., jumping from Principle 01 to Principle 05), this indicates dense slide transitions. Go back and resample:

// Resample in the [start, end] range at 1-2 minute intervals
const targets = [];
for (let t = START; t <= END; t += 90) targets.push(t);

Step 6: Write Markdown Article

Article structure (adjust based on course type):

# Course Title · Complete Review Notes

> Course Info: Instructor / Date / Duration / Platform / Original Video Link

## Who This Article Is For
(1 paragraph, directly state the reader profile + what they will learn)

## Course Overview Structure

00:00 - 08:00 Introduction 08:00 - 25:00 Part 1 ... ...


## Part 1 · ...
> ⏱ Timestamp: **16:00 – 25:00**

### Sub-section 1
> ⏱ **16:00** · Slide 9/38
![placeholder-frame-XXXXs.jpg](placeholder-frame-XXXXs.jpg)
(Key point + memorable quote + checklist)

...

## Actionable Next Steps for Beginners
(Action items broken down by week)

## Appendix · Key Resource Links

Writing rules:

  • Use unique filenames for each image placeholder: placeholder-frame-{seconds}s.jpg, for easy localization with selection-with-ellipsis later.
  • Every slide must include an exact timestamp (hh:mm or mm:ss) + slide number.
  • Slide content should be copied directly into a table — do not summarize (the user wants to see the original text).
  • Use Markdown tables or lists for structured content like examples/counterexamples / checklists.
  • Must end with "Actionable Next Steps for Beginners" broken down by week; otherwise the article is read-only.

Step 7: Push to Feishu

7.1 Check lark-cli Authorization Status

lark-cli auth status

When running this skill for the first time you need to authorize these scopes (add one at a time):

  • space:folder:create — create folders
  • docx:document:create — create documents
  • docx:document:write_only + docx:document:readonly — modify documents (required for media insertion)
  • docs:document.media:upload — upload images to documents

Authorization command:

nohup lark-cli auth login --scope "<scope>" > /tmp/lark-auth.log 2>&1 &
sleep 5
cat /tmp/lark-auth.log  # Get the device-flow URL
open "<URL>"  # Ask the user to authorize in their browser
# Wait for the user to complete
until grep -q "Authorization successful" /tmp/lark-auth.log; do sleep 3; done

⚠️ Scopes must be added one at a time — requesting multiple scopes at once will return an "invalid scope" error.

7.2 Create Folder (defaults to the user's personal space root)

lark-cli drive +create-folder --name "<Folder Name>"
# Returns folder_token; note it down

7.3 Prepare Clean Markdown (Without Image Placeholders)

sed '/!\[.*\](placeholder-frame/d' article.md > article-clean.md

7.4 Create Document

cd ~/course-frames/article  # Must cd into the markdown path (CLI requirement)
lark-cli docs +create \
  --markdown @article-clean.md \
  --folder-token "<folder_token>" \
  --title "<Document Title>" \
  > /tmp/doc-create.json 2>&1
# Extract doc_id

7.5 Insert Images One by One

For each image, use the chapter title or a unique text phrase as an anchor:

lark-cli docs +media-insert \
  --doc "<doc_id>" \
  --file "frame-XXXXs-MMMmSSs.jpg" \
  --type image \
  --selection-with-ellipsis "<unique heading text>" \
  --align center \
  --caption "<Timestamp · Description>"

Anchor rules:

  • Use the first 15 characters of the section heading (sufficiently unique).
  • For multiple images in the same section → use unique phrases from different paragraphs.
  • If it fails, use the start...end format: --selection-with-ellipsis "first paragraph...last paragraph"

7.6 Error Handling

  • Server timeout → retry once. Document creation containing over 16k characters tends to time out; splitting the article into two parts can help.
  • "Must be created in root folder" error → folder_token is misspelled or not transmitted.
  • Image placeholders still present → placeholder-frame-XXX remnants in the markdown. First rewrite the document with --mode overwrite using the clean version, then insert images.

Anti-Patterns (Avoid These Pitfalls)

❌ Anti-pattern 1: Attempting to directly download the video with ffmpeg

HLS + token will almost certainly return a 403 error. Even if it works, you'd spend 20 minutes downloading the full video and another 5 minutes extracting frames with ffmpeg. video → canvas captures 16 frames in 5 seconds.

❌ Anti-pattern 2: Making Claude watch the entire video

You don't have that capability. Even if you did (multimodal video API), the cost is 50 times that of frame capture. Frame capture + image reading + timestamp localization is the leverage.

❌ Anti-pattern 3: Calling drawImage without waiting long enough after a seek

The seeked event firing does not mean the frame is fully rendered. The GPU buffer has a 200-500ms delay. Wait at least 800ms; 1 second is more stable. The symptom is: "first two frames are OK, but from the third onward, all frames are the same image."

❌ Anti-pattern 4: Requesting all scopes at once

lark-cli auth login --scope "scope1 scope2 scope3" returns an "invalid scope" error. One scope at a time.

❌ Anti-pattern 5: Trying to run both video capture and Feishu operations with gstack browse

gstack browse daemon is unstable during bash session switches. Playwright MCP for video capture + lark-cli for Feishu operations is the cleanest approach.

❌ Anti-pattern 6: Hard-trying after cookies have expired

Check expires_utc < current time → directly tell the user "please log in again"; do not try 5 different solutions.

Common User Questions

"Why not just give me the video captions?" Answer: We can, but it requires running Whisper separately (an extra 5-10 minutes). If the user explicitly wants a transcript, run it; otherwise, illustrated notes are the default.

"Why not capture more frames?" Answer: Each frame is ~200KB. Feishu documents have size limits for insertion + there's visual fatigue. 12-18 frames is the sweet spot for a 2-hour class.

"Can I skip Feishu?" Answer: The default output is ~/course-frames/article/article.md + the same directory's *.jpg. The user can manually distribute them anywhere.

Output Specification

After each successful run, the final response must include:

  1. Feishu document URL (directly clickable)
  2. Total frames captured + total duration
  3. Chapter outline (for the user to preview)
  4. One "Next step suggestion" sentence (e.g., "Let me know in comments which section you'd like expanded")

Companion Scripts

scripts/capture-frames.js — Playwright evaluate functions for probing and frame capture (paste into mcp__playwright__browser_evaluate)

scripts/decode-batches.py — Save script for batch base64 → jpg

scripts/insert-images.sh — Feishu lark-cli batch image insertion template

For reference, see a completed case: examples/deepsea-2026-04-23.md

相关技能