Question about CustomCommandCritical

Shouldn’t setting CustomCommandCritical=true cause the process to fail? I have that set in the profile and I have “strict” checked, but it just ignores the scripts return value of 1 and continues processing the file.

This is the latest profile I’m using and I have MCEBuddy 2.5 Beta 6.

[Move Movie Only]

Description=Just Copy

order=copy

copy-ext=.ts

copy-remuxto=.mkv

copy-audiodelay=skip

ffmpeg-VideoOptimized=true

ffmpeg-AudioOptimized=true

copy-VideoOptimized=true

copy-AudioOptimized=true

CustomCommandPath=C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

CustomCommandParameters= -File “e:\plex\convertHdr10+ToAV1.ps1” -InputFile “%sourcefile%”

CustomCommandHangPeriod=0

CustomCommandCritical=true

CustomCommandUISession=true

Thanks for providing that information, Dan.

It’s interesting that even with CustomCommandCritical=true and MCEBuddy 2.5 Beta 6, it’s still not failing. The Move Movie Only profile seems straightforward.

Could you also provide the contents of your convertHdr10+ToAV1.ps1 script, specifically how it’s returning the error code? I want to ensure the PowerShell script is indeed returning a non-zero exit code in a way that MCEBuddy can interpret.

For example, in PowerShell, you might use exit 1 to return an error. If the script is ending without an explicit exit command, it might be implicitly returning 0.

Here is some relevant information from the log file:

2025-08-23T11:07:27 MCEBuddy.AppWrapper.Base → Cleanup summary: 0 removed, 0 failed
2025-08-23T11:07:27 MCEBuddy.AppWrapper.Base → Cleaning up extracted subtitle files…
2025-08-23T11:07:27 MCEBuddy.AppWrapper.Base → Removed current instance marker: W:\Temp\VideoProcessing_Instances\convertHdr10+ToAV1.52988.marker
2025-08-23T11:07:27 MCEBuddy.AppWrapper.Base → Cleanup handlers unregistered
→ Process exited with code 1
2025-08-23T11:07:30 MCEBuddy.Engine.ConversionJob → Finished custom command, file size [KB] 62,040,758.00
INFORMATION> 2025-08-23T11:07:30 MCEBuddy.Engine.ConversionJob → Moving converted file to destination

Can you attach the complete conversion log. Some of the messages in the log above I don’t recognize as coming from MCEBuddy - can you confirm that they’re coming from your script?

If you can share your script that would be great so we can replicate your setup and see what’s going on.

My current script is kind of a monstrosity. :slight_smile: It’s my side project to kind of do everything to fix plex issues. It’s grown to about 5k lines of code, but it does finally fix the black screen issues, the dolby vision issues, the 10second start lag issues, and rebuffering. :slight_smile:

I found a work around to manually move the file to my failed folder. Plex detects the file is gone and then flags it as a failure.

I deleted the logs I had from my failed runs. The next run I get that fails, I’ll attach the log again. I do see that all the output from my script shows in the logs with “mcebuddy.appwrapper.base”

2025-08-24T07:14:53 MCEBuddy.AppWrapper.Base → Plex Optimizations Enabled:
2025-08-24T07:14:53 MCEBuddy.AppWrapper.Base → Fragmented MP4 with faststart
2025-08-24T07:14:53 MCEBuddy.AppWrapper.Base → 2-second keyframe intervals for smooth seeking
2025-08-24T07:14:53 MCEBuddy.AppWrapper.Base → Conservative HEVC levels for device compatibility
2025-08-24T07:14:53 MCEBuddy.AppWrapper.Base → SRT subtitle conversion for better compatibility
2025-08-24T07:14:53 MCEBuddy.AppWrapper.Base → HDR metadata preservation for 4K HDR content
2025-08-24T07:14:53 MCEBuddy.AppWrapper.Base → Audio streams: Selected best stream
2025-08-24T07:14:53 MCEBuddy.AppWrapper.Base → Subtitle streams: 0 to convert, 0 to copy, 3 ignored
2025-08-24T07:14:53 MCEBuddy.AppWrapper.Base → Scanning for external subtitle files…
2025-08-24T07:14:53 MCEBuddy.AppWrapper.Base → No external English subtitle files found

Here is the relevant part from my script:

} catch {

Write-Error "Processing failed: $\_"

Write-Error "Stack trace: $($\_.ScriptStackTrace)"



 \# --- START OF NEW LOGIC ---

\# Move the failed input file to the specified folder

try {

    if (-not (Test-Path $FailedFolder)) {

        New-Item -Path $FailedFolder -ItemType Directory -Force | Out-Null

        Write-Host "Created failed folder at '$FailedFolder'" -ForegroundColor Yellow

    }

    $destinationPath = Join-Path $FailedFolder (Split-Path $InputFile -Leaf)

    Move-Item -Path $InputFile -Destination $destinationPath -Force

    Write-Host "Moved failed file '$InputFile' to '$destinationPath'" -ForegroundColor Red

} catch {

    Write-Error "Failed to move the file to the failed folder: $\_"

}

\# --- END OF NEW LOGIC ---



\# Ensure cleanup on error

if ($spaceMonitorJob) { Stop-SpaceMonitoringWithCleanup -MonitorJob $spaceMonitorJob }

Stop-ActiveProcesses

Clear-TempFiles

Clear-ExtractedSubtitles



exit 1

} finally {

\# Final cleanup - FIXED to use improved cleanup function

if ($spaceMonitorJob) { Stop-SpaceMonitoringWithCleanup -MonitorJob $spaceMonitorJob }

Stop-ActiveProcesses

Clear-TempFiles

Clear-ExtractedSubtitles

Remove-CurrentInstanceMarker 



\# Clear any remaining progress indicators

$progressActivities = @("Video Processing", "Video encoding", "Extract HDR10+ metadata", 

                      "Inject HDR10+ metadata", "MP4 containerization", "Final MKV remux", "Quality Validation")

foreach ($activity in $progressActivities) {

    Write-Progress -Activity $activity -Completed

}



\# Unregister event handlers

if ($Script:CleanupRegistered) {

    try {

        Get-EventSubscriber | Where-Object { $\_.SourceIdentifier -match "PowerShell.Exiting|ProcessExit" } | Unregister-Event -ErrorAction SilentlyContinue

        Write-Host "Cleanup handlers unregistered" -ForegroundColor Gray

    }

    catch {

        \# Ignore cleanup errors during shutdown

    }

}

}

Write-Host “Processing completed successfully!” -ForegroundColor Green

exit 0

Here is a log from a run that failed miserably

because of a coding problem in my script. But it does show that the script failed, but mcebuddy kept going.

1 Like

I see the issue, your profile hasn’t instructed custom command to check for the exit code:

2025-08-24T10:54:25 MCEBuddy.Transcode.CustomCommand → About to run custom command with parameters:
PreCustomCommandPath = c:\windows\system32\windowspowershell\v1.0\powershell.exe
PreCustomCommandParameters = -File “e:\plex\convertHdr10+ToAV1.ps1” -InputFile “E:\Radarr\Guardians of the Galaxy (2014)\Guardians of the Galaxy (2014).mkv”
PreCustomCommandHangPeriod = 0
PreCustomCommandCritical = True
PreCustomCommandUISession = True
PreCustomCommandShowWindow = True
PreCustomCommandExitCodeCheck = False

You need to set the CustomCommandExitCodeCheck to true in the profile if you want MCEBuddy to look at the exit codes. CustomCommandCritical just look for terminations and problems with the process itself and doesn’t look to the return or exit codes.

From the customcommand documentation: MCEBuddy - Advanced Settings, Commands and Tweaking

CustomCommandCritical, when this is set to true, MCEBuddy will fail the entire conversion if the custom command is invalid or if the process is terminated (due to hang detection). If it is set to false then MCEBuddy will continue with the conversion processing irrespective of the custom command failure/success UNLESS the converted file has been renamed or deleted. By default the value is false.

CustomCommandExitCodeCheck(v2.4.1+) is set to true if you want MCEBuddy to check the Exit Code of the custom command application. If the return code is 0 (default) it is considered a success, if not 0 (+ve or -ve) then it is considered a failure. If the Exit Code fails MCEBuddy will stop further processing and fail the conversion.

Thank you! I must have either been asleep or looking at older info, but I totally missed that.