Add JAX backend with frame-varying random keys
- Add sexp_to_jax.py: JAX compiler for S-expression effects - Use jax.random.fold_in for deterministic but varying random per frame - Pass seed from recipe config through to JAX effects - Fix NVENC detection to do actual encode test - Add set_random_seed for deterministic Python random The fold_in approach allows frame_num to be traced (not static) while still producing different random patterns per frame, fixing the interference pattern issue. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -37,19 +37,39 @@ _nvenc_available: Optional[bool] = None
|
||||
|
||||
|
||||
def check_nvenc_available() -> bool:
|
||||
"""Check if NVENC hardware encoding is available."""
|
||||
"""Check if NVENC hardware encoding is available and working.
|
||||
|
||||
Does a real encode test to catch cases where nvenc is listed
|
||||
but CUDA libraries aren't loaded.
|
||||
"""
|
||||
global _nvenc_available
|
||||
if _nvenc_available is not None:
|
||||
return _nvenc_available
|
||||
|
||||
try:
|
||||
# First check if encoder is listed
|
||||
result = subprocess.run(
|
||||
["ffmpeg", "-encoders"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=5
|
||||
)
|
||||
_nvenc_available = "h264_nvenc" in result.stdout
|
||||
if "h264_nvenc" not in result.stdout:
|
||||
_nvenc_available = False
|
||||
return _nvenc_available
|
||||
|
||||
# Actually try to encode a small test frame
|
||||
result = subprocess.run(
|
||||
["ffmpeg", "-y", "-f", "lavfi", "-i", "testsrc=duration=0.1:size=64x64:rate=1",
|
||||
"-c:v", "h264_nvenc", "-f", "null", "-"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=10
|
||||
)
|
||||
_nvenc_available = result.returncode == 0
|
||||
if not _nvenc_available:
|
||||
import sys
|
||||
print("NVENC listed but not working, falling back to libx264", file=sys.stderr)
|
||||
except Exception:
|
||||
_nvenc_available = False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user