diff --git a/frame_extractor.bat b/frame_extractor.bat new file mode 100644 index 0000000..b2c3a58 --- /dev/null +++ b/frame_extractor.bat @@ -0,0 +1,35 @@ +@echo off + +if "%1"=="" ( + echo Please provide the input file as the first argument. + goto :eof +) +if "%2"=="" ( + echo Please provide the scale as the third argument. + goto :eof +) + +set input_file=%1 +set scale_width=%2 +if "%scale_width%"=="0" ( + set scale_width=-1 +) +set video_string="scale=%scale_width%:-1" +if not "%3"=="" ( + set video_string=%video_string%,colorkey=%3:0.1:0.1 +) + +set output_folder=dumped_frames + +if exist %output_folder% ( + rmdir %output_folder% /Q/S +) + +mkdir %output_folder% + +ffmpeg -i %input_file% -nostats -loglevel 0 -vf "%video_string%,split[a][b];[a]alphaextract[am];[b][am]alphamerge" "%output_folder%/frame_%%04d.png" + +ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 "%output_folder%/frame_0001.png" > %output_folder%/frame_size.txt +set /p frame_size=<%output_folder%/frame_size.txt + +echo Done, the images have been dumped to %output_folder% with frame size of %frame_size%. \ No newline at end of file diff --git a/spritesheet_maker.bat b/spritesheet_maker.bat new file mode 100644 index 0000000..113f169 --- /dev/null +++ b/spritesheet_maker.bat @@ -0,0 +1,58 @@ +@echo off + +if "%1"=="" ( + echo Please provide the input file as the first argument. + goto :eof +) +if "%2"=="" ( + echo Please provide the scale as the third argument. + goto :eof +) +if "%3"=="" ( + echo Please provide the output file name as the fourth argument. + goto :eof +) + +set input_file=%1 +set scale_width=%2 +if "%scale_width%"=="0" ( + set scale_width=-1 +) +set output_file=%3 +set video_string="scale=%scale_width%:-1" +if not "%4"=="" ( + set video_string=%video_string%,colorkey=%4:0.1:0.1 +) + +set temp_folder=%temp%\sprite_sheet_frames + +mkdir %temp_folder% + +ffprobe -loglevel error -stats -select_streams -count_frames -show_entries stream=nb_read_frames -print_format default=nokey=1:noprint_wrappers=1 %input_file% > %temp_folder%/frame_count.txt + +set /p frame_count=<%temp_folder%/frame_count.txt + +set /a row=1 +set /a col=%frame_count%/%row% + +:loop +set /a col=%frame_count%/%row% +if %row% gtr %col% ( + goto found +) +set /a row=%row%+1 +goto loop + +:found +set /a col=%col%+1 + +ffmpeg -i %input_file% -nostats -loglevel 0 -vf "%video_string%,split[a][b];[a]alphaextract[am];[b][am]alphamerge" "%temp_folder%/frame_%%04d.bmp" + +ffmpeg -i "%temp_folder%/frame_%%04d.bmp" -nostats -loglevel 0 -filter_complex tile=%row%x%col% -update true %output_file% + +ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 "%temp_folder%/frame_0001.bmp" > %temp_folder%/frame_size.txt +set /p frame_size=<%temp_folder%/frame_size.txt + +rmdir %temp_folder% /Q/S + +echo Done, the sprite sheet is saved as %output_file%. There are %frame_count% frames on a grid of size %row%x%col% with a frame size of %frame_size% \ No newline at end of file diff --git a/upload_dumped_frames.ps1 b/upload_dumped_frames.ps1 new file mode 100644 index 0000000..dabdf58 --- /dev/null +++ b/upload_dumped_frames.ps1 @@ -0,0 +1,94 @@ +Add-Type -AssemblyName System.Net.Http + +$url = 'https://apis.roblox.com/assets/v1/assets' +$operationUrlBase = 'https://apis.roblox.com/assets/v1/operations' +$decalToImage = 'https://f3xteam.com/bt/getDecalImageID/' +$apiKey = '' +$userId = '' + +$folderPath = './dumped_frames' + +if (Test-Path $folderPath) { + # Get all files in the folder + $files = Get-ChildItem -Path $folderPath + + # Iterate over each file and display its name + foreach ($file in $files) { + $fileNameNoExtension = [System.IO.Path]::GetFileNameWithoutExtension($file.Name) + $filePath = $file.FullName + + $requestPayload = @{ + assetType = "Decal" + displayName = $fileNameNoExtension + description = "bulk uploader in powershell no way" + creationContext = @{ + creator = @{ + userId = $userId + } + } + } | ConvertTo-Json + $multipartContent = New-Object System.Net.Http.MultipartFormDataContent + + # Add JSON request part + $jsonContent = New-Object System.Net.Http.StringContent -ArgumentList @($requestPayload, [System.Text.Encoding]::UTF8, "application/json") + $multipartContent.Add($jsonContent, "request") + + # Add file part + $fileStream = [System.IO.File]::OpenRead($filePath) + $fileContent = New-Object System.Net.Http.StreamContent($fileStream) + $fileContent.Headers.ContentType = [System.Net.Http.Headers.MediaTypeHeaderValue]::Parse("image/png") + $multipartContent.Add($fileContent, "fileContent", [System.IO.Path]::GetFileName($filePath)) + + # Prepare the HTTP request + $httpClient = New-Object System.Net.Http.HttpClient + $httpClient.DefaultRequestHeaders.Add("x-api-key", $apiKey) + + # Send the POST request + $response = $httpClient.PostAsync($url, $multipartContent).Result + + # Output the response + $responseContent = $response.Content.ReadAsStringAsync().Result + # Write-Output $responseContent + + # Parse the response to get the operationId + $responseJson = $responseContent | ConvertFrom-Json + $operationId = $responseJson.operationId + + # Wait for 5 seconds + Start-Sleep -Seconds 1 + + # Check the operation status + $operationUrl = "$operationUrlBase/$operationId" + $operationResponse = $httpClient.GetAsync($operationUrl).Result + $operationResponseContent = $operationResponse.Content.ReadAsStringAsync().Result + $operationResponseJson = $operationResponseContent | ConvertFrom-Json + + while ($operationResponseJson.done -ne "True") { + $operationResponse = $httpClient.GetAsync($operationUrl).Result + $operationResponseContent = $operationResponse.Content.ReadAsStringAsync().Result + $operationResponseJson = $operationResponseContent | ConvertFrom-Json + Write-Output "Operation $fileNameNoExtension is not completed yet." + Start-Sleep -Seconds 1 + } + + # Check if the operation is done + if ($operationResponseJson.done -eq $true -or $operationResponseJson.response.assetId -ne $null) { + $assetId = $operationResponseJson.response.assetId + $convertedAssetId = $httpClient.GetAsync("$decalToImage$assetId").Result.Content.ReadAsStringAsync().Result + while ($convertedAssetId -match "error") { + $convertedAssetId = $httpClient.GetAsync("$decalToImage$assetId").Result.Content.ReadAsStringAsync().Result + Write-Output "decal to image failed so lets try that again" + Start-Sleep -Seconds 1 + } + Write-Output "$fileNameNoExtension -> $convertedAssetId" + Add-Content -Path "./asset_ids.txt" -Value "$fileNameNoExtension='rbxassetid://$convertedAssetId'" + } + + # Clean up + $fileStream.Dispose() + $httpClient.Dispose() + $multipartContent.Dispose() + } +} else { + Write-Host "Folder not found: $folderPath" +} \ No newline at end of file