forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiBe12d32fTahinli6 days ago3982 commits

bench-benchp1-clips.sh53 lines, 3.2 KiBHistoryRawDownload
1#!/usr/bin/env bash
2# bench-benchp1-clips.sh: generate the inputs for the subtitle, Ogg and RIFF bench rows of
3# lanes/bench.md ("lane benchp1"). Clips go to $BENCH_CLIPS (default ~/.cache/benchp1-clips),
4# never into the repo. The .sup input is written by `ec-pgs --example benchp1 gen` (ffmpeg has no
5# PGS encoder), so it is not made here.
6set -euo pipefail
7d=${BENCH_CLIPS:-$HOME/.cache/benchp1-clips}
8mkdir -p "$d"
9ff() { ffmpeg -nostdin -v error -y "$@"; }
10
11# ASS with many styled events: 20 styles, one event every 0.5 s for 2 h (14400 events).
12# awk writes the script; ffmpeg converts it to SRT and WebVTT (14400 cues each) for ec-subs.
13if [ ! -s "$d/styled-2h.ass" ]; then
14 awk 'BEGIN {
15 print "[Script Info]\nTitle: benchp1\nScriptType: v4.00+\nPlayResX: 1920\nPlayResY: 1080\nWrapStyle: 0\n"
16 print "[V4+ Styles]"
17 print "Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding"
18 for (s = 0; s < 20; s++) {
19 printf "Style: S%02d,Arial,%d,&H00%02X%02X%02X,&H000000FF,&H00000000,&H64000000,%d,0,0,0,100,100,0,0,1,2,1,%d,10,10,40,1\n", s, 36 + s, (s * 37) % 256, (s * 91) % 256, (s * 53) % 256, s % 2, 1 + (s % 9)
20 }
21 print "\n[Events]"
22 print "Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"
23 for (i = 0; i < 14400; i++) {
24 t0 = i * 50; t1 = t0 + 120
25 s = i % 20
26 printf "Dialogue: %d,%d:%02d:%02d.%02d,%d:%02d:%02d.%02d,S%02d,,0,0,0,,{\\an%d\\pos(%d,%d)\\fad(200,200)\\c&H%02X%02X%02X&\\b%d}Event %d {\\i1}styled{\\i0} text \\N line two of %d {\\fscx%d\\frz%d}\n",
27 i % 3, int(t0 / 360000), int(t0 / 6000) % 60, int(t0 / 100) % 60, t0 % 100,
28 int(t1 / 360000), int(t1 / 6000) % 60, int(t1 / 100) % 60, t1 % 100,
29 s, 1 + (i % 9), 100 + (i * 7) % 1700, 80 + (i * 13) % 900,
30 (i * 31) % 256, (i * 17) % 256, (i * 5) % 256, i % 2, i, i, 90 + i % 30, (i % 60) - 30
31 }
32 }' > "$d/styled-2h.ass"
33fi
34[ -s "$d/styled-2h.srt" ] || ff -i "$d/styled-2h.ass" -c:s srt "$d/styled-2h.srt"
35[ -s "$d/styled-2h.vtt" ] || ff -i "$d/styled-2h.ass" -c:s webvtt "$d/styled-2h.vtt"
36
37# Vorbis and Opus in Ogg, 10 min, stereo pink noise.
38[ -s "$d/vorbis-10m.ogg" ] || ff -f lavfi -i "anoisesrc=d=600:c=pink:r=48000:a=0.2:seed=7" \
39 -ac 2 -c:a libvorbis -q:a 4 "$d/vorbis-10m.ogg"
40[ -s "$d/opus-10m.ogg" ] || ff -f lavfi -i "anoisesrc=d=600:c=pink:r=48000:a=0.2:seed=7" \
41 -ac 2 -c:a libopus -b:a 128k "$d/opus-10m.ogg"
42
43# 24-bit 5.1 WAV, 10 min at 48 kHz: six independent pink-noise channels joined as 5.1.
44inputs=()
45for seed in 1 2 3 4 5 6; do
46 inputs+=(-f lavfi -i "anoisesrc=d=600:c=pink:r=48000:a=0.2:seed=$seed")
47done
48[ -s "$d/wav-51-24b-10m.wav" ] || ff "${inputs[@]}" -filter_complex \
49 "[0:a][1:a][2:a][3:a][4:a][5:a]amerge=inputs=6,pan=5.1(side)|c0=c0|c1=c1|c2=c2|c3=c3|c4=c4|c5=c5[a]" \
50 -map "[a]" -ar 48000 -c:a pcm_s24le -f wav "$d/wav-51-24b-10m.wav"
51[ -s "$d/wav-51-24b-10m.s24le.md5" ] || ffmpeg -nostdin -v error -i "$d/wav-51-24b-10m.wav" -f s24le - \
52 | md5sum | cut -d' ' -f1 > "$d/wav-51-24b-10m.s24le.md5"
53echo "clips in $d"