Last active
October 29, 2025 22:11
-
-
Save bradmartin333/2a3b397cbf9ef6460de2e55034ddf939 to your computer and use it in GitHub Desktop.
powershell script for generating test clips
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .SYNOPSIS | |
| Generates a high frame rate video with SMPTE timecode overlay. | |
| .DESCRIPTION | |
| This script creates a video file with a timecode burned in using FFmpeg. | |
| The video frame rate is configurable and can be set to any desired duration. | |
| .PARAMETER Duration | |
| Duration of the video in seconds (default: 10) | |
| .PARAMETER FrameRate | |
| Frame rate of the video in FPS (default: 120) | |
| .PARAMETER OutputFile | |
| Output file path (default: auto-generated based on parameters) | |
| .PARAMETER Resolution | |
| Video resolution in WIDTHxHEIGHT format (default: 1920x1080) | |
| .PARAMETER FontSize | |
| Font size for the timecode display (default: 96) | |
| .PARAMETER BackgroundColor | |
| Background color in hex format (default: black) - only used when BackgroundAnimation is "none" | |
| .PARAMETER BackgroundAnimation | |
| Background animation style: "none", "gradient", "plasma", "mandelbrot", "testsrc", "hue" (default: "none") | |
| .EXAMPLE | |
| .\make_120fps_timecode_clip.ps1 -Duration 30 -OutputFile "output.mp4" | |
| Creates a 30-second video with timecode at 120 FPS | |
| .EXAMPLE | |
| .\make_120fps_timecode_clip.ps1 -Duration 60 -FrameRate 90 | |
| Creates a 60-second video at 90 FPS | |
| .EXAMPLE | |
| .\make_120fps_timecode_clip.ps1 -Duration 60 -Resolution "3840x2160" -FontSize 192 | |
| Creates a 60-second 4K video with larger timecode text | |
| .EXAMPLE | |
| .\make_120fps_timecode_clip.ps1 -Duration 30 -BackgroundAnimation "plasma" -FrameRate 90 | |
| Creates a 30-second video at 90 FPS with animated plasma background | |
| #> | |
| param( | |
| [Parameter(Mandatory = $false)] | |
| [int]$Duration = 10, | |
| [Parameter(Mandatory = $false)] | |
| [int]$FrameRate = 120, | |
| [Parameter(Mandatory = $false)] | |
| [string]$OutputFile = "", | |
| [Parameter(Mandatory = $false)] | |
| [string]$Resolution = "1920x1080", | |
| [Parameter(Mandatory = $false)] | |
| [int]$FontSize = 96, | |
| [Parameter(Mandatory = $false)] | |
| [string]$BackgroundColor = "black", | |
| [Parameter(Mandatory = $false)] | |
| [ValidateSet("none", "gradient", "plasma", "mandelbrot", "testsrc", "hue")] | |
| [string]$BackgroundAnimation = "none" | |
| ) | |
| # Check if FFmpeg is installed | |
| $ffmpegPath = Get-Command ffmpeg -ErrorAction SilentlyContinue | |
| if (-not $ffmpegPath) { | |
| Write-Error "FFmpeg is not installed or not in PATH. Please install FFmpeg first." | |
| Write-Host "Download from: https://ffmpeg.org/download.html" | |
| exit 1 | |
| } | |
| # Parse resolution | |
| $resolutionParts = $Resolution -split 'x' | |
| if ($resolutionParts.Count -ne 2) { | |
| Write-Error "Invalid resolution format. Use WIDTHxHEIGHT (e.g., 1920x1080)" | |
| exit 1 | |
| } | |
| $width = [int]$resolutionParts[0] | |
| $height = [int]$resolutionParts[1] | |
| # Generate intelligent output filename if not specified | |
| if ([string]::IsNullOrWhiteSpace($OutputFile)) { | |
| $timestamp = Get-Date -Format "yyyyMMdd_HHmmss" | |
| $bgName = if ($BackgroundAnimation -eq "none") { $BackgroundColor } else { $BackgroundAnimation } | |
| $OutputFile = "timecode_${FrameRate}fps_${Duration}s_${width}x${height}_${bgName}_${timestamp}.mp4" | |
| Write-Host "Auto-generated filename: $OutputFile" -ForegroundColor Yellow | |
| } | |
| Write-Host "Generating $FrameRate FPS timecode video..." -ForegroundColor Green | |
| Write-Host "Duration: $Duration seconds" -ForegroundColor Cyan | |
| Write-Host "Frame Rate: $FrameRate FPS" -ForegroundColor Cyan | |
| Write-Host "Resolution: $Resolution" -ForegroundColor Cyan | |
| Write-Host "Background: $BackgroundAnimation" -ForegroundColor Cyan | |
| Write-Host "Output: $OutputFile" -ForegroundColor Cyan | |
| Write-Host "" | |
| # Select background source based on animation type | |
| switch ($BackgroundAnimation) { | |
| "gradient" { | |
| # Animated gradient background | |
| $backgroundSource = "gradients=s=${Resolution}:r=${FrameRate}:d=${Duration}:c0=0x00ff00:c1=0x0000ff:c2=0xff00ff:c3=0xffff00:c4=0x00ffff:c5=0xff0000:c6=0x00ff00:c7=0x0000ff:x0=0:y0=0:x1=${width}:y1=${height}:nb_colors=8:speed=0.5" | |
| } | |
| "plasma" { | |
| # Plasma effect background | |
| $backgroundSource = "nullsrc=s=${Resolution}:r=${FrameRate}:d=${Duration},geq=r='sin(sqrt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2))/10+T)*127+128':g='sin(sqrt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2))/7-T)*127+128':b='sin(sqrt((X-W/2)*(X-W/2)+(Y-H/2)*(Y-H/2))/5+T*2)*127+128'" | |
| } | |
| "mandelbrot" { | |
| # Mandelbrot fractal zoom | |
| $backgroundSource = "mandelbrot=s=${Resolution}:r=${FrameRate}:maxiter=500:end_scale=0.01" | |
| } | |
| "testsrc" { | |
| # Animated test pattern | |
| $backgroundSource = "testsrc=s=${Resolution}:r=${FrameRate}:d=${Duration}" | |
| } | |
| "hue" { | |
| # Rotating hue color cycle | |
| $backgroundSource = "color=c=red:s=${Resolution}:r=${FrameRate}:d=${Duration},hue=H=2*PI*t:s=1" | |
| } | |
| default { | |
| # Solid color background | |
| $backgroundSource = "color=c=${BackgroundColor}:s=${Resolution}:r=${FrameRate}:d=${Duration}" | |
| } | |
| } | |
| # Build FFmpeg command | |
| # Using selected background source with timecode overlay | |
| $ffmpegArgs = @( | |
| "-f", "lavfi", | |
| "-i", $backgroundSource, | |
| "-vf", "drawtext=fontfile=C\\:/Windows/Fonts/arial.ttf:fontsize=${FontSize}:fontcolor=white:box=1:[email protected]:boxborderw=10:x=(w-text_w)/2:y=(h-text_h)/2:timecode='00\:00\:00\:00':rate=${FrameRate}", | |
| "-c:v", "libx264", | |
| "-preset", "medium", | |
| "-crf", "18", | |
| "-pix_fmt", "yuv420p", | |
| "-r", $FrameRate, | |
| "-y", | |
| $OutputFile | |
| ) | |
| # Execute FFmpeg | |
| try { | |
| $process = Start-Process -FilePath "ffmpeg" -ArgumentList $ffmpegArgs -NoNewWindow -Wait -PassThru | |
| if ($process.ExitCode -eq 0) { | |
| Write-Host "" | |
| Write-Host "Video created successfully!" -ForegroundColor Green | |
| Write-Host "Output file: $OutputFile" -ForegroundColor Cyan | |
| # Get file info | |
| if (Test-Path $OutputFile) { | |
| $fileInfo = Get-Item $OutputFile | |
| $fileSizeMB = [math]::Round($fileInfo.Length / 1MB, 2) | |
| Write-Host "File size: $fileSizeMB MB" -ForegroundColor Cyan | |
| } | |
| } | |
| else { | |
| Write-Error "FFmpeg encountered an error (Exit code: $($process.ExitCode))" | |
| exit 1 | |
| } | |
| } | |
| catch { | |
| Write-Error "Failed to execute FFmpeg: $_" | |
| exit 1 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment