53 lines
2.0 KiB
Bash
Executable File
53 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
OUT_DIR="$ROOT_DIR/tests/fixtures/generated"
|
|
|
|
mkdir -p "$OUT_DIR"
|
|
|
|
ffmpeg -y -hide_banner -loglevel error -f lavfi -i testsrc=size=128x72:rate=30 -f lavfi -i sine=frequency=1000:sample_rate=44100 -t 1 -c:v libx264 -pix_fmt yuv420p -c:a aac -movflags +faststart "$OUT_DIR/clean.mp4"
|
|
ffmpeg -y -hide_banner -loglevel error -f lavfi -i testsrc=size=128x72:rate=30 -f lavfi -i sine=frequency=1000:sample_rate=44100 -t 1 -c:v libx264 -pix_fmt yuv420p -c:a aac "$OUT_DIR/no_faststart.mp4"
|
|
ffmpeg -y -hide_banner -loglevel error -f lavfi -i testsrc=size=128x72:rate=30 -t 1 -c:v libx264 -pix_fmt yuv420p "$OUT_DIR/video_only.mp4"
|
|
ffmpeg -y -hide_banner -loglevel error -f lavfi -i sine=frequency=1000:sample_rate=44100 -t 1 -c:a aac "$OUT_DIR/audio_only.mp4"
|
|
ffmpeg -y -hide_banner -loglevel error -f lavfi -i testsrc=size=128x72:rate=30 -f lavfi -i sine=frequency=1000:sample_rate=44100 -t 1 -c:v libx264 -pix_fmt yuv420p -c:a aac "$OUT_DIR/clean.mkv"
|
|
|
|
# Create a truncated file to simulate partial download/corruption
|
|
cp "$OUT_DIR/clean.mp4" "$OUT_DIR/truncated.mp4"
|
|
python3 - <<PY
|
|
import os
|
|
path = "$OUT_DIR/truncated.mp4"
|
|
size = os.path.getsize(path)
|
|
with open(path, "r+b") as f:
|
|
f.truncate(max(0, size - 2048))
|
|
PY
|
|
|
|
# Heavier truncation for more pronounced errors
|
|
cp "$OUT_DIR/clean.mp4" "$OUT_DIR/truncated_hard.mp4"
|
|
python3 - <<PY
|
|
import os
|
|
path = "$OUT_DIR/truncated_hard.mp4"
|
|
size = os.path.getsize(path)
|
|
with open(path, "r+b") as f:
|
|
f.truncate(max(0, size // 2))
|
|
PY
|
|
|
|
# Corrupt bytes in the middle of the file
|
|
cp "$OUT_DIR/clean.mp4" "$OUT_DIR/corrupt_mid.mp4"
|
|
python3 - <<PY
|
|
import os
|
|
path = "$OUT_DIR/corrupt_mid.mp4"
|
|
with open(path, "r+b") as f:
|
|
f.seek(0, os.SEEK_END)
|
|
size = f.tell()
|
|
if size > 4096:
|
|
f.seek(size // 2)
|
|
chunk = bytearray(f.read(1024))
|
|
for i in range(len(chunk)):
|
|
chunk[i] ^= 0xFF
|
|
f.seek(size // 2)
|
|
f.write(chunk)
|
|
PY
|
|
|
|
echo "Fixtures written to $OUT_DIR"
|