# $videoName = $args[0]
# $tabIp = $args[1]
# $ffmpegPath = "C:\ProgramData\chocolatey\bin\ffmpeg.exe"
# $rtspUrl = "rtsp://$tabIp/h265/ch1/main/av_stream"
# 
# Write-Host "Starting 10-second recording: $videoName"
# 
# # Запуск записи 10-секундного видео
# Start-Process -FilePath $ffmpegPath -ArgumentList "-t 10 -i $rtspUrl -vf scale=480:480 -vcodec libx264 -preset slower -crf 28 -b:v 1000k -g 50 -bf 2 -an -vsync 0 -loglevel error $videoName" -NoNewWindow -Wait
# 
# Write-Host "Recording finished: $videoName"
$videoName = $args[0]
$tabIp = $args[1]
$ffmpegPath = "C:\ProgramData\chocolatey\bin\ffmpeg.exe"
$rtspUrl = "rtsp://$tabIp/h265/ch1/main/av_stream"

Write-Host "Starting 10-second recording: $videoName"

Start-Process -FilePath $ffmpegPath -ArgumentList @(
    "-t", "10",
    "-rtsp_transport", "tcp",
    "-i", $rtspUrl,
    "-vf", "scale=480:480,drawtext=fontfile=C\\:/Windows/Fonts/segoeui.ttf:text=`%{localtime}:x=10:y=10:fontsize=24:fontcolor=white:borderw=2:bordercolor=black",
    "-vcodec", "libx264",
    "-preset", "slower",
    "-crf", "28",
    "-b:v", "1000k",
    "-g", "50",
    "-bf", "2",
    "-an",
    "-vsync", "vfr",
    "-loglevel", "error",
    $videoName
) -NoNewWindow -Wait


Write-Host "Recording finished: $videoName"


