Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe Premiere Pro Auto Shutdown PC after Encoding Done – Premiere Pro / Media Encoder

  • Luca Terzi

    October 16, 2015 at 12:04 pm

    I’ve just wrote something that takes into account the load of the CPU for the specific process.
    When AME finishes the CPU of the process “Adobe QT32 Server” used by AME to encode drops to 0.000000, and that’s what I’m looking for.
    This code is set to shutdown the pc if the that process reaches that condition, checking every 90s and in case it finds the process at 0.000000 it will wait other 90s to be sure that the encoding is really ended.

    @echo off

    SET “SERVICE=Themes”
    SET USAGE=”0.000000″
    SET /A “INTERVAL=90”
    SET prc=Adobe QT32 Server

    :LOOP
    cls
    For /F “tokens=2 delims=,” %%P in (‘typeperf “Process(%prc%)%% Processor time” -sc 1 ^| FINDSTR /rc:”[0-9]”‘) do (
    IF %%P EQU %USAGE% (
    echo Waiting 60s…
    Ping -n %INTERVAL% Localhost >NUL
    For /F “skip=1 tokens=2 delims=,” %%P in (‘typeperf “Process(%prc%)%% Processor time” -sc 1 ^| FINDSTR /RC:”[0-9]”‘) do (
    IF %%P EQU %USAGE% (
    echo Encoding DONE!
    echo Closing Adobe Media Encoder…
    taskkill /IM “Adobe Media Encoder.exe” >NUL
    echo Now Shutdown…
    shutdown /s /t 60
    ))
    ) ELSE (
    echo Encoding in Progress!
    )
    )
    Ping -n %INTERVAL% Localhost >NUL
    GOTO :LOOP

    Hope you will find it useful.
    LT

  • Oki Pienandoro

    May 17, 2016 at 4:13 am

    Can you post the bat file?
    I can’t get it to work (AME CC 2014)

    ——————————————
    Sorry for the english, not native speaker.

  • Luca Terzi

    May 17, 2016 at 7:27 am

    Hi,

    Indeed I completely changed everything time ago, but I forgot to post it here.. But this time I did it with PowerShell ISE.

    Now it checks the total load of the CPU and it shuts down the computer if the load is lower than 20% (in this case).
    If it detects that the CPU works under the 20% then it checks it again after 60 seconds (in this case), and in case it’s not loaded it shuts down AME and then the computer:

    # Set the policy otherwise it will not run
    Set-ExecutionPolicy Bypass -Scope CurrentUser

    # Close the programs before to check the use of the CPU
    Write-Host “Closing Skype..”
    Get-Process -name Skype -erroraction silentlycontinue |
    Stop-Process
    Write-Host “..DONE”

    # Minutes to wait before checking the CPU’s load
    $time = 60

    Start-Sleep -s $time

    # Load reference percentage:
    $ref = 20

    $cpu = Get-WmiObject -class Win32_Processor |select LoadPercentage
    $load = $cpu.LoadPercentage

    while ($load -gt 0)
    {
    # Get the current load of the cpu
    $cpu = Get-WmiObject -class Win32_Processor |select LoadPercentage
    $load = $cpu.LoadPercentage
    Write-Host “$load %”

    # If the cpu works under the reference number check if it’s really finished and in case shutdown the pc
    if ($load -lt $ref) { Write-Host “Encoding Finished?”
    Start-Sleep -s $time
    # Get the current load of the cpu, again..
    $cpu = Get-WmiObject -class Win32_Processor |select LoadPercentage
    $load = $cpu.LoadPercentage
    Write-Host “$load %”
    if ($load -lt $ref) { Write-Host “Encoding Finished!”
    Write-Host “Closing Adobe Media Encoder…”
    Get-Process -name ‘Adobe Media Encoder’ -erroraction silentlycontinue |
    Stop-Process
    Write-Host “..DONE!”
    Start-Sleep -s 15
    Write-Host “Now sleep..”
    Stop-Computer
    Start-Sleep -s $time
    }
    }

    else { Write-Host “Encoding in Progress!”
    Start-Sleep -s $time
    }
    Clear-Host
    }

  • Oki Pienandoro

    May 17, 2016 at 9:11 am

    This is the fastest reply i ever came across from an old thread !
    Thank you.

    Couple of question,..
    1. I try to run it on idle/working AME, and the script simply close again. Where did i do wrong ? I copy paste the script into PowerShell ISE, save it then run it.
    2. Why there is a function to close Skype ?
    3. Is it possible to check the upload status in published option jobs?
    4. Can it be used/expand to sent email using SendEmail ?
    https://caspian.dotconf.net/menu/Software/SendEmail/

    Also, i came across this command couple of hours ago(but i translate it into english), from German YouTube:
    https://www.youtube.com/watch?v=NiZn8VN5YTE

    Basically the way it works is by checking whether the dummy files (sd.*) is created (we put a “fake” render at the end of job queue).
    After the dummy file is created, it execute the shutdown command. So it’s not a guess work based on CPU load.
    I also add a line to sent an email using the SendEmail app that i posted above (i wish it can sent just the URL), i use a workaround to sent an AMEEncodingLog.txt.txt files instead. Not pretty.

    It works wonderful, but this one has limitation to expand the script beyond this.
    While your script i believe can be expanded to any program that heavily utilize CPU load, right ?

    @echo off
    title AME Auto Shutdown

    :A

    if exist sd.* goto TRUE

    echo.
    echo Date: %date%
    echo Time: %time%
    echo.
    echo State: Renders.
    echo.

    ping /n 2 localhost >nul

    cls

    goto :A

    :TRUE
    echo.
    color 0c
    echo Date: %date%
    echo Time: %time%
    echo.

    echo The PC has been shut down successfully on %date% at %time% ! >> log.txt

    echo Status: RENDERING FINISHED!
    echo.
    echo PC will shut down in 60 seconds!
    echo.

    shutdown /f /s /t 60

    pause >nul

    cls

    ——————————————
    Sorry for the english, not native speaker.

    Some contents or functionalities here are not available due to your cookie preferences!

    This happens because the functionality/content marked as “Google Youtube” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

  • Luca Terzi

    May 17, 2016 at 9:26 am

    I did it with Windows 7 and I just tried it with Windows 10 and it works perfectly, how did you save the file? Mine has extension .ps1

    There is a function to close skype because I wanted like this in my computer 🙂

    Unfortunately I don’t know how to check the upload status.

    For sending an email you have to implement this: https://technet.microsoft.com/en-us/library/hh849925.aspx

    Last but not least, yes, it checks only the load of the CPU, not AME directly (but with an encoding program such as AME is very effective because the CPU usage drops to very few percentage points after the program finishes to encode a video).

Page 2 of 2

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy