Restore YT-Lite content after user excluded it from this update
Browse files- LICENSES.md +0 -3
- README.md +1 -1
- metadata/finevideo_local_seed.json +0 -0
- metadata/media-inventory.json +0 -0
- preparation/fetch_assets.py +0 -79
- preparation/import_finevideo_batch.py +0 -496
- preparation/transcode_videos_h265.py +0 -205
- release-manifest.json +0 -41
LICENSES.md
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
# FineVideo source terms
|
| 2 |
-
|
| 3 |
-
Source videos retain their original Creative Commons Attribution licenses and attribution requirements. FineVideo is the direct source; YouTube-Commons is upstream. Use is also subject to the [FineVideo Terms of Use](https://huggingface.co/datasets/HuggingFaceFV/finevideo#terms-of-use-for-finevideo), including its redistribution and dataset-version conditions. This update preserves the existing media files.
|
|
|
|
|
|
|
|
|
|
|
|
README.md
CHANGED
|
@@ -23,6 +23,6 @@ The application categories are **Other (939), Learning (248), News (161), Gaming
|
|
| 23 |
|
| 24 |
The release retains duplicate entries: the 1,419 MP4 files contain **1,321 distinct file hashes**, with 98 additional byte-identical copies. Counts and cumulative duration therefore describe the released entries, rather than unique source videos.
|
| 25 |
|
| 26 |
-
This repository contains the media assets under `videos/` and `thumbnails/`
|
| 27 |
|
| 28 |
The source material retains its original licenses and attribution requirements. Use is subject to the [FineVideo Terms of Use](https://huggingface.co/datasets/HuggingFaceFV/finevideo#terms-of-use-for-finevideo).
|
|
|
|
| 23 |
|
| 24 |
The release retains duplicate entries: the 1,419 MP4 files contain **1,321 distinct file hashes**, with 98 additional byte-identical copies. Counts and cumulative duration therefore describe the released entries, rather than unique source videos.
|
| 25 |
|
| 26 |
+
This repository contains the media assets under `videos/` and `thumbnails/`. The corresponding seed metadata and preparation scripts are maintained in the WebArena-Pro application repository.
|
| 27 |
|
| 28 |
The source material retains its original licenses and attribution requirements. Use is subject to the [FineVideo Terms of Use](https://huggingface.co/datasets/HuggingFaceFV/finevideo#terms-of-use-for-finevideo).
|
metadata/finevideo_local_seed.json
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
metadata/media-inventory.json
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
preparation/fetch_assets.py
DELETED
|
@@ -1,79 +0,0 @@
|
|
| 1 |
-
import argparse
|
| 2 |
-
from pathlib import Path
|
| 3 |
-
|
| 4 |
-
from huggingface_hub import snapshot_download
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
ROOT = Path(__file__).resolve().parent
|
| 8 |
-
STATIC_DIR = ROOT / "static"
|
| 9 |
-
DEFAULT_REPO_ID = "WebArena-Pro/yt-lite-data"
|
| 10 |
-
ALLOW_PATTERNS = ["videos/*", "thumbnails/*"]
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
def parse_args():
|
| 14 |
-
parser = argparse.ArgumentParser(
|
| 15 |
-
description="Fetch yt-lite video and thumbnail assets from Hugging Face."
|
| 16 |
-
)
|
| 17 |
-
parser.add_argument(
|
| 18 |
-
"--repo-id",
|
| 19 |
-
default=DEFAULT_REPO_ID,
|
| 20 |
-
help="Hugging Face dataset repo containing videos/ and thumbnails/.",
|
| 21 |
-
)
|
| 22 |
-
parser.add_argument(
|
| 23 |
-
"--revision",
|
| 24 |
-
default=None,
|
| 25 |
-
help="Optional repo revision, branch, or commit.",
|
| 26 |
-
)
|
| 27 |
-
parser.add_argument(
|
| 28 |
-
"--token",
|
| 29 |
-
default=None,
|
| 30 |
-
help="Optional HF token. Falls back to cached login or HF_TOKEN.",
|
| 31 |
-
)
|
| 32 |
-
parser.add_argument(
|
| 33 |
-
"--force",
|
| 34 |
-
action="store_true",
|
| 35 |
-
help="Force re-download even if local cached copies already exist.",
|
| 36 |
-
)
|
| 37 |
-
parser.add_argument(
|
| 38 |
-
"--dry-run",
|
| 39 |
-
action="store_true",
|
| 40 |
-
help="Show what would be fetched without downloading files.",
|
| 41 |
-
)
|
| 42 |
-
return parser.parse_args()
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
def main():
|
| 46 |
-
args = parse_args()
|
| 47 |
-
STATIC_DIR.mkdir(parents=True, exist_ok=True)
|
| 48 |
-
|
| 49 |
-
result = snapshot_download(
|
| 50 |
-
repo_id=args.repo_id,
|
| 51 |
-
repo_type="dataset",
|
| 52 |
-
revision=args.revision,
|
| 53 |
-
local_dir=STATIC_DIR,
|
| 54 |
-
allow_patterns=ALLOW_PATTERNS,
|
| 55 |
-
force_download=args.force,
|
| 56 |
-
token=args.token,
|
| 57 |
-
dry_run=args.dry_run,
|
| 58 |
-
)
|
| 59 |
-
|
| 60 |
-
if args.dry_run:
|
| 61 |
-
planned = result if isinstance(result, list) else []
|
| 62 |
-
print(f"Repo: {args.repo_id}")
|
| 63 |
-
print(f"Would fetch files: {len(planned)}")
|
| 64 |
-
for item in planned[:20]:
|
| 65 |
-
print(item.filename)
|
| 66 |
-
if len(planned) > 20:
|
| 67 |
-
print(f"... and {len(planned) - 20} more")
|
| 68 |
-
return 0
|
| 69 |
-
|
| 70 |
-
video_count = len(list((STATIC_DIR / "videos").glob("*.mp4")))
|
| 71 |
-
thumb_count = len(list((STATIC_DIR / "thumbnails").glob("*.*")))
|
| 72 |
-
print(f"Fetched assets from {args.repo_id}")
|
| 73 |
-
print(f"Videos present: {video_count}")
|
| 74 |
-
print(f"Thumbnails present: {thumb_count}")
|
| 75 |
-
return 0
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
if __name__ == "__main__":
|
| 79 |
-
raise SystemExit(main())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
preparation/import_finevideo_batch.py
DELETED
|
@@ -1,496 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Bounded FineVideo batch importer for yt-lite.
|
| 3 |
-
|
| 4 |
-
This importer supports two bounded sources:
|
| 5 |
-
- rows: the Hugging Face dataset-viewer /rows endpoint.
|
| 6 |
-
- hub-parquet: explicitly selected Hugging Face repo parquet shards.
|
| 7 |
-
|
| 8 |
-
Both modes decode MP4 payloads, generate local thumbnails with ffmpeg, and
|
| 9 |
-
write each successful local-video entry immediately to
|
| 10 |
-
data/finevideo_local_seed.json.
|
| 11 |
-
|
| 12 |
-
For unstable ranges, prefer smaller batches such as --count 10 or --count 25
|
| 13 |
-
and rerun from the same offset; completed rows are skipped unless --overwrite is
|
| 14 |
-
used.
|
| 15 |
-
"""
|
| 16 |
-
|
| 17 |
-
from __future__ import annotations
|
| 18 |
-
|
| 19 |
-
import argparse
|
| 20 |
-
import base64
|
| 21 |
-
import json
|
| 22 |
-
import os
|
| 23 |
-
import subprocess
|
| 24 |
-
import time
|
| 25 |
-
from datetime import datetime
|
| 26 |
-
from pathlib import Path
|
| 27 |
-
from urllib.error import HTTPError, URLError
|
| 28 |
-
from urllib.parse import urlencode
|
| 29 |
-
from urllib.request import Request, urlopen
|
| 30 |
-
|
| 31 |
-
try:
|
| 32 |
-
from huggingface_hub import hf_hub_download, get_token
|
| 33 |
-
except ImportError:
|
| 34 |
-
hf_hub_download = None
|
| 35 |
-
get_token = None
|
| 36 |
-
|
| 37 |
-
try:
|
| 38 |
-
import pyarrow.parquet as pq
|
| 39 |
-
except ImportError:
|
| 40 |
-
pq = None
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
DATASET = "HuggingFaceFV/finevideo"
|
| 44 |
-
API_ROOT = "https://datasets-server.huggingface.co"
|
| 45 |
-
ROOT = Path(__file__).resolve().parent
|
| 46 |
-
VIDEO_DIR = ROOT / "static" / "videos"
|
| 47 |
-
THUMBNAIL_DIR = ROOT / "static" / "thumbnails"
|
| 48 |
-
SEED_PATH = ROOT / "data" / "finevideo_local_seed.json"
|
| 49 |
-
MAX_COUNT = 100
|
| 50 |
-
MAX_SHARD_COUNT = 5
|
| 51 |
-
MAX_PARQUET_ROWS = 100
|
| 52 |
-
RETRYABLE_HTTP_CODES = {502, 503, 504}
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
def token_from_env() -> str | None:
|
| 56 |
-
return (
|
| 57 |
-
os.environ.get("HF_TOKEN") or
|
| 58 |
-
os.environ.get("HUGGINGFACE_HUB_TOKEN") or
|
| 59 |
-
(get_token() if get_token else None)
|
| 60 |
-
)
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
def api_get_rows(offset: int, token: str | None, retries: int, backoff: float) -> dict:
|
| 64 |
-
params = {
|
| 65 |
-
"dataset": DATASET,
|
| 66 |
-
"config": "default",
|
| 67 |
-
"split": "train",
|
| 68 |
-
"offset": str(offset),
|
| 69 |
-
"length": "1",
|
| 70 |
-
}
|
| 71 |
-
url = f"{API_ROOT}/rows?{urlencode(params)}"
|
| 72 |
-
headers = {"User-Agent": "yt-lite-finevideo-batch/1.0"}
|
| 73 |
-
if token:
|
| 74 |
-
headers["Authorization"] = f"Bearer {token}"
|
| 75 |
-
|
| 76 |
-
for attempt in range(1, retries + 1):
|
| 77 |
-
try:
|
| 78 |
-
with urlopen(Request(url, headers=headers), timeout=180) as response:
|
| 79 |
-
return json.loads(response.read().decode("utf-8"))
|
| 80 |
-
except HTTPError as exc:
|
| 81 |
-
detail = exc.read().decode("utf-8", errors="replace")
|
| 82 |
-
if exc.code not in RETRYABLE_HTTP_CODES or attempt == retries:
|
| 83 |
-
raise SystemExit(
|
| 84 |
-
f"Dataset-viewer /rows failed at offset {offset}: "
|
| 85 |
-
f"HTTP {exc.code}\n{detail}"
|
| 86 |
-
) from exc
|
| 87 |
-
wait = backoff * (2 ** (attempt - 1))
|
| 88 |
-
print(
|
| 89 |
-
f"Retryable HTTP {exc.code} at offset {offset}; "
|
| 90 |
-
f"retry {attempt}/{retries} after {wait:.1f}s"
|
| 91 |
-
)
|
| 92 |
-
time.sleep(wait)
|
| 93 |
-
except URLError as exc:
|
| 94 |
-
if attempt == retries:
|
| 95 |
-
raise SystemExit(
|
| 96 |
-
f"Dataset-viewer /rows failed at offset {offset}: {exc}"
|
| 97 |
-
) from exc
|
| 98 |
-
wait = backoff * (2 ** (attempt - 1))
|
| 99 |
-
print(
|
| 100 |
-
f"Retryable network error at offset {offset}: {exc}; "
|
| 101 |
-
f"retry {attempt}/{retries} after {wait:.1f}s"
|
| 102 |
-
)
|
| 103 |
-
time.sleep(wait)
|
| 104 |
-
|
| 105 |
-
raise SystemExit(f"Dataset-viewer /rows failed at offset {offset}")
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
def decode_mp4(value) -> bytes:
|
| 109 |
-
if isinstance(value, (bytes, bytearray, memoryview)):
|
| 110 |
-
data = bytes(value)
|
| 111 |
-
if len(data) < 16 or data[4:8] != b"ftyp":
|
| 112 |
-
raise ValueError("binary payload does not look like an MP4")
|
| 113 |
-
return data
|
| 114 |
-
|
| 115 |
-
if not isinstance(value, str):
|
| 116 |
-
raise ValueError("mp4 field is not a string or bytes")
|
| 117 |
-
if value.startswith(("http://", "https://")):
|
| 118 |
-
raise ValueError("mp4 field is a URL, not an inline payload")
|
| 119 |
-
|
| 120 |
-
payload = value.strip()
|
| 121 |
-
if payload.startswith('"') and payload.endswith('"'):
|
| 122 |
-
payload = json.loads(payload)
|
| 123 |
-
elif payload.startswith('"'):
|
| 124 |
-
raise ValueError("mp4 field appears truncated")
|
| 125 |
-
|
| 126 |
-
data = base64.b64decode(payload, validate=True)
|
| 127 |
-
if len(data) < 16 or data[4:8] != b"ftyp":
|
| 128 |
-
raise ValueError("decoded payload does not look like an MP4")
|
| 129 |
-
return data
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
def normalize_metadata(value) -> dict:
|
| 133 |
-
if isinstance(value, dict):
|
| 134 |
-
return value
|
| 135 |
-
if isinstance(value, str):
|
| 136 |
-
return json.loads(value)
|
| 137 |
-
if isinstance(value, (bytes, bytearray, memoryview)):
|
| 138 |
-
return json.loads(bytes(value).decode("utf-8"))
|
| 139 |
-
raise ValueError("metadata is not a JSON object")
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
def format_duration(seconds) -> str:
|
| 143 |
-
try:
|
| 144 |
-
total = int(round(float(seconds)))
|
| 145 |
-
except (TypeError, ValueError):
|
| 146 |
-
return "0:00"
|
| 147 |
-
minutes, secs = divmod(total, 60)
|
| 148 |
-
return f"{minutes}:{secs:02d}"
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
def site_category(metadata: dict) -> str:
|
| 152 |
-
parent = (metadata.get("content_parent_category") or "").lower()
|
| 153 |
-
fine = (metadata.get("content_fine_category") or "").lower()
|
| 154 |
-
joined = f"{parent} {fine}"
|
| 155 |
-
if "game" in joined:
|
| 156 |
-
return "Gaming"
|
| 157 |
-
if "music" in joined:
|
| 158 |
-
return "Music"
|
| 159 |
-
if "travel" in joined:
|
| 160 |
-
return "Travel"
|
| 161 |
-
if "news" in joined:
|
| 162 |
-
return "News"
|
| 163 |
-
if "education" in joined or "engineering" in joined or "career" in joined:
|
| 164 |
-
return "Learning"
|
| 165 |
-
return "Other"
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
def seed_entry(
|
| 169 |
-
row_number: int,
|
| 170 |
-
metadata: dict,
|
| 171 |
-
source: str | None = None,
|
| 172 |
-
source_shard: int | None = None,
|
| 173 |
-
source_row: int | None = None,
|
| 174 |
-
) -> dict:
|
| 175 |
-
video_id = f"fv{row_number:03d}"
|
| 176 |
-
title = (
|
| 177 |
-
metadata.get("youtube_title") or
|
| 178 |
-
metadata.get("content_metadata", {}).get("title") or
|
| 179 |
-
f"FineVideo sample {row_number:03d}"
|
| 180 |
-
)
|
| 181 |
-
channel = metadata.get("youtube_channel") or "FineVideo"
|
| 182 |
-
views = metadata.get("youtube_view_count")
|
| 183 |
-
description = (
|
| 184 |
-
metadata.get("youtube_description") or
|
| 185 |
-
metadata.get("content_metadata", {}).get("description") or
|
| 186 |
-
"FineVideo local prototype sample."
|
| 187 |
-
)
|
| 188 |
-
fine = metadata.get("content_fine_category")
|
| 189 |
-
parent = metadata.get("content_parent_category")
|
| 190 |
-
if fine or parent:
|
| 191 |
-
description = f"FineVideo sample: {fine or 'Unknown'} / {parent or 'Unknown'}."
|
| 192 |
-
|
| 193 |
-
entry = {
|
| 194 |
-
"id": video_id,
|
| 195 |
-
"title": title,
|
| 196 |
-
"channel": channel,
|
| 197 |
-
"views": f"{views} views" if views is not None else "0 views",
|
| 198 |
-
"duration": format_duration(metadata.get("duration_seconds")),
|
| 199 |
-
"category": site_category(metadata),
|
| 200 |
-
"video_path": f"videos/finevideo_test_{row_number:03d}.mp4",
|
| 201 |
-
"thumbnail": f"/static/thumbnails/finevideo_test_{row_number:03d}.jpg",
|
| 202 |
-
"description": description,
|
| 203 |
-
"created_at": datetime.utcnow().isoformat(),
|
| 204 |
-
}
|
| 205 |
-
if source:
|
| 206 |
-
entry["source"] = source
|
| 207 |
-
if source_shard is not None:
|
| 208 |
-
entry["source_shard"] = source_shard
|
| 209 |
-
if source_row is not None:
|
| 210 |
-
entry["source_row"] = source_row
|
| 211 |
-
return entry
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
def generate_thumbnail(video_path: Path, thumbnail_path: Path, overwrite: bool) -> None:
|
| 215 |
-
if thumbnail_path.exists() and not overwrite:
|
| 216 |
-
return
|
| 217 |
-
thumbnail_path.parent.mkdir(parents=True, exist_ok=True)
|
| 218 |
-
subprocess.run(
|
| 219 |
-
[
|
| 220 |
-
"ffmpeg",
|
| 221 |
-
"-y",
|
| 222 |
-
"-ss",
|
| 223 |
-
"00:00:01",
|
| 224 |
-
"-i",
|
| 225 |
-
str(video_path),
|
| 226 |
-
"-frames:v",
|
| 227 |
-
"1",
|
| 228 |
-
"-q:v",
|
| 229 |
-
"2",
|
| 230 |
-
str(thumbnail_path),
|
| 231 |
-
],
|
| 232 |
-
check=True,
|
| 233 |
-
)
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
def read_seed() -> list[dict]:
|
| 237 |
-
if not SEED_PATH.exists():
|
| 238 |
-
return []
|
| 239 |
-
return json.loads(SEED_PATH.read_text(encoding="utf-8"))
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
def write_seed(entries: list[dict]) -> None:
|
| 243 |
-
SEED_PATH.parent.mkdir(parents=True, exist_ok=True)
|
| 244 |
-
entries = sorted(entries, key=lambda entry: entry["id"])
|
| 245 |
-
SEED_PATH.write_text(
|
| 246 |
-
json.dumps(entries, indent=2, ensure_ascii=False) + "\n",
|
| 247 |
-
encoding="utf-8",
|
| 248 |
-
)
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
def update_seed(new_entries: list[dict]) -> None:
|
| 252 |
-
entries_by_id = {entry["id"]: entry for entry in read_seed()}
|
| 253 |
-
for entry in new_entries:
|
| 254 |
-
entries_by_id[entry["id"]] = entry
|
| 255 |
-
write_seed(list(entries_by_id.values()))
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
def seed_has_entry(video_id: str) -> bool:
|
| 259 |
-
return any(entry.get("id") == video_id for entry in read_seed())
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
def seed_entry_for_source(source: str, source_shard: int, source_row: int) -> dict | None:
|
| 263 |
-
for entry in read_seed():
|
| 264 |
-
if (
|
| 265 |
-
entry.get("source") == source and
|
| 266 |
-
entry.get("source_shard") == source_shard and
|
| 267 |
-
entry.get("source_row") == source_row
|
| 268 |
-
):
|
| 269 |
-
return entry
|
| 270 |
-
return None
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
def next_row_number() -> int:
|
| 274 |
-
max_id = 0
|
| 275 |
-
for entry in read_seed():
|
| 276 |
-
video_id = entry.get("id", "")
|
| 277 |
-
if video_id.startswith("fv"):
|
| 278 |
-
try:
|
| 279 |
-
max_id = max(max_id, int(video_id[2:]))
|
| 280 |
-
except ValueError:
|
| 281 |
-
pass
|
| 282 |
-
return max_id + 1
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
def import_rows(
|
| 286 |
-
offset: int,
|
| 287 |
-
count: int,
|
| 288 |
-
overwrite: bool,
|
| 289 |
-
token: str | None,
|
| 290 |
-
retries: int,
|
| 291 |
-
backoff: float,
|
| 292 |
-
) -> None:
|
| 293 |
-
VIDEO_DIR.mkdir(parents=True, exist_ok=True)
|
| 294 |
-
THUMBNAIL_DIR.mkdir(parents=True, exist_ok=True)
|
| 295 |
-
|
| 296 |
-
for dataset_offset in range(offset, offset + count):
|
| 297 |
-
row_number = dataset_offset + 1
|
| 298 |
-
video_id = f"fv{row_number:03d}"
|
| 299 |
-
video_path = VIDEO_DIR / f"finevideo_test_{row_number:03d}.mp4"
|
| 300 |
-
thumbnail_path = THUMBNAIL_DIR / f"finevideo_test_{row_number:03d}.jpg"
|
| 301 |
-
seeded = seed_has_entry(video_id)
|
| 302 |
-
|
| 303 |
-
if video_path.exists() and thumbnail_path.exists() and seeded and not overwrite:
|
| 304 |
-
print(f"Skipping existing seeded row: {video_id}")
|
| 305 |
-
continue
|
| 306 |
-
|
| 307 |
-
payload = api_get_rows(dataset_offset, token, retries, backoff)
|
| 308 |
-
rows = payload.get("rows", [])
|
| 309 |
-
if len(rows) != 1:
|
| 310 |
-
raise SystemExit(f"Expected exactly one row at offset {dataset_offset}, got {len(rows)}")
|
| 311 |
-
|
| 312 |
-
item = rows[0]
|
| 313 |
-
row = item.get("row", {})
|
| 314 |
-
if item.get("truncated_cells"):
|
| 315 |
-
raise SystemExit(f"Row {dataset_offset} has truncated cells: {item['truncated_cells']}")
|
| 316 |
-
|
| 317 |
-
metadata = row.get("json") or {}
|
| 318 |
-
if not isinstance(metadata, dict):
|
| 319 |
-
raise SystemExit(f"Row {dataset_offset} metadata is not a JSON object")
|
| 320 |
-
|
| 321 |
-
if video_path.exists() and not overwrite:
|
| 322 |
-
print(f"Keeping existing video: {video_path}")
|
| 323 |
-
else:
|
| 324 |
-
video_path.write_bytes(decode_mp4(row.get("mp4")))
|
| 325 |
-
print(f"Saved video: {video_path}")
|
| 326 |
-
|
| 327 |
-
generate_thumbnail(video_path, thumbnail_path, overwrite)
|
| 328 |
-
print(f"Ready thumbnail: {thumbnail_path}")
|
| 329 |
-
if seeded and not overwrite:
|
| 330 |
-
print(f"Keeping existing seed entry: {video_id}")
|
| 331 |
-
else:
|
| 332 |
-
update_seed([seed_entry(row_number, metadata)])
|
| 333 |
-
print(f"Updated seed entry: {video_id}")
|
| 334 |
-
|
| 335 |
-
print(f"Seed file ready: {SEED_PATH}")
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
def shard_filename(shard_index: int) -> str:
|
| 339 |
-
return f"data/train-{shard_index:05d}-of-01357.parquet"
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
def download_shard(shard_index: int, token: str | None) -> Path:
|
| 343 |
-
if hf_hub_download is None:
|
| 344 |
-
raise SystemExit("huggingface_hub is required for --source hub-parquet")
|
| 345 |
-
filename = shard_filename(shard_index)
|
| 346 |
-
path = hf_hub_download(
|
| 347 |
-
repo_id=DATASET,
|
| 348 |
-
repo_type="dataset",
|
| 349 |
-
filename=filename,
|
| 350 |
-
token=token,
|
| 351 |
-
)
|
| 352 |
-
return Path(path)
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
def import_hub_parquet(
|
| 356 |
-
shard_start: int,
|
| 357 |
-
shard_count: int,
|
| 358 |
-
max_rows: int,
|
| 359 |
-
overwrite: bool,
|
| 360 |
-
token: str | None,
|
| 361 |
-
) -> None:
|
| 362 |
-
if pq is None:
|
| 363 |
-
raise SystemExit("pyarrow is required for --source hub-parquet")
|
| 364 |
-
|
| 365 |
-
VIDEO_DIR.mkdir(parents=True, exist_ok=True)
|
| 366 |
-
THUMBNAIL_DIR.mkdir(parents=True, exist_ok=True)
|
| 367 |
-
|
| 368 |
-
imported = 0
|
| 369 |
-
for shard_index in range(shard_start, shard_start + shard_count):
|
| 370 |
-
if imported >= max_rows:
|
| 371 |
-
break
|
| 372 |
-
parquet_path = download_shard(shard_index, token)
|
| 373 |
-
table = pq.read_table(parquet_path, columns=["mp4", "json"])
|
| 374 |
-
rows = table.to_pylist()
|
| 375 |
-
print(f"Reading shard {shard_index}: {parquet_path} rows={len(rows)}")
|
| 376 |
-
|
| 377 |
-
for source_row, row in enumerate(rows):
|
| 378 |
-
if imported >= max_rows:
|
| 379 |
-
break
|
| 380 |
-
|
| 381 |
-
existing = seed_entry_for_source("hub-parquet", shard_index, source_row)
|
| 382 |
-
if existing and not overwrite:
|
| 383 |
-
video_path = ROOT / "static" / existing["video_path"]
|
| 384 |
-
thumbnail_path = ROOT / existing["thumbnail"].lstrip("/")
|
| 385 |
-
if video_path.exists() and thumbnail_path.exists():
|
| 386 |
-
print(
|
| 387 |
-
"Skipping existing source row: "
|
| 388 |
-
f"shard={shard_index} row={source_row} id={existing['id']}"
|
| 389 |
-
)
|
| 390 |
-
continue
|
| 391 |
-
|
| 392 |
-
row_number = (
|
| 393 |
-
int(existing["id"][2:])
|
| 394 |
-
if existing and existing.get("id", "").startswith("fv")
|
| 395 |
-
else next_row_number()
|
| 396 |
-
)
|
| 397 |
-
video_id = f"fv{row_number:03d}"
|
| 398 |
-
video_path = VIDEO_DIR / f"finevideo_test_{row_number:03d}.mp4"
|
| 399 |
-
thumbnail_path = THUMBNAIL_DIR / f"finevideo_test_{row_number:03d}.jpg"
|
| 400 |
-
|
| 401 |
-
if video_path.exists() and thumbnail_path.exists() and seed_has_entry(video_id) and not overwrite:
|
| 402 |
-
print(f"Skipping existing seeded row: {video_id}")
|
| 403 |
-
continue
|
| 404 |
-
|
| 405 |
-
if video_path.exists() and not overwrite:
|
| 406 |
-
print(f"Keeping existing video: {video_path}")
|
| 407 |
-
else:
|
| 408 |
-
video_path.write_bytes(decode_mp4(row.get("mp4")))
|
| 409 |
-
print(f"Saved video: {video_path}")
|
| 410 |
-
|
| 411 |
-
generate_thumbnail(video_path, thumbnail_path, overwrite)
|
| 412 |
-
print(f"Ready thumbnail: {thumbnail_path}")
|
| 413 |
-
metadata = normalize_metadata(row.get("json") or {})
|
| 414 |
-
if existing and not overwrite:
|
| 415 |
-
print(f"Keeping existing seed entry: {video_id}")
|
| 416 |
-
else:
|
| 417 |
-
update_seed([
|
| 418 |
-
seed_entry(
|
| 419 |
-
row_number,
|
| 420 |
-
metadata,
|
| 421 |
-
source="hub-parquet",
|
| 422 |
-
source_shard=shard_index,
|
| 423 |
-
source_row=source_row,
|
| 424 |
-
)
|
| 425 |
-
])
|
| 426 |
-
print(
|
| 427 |
-
"Updated seed entry: "
|
| 428 |
-
f"{video_id} shard={shard_index} row={source_row}"
|
| 429 |
-
)
|
| 430 |
-
imported += 1
|
| 431 |
-
|
| 432 |
-
print(f"Imported {imported} new/updated rows from hub parquet shards")
|
| 433 |
-
print(f"Seed file ready: {SEED_PATH}")
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
def main() -> None:
|
| 437 |
-
parser = argparse.ArgumentParser(description=__doc__)
|
| 438 |
-
parser.add_argument("--source", choices=["rows", "hub-parquet"], default="rows")
|
| 439 |
-
parser.add_argument("--offset", type=int)
|
| 440 |
-
parser.add_argument("--count", type=int)
|
| 441 |
-
parser.add_argument("--shard-start", type=int)
|
| 442 |
-
parser.add_argument("--shard-count", type=int)
|
| 443 |
-
parser.add_argument("--max-rows", type=int)
|
| 444 |
-
parser.add_argument("--overwrite", action="store_true")
|
| 445 |
-
parser.add_argument("--retries", type=int, default=5)
|
| 446 |
-
parser.add_argument("--backoff", type=float, default=5.0)
|
| 447 |
-
parser.add_argument("--token", default=token_from_env())
|
| 448 |
-
args = parser.parse_args()
|
| 449 |
-
|
| 450 |
-
if args.retries < 1:
|
| 451 |
-
parser.error("--retries must be >= 1")
|
| 452 |
-
if args.backoff < 0:
|
| 453 |
-
parser.error("--backoff must be >= 0")
|
| 454 |
-
|
| 455 |
-
if args.source == "rows":
|
| 456 |
-
if args.offset is None:
|
| 457 |
-
parser.error("--offset is required for --source rows")
|
| 458 |
-
if args.count is None:
|
| 459 |
-
parser.error("--count is required for --source rows")
|
| 460 |
-
if args.offset < 0:
|
| 461 |
-
parser.error("--offset must be >= 0")
|
| 462 |
-
if args.count < 1:
|
| 463 |
-
parser.error("--count must be >= 1")
|
| 464 |
-
if args.count > MAX_COUNT:
|
| 465 |
-
parser.error(f"--count is capped at {MAX_COUNT}")
|
| 466 |
-
|
| 467 |
-
import_rows(args.offset, args.count, args.overwrite, args.token, args.retries, args.backoff)
|
| 468 |
-
else:
|
| 469 |
-
if args.shard_start is None:
|
| 470 |
-
parser.error("--shard-start is required for --source hub-parquet")
|
| 471 |
-
if args.shard_count is None:
|
| 472 |
-
parser.error("--shard-count is required for --source hub-parquet")
|
| 473 |
-
if args.max_rows is None:
|
| 474 |
-
parser.error("--max-rows is required for --source hub-parquet")
|
| 475 |
-
if args.shard_start < 0:
|
| 476 |
-
parser.error("--shard-start must be >= 0")
|
| 477 |
-
if args.shard_count < 1:
|
| 478 |
-
parser.error("--shard-count must be >= 1")
|
| 479 |
-
if args.shard_count > MAX_SHARD_COUNT:
|
| 480 |
-
parser.error(f"--shard-count is capped at {MAX_SHARD_COUNT}")
|
| 481 |
-
if args.max_rows < 1:
|
| 482 |
-
parser.error("--max-rows must be >= 1")
|
| 483 |
-
if args.max_rows > MAX_PARQUET_ROWS:
|
| 484 |
-
parser.error(f"--max-rows is capped at {MAX_PARQUET_ROWS}")
|
| 485 |
-
|
| 486 |
-
import_hub_parquet(
|
| 487 |
-
args.shard_start,
|
| 488 |
-
args.shard_count,
|
| 489 |
-
args.max_rows,
|
| 490 |
-
args.overwrite,
|
| 491 |
-
args.token,
|
| 492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,205 +0,0 @@
|
|
| 1 |
-
import argparse
|
| 2 |
-
import json
|
| 3 |
-
import subprocess
|
| 4 |
-
import sys
|
| 5 |
-
from pathlib import Path
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
ROOT = Path(__file__).resolve().parent
|
| 9 |
-
DEFAULT_SOURCE_DIR = ROOT / "static" / "videos"
|
| 10 |
-
DEFAULT_OUTPUT_DIR = ROOT / "static" / "videos_h265"
|
| 11 |
-
SCALE_FILTER = (
|
| 12 |
-
"scale=w=1280:h=720:force_original_aspect_ratio=decrease,"
|
| 13 |
-
"pad=1280:720:(ow-iw)/2:(oh-ih)/2:color=black"
|
| 14 |
-
)
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
def parse_args():
|
| 18 |
-
parser = argparse.ArgumentParser(
|
| 19 |
-
description="Safely transcode local yt-lite videos to 720p HEVC."
|
| 20 |
-
)
|
| 21 |
-
parser.add_argument(
|
| 22 |
-
"--source-dir",
|
| 23 |
-
type=Path,
|
| 24 |
-
default=DEFAULT_SOURCE_DIR,
|
| 25 |
-
help="Directory containing source MP4 files.",
|
| 26 |
-
)
|
| 27 |
-
parser.add_argument(
|
| 28 |
-
"--output-dir",
|
| 29 |
-
type=Path,
|
| 30 |
-
default=DEFAULT_OUTPUT_DIR,
|
| 31 |
-
help="Directory where transcoded MP4 files should be written.",
|
| 32 |
-
)
|
| 33 |
-
parser.add_argument(
|
| 34 |
-
"--limit",
|
| 35 |
-
type=int,
|
| 36 |
-
default=None,
|
| 37 |
-
help="Optional cap on how many pending files to process in this run.",
|
| 38 |
-
)
|
| 39 |
-
parser.add_argument(
|
| 40 |
-
"--ffmpeg",
|
| 41 |
-
default="ffmpeg",
|
| 42 |
-
help="ffmpeg executable to use.",
|
| 43 |
-
)
|
| 44 |
-
parser.add_argument(
|
| 45 |
-
"--ffprobe",
|
| 46 |
-
default="ffprobe",
|
| 47 |
-
help="ffprobe executable to use.",
|
| 48 |
-
)
|
| 49 |
-
return parser.parse_args()
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
def run(cmd):
|
| 53 |
-
return subprocess.run(cmd, capture_output=True, text=True)
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
def probe_video(ffprobe_bin, path):
|
| 57 |
-
cmd = [
|
| 58 |
-
ffprobe_bin,
|
| 59 |
-
"-v",
|
| 60 |
-
"error",
|
| 61 |
-
"-select_streams",
|
| 62 |
-
"v:0",
|
| 63 |
-
"-show_entries",
|
| 64 |
-
"stream=codec_name,width,height,level",
|
| 65 |
-
"-of",
|
| 66 |
-
"json",
|
| 67 |
-
str(path),
|
| 68 |
-
]
|
| 69 |
-
result = run(cmd)
|
| 70 |
-
if result.returncode != 0:
|
| 71 |
-
return None
|
| 72 |
-
try:
|
| 73 |
-
payload = json.loads(result.stdout or "{}")
|
| 74 |
-
except json.JSONDecodeError:
|
| 75 |
-
return None
|
| 76 |
-
streams = payload.get("streams") or []
|
| 77 |
-
return streams[0] if streams else None
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
def is_expected_output(ffprobe_bin, path):
|
| 81 |
-
if not path.exists() or path.stat().st_size == 0:
|
| 82 |
-
return False
|
| 83 |
-
stream = probe_video(ffprobe_bin, path)
|
| 84 |
-
if not stream:
|
| 85 |
-
return False
|
| 86 |
-
if stream.get("codec_name") != "hevc":
|
| 87 |
-
return False
|
| 88 |
-
return stream.get("width") == 1280 and stream.get("height") == 720
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
def transcode_one(ffmpeg_bin, source_path, output_path):
|
| 92 |
-
temp_path = output_path.with_suffix(".tmp.mp4")
|
| 93 |
-
if temp_path.exists():
|
| 94 |
-
temp_path.unlink()
|
| 95 |
-
|
| 96 |
-
cmd = [
|
| 97 |
-
ffmpeg_bin,
|
| 98 |
-
"-hide_banner",
|
| 99 |
-
"-loglevel",
|
| 100 |
-
"error",
|
| 101 |
-
"-y",
|
| 102 |
-
"-i",
|
| 103 |
-
str(source_path),
|
| 104 |
-
"-map",
|
| 105 |
-
"0:v:0",
|
| 106 |
-
"-map",
|
| 107 |
-
"0:a?",
|
| 108 |
-
"-vf",
|
| 109 |
-
SCALE_FILTER,
|
| 110 |
-
"-c:v",
|
| 111 |
-
"libx265",
|
| 112 |
-
"-preset",
|
| 113 |
-
"medium",
|
| 114 |
-
"-pix_fmt",
|
| 115 |
-
"yuv420p",
|
| 116 |
-
"-x265-params",
|
| 117 |
-
"level-idc=31",
|
| 118 |
-
"-tag:v",
|
| 119 |
-
"hvc1",
|
| 120 |
-
"-c:a",
|
| 121 |
-
"aac",
|
| 122 |
-
"-b:a",
|
| 123 |
-
"128k",
|
| 124 |
-
"-movflags",
|
| 125 |
-
"+faststart",
|
| 126 |
-
str(temp_path),
|
| 127 |
-
]
|
| 128 |
-
result = subprocess.run(cmd)
|
| 129 |
-
if result.returncode != 0:
|
| 130 |
-
if temp_path.exists():
|
| 131 |
-
temp_path.unlink()
|
| 132 |
-
return False
|
| 133 |
-
temp_path.replace(output_path)
|
| 134 |
-
return True
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
def human_gb(byte_count):
|
| 138 |
-
return byte_count / (1024 ** 3)
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
def main():
|
| 142 |
-
args = parse_args()
|
| 143 |
-
source_dir = args.source_dir.resolve()
|
| 144 |
-
output_dir = args.output_dir.resolve()
|
| 145 |
-
|
| 146 |
-
if not source_dir.exists():
|
| 147 |
-
print(f"Source directory does not exist: {source_dir}", file=sys.stderr)
|
| 148 |
-
return 1
|
| 149 |
-
|
| 150 |
-
output_dir.mkdir(parents=True, exist_ok=True)
|
| 151 |
-
|
| 152 |
-
source_files = sorted(source_dir.glob("*.mp4"))
|
| 153 |
-
pending_files = []
|
| 154 |
-
skipped_existing = 0
|
| 155 |
-
|
| 156 |
-
for source_path in source_files:
|
| 157 |
-
output_path = output_dir / source_path.name
|
| 158 |
-
if is_expected_output(args.ffprobe, output_path):
|
| 159 |
-
skipped_existing += 1
|
| 160 |
-
continue
|
| 161 |
-
pending_files.append(source_path)
|
| 162 |
-
|
| 163 |
-
if args.limit is not None:
|
| 164 |
-
pending_files = pending_files[: args.limit]
|
| 165 |
-
|
| 166 |
-
transcoded = 0
|
| 167 |
-
failed = []
|
| 168 |
-
|
| 169 |
-
for index, source_path in enumerate(pending_files, start=1):
|
| 170 |
-
output_path = output_dir / source_path.name
|
| 171 |
-
print(
|
| 172 |
-
f"[{index}/{len(pending_files)}] Transcoding {source_path.name} -> {output_path.name}",
|
| 173 |
-
flush=True,
|
| 174 |
-
)
|
| 175 |
-
success = transcode_one(args.ffmpeg, source_path, output_path)
|
| 176 |
-
if not success or not is_expected_output(args.ffprobe, output_path):
|
| 177 |
-
failed.append(source_path.name)
|
| 178 |
-
print(f" failed: {source_path.name}", flush=True)
|
| 179 |
-
continue
|
| 180 |
-
transcoded += 1
|
| 181 |
-
print(f" ok: {source_path.name}", flush=True)
|
| 182 |
-
|
| 183 |
-
output_files = sorted(output_dir.glob("*.mp4"))
|
| 184 |
-
output_bytes = sum(path.stat().st_size for path in output_files)
|
| 185 |
-
consistent_count = sum(1 for path in output_files if is_expected_output(args.ffprobe, path))
|
| 186 |
-
|
| 187 |
-
print("")
|
| 188 |
-
print("Summary")
|
| 189 |
-
print(f" source files: {len(source_files)}")
|
| 190 |
-
print(f" skipped existing outputs: {skipped_existing}")
|
| 191 |
-
print(f" transcoded this run: {transcoded}")
|
| 192 |
-
print(f" failed this run: {len(failed)}")
|
| 193 |
-
print(f" output files present: {len(output_files)}")
|
| 194 |
-
print(f" consistent outputs: {consistent_count}")
|
| 195 |
-
print(f" output size GB: {human_gb(output_bytes):.4f}")
|
| 196 |
-
if failed:
|
| 197 |
-
print(" failed files:")
|
| 198 |
-
for name in failed:
|
| 199 |
-
print(f" {name}")
|
| 200 |
-
|
| 201 |
-
return 0 if not failed else 2
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
if __name__ == "__main__":
|
| 205 |
-
raise SystemExit(main())
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
release-manifest.json
DELETED
|
@@ -1,41 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"repo_id": "WebArena-Pro/yt-lite-data",
|
| 3 |
-
"files": [
|
| 4 |
-
{
|
| 5 |
-
"path": "LICENSES.md",
|
| 6 |
-
"bytes": 437,
|
| 7 |
-
"sha256": "bc665d3901a5f63def06a572b6b88d25b133f24f5baf480e30f2136059312892"
|
| 8 |
-
},
|
| 9 |
-
{
|
| 10 |
-
"path": "README.md",
|
| 11 |
-
"bytes": 2607,
|
| 12 |
-
"sha256": "e065e78bd7be77ef5d248c7ba52e754d8cdc9f00aaa2aa900ef4f24c55bd6ef4"
|
| 13 |
-
},
|
| 14 |
-
{
|
| 15 |
-
"path": "metadata/finevideo_local_seed.json",
|
| 16 |
-
"bytes": 711259,
|
| 17 |
-
"sha256": "0956cdadda5d0c3b11362d1b9d7138a6d18de462b795cc1e668a26594393d76e"
|
| 18 |
-
},
|
| 19 |
-
{
|
| 20 |
-
"path": "metadata/media-inventory.json",
|
| 21 |
-
"bytes": 660125,
|
| 22 |
-
"sha256": "cfa267110d2292ed26d473c21d3c1c1626ea3263f11d40da58a3db398d3773df"
|
| 23 |
-
},
|
| 24 |
-
{
|
| 25 |
-
"path": "preparation/fetch_assets.py",
|
| 26 |
-
"bytes": 2248,
|
| 27 |
-
"sha256": "a513f5618c7647ba88693373ef32f44a009ff88a1454d25bbfa6a0c219c94075"
|
| 28 |
-
},
|
| 29 |
-
{
|
| 30 |
-
"path": "preparation/import_finevideo_batch.py",
|
| 31 |
-
"bytes": 17018,
|
| 32 |
-
"sha256": "8c8ead12160c7db34e898a56116881b1ae1e21fc317b2a63338be81acdf58259"
|
| 33 |
-
},
|
| 34 |
-
{
|
| 35 |
-
"path": "preparation/transcode_videos_h265.py",
|
| 36 |
-
"bytes": 5487,
|
| 37 |
-
"sha256": "e5320dee631a9702e7527e3ac5f33843660b65f3024567e001a63eb4f2139726"
|
| 38 |
-
}
|
| 39 |
-
],
|
| 40 |
-
"remote_media_preserved": true
|
| 41 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|