forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

gen.sh33 lines, 2.1 KiBHistoryRawDownload
1#!/usr/bin/env bash
2# Regenerates the tiny committed fixtures and their expectations from synthetic sources
3# (testsrc2 and sine only). Needs ffmpeg with libx264 and libx265.
4# expected.txt: <file> <stream-index-in-ffmpeg> <codec> <packets> <bytes> <fnv1a64 of ffmpeg's bytes>
5# LPCM is hashed over ffmpeg's s16be decode, which is what the demuxer's packets are.
6set -euo pipefail
7cd "$(dirname "$0")"
8V=(-f lavfi -i testsrc2=size=160x120:rate=25:duration=0.6)
9A=(-f lavfi -i sine=frequency=440:sample_rate=48000:duration=0.6)
10X=(-c:v libx264 -preset ultrafast -g 12 -bf 2)
11ffmpeg -v error -y "${V[@]}" "${A[@]}" "${X[@]}" -c:a aac -f mpegts tiny_h264_aac.ts
12ffmpeg -v error -y "${V[@]}" "${A[@]}" "${X[@]}" -c:a ac3 -f mpegts -mpegts_m2ts_mode 1 tiny_h264_ac3.m2ts
13ffmpeg -v error -y "${V[@]}" "${A[@]}" "${X[@]}" -c:a eac3 -f mpegts tiny_h264_eac3.ts
14ffmpeg -v error -y -f lavfi -i testsrc2=size=160x120:rate=25:duration=0.3 -f lavfi -i sine=frequency=440:sample_rate=48000:duration=0.3 "${X[@]}" -c:a pcm_bluray -f mpegts -mpegts_m2ts_mode 1 tiny_h264_lpcm.m2ts
15ffmpeg -v error -y "${V[@]}" "${A[@]}" -c:v libx265 -preset ultrafast -g 12 -x265-params log-level=none -c:a aac -f mpegts tiny_hevc_aac.ts
16python3 -I - <<'PY'
17import subprocess
18def fnv(b):
19 h = 0xcbf29ce484222325
20 for x in b:
21 h = ((h ^ x) * 0x100000001b3) & 0xFFFFFFFFFFFFFFFF
22 return h
23rows = []
24for f in ["tiny_h264_aac.ts", "tiny_h264_ac3.m2ts", "tiny_h264_eac3.ts", "tiny_h264_lpcm.m2ts", "tiny_hevc_aac.ts"]:
25 for idx, codec in enumerate(["video", "audio"]):
26 if codec == "audio" and "lpcm" in f:
27 data = subprocess.run(["ffmpeg","-v","error","-i",f,"-map","0:1","-f","s16be","-"],capture_output=True,check=True).stdout
28 else:
29 data = subprocess.run(["ffmpeg","-v","error","-i",f,"-map",f"0:{idx}","-c","copy","-f","data","-"],capture_output=True,check=True).stdout
30 pk = subprocess.run(["ffprobe","-v","error","-select_streams",str(idx),"-show_entries","packet=pts","-of","csv=p=0",f],capture_output=True,check=True).stdout.split()
31 rows.append(f"{f} {idx} {len(pk)} {len(data)} {fnv(data):016x}")
32open("expected.txt","w").write("\n".join(rows) + "\n")
33PY