Help me write a batch script for HandBrake/IFME

Mike2046

Junior Member
Oct 21, 2017
1
0
1
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 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 TEMPfolder, 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 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 TEMP folder
  • Once the encoding completes successfully (maybe use ERRORLEVEL here?), replace the original file with the encoded one.

Can this be done?

I've been using IFME mainly. Here's the encoding details (copied from IFME console):

"C:\Users\Mycroft\Desktop\release-ifme7\plugin\ffmpeg64\ffmpeg" -hide_banner -v error -i "E:\test.mp4" -strict -1 -map 0:2 -f yuv4mpegpipe -pix_fmt yuv420p -s 672x288 -r 32.125 - | "C:\Users\Mycroft\Desktop\release-ifme7\plugin\video.x265gcc\x265-08" - --y4m -p medium --crf 26 -t psnr --output-depth 8 -f 12675 -o video0000_eng.h265
y4m [info]: 672x288 fps 257/8 i420p8 sar 1:1 unknown frame count
raw [info]: output file: video0000_eng.h265
x265 [info]: HEVC encoder version 2.5+13-ed2fd6c3b8d7
x265 [info]: build info [Windows][GCC 7.1.0][64 bit] 8bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
x265 [info]: Main profile, Level-2.1 (Main tier)
x265 [info]: Thread pool created using 4 threads
x265 [info]: Slices : 1
x265 [info]: frame threads / pool features : 2 / wpp(5 rows)
x265 [warning]: Source height < 720p; disabling lookahead-slices
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
x265 [info]: ME / range / subpel / merge : hex / 57 / 2 / 2
x265 [info]: Keyframe min / max / scenecut / bias: 25 / 250 / 40 / 5.00
x265 [info]: Lookahead / bframes / badapt : 20 / 4 / 2
x265 [info]: b-pyramid / weightp / weightb : 1 / 1 / 0
x265 [info]: References / ref-limit cu / depth : 3 / on / on
x265 [info]: AQ: mode / str / qg-size / cu-tree : 1 / 0.0 / 32 / 1
x265 [info]: Rate Control / qCompress : CRF-26.0 / 0.60
x265 [info]: tools: rd=3 rskip signhide tmvp strong-intra-smoothing deblock sao​

Unlike the test video here, most of the videos I want to encode are `H264 - MPEG-4 AVC (part 10) (avc1)` with at least 720p resolution (as shown in VLC Codec Info.) Is this optimal, or can I tweak it to make it better without increase in size? And what would be the equivalent command line parameters for Handbrake?

Looking forward to any help.