---
name: dvd-pressing
description: DVD video compression workflow. Use when the user says "dvd 压制", "压到一张 DVD", "刻光盘", "需要刻录的文件", or asks to compress large videos so one or more files fit on a single DVD, especially when audio matters more than image quality and when replacing files in a burn-folder such as a mounted Windows/SMB path.
---

# dvd 压制

## Core Workflow

1. Verify the real inputs first:
   - Confirm each file exists at the exact path supplied by the user.
   - Use `ffprobe` to record duration, size, video codec/profile/resolution/bitrate, and audio codec/bitrate.
   - Compute true bytes, not only `ls -lh`; single-layer DVD target is `4,700,000,000` bytes. Leave margin unless the user explicitly wants to maximize quality.

2. Choose compression mode:
   - **Audio-first DVD fit**: use when the user says picture has little value or "mainly sound". Keep audio stream with `-c:a copy`, downscale video to `720x1280`, encode HEVC Main10 around `2m`. This usually keeps long police/bodycam phone videos readable while making two 1-hour files fit on one single-layer DVD.
   - **Image-preserving DVD fit**: use when picture still matters. Keep resolution if possible and lower HEVC bitrate to fit the requested disc count. Use a conservative byte budget and verify after encoding.
   - Do not convert to H.264 unless the user asks for compatibility over size/quality; the user's phone sources are already HEVC and compatibility was explicitly deprioritized in the original workflow.

3. Encode to a staging/output directory first. Do not overwrite source files.

4. Verify before claiming completion:
   - `ffprobe` duration must match source.
   - Output stream should be HEVC Main10 unless intentionally changed.
   - Audio should remain AAC and copied when audio quality is the priority.
   - Sum output sizes and compare to DVD byte budget.

5. If replacing a burn folder:
   - Use a local input folder such as `$HOME/Movies/to-burn`.
   - List current files in the destination before changing it.
   - Move existing files into a sibling backup directory named `已替换文件备份_YYYYMMDD_HHMMSS`.
   - Copy the new outputs into the destination using the original filenames unless the user requests suffixes.
   - Re-list and re-probe destination files after copy. SMB writes can stall; wait for copy completion and verify final file sizes.

## Recommended Script

Use `scripts/dvd_press.py` for repeatable runs. It wraps `ffmpeg`/`ffprobe`, supports dry runs, Windows-path resolution for the usual scanned-documents share, and safe burn-folder replacement.

Audio-first example:

```bash
python3 $HOME/.codex/skills/dvd-pressing/scripts/dvd_press.py \
  --audio-focus \
  --output-dir $HOME/Downloads/DVD一盘压缩版 \
  "/path/to/video1.mp4" "/path/to/video2.mp4"
```

Replace burn-folder after encoding:

```bash
python3 $HOME/.codex/skills/dvd-pressing/scripts/dvd_press.py \
  --audio-focus \
  --output-dir $HOME/Downloads/DVD一盘压缩版 \
  --dest "D:\\Scanned Documents\\刻光盘_win7便携版\\需要刻录的文件" \
  --replace-dest \
  "/path/to/video1.mp4" "/path/to/video2.mp4"
```

## Manual ffmpeg Pattern

When not using the script, use this baseline for audio-first video:

```bash
ffmpeg -hide_banner -y -i "$in" \
  -map 0:v:0 -map '0:a?' -map_metadata 0 \
  -vf 'scale=720:1280:force_original_aspect_ratio=decrease:flags=lanczos,pad=720:1280:(ow-iw)/2:(oh-ih)/2,format=p010le' \
  -c:v hevc_videotoolbox -b:v 2000k -maxrate 2600k -bufsize 4000k -profile:v main10 -tag:v hvc1 \
  -c:a copy -movflags +faststart \
  "$out"
```

Use exact verification commands:

```bash
ffprobe -v error -show_entries format=duration,size,bit_rate \
  -show_entries stream=codec_name,profile,width,height,bit_rate \
  -of default=nokey=1:noprint_wrappers=1 "$file"
```

## Stop Rules

- Do not say the job is done until destination files are present and probed.
- Do not delete source files or backups unless the user explicitly asks.
- If the mounted share is missing, stop and report the missing mount instead of inventing a path.
- If the total output exceeds the DVD budget, rerun with lower video bitrate or lower resolution; do not silently leave oversized files in the burn folder.
