aboutsummaryrefslogtreecommitdiff
path: root/test-data/generate.sh
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-09-15 00:05:48 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-09-15 00:05:48 +0200
commit8277ea3feb44f634248788cc50d2fe355a58a5d6 (patch)
treed92ce2f4eb2da76d199494fbd8d8b4912e0afad5 /test-data/generate.sh
parent05144068b1d5cc48da3bb6584cc2224eefc2fbc7 (diff)
downloadmp4-8277ea3feb44f634248788cc50d2fe355a58a5d6.tar.gz
mp4-8277ea3feb44f634248788cc50d2fe355a58a5d6.zip
test: generate media fixtures locally
Diffstat (limited to 'test-data/generate.sh')
-rwxr-xr-xtest-data/generate.sh68
1 files changed, 62 insertions, 6 deletions
diff --git a/test-data/generate.sh b/test-data/generate.sh
index 7780b0f..423d852 100755
--- a/test-data/generate.sh
+++ b/test-data/generate.sh
@@ -1,12 +1,11 @@
#!/usr/bin/env bash
-# Generates synthetic ISOBMFF files for benchmarking the track parser. Each file
-# carries an H.264 video track and an AAC audio track. B-frames produce a ctts
-# table and faststart places the moov box before mdat.
+# Generates deterministic ISOBMFF fixtures used by tests and benchmarks.
set -euo pipefail
dir="$(cd "$(dirname "$0")" && pwd)"
-gen() {
+# Progressive H.264/AAC files with B-frames and a front-loaded moov.
+gen_av() {
local dur="$1" name="$2"
ffmpeg -y -loglevel error \
-f lavfi -i "testsrc=duration=${dur}:size=640x480:rate=30" \
@@ -18,5 +17,62 @@ gen() {
echo "wrote ${name}"
}
-gen 10 h264-aac-10s.mp4
-gen 60 h264-aac-60s.mp4
+gen_av 10 h264-aac-10s.mp4
+gen_av 60 h264-aac-60s.mp4
+
+# Audio-only input exercises fragment cuts without a video clock.
+ffmpeg -y -loglevel error \
+ -f lavfi -i "sine=frequency=440:duration=10:sample_rate=48000" \
+ -c:a aac -b:a 128k -movflags +faststart \
+ "${dir}/aac-10s.mp4"
+echo "wrote aac-10s.mp4"
+
+# Exact one-second GOPs exercise fragments containing interior keyframes.
+ffmpeg -y -loglevel error \
+ -f lavfi -i "testsrc=duration=10:size=640x480:rate=30" \
+ -f lavfi -i "sine=frequency=440:duration=10:sample_rate=48000" \
+ -c:v libx264 -preset veryfast -pix_fmt yuv420p \
+ -g 30 -keyint_min 30 -sc_threshold 0 \
+ -c:a aac -b:a 128k -movflags +faststart \
+ "${dir}/h264-aac-10s-gop1.mp4"
+echo "wrote h264-aac-10s-gop1.mp4"
+
+# Two aligned video renditions and two audio tracks exercise muxed track
+# selection and fragment-boundary validation.
+ffmpeg -y -loglevel error \
+ -f lavfi -i "testsrc=duration=3:size=160x90:rate=10" \
+ -f lavfi -i "testsrc2=duration=3:size=128x72:rate=10" \
+ -f lavfi -i "sine=frequency=440:duration=3:sample_rate=48000" \
+ -f lavfi -i "sine=frequency=880:duration=3:sample_rate=48000" \
+ -map 0:v -map 1:v -map 2:a -map 3:a \
+ -c:v libx264 -preset veryfast -profile:v baseline -pix_fmt yuv420p \
+ -g 10 -keyint_min 10 -sc_threshold 0 \
+ -c:a aac -b:a 64k -movflags +faststart \
+ "${dir}/h264-2video-2audio-3s.mp4"
+echo "wrote h264-2video-2audio-3s.mp4"
+
+# More than four tracks exercises dynamically-sized reader and writer state.
+audio_inputs=()
+audio_maps=()
+for i in 0 1 2 3 4 5; do
+ audio_inputs+=( -f lavfi -i "sine=frequency=$((440 + i * 110)):duration=1:sample_rate=48000" )
+ audio_maps+=( -map "${i}:a" )
+done
+ffmpeg -y -loglevel error \
+ "${audio_inputs[@]}" "${audio_maps[@]}" \
+ -c:a aac -b:a 32k -movflags +faststart \
+ "${dir}/aac-6track-1s.mp4"
+echo "wrote aac-6track-1s.mp4"
+
+# Small audio fixtures cover channel metadata and ALAC sample entries.
+ffmpeg -y -loglevel error \
+ -f lavfi -i "sine=frequency=440:duration=2:sample_rate=48000" \
+ -ac 2 -c:a aac -b:a 128k -movflags +faststart \
+ "${dir}/aac-stereo-2s.m4a"
+echo "wrote aac-stereo-2s.m4a"
+
+ffmpeg -y -loglevel error \
+ -f lavfi -i "anullsrc=channel_layout=5.1:sample_rate=48000" -t 2 \
+ -c:a alac -movflags +faststart \
+ "${dir}/alac-5.1-2s.m4a"
+echo "wrote alac-5.1-2s.m4a"