forge
Explore
Log in

Don't you dare go Hollow

edith

Clone
★ 0

0 watching0 forksRust18.3 MiB2e2ed69Tahinli3 months ago69 commits

gen_fixtures.sh72 lines, 4.3 KiBHistoryRawDownload
1#!/usr/bin/env bash
2# Regenerates the gitignored test fixtures under assets/.
3# Needs the ffmpeg CLI (dev tool only — the app itself never uses ffmpeg).
4set -euo pipefail
5cd "$(dirname "$0")/.."
6mkdir -p assets
7ffmpeg -y -f lavfi -i testsrc2=size=1280x720:rate=30:duration=5 \
8 -c:v libx264 -profile:v baseline -pix_fmt yuv420p assets/test_baseline.mp4
9ffmpeg -y -f lavfi -i testsrc2=size=1280x720:rate=30:duration=5 \
10 -c:v libx264 -profile:v high -pix_fmt yuv420p assets/test_high.mp4
11# A/V fixture: video + stereo AAC. Left channel 440 Hz, right 880 Hz, so
12# channel mapping mistakes are audible; 1 Hz volume pulse makes drift visible.
13ffmpeg -y -f lavfi -i testsrc2=size=1280x720:rate=30:duration=5 \
14 -f lavfi -i "sine=frequency=440:duration=5" \
15 -f lavfi -i "sine=frequency=880:duration=5" \
16 -filter_complex "[1:a][2:a]join=inputs=2:channel_layout=stereo,volume='0.5+0.5*sin(2*PI*t)':eval=frame[a]" \
17 -map 0:v -map "[a]" -c:v libx264 -profile:v baseline -pix_fmt yuv420p \
18 -c:a aac -b:a 128k assets/test_av.mp4
19# Second A/V fixture for multi-file import: same properties as test_av.mp4
20# (1280x720@30 baseline, AAC-LC 44.1k stereo) but plainly different content —
21# testsrc pattern, 4 s, an octave up (660/1320 Hz) with the same 1 Hz pulse.
22ffmpeg -y -f lavfi -i testsrc=size=1280x720:rate=30:duration=4 \
23 -f lavfi -i "sine=frequency=660:duration=4" \
24 -f lavfi -i "sine=frequency=1320:duration=4" \
25 -filter_complex "[1:a][2:a]join=inputs=2:channel_layout=stereo,volume='0.5+0.5*sin(2*PI*t)':eval=frame[a]" \
26 -map 0:v -map "[a]" -c:v libx264 -profile:v baseline -pix_fmt yuv420p \
27 -c:a aac -b:a 128k assets/test_av2.mp4
28# Multi-audio fixture: one video and three audio streams, so stream selection
29# has something to select. Stream 0 is AAC 44.1k stereo (440 Hz left, 880 Hz
30# right), stream 1 is AAC 22.05k mono 220 Hz tagged French — different rate,
31# layout and content, so a test can tell which stream it was handed — and
32# stream 2 is AC-3, the codec we cannot decode and must still list.
33ffmpeg -y -f lavfi -i testsrc2=size=320x240:rate=30:duration=2 \
34 -f lavfi -i "sine=frequency=440:duration=2" \
35 -f lavfi -i "sine=frequency=880:duration=2" \
36 -f lavfi -i "sine=frequency=220:duration=2" \
37 -f lavfi -i "sine=frequency=330:duration=2" \
38 -filter_complex "[1:a][2:a]join=inputs=2:channel_layout=stereo[a0]" \
39 -map 0:v -map "[a0]" -map 3:a -map 4:a \
40 -c:v libx264 -profile:v baseline -pix_fmt yuv420p \
41 -c:a:0 aac -ar:a:0 44100 -ac:a:0 2 \
42 -c:a:1 aac -ar:a:1 22050 -ac:a:1 1 \
43 -c:a:2 ac3 -ar:a:2 44100 -ac:a:2 2 \
44 -metadata:s:a:1 language=fra assets/test_multiaudio.mp4
45# Unsupported-audio fixture: an AC-3 track, which we cannot decode at all. The
46# file plays as picture with silence, and the point is that it says so.
47ffmpeg -y -f lavfi -i testsrc2=size=320x180:rate=30:duration=2 \
48 -f lavfi -i "sine=frequency=440:duration=2" \
49 -map 0:v -map 1:a -c:v libx264 -profile:v baseline -pix_fmt yuv420p \
50 -c:a ac3 -b:a 192k assets/test_ac3.mp4
51# Multi-language fixture: the shape real media has — one video and two AAC
52# streams that *agree* on rate and layout (44.1k stereo) and differ only in
53# language and content, 440/880 Hz undefined and 220/330 Hz French. One
54# timeline means one set of audio parameters, so this is the file where the
55# second stream can actually be put on the timeline; test_multiaudio.mp4 is the
56# file where it cannot, and both cases have to be shown.
57ffmpeg -y -f lavfi -i testsrc2=size=320x240:rate=30:duration=2 \
58 -f lavfi -i "sine=frequency=440:duration=2" \
59 -f lavfi -i "sine=frequency=880:duration=2" \
60 -f lavfi -i "sine=frequency=220:duration=2" \
61 -f lavfi -i "sine=frequency=330:duration=2" \
62 -filter_complex "[1:a][2:a]join=inputs=2:channel_layout=stereo[a0];\
63[3:a][4:a]join=inputs=2:channel_layout=stereo[a1]" \
64 -map 0:v -map "[a0]" -map "[a1]" \
65 -c:v libx264 -profile:v baseline -pix_fmt yuv420p \
66 -c:a aac -ar 44100 -ac 2 \
67 -metadata:s:a:1 language=fra assets/test_multilang.mp4
68# Mismatch fixture: different resolution and no audio track at all, so import
69# has something concrete to refuse.
70ffmpeg -y -f lavfi -i testsrc2=size=640x360:rate=30:duration=2 \
71 -an -c:v libx264 -profile:v baseline -pix_fmt yuv420p assets/test_mismatch.mp4
72echo "fixtures written to assets/"