How to generate a notifications once Handbreak finished its current work?

When I create trainings I normally record them and hand them out to the users who attend the training, so they can watch them again. The issue here is that the software I´m using here couldn´t make use from H.265 (x265) so I need to use Handbreak here to convert that. Unfortunately handbreak do not come up with any notification features to inform me when it finished his work (and depending on the training it sometimes has 3-5 hours of video material to work with). So its I time to build something to fill the gap.

Currently the Open Source Video Transcoder handbreak 1.0.7 (https://handbrake.fr) do not offer a notification features. So if a queue is finished there is no way to inform you. However in the preferences it has a feature called "Send File to" which can be used to do anything we need here and would require only some lines of code. However storing the password as plain text inside the powershell script, so that it would be very easy for everyone (3rd party persons, trojan, virus, ...) to capture that is a very bad approach, we need to involve the Convert​From-​Secure​String here, which according to Microsoft ConvertFrom-SecureString make use from from DPAPI and encrypts the password so that it can be only read on that machine (keep noted that a 3rd party persons, trojan, virus, ... can decrypt the password on the machine as well, so its only a security layer and no 100% secure solution). It might therefore also a good idea to build a 2nd mailbox here which will only be used to send out such notifications.

So if you wish to send an email once handbreak is finished and / or play an sound do the following:

1.) Make sure that you at least run powershell 3.0 (would prefer if you update to powershell 5.0 / Management Framework 5.0 via the download here). You can check the version you are currently running via:

$PSVersionTable.PSVersion

2.) Start a powershell (run as admin) and enter the following:

Set-ExecutionPolicy Unrestricted

Otherwise we need to sign our script and without that option it will not work then.

3.) Then inside powershell navigate to your script folder (if you do not have a Scripts create one)

7.) Now we need to test out script. Sometimes a antivirus client might block outgoing email connections. Then the script would fail and we need to configure it correctly. To test the script use the still open powershell prompt, and navigate to the scripts folder (e.g. C:\Scripts) then run:

.\HandBreak-Notify_Plugin.ps1

8.) Now open handbreak, click on tools -> Preferences -> General

9.) mark the "send file to" option, then browse to "C:\Windows\System32\WindowsPowerShell\v1.0\" and select the powershell.exe

10.) In the arguments dialog inside HandBreak enter:

-Command C:\Scripts\Handbreak-Notify_Plugin.ps1

11.) Test your solution with a small movie. Once it finished you should see that a powershell windows popup and then quickly disappear (if everything is working as expected). During that an email is generated and some sound appears.