Skip to content

Shenrui-Ma/video-regen-recipes / templates/character-short/bit-by-bit-heartache

bit-by-bit-heartache

Verified

用角色参考图在本机制作 Heartache 连续动作配乐短片.

FileKindSize
.gitignoreother430 B
LICENSEother1.1 KB
LICENSES.mdmarkdown1.4 KB
README.mdmarkdown9.3 KB
SKILL.mdskill md7.3 KB
assets/README.mdmarkdown4.9 KB
assets/default/manifest.jsonconfig3.8 KB
assets/runtime-assets.jsonconfig5.5 KB
profile.jsonconfig3.8 KB
prompts/ref2va.template.txtmarkdown1.6 KB
prompts/yaoguang.historical.txtmarkdown5.0 KB
references/background-removal.mdmarkdown5.5 KB
references/changelog.mdmarkdown916 B
references/character-input.mdmarkdown4.7 KB
references/deployment.mdmarkdown4.9 KB
references/editing.mdmarkdown3.7 KB
references/environment.lock.jsonconfig1.5 KB
references/first-segment-validation.jsonconfig1.8 KB
references/generation.mdmarkdown3.8 KB
references/media-preflight.mdmarkdown4.2 KB
references/native-continuation.mdmarkdown17.8 KB
references/node-sources.jsonconfig6.7 KB
references/node-sources.mdmarkdown3.8 KB
references/package-verification.jsonconfig1.7 KB
references/reference-check.jsonconfig968 B
references/reproduction.mdmarkdown10.1 KB
references/validation.mdmarkdown2.6 KB
references/workflow-recovery.mdmarkdown2.2 KB
references/workflow.lock.jsonconfig1.2 KB
references/yaoguang-run.jsonconfig7.4 KB
scripts/character/prepare_character.pyscript6.5 KB
scripts/distribution/fetch_assets.pyscript5.8 KB
scripts/distribution/package_skill.pyscript5.6 KB
scripts/plan_segments.pyscript3.4 KB
scripts/prepare_driver.pyscript5.2 KB
scripts/render_default.pyscript5.5 KB
scripts/runtime/graphs.pyscript11.3 KB
scripts/runtime/heartache.pyscript14.6 KB
scripts/runtime/local_io.pyscript3.3 KB
scripts/runtime/media.pyscript13.2 KB
scripts/runtime/run_segment.pyscript13.3 KB
sources.mdmarkdown2.4 KB
tests/test_background_removal.pyscript2.6 KB
tests/test_character_input.pyscript12.2 KB
tests/test_default.pyscript879 B
tests/test_distribution.pyscript12.3 KB
tests/test_media_preflight.pyscript2.1 KB
tests/test_prepare_driver.pyscript1.9 KB
tests/test_release_review.pyscript1.7 KB
tests/test_reproduction.pyscript1.9 KB
tests/test_runtime_cli.pyscript11.3 KB
tests/test_runtime_graph.pyscript4.8 KB
tests/test_runtime_io.pyscript2.1 KB
tests/test_runtime_media.pyscript10.2 KB
tests/test_runtime_runner.pyscript1.6 KB
tests/test_segment_plan.pyscript3.4 KB
tests/test_skill_contract.pyscript1.6 KB
workflows/continue.editor.jsonconfig23.8 KB
workflows/first.editor.jsonconfig19.8 KB
workflows/node-schema.jsonconfig22.2 KB
workflows/provenance.jsonconfig911 B

scripts/prepare_driver.py

View on GitHub
#!/usr/bin/env python3
"""Verify the frozen historical driver and prepare four video-only H3 references.

Python 3.9+, FFmpeg and ffprobe. No ComfyUI, network or GPU calls.
This prepares reference media; it does not generate a new character.
"""
import argparse
from fractions import Fraction
import hashlib
import json
from pathlib import Path
import subprocess

EXPECTED_SHA256 = 'e63386ab88bf4a11dc2fd859b0075099229cad44d77366a220c6e0bb0ba0ca0d'
RANGES = [(0, 158), (151, 309), (302, 443), (436, 577)]


def sha256(path):
    digest = hashlib.sha256()
    with Path(path).open('rb') as stream:
        for chunk in iter(lambda: stream.read(1024 * 1024), b''):
            digest.update(chunk)
    return digest.hexdigest()


def probe(path, ffprobe='ffprobe'):
    result = subprocess.run([
        ffprobe, '-v', 'error', '-count_frames', '-select_streams', 'v:0',
        '-show_entries', 'stream=width,height,avg_frame_rate,nb_read_frames',
        '-of', 'json', str(path),
    ], check=True, capture_output=True, text=True)
    streams = json.loads(result.stdout)['streams']
    if not streams:
        raise ValueError('Input has no video stream')
    video = streams[0]
    return {'width': int(video['width']), 'height': int(video['height']),
            'frames': int(video['nb_read_frames']), 'fps': video['avg_frame_rate']}


def validate_master(metadata, digest):
    if (metadata['frames'], metadata['width'], metadata['height']) != (577, 1344, 768):
        raise ValueError('Expected the historical 577-frame, 1344x768 driver. '
                         'A 578/579-frame reconstruction is a different input; do not trim it silently.')
    if Fraction(metadata['fps']) != 24:
        raise ValueError('Expected exactly 24 fps')
    if digest != EXPECTED_SHA256:
        raise ValueError('Historical driver SHA256 mismatch; use the pinned reference asset')


def segment_command(ffmpeg, source, output, start, end):
    return [ffmpeg, '-hide_banner', '-loglevel', 'error', '-nostdin', '-n',
            '-i', str(source), '-map', '0:v:0', '-an',
            '-vf', f'trim=start_frame={start}:end_frame={end},setpts=PTS-STARTPTS',
            '-r', '24', '-vsync', 'cfr', '-c:v', 'libx264', '-preset', 'medium',
            '-crf', '0', '-pix_fmt', 'yuv420p', '-map_metadata', '-1',
            '-map_chapters', '-1', '-movflags', '+faststart', str(output)]


def prepare(source, output_dir, ffmpeg='ffmpeg', ffprobe='ffprobe'):
    source = Path(source).resolve()
    digest = sha256(source)
    metadata = probe(source, ffprobe)
    validate_master(metadata, digest)
    output_dir = Path(output_dir).resolve()
    # Never overwrite an old run, including a partially completed one.
    output_dir.mkdir(parents=True, exist_ok=False)
    manifest = {'schema_version': 1, 'input_sha256': digest, 'input': metadata,
                'reference_audio_connected': False,
                'scope': 'Lossless video slices of the frozen driver. Original historical '
                         'segments included AAC; these video-only files have different file hashes. '
                         'This is reference preparation, not H3 inference.',
                'segments': []}
    for index, (start, end) in enumerate(RANGES, 1):
        path = output_dir / f'seg{index}_ref24_1344x768.mp4'
        subprocess.run(segment_command(ffmpeg, source, path, start, end), check=True)
        actual = probe(path, ffprobe)
        if (actual['frames'], actual['width'], actual['height'], Fraction(actual['fps'])) != (
                end - start, 1344, 768, Fraction(24)):
            raise ValueError(f'Segment {index} failed its frame/shape/fps contract: {actual}')
        subprocess.run([ffmpeg, '-v', 'error', '-xerror', '-nostdin', '-i', str(path),
                        '-map', '0:v:0', '-f', 'null', '-'], check=True)
        manifest['segments'].append({'segment': index, 'path': path.name,
                                     'interval': [start, end], **actual,
                                     'sha256': sha256(path), 'full_decode': True})
    with (output_dir / 'reference-manifest.json').open('x', encoding='utf-8') as stream:
        json.dump(manifest, stream, ensure_ascii=False, indent=2)
        stream.write('\n')
    return manifest


def main():
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument('--input', type=Path, required=True, help='Downloaded heartache-driver-577f.mp4')
    parser.add_argument('--output-dir', type=Path, help='New directory, outside the recipe checkout')
    parser.add_argument('--check-only', action='store_true', help='Validate input without writing output')
    parser.add_argument('--ffmpeg', default='ffmpeg')
    parser.add_argument('--ffprobe', default='ffprobe')
    args = parser.parse_args()
    if not args.check_only and args.output_dir is None:
        parser.error('--output-dir is required unless --check-only is set')
    if args.check_only:
        digest = sha256(args.input)
        metadata = probe(args.input, args.ffprobe)
        validate_master(metadata, digest)
        print(json.dumps({'verified': True, 'sha256': digest, **metadata}, indent=2))
    else:
        print(json.dumps(prepare(args.input, args.output_dir, args.ffmpeg, args.ffprobe), indent=2))


if __name__ == '__main__':
    main()
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall