mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-10-30 09:16:55 +00:00
* perf(aws-lambda): run chunks through a Distributed Map to lift the 40-chunk cap The inline Map runs at most 40 chunk renders at once. Both state machine definitions (CDK and SAM) now use a Distributed Map with STANDARD child executions, capped at the function's reserved concurrency so chunks past it queue instead of being throttled. Progress reads each chunk's child execution history so frames, cost and chunk errors still show up. * fix(aws-lambda): retry Lambda throttles for minutes and stop on oversized chunks A throttled task used to burn its four catch-all retries in about 30 s. It now gets its own jittered backoff of several minutes, because another render on the same function can still hold the reserved slots. Plan treats CHUNK_EXCEEDS_WORKER_TIMEOUT as terminal in both definitions. * chore(aws-lambda): trim stack comments to keep the comment share flat * fix(aws-lambda): keep render --wait working at hundreds of chunks Progress polls read the chunk Map Run's counts (one DescribeMapRun) instead of every child execution's history, take exact chunk frames and cost from the Map output once it exits, and read failed children only when the counts show a failure. The SDK client retries throttled calls up to 8 times with backoff. * feat(aws-lambda): size each render's concurrency to the account instead of a fixed 8 * fix(lambda): keep the concurrency SDK external in published modules * fix(cli): keep an existing stack's reserved concurrency on redeploy Redeploying without --concurrency sent ReservedConcurrency=-1, which removed the cap of 8 that earlier CLI versions reserved by default and stopped recording it in the state file. The override is now left out when the flag is omitted, so SAM keeps the stack's current value (a new stack still gets the template's unreserved default). The state file records the deployed value, and deploy prints the kept reservation. * fix(aws-lambda): keep progress working for callers without DescribeMapRun Callers whose IAM policy came from an earlier `lambda policies user` lack states:DescribeMapRun, so reading a running Distributed Map threw AccessDeniedException out of `lambda progress` and `render --wait` while the render itself went on to succeed. getRenderProgress now catches only that error around the map-run read, returns the parent snapshot (status, plan and assemble progress) and adds a warning to re-apply the policy, which both commands print. Other errors still throw. * fix(cli): let the documented deploy policy drop a reserved concurrency When a redeploy removes a function's reserved concurrency, CloudFormation calls lambda:DeleteFunctionConcurrency. The policy printed by `lambda policies role|user` granted only PutFunctionConcurrency, so the update failed and rolled back. Grant it, and pin it with states:DescribeMapRun in the required-actions test. * fix(aws-lambda): read smoke chunk hashes from the Distributed Map output With chunks in a Distributed Map, their task results live in child executions, so the smoke gate's chunk-hash check found 0 chunks in the parent history and failed every v1/v2 comparison. Read Chunks[] from the RenderChunks / RenderChunksV2 MapStateExited output instead, as getRenderProgress does. The stack this script deploys only has the Distributed Map, so the inline-Map path is gone. * fix(producer): cap a pinned chunk size at the worker concurrency, not 16 With --chunk-size or --target-chunk-frames and no --max-parallel-chunks, the plan still capped the render at 16 chunks however many workers the account allowed, so --chunk-size 30 on a 60 s render gave 16 chunks of 113 frames. The cap is now one wave across the worker concurrency, as the --max-parallel-chunks docs say; 16 remains when the concurrency is unknown. * feat(cli): remove a stack's reserved concurrency with --concurrency=none Since an omitted --concurrency now keeps the stack's reservation, there was no CLI way back to the unreserved default. --concurrency=none sends ReservedConcurrency=-1, the state file records the stack as unreserved and deploy says the reservation was removed. Positive N and an omitted flag behave as before; any other value is rejected instead of being silently ignored. * chore(aws-lambda): raise the package size budget for account-sized concurrency Measured with pnpm@10.17.1 pack after rebasing on main with the S3 assembly change: 67,763 packed / 244,685 unpacked; the budget is the check's own 5% headroom over that.
240 lines
8.4 KiB
Bash
Executable File
240 lines
8.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Canonical decoded-output comparison shared by the real-AWS smoke test and
|
|
# its local unit test. This file defines functions only; sourcing it has no
|
|
# side effects.
|
|
|
|
hf_sha256() {
|
|
sha256sum "$1" | awk '{print $1}'
|
|
}
|
|
|
|
hf_canonical_video_framemd5() {
|
|
local input="$1" output="$2" raw
|
|
raw=$(mktemp)
|
|
if ! ffmpeg -nostdin -v error -y -i "$input" \
|
|
-map 0:v:0 -an -vf format=rgba -fps_mode passthrough \
|
|
-f framemd5 "$raw"; then
|
|
rm -f "$raw"
|
|
return 1
|
|
fi
|
|
# Ignore container timestamp/header differences here: normalized ffprobe
|
|
# metadata and duration are gated separately. This file pins decoded pixel
|
|
# bytes, frame order, frame count, and per-frame byte size.
|
|
awk -F',' '
|
|
!/^#/ && NF >= 6 {
|
|
size=$5; hash=$6
|
|
gsub(/[[:space:]]/, "", size)
|
|
gsub(/[[:space:]]/, "", hash)
|
|
print size "," hash
|
|
}
|
|
' "$raw" > "$output"
|
|
rm -f "$raw"
|
|
[ -s "$output" ]
|
|
}
|
|
|
|
hf_normalized_ffprobe_metadata() {
|
|
local input="$1" output="$2"
|
|
ffprobe -v error \
|
|
-show_entries \
|
|
stream=index,codec_type,codec_name,profile,pix_fmt,width,height,sample_aspect_ratio,display_aspect_ratio,r_frame_rate,avg_frame_rate,time_base,color_range,color_space,color_transfer,color_primaries,chroma_location,field_order,sample_fmt,sample_rate,channels,channel_layout \
|
|
-of json "$input" |
|
|
jq -S '{
|
|
streams: ((.streams // [])
|
|
| sort_by(.codec_type, .index)
|
|
| map(del(.index)))
|
|
}' > "$output"
|
|
}
|
|
|
|
hf_duration_seconds() {
|
|
ffprobe -v error -show_entries format=duration -of default=nw=1:nk=1 "$1"
|
|
}
|
|
|
|
hf_has_audio() {
|
|
[ -n "$(ffprobe -v error -select_streams a:0 -show_entries stream=index -of csv=p=0 "$1" 2>/dev/null | head -1)" ]
|
|
}
|
|
|
|
hf_decode_pcm() {
|
|
ffmpeg -nostdin -v error -i "$1" -map 0:a:0 -vn \
|
|
-ac 2 -ar 48000 -c:a pcm_s16le -f s16le "$2"
|
|
}
|
|
|
|
# Chunks run in Distributed Map child executions; the Map's exit output carries every result.
|
|
hf_extract_chunk_hashes() {
|
|
local history="$1" output="$2"
|
|
jq '[
|
|
.events[] |
|
|
select(.type == "MapStateExited") |
|
|
.stateExitedEventDetails |
|
|
select(.name == "RenderChunks" or .name == "RenderChunksV2") |
|
|
(.output | fromjson | .Chunks // [])[] |
|
|
{ChunkIndex, Sha256, FramesEncoded}
|
|
] | sort_by(.ChunkIndex)' "$history" > "$output"
|
|
}
|
|
|
|
# Compare two rendered outputs. Writes durable evidence at <prefix>.* and a
|
|
# machine-readable <prefix>.json. Returns 0 only for semantic equivalence.
|
|
hf_compare_render_semantics() {
|
|
local v1="$1" v2="$2" prefix="$3"
|
|
local v1_history="${4:-}" v2_history="${5:-}"
|
|
local tolerance="${SEMANTIC_DURATION_TOLERANCE_SECONDS:-0.001}"
|
|
local work
|
|
work=$(mktemp -d)
|
|
|
|
local v1_frames="${prefix}.v1.framemd5"
|
|
local v2_frames="${prefix}.v2.framemd5"
|
|
local v1_meta="${prefix}.v1.ffprobe.json"
|
|
local v2_meta="${prefix}.v2.ffprobe.json"
|
|
local v1_duration v2_duration duration_delta
|
|
local v1_encoded_sha v2_encoded_sha encoded_equal
|
|
local video_equal metadata_equal duration_equal
|
|
local audio_state audio_equal v1_audio_sha="" v2_audio_sha=""
|
|
local v1_audio_bytes=0 v2_audio_bytes=0
|
|
local encoded_gated=false
|
|
local chunks_checked=false chunks_equal=true v1_chunk_count=0 v2_chunk_count=0
|
|
if [ "${REQUIRE_ENCODED_SHA_EQUAL:-false}" = true ]; then encoded_gated=true; fi
|
|
|
|
if ! hf_canonical_video_framemd5 "$v1" "$v1_frames" ||
|
|
! hf_canonical_video_framemd5 "$v2" "$v2_frames" ||
|
|
! hf_normalized_ffprobe_metadata "$v1" "$v1_meta" ||
|
|
! hf_normalized_ffprobe_metadata "$v2" "$v2_meta"; then
|
|
rm -rf "$work"
|
|
return 2
|
|
fi
|
|
|
|
if cmp -s "$v1_frames" "$v2_frames"; then video_equal=true; else video_equal=false; fi
|
|
if cmp -s "$v1_meta" "$v2_meta"; then metadata_equal=true; else metadata_equal=false; fi
|
|
|
|
if ! v1_duration=$(hf_duration_seconds "$v1") ||
|
|
! v2_duration=$(hf_duration_seconds "$v2"); then
|
|
rm -rf "$work"
|
|
return 2
|
|
fi
|
|
duration_delta=$(awk -v a="$v1_duration" -v b="$v2_duration" \
|
|
'BEGIN { d=a-b; if (d<0) d=-d; printf("%.9f", d) }')
|
|
if awk -v d="$duration_delta" -v t="$tolerance" 'BEGIN { exit !(d <= t) }'; then
|
|
duration_equal=true
|
|
else
|
|
duration_equal=false
|
|
fi
|
|
|
|
local v1_has_audio=false v2_has_audio=false
|
|
if hf_has_audio "$v1"; then v1_has_audio=true; fi
|
|
if hf_has_audio "$v2"; then v2_has_audio=true; fi
|
|
if [ "$v1_has_audio" = false ] && [ "$v2_has_audio" = false ]; then
|
|
audio_state="no-audio-on-either"
|
|
audio_equal=true
|
|
elif [ "$v1_has_audio" != "$v2_has_audio" ]; then
|
|
audio_state="audio-stream-mismatch"
|
|
audio_equal=false
|
|
else
|
|
audio_state="decoded-pcm"
|
|
if ! hf_decode_pcm "$v1" "$work/v1.pcm" ||
|
|
! hf_decode_pcm "$v2" "$work/v2.pcm"; then
|
|
rm -rf "$work"
|
|
return 2
|
|
fi
|
|
v1_audio_sha=$(hf_sha256 "$work/v1.pcm")
|
|
v2_audio_sha=$(hf_sha256 "$work/v2.pcm")
|
|
v1_audio_bytes=$(wc -c < "$work/v1.pcm" | tr -d '[:space:]')
|
|
v2_audio_bytes=$(wc -c < "$work/v2.pcm" | tr -d '[:space:]')
|
|
if [ "$v1_audio_sha" = "$v2_audio_sha" ] && [ "$v1_audio_bytes" = "$v2_audio_bytes" ]; then
|
|
audio_equal=true
|
|
else
|
|
audio_equal=false
|
|
fi
|
|
fi
|
|
|
|
v1_encoded_sha=$(hf_sha256 "$v1")
|
|
v2_encoded_sha=$(hf_sha256 "$v2")
|
|
if [ "$v1_encoded_sha" = "$v2_encoded_sha" ]; then encoded_equal=true; else encoded_equal=false; fi
|
|
|
|
local semantic_equal=false
|
|
if [ "$video_equal" = true ] &&
|
|
[ "$metadata_equal" = true ] &&
|
|
[ "$duration_equal" = true ] &&
|
|
[ "$audio_equal" = true ]; then
|
|
semantic_equal=true
|
|
fi
|
|
if [ "$encoded_gated" = true ] && [ "$encoded_equal" != true ]; then
|
|
semantic_equal=false
|
|
fi
|
|
|
|
if [ -n "$v1_history" ] || [ -n "$v2_history" ]; then
|
|
chunks_checked=true
|
|
if [ -z "$v1_history" ] || [ -z "$v2_history" ] ||
|
|
! hf_extract_chunk_hashes "$v1_history" "${prefix}.v1.chunk-hashes.json" ||
|
|
! hf_extract_chunk_hashes "$v2_history" "${prefix}.v2.chunk-hashes.json"; then
|
|
rm -rf "$work"
|
|
return 2
|
|
fi
|
|
v1_chunk_count=$(jq 'length' "${prefix}.v1.chunk-hashes.json")
|
|
v2_chunk_count=$(jq 'length' "${prefix}.v2.chunk-hashes.json")
|
|
if [ "$v1_chunk_count" -eq 0 ] ||
|
|
[ "$v2_chunk_count" -eq 0 ] ||
|
|
! cmp -s "${prefix}.v1.chunk-hashes.json" "${prefix}.v2.chunk-hashes.json"; then
|
|
chunks_equal=false
|
|
semantic_equal=false
|
|
fi
|
|
fi
|
|
|
|
jq -n \
|
|
--arg v1 "$v1" --arg v2 "$v2" \
|
|
--argjson semanticEqual "$semantic_equal" \
|
|
--argjson videoEqual "$video_equal" \
|
|
--argjson v1VideoFrameCount "$(wc -l < "$v1_frames" | tr -d '[:space:]')" \
|
|
--argjson v2VideoFrameCount "$(wc -l < "$v2_frames" | tr -d '[:space:]')" \
|
|
--argjson metadataEqual "$metadata_equal" \
|
|
--arg v1Duration "$v1_duration" --arg v2Duration "$v2_duration" \
|
|
--arg durationDelta "$duration_delta" --arg durationTolerance "$tolerance" \
|
|
--arg audioState "$audio_state" --argjson audioEqual "$audio_equal" \
|
|
--arg v1AudioSha256 "$v1_audio_sha" --arg v2AudioSha256 "$v2_audio_sha" \
|
|
--argjson v1AudioBytes "$v1_audio_bytes" --argjson v2AudioBytes "$v2_audio_bytes" \
|
|
--arg v1EncodedSha256 "$v1_encoded_sha" --arg v2EncodedSha256 "$v2_encoded_sha" \
|
|
--argjson encodedShaEqual "$encoded_equal" \
|
|
--argjson encodedShaGated "$encoded_gated" \
|
|
--argjson chunksChecked "$chunks_checked" \
|
|
--argjson chunksEqual "$chunks_equal" \
|
|
--argjson v1ChunkCount "$v1_chunk_count" \
|
|
--argjson v2ChunkCount "$v2_chunk_count" \
|
|
'{
|
|
v1: $v1,
|
|
v2: $v2,
|
|
semanticEqual: $semanticEqual,
|
|
video: {
|
|
equal: $videoEqual,
|
|
v1FrameCount: $v1VideoFrameCount,
|
|
v2FrameCount: $v2VideoFrameCount
|
|
},
|
|
metadata: {equal: $metadataEqual},
|
|
chunks: {
|
|
checked: $chunksChecked,
|
|
equal: $chunksEqual,
|
|
v1Count: $v1ChunkCount,
|
|
v2Count: $v2ChunkCount
|
|
},
|
|
duration: {
|
|
v1Seconds: ($v1Duration | tonumber),
|
|
v2Seconds: ($v2Duration | tonumber),
|
|
deltaSeconds: ($durationDelta | tonumber),
|
|
toleranceSeconds: ($durationTolerance | tonumber),
|
|
equal: (($durationDelta | tonumber) <= ($durationTolerance | tonumber))
|
|
},
|
|
audio: {
|
|
state: $audioState,
|
|
equal: $audioEqual,
|
|
v1Sha256: $v1AudioSha256,
|
|
v2Sha256: $v2AudioSha256,
|
|
v1Bytes: $v1AudioBytes,
|
|
v2Bytes: $v2AudioBytes
|
|
},
|
|
encoded: {
|
|
equal: $encodedShaEqual,
|
|
gated: $encodedShaGated,
|
|
v1Sha256: $v1EncodedSha256,
|
|
v2Sha256: $v2EncodedSha256
|
|
}
|
|
}' > "${prefix}.json"
|
|
|
|
rm -rf "$work"
|
|
[ "$semantic_equal" = true ]
|
|
}
|