# Read input: The drag-and-dropped file Param([string]$inFilePath='savdalhv01'); # Settings $outHeight = 290; # Where are we? $scriptpath = $MyInvocation.MyCommand.Path; $scriptFolder = Split-Path $scriptpath; # Scale the video $endAt = $inFilePath.lastIndexOf('\'); $droppedFolder = $inFilePath.Substring(0, $endAt); $extAt = $inFilePath.lastIndexOf('.'); $fileName = $inFilePath.Substring($endAt+1, $extAt-$endAt-1 ); $outputPath = $droppedFolder + '\' + $fileName + '_t.mp4'; # Delete existing thumb file if ( [System.IO.File]::Exists($outputPath) ) { Remove-Item $outputPath; } $result = & "$scriptFolder\ffmpeg.exe" -i "$inFilePath" -vf "scale=-2':'$outHeight" -an -pix_fmt yuv420p -preset medium -movflags +faststart "$outputPath"; # Save a poster image $posterPath = $droppedFolder + '\' + $fileName + '_t.jpg'; if ( -not( [System.IO.File]::Exists($posterPath) ) ) { $result = & "$scriptFolder\ffmpeg.exe" -y -i "$outputPath" -ss 1 -vframes 1 -r 1 -f image2 "$posterPath"; }