forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

gen-mp4-parity-corpus.sh40 lines, 2.3 KiBHistoryRawDownload
1#!/usr/bin/env bash
2# gen-mp4-parity-corpus.sh: write the generated mp4/mov cases that the ec-mp4 parity
3# test (crates/ec-mp4/tests/it/edith_parity.rs) compares against ffprobe.
4#
5# Usage: scripts/gen-mp4-parity-corpus.sh <out-dir>
6#
7# Each case isolates one thing the demuxer must read the way edith does:
8# bframes.mp4 B-frames: ctts v0 offsets, a sample order that differs from display order
9# negcts.mp4 negative composition offsets (ctts v1), -movflags negative_cts_offsets
10# rot90.mp4 tkhd display matrix of a quarter turn (copied from tests/data)
11# rot270.mp4 the other quarter turn (copied from tests/data)
12# qt.mov QuickTime container (-f mov): mp4a in a sound description
13# emptyedit.mp4 an audio track delayed by 0.5 s: an empty edit ahead of the media
14# aac-prime.mp4 AAC audio alone: the encoder delay is an edit list (elst) of its own
15# mp3.mp4 an mp4a entry carrying MP3
16#
17# Needs ffmpeg with libx264. Output is deterministic for a given ffmpeg build.
18set -euo pipefail
19out=${1:?usage: gen-mp4-parity-corpus.sh <out-dir>}
20here=$(cd -- "$(dirname -- "$0")" && pwd)
21mkdir -p "$out"
22cd "$out"
23ff() { ffmpeg -hide_banner -v error -y "$@"; }
24ff -f lavfi -i testsrc2=size=320x240:rate=24:duration=2 \
25 -f lavfi -i sine=frequency=440:duration=2 \
26 -c:v libx264 -bf 2 -g 24 -pix_fmt yuv420p -c:a aac -b:a 128k bframes.mp4
27ff -f lavfi -i testsrc2=size=320x240:rate=24:duration=2 \
28 -c:v libx264 -bf 2 -pix_fmt yuv420p -movflags negative_cts_offsets negcts.mp4
29# The display matrices: stream copies of the committed rotation clips, whose tkhd
30# matrix ffmpeg wrote with -display_rotation (crates/ec-mp4/tests/data/gen.sh).
31ff -i "$here/../crates/ec-mp4/tests/data/rot90.mp4" -c copy rot90.mp4
32ff -i "$here/../crates/ec-mp4/tests/data/rot270.mp4" -c copy rot270.mp4
33ff -f lavfi -i testsrc2=size=320x240:rate=24:duration=2 \
34 -f lavfi -i sine=frequency=440:duration=2 \
35 -c:v libx264 -bf 2 -pix_fmt yuv420p -c:a aac -f mov qt.mov
36ff -f lavfi -i sine=frequency=440:duration=2 -itsoffset 0.5 \
37 -f lavfi -i testsrc2=size=64x64:rate=24:duration=2 \
38 -map 0:a -map 1:v -c:v libx264 -c:a aac -shortest emptyedit.mp4
39ff -f lavfi -i sine=frequency=440:duration=2 -c:a aac -b:a 96k aac-prime.mp4
40ff -f lavfi -i sine=frequency=440:duration=2 -c:a libmp3lame -b:a 96k -f mp4 mp3.mp4