# Video Download With Korean Title

> Use when the user asks to save a video from a URL (X, YouTube, Instagram, etc.) to NAS. Downloads the video, extracts keyframes, has vision model generate a short Korean title, and renames to "platform_한글제목.mp4".

- Skill: `wcpaka-lgtm/video-download-with-korean-title` (Agent Skill)
- Install (CLI): `npx skillmds@latest add wcpaka-lgtm/video-download-with-korean-title`
- Raw SKILL.md: https://api.skillmd.com/api/skills/wcpaka-lgtm/video-download-with-korean-title/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: wcpaka-lgtm (https://skillmd.com/u/wcpaka-lgtm)
- Updated: 2026-09-21
- Page: https://skillmd.com/skills/wcpaka-lgtm/video-download-with-korean-title

---


# Video Download with Korean Auto-Title

User wants a video from a URL saved to NAS with a short Korean title derived from the video content. Pipeline:

1. **yt-dlp downloads** the video to `G:\내 드라이브\NAS폴더\NASfolder\동영상저장` as `platform_<id>.mp4`
2. **ffmpeg extracts 6 keyframes** at 10%, 25%, 40%, 55%, 70%, 85% of duration (or 8/20/32/44/56/68s for 80s videos)
3. **delegate_task (leaf)** uses `vision_analyze` to look at the frames and produce a Korean title (5–12 chars, no Windows-illegal chars, no "영상"/"동영상" suffix)
4. **Rename** to `platform_<Korean title>.mp4` and clean up temp thumbs

## Default save path
`G:\내 드라이브\NAS폴더\NASfolder\동영상저장`

## Platform detection (for filename prefix)
- `x.com` or `twitter.com` → `x_`
- `youtube.com` or `youtu.be` → `youtube_`
- `instagram.com` → `instagram_`
- `tiktok.com` → `tiktok_`
- Otherwise → `video_`

## Key commands

**Download:**
```bash
yt-dlp "<URL>" -o "G:/내 드라이브/NAS폴더/NASfolder/동영상저장/<platform>_<%(id)s>.%(ext)s"
```
(Note: include `%(id)s` placeholder so the initial filename is unique; the rename step replaces it.)

**Extract keyframes (ffmpeg):**
```python
import os, subprocess
FFMPEG = r"C:\Users\okya1\AppData\Local\Microsoft\WinGet\Packages\Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe\ffmpeg-8.1.1-full_build\bin\ffmpeg.exe"
# Adjust the 6 timestamps based on video duration
# For ~80s video, use 8/20/32/44/56/68. For unknown length, compute from duration.
times = [8, 20, 32, 44, 56, 68]  # seconds
for i, t in enumerate(times):
    subprocess.run([FFMPEG, "-y", "-ss", str(t), "-i", video_path,
                    "-frames:v", "1", "-q:v", "3", f"frame_{i:02d}.jpg"])
```

**Compute frame times for arbitrary video length:**
```python
duration = 80.666  # from ffprobe
times = [duration * p for p in [0.10, 0.25, 0.40, 0.55, 0.70, 0.85]]
```

**Vision analysis prompt to delegate_task (leaf):**
```
너는 영상 키프레임 6장을 보고 그 영상에 어울리는 짧은 한글 제목을 만드는 역할이야.

## 입력
영상은 <platform> URL에서 받은 <duration>짜리 영상이고, 6장의 키프레임이 다음 위치에 있어:
- C:\Users\okya1\AppData\Local\Temp\x_thumbs_<id>\frame_00.jpg (8s)
- ... (frame_01 ~ frame_05)

vision_analyze 도구로 각 프레임을 보고 영상 내용을 파악해줘. (6장 다 안 봐도 되지만 시간대별로 다르니 가능하면 6장 다 봐)

## 출력 형식
제목: <한글 제목 5~12자>
근거: <어떤 장면인지 한 줄 설명>

## 제약
- 한글로만 작성 (영어, 숫자는 불가피할 때만)
- 5~12자 이내, 공백 포함 가능
- 파일명용이므로 Windows 파일명에 안 되는 문자(< > : " / \ | ? *) 사용 금지
- "영상", "동영상" 같은 메타 단어 금지
```

**Rename (Windows-safe sanitize):**
```python
import os, re
src = r"G:\내 드라이브\NAS폴더\NASfolder\동영상저장\x_<id>.mp4"
raw_title = "<subagent output>"
safe = re.sub(r'[<>:"/\\|?*]', '', raw_title).strip()
safe = re.sub(r'\s+', ' ', safe)
dst = rf"G:\내 드라이브\NAS폴더\NASfolder\동영상저장\x_{safe}.mp4"
os.rename(src, dst)
```

## Pitfalls
- **ffmpeg can't open Korean paths on Windows** — even via Python subprocess, ffmpeg fails with "Illegal byte sequence" on paths containing 한글. Workaround: copy the source to an ASCII temp path (e.g. `%TEMP%\yt_conv\in.webm`), convert there, `shutil.move` the result back to the 한글 destination, then clean up. Note the copy+convert can take >5 min for long videos — run the ffmpeg convert as a background terminal job or a written-out .py script, not inside execute_code (which has a hard timeout).
- **yt-dlp goes stale fast** — "Signature extraction failed" / "Only images are available" means the installed yt-dlp is outdated vs YouTube's player changes. Fix with `pip install -U yt-dlp` (check version with `yt-dlp --version`) and retry.
- **MSYS path gotcha**: When using `-o` with absolute Windows paths in git-bash, yt-dlp can create files with literal `\c\Users\...` as a filename in cwd instead of resolving the path. Workaround: use forward slashes in `-o` template and verify with `os.path.exists` after.
- **Merged files**: Twitter videos come as two separate HLS streams (video + audio) and yt-dlp merges them. Don't pass `-f best` (gets a warning); omit format selection so it picks best video+audio and merges.
- **Korean filenames on Windows**: File system supports them fine. Just sanitize the 9 illegal chars.
- **Long videos**: Don't extract all keyframes at fixed times — scale to `duration * [0.1, 0.25, 0.4, 0.55, 0.7, 0.85]`.
- **Subagent returns prefix**: The leaf subagent may wrap output in markdown. Parse out the line starting with `제목:` and use the value after it.

## Verification checklist
- `os.path.exists(final_path)` after rename → True
- File size matches the download
- Thumbnail dir cleaned up (`%TEMP%\x_thumbs_*` removed)

