1.    4 Weeks Ago #1
    Join Date : Jun 2016
    Posts : 5
    Windows 10 Professional

    A Powershell Script for HandBrake


    Here's the thing. My system is an age-old i3-530 overclocked to 3.5GHz coupled with GTX 1050 2GB. I have around 1.5TB of tutorial videos that I have to encode due to dearth in HDD space. I want to encode the videos while keeping the folder and subfolder structure intact.

    Here's the problem though. Since my system is overclocked, I sometimes get
    Code:
    BSOD
    with IFME. And when I run Handbrake GUI, sometimes it stops working. The difference is that in case of IFME, the incomplete file is in a
    Code:
    TEMP 
    folder, whereas it's pretty darn hard to differentiate between an incomplete and a complete output of HandBrake.

    Here's what I want to do. I want to run a
    Code:
    Powershell
    script (I'm a Windows 10 x64 user), which will do the following -


    For each .mp4 in given folder:


    • Run IFME/Handbrake with proper arguments with output file in a
      Code:
      TEMP
      folder
    • Once the encoding completes successfully (maybe use
      Code:
      ERRORLEVEL
      here?), replace the original file with the encoded one.


    Can this be done?
      My ComputerSystem Spec
  2.    4 Weeks Ago #2
    Join Date : Jun 2014
    Posts : 543
    Microsoft Windows 10 Pro 64-bit

    Why not just set the CPU to where it should be and see if the problem stop's.
      My ComputerSystem Spec
  3.    4 Weeks Ago #3
    Join Date : Aug 2016
    S/E England
    Posts : 4,515
    10 Home x64 (1709) (10 Pro on 2nd pc)

    Quote Originally Posted by sml156 View Post
    Why not just set the CPU to where it should be and see if the problem stop's.
    I agree.


    Quote Originally Posted by Mycroft2046 View Post
    I have around 1.5TB of tutorial videos that I have to encode due to dearth in HDD space...


    On another note, I have similar space concerns, so I have looked for the most compression I can get away with without noticeable quality loss. It's not the size of the original files that you should be looking at, rather the duration of the videos that's the determining factor.

    I use the free Open Source command line utility FFmpeg for my processing. The settings I use are:
    Codec: X.264 with Constant Rate Factor (CRF) of 28, preset 'veryslow' and tune 'film' (for live action) or 'animation' (if your tutorials are slideshows). This produces about 200MB for an hour of live action video (less if there's little action taking place). These settings are also available in Handbrake, just choose the H.264 codec to access them.

    If you want to script your conversions, FFmpeg (as it's used from a command line) may be easier to set up. a typical command line would be:

    FFMPEG -i input.mp4 -crf 28 -preset veryslow -tune film output.mp4
      My ComputersSystem Spec
  4.    4 Weeks Ago #4
    Join Date : Jun 2016
    Posts : 5
    Windows 10 Professional
    Thread Starter

    Quote Originally Posted by sml156 View Post
    Why not just set the CPU to where it should be and see if the problem stop's.
    Unfortunately, it doesn't. I've tried to run them in stock settings, but that doesn't work as well. And I only get problems with IFME or Handbrake. I regularly use 7Zip to compress files of size 2GB, or run multithreaded Python scripts that push the CPU to the extreme, but no problem occurs then.
      My ComputerSystem Spec
  5.    4 Weeks Ago #5
    Join Date : Jun 2016
    Posts : 5
    Windows 10 Professional
    Thread Starter

    Quote Originally Posted by Bree View Post
    I agree.




    On another note, I have similar space concerns, so I have looked for the most compression I can get away with without noticeable quality loss. It's not the size of the original files that you should be looking at, rather the duration of the videos that's the determining factor.

    I use the free Open Source command line utility FFmpeg for my processing. The settings I use are:
    Codec: X.264 with Constant Rate Factor (CRF) of 28, preset 'veryslow' and tune 'film' (for live action) or 'animation' (if your tutorials are slideshows). This produces about 200MB for an hour of live action video (less if there's little action taking place). These settings are also available in Handbrake, just choose the H.264 codec to access them.

    If you want to script your conversions, FFmpeg (as it's used from a command line) may be easier to set up. a typical command line would be:

    FFMPEG -i input.mp4 -crf 28 -preset veryslow -tune film output.mp4
    Since most of my tutorials are screen grabs, I think they are comparable to slideshows. How does animation preset work with slideshows? Is sharpness of the texts affected?
      My ComputerSystem Spec
  6.    4 Weeks Ago #6
    Join Date : Aug 2016
    S/E England
    Posts : 4,515
    10 Home x64 (1709) (10 Pro on 2nd pc)

    Quote Originally Posted by Mycroft2046 View Post
    Since most of my tutorials are screen grabs, I think they are comparable to slideshows. How does animation preset work with slideshows? Is sharpness of the texts affected?
    No. Details are preserved as much as possible, they are the last thing to be affected at higher CRF values. It appears to be large areas of a single colour which 'animation' tuning takes advantage of to reduce the filesize. That, and the fact that an animation will have several consecutive identical frames. For 'film' tuning it appears to be fast motion where the tuning get's its savings.

    Either way, tuning is the (optional) icing on the cake - for a particular type of video tuning can get you a little bit extra compression for a given CRF value, it's by increasing the CRF that the biggest savings are found.

    The preset works by allowing more (or less) time to process each frame. For a given CRF using veryslow gives the best perceived quality and the smallest filesize, while ultrafast makes larger files with noticeable compression artefacts (useful for a quick test of other settings, but not recommended for a video you want to keep).

    You can experiment with different CRF levels. More info on CRF, tuning and preset here...
    ...a subjectively sane range is 18-28...
    ...The range is exponential, so increasing the CRF value +6 is roughly half the bitrate while -6 is roughly twice the bitrate. General usage is to choose the highest CRF value that still provides an acceptable quality. If the output looks good, then try a higher value and if it looks bad then choose a lower value.
    https://trac.ffmpeg.org/wiki/Encode/H.264
    (this FFmpeg documentation is equally applicable to Handbrake, the settings are standard H.264 ones)
    Last edited by Bree; 4 Weeks Ago at 13:36.
      My ComputersSystem Spec

 


Similar Threads
Thread Forum
How to automatically (cmd/powershell script) unpin all apps in start
Hi. I would like to automatize cleaning the Windows 10's start menu from all these default pinned apps that I'm not using. I don't want to remove apps, only unpin from from start. I tried to google help, but didn't find any. There seems to be...
Customization
Windows Script Hoist - no script engine for file extension .js
I am using Windows 10 Home on a HP i3 laptop. Just recently I have started receiving an error pop-up which says "Windows Script Host - There is no script engine for file extension ".js"". There doesn't seem to be a pattern to when the error...
General Support
Solved Problem Getting a Powershell Script to Run in Task Scheduler
Hope I'm in the right place! I am trying to get a Powershell script to run daily in the task scheduler. It basically purges a folder on one of my drives: Get-ChildItem –Path “D:\Dropbox\Quicken\Backup” –Recurse | Where-Object CreationTime...
Software and Apps
Customization PowerShell Script - Add to New Context Menu in Windows 10
How to Add Windows PowerShell Script to New Context Menu in Windows 10 A .ps1 script file is a text file that contains one or more Windows PowerShell commands or expressions. A .ps1 file will open with Notepad by default. To run a .ps1 file with...
Tutorials
General Tips Change PowerShell Script Execution Policy in Windows 10
How to Set PowerShell Script Execution Policy in Windows 10 The PowerShell script execution policy enables you to determine which Windows PowerShell scripts (if any) will be allowed to run on your computer. Windows PowerShell has four different...
Tutorials
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 11:56.
Find Us
Twitter Facebook Google+ Ten Forums iOS App Ten Forums Android App



Windows 10 Forums