Skip to content

Instantly share code, notes, and snippets.

@Black-Platypus
Black-Platypus / ffmpeg_target_size.cmd
Created September 26, 2021 18:08
Windows Script: FFMPEG video compression/specific file size
@echo off
REM Windows implementation of Marian Minar's answer to "ffmpeg video compression / specific file size" https://stackoverflow.com/a/61146975/2902367
SET "video=%~1"
SET "target_video_size_MB=%~2"
SET "output_file=%~dpn1 %~2MB.mp4"
REM I usually don't see a big difference between two-pass and single-pass... set to anything but "true" to turn off two-pass encoding
SET "twopass=true"
REM We need a way to do floating point arithmetic in CMD, here is a quick one. Change the path to a location that's convenient for you
set "mathPath=c:\bin\Math.vbs"
REM Creating the Math VBS file
@Black-Platypus
Black-Platypus / RegExMatches.vbs
Last active August 21, 2021 01:17
VBA: get RegEx matches as simple Array, using /pattern/[flags] syntax
' About: https://www.reddit.com/r/vba/comments/p8i523/code_vba_function_get_regex_matches_as_array/
Function matches(ByVal text As String, pattern As String) As Variant()
Dim allMatches As Object, flagMatches As Object
Dim RE As Object, FRE As Object, fGlobal As Boolean, fIgnoreCase As Boolean, fMultiLine As Boolean
Set RE = CreateObject("vbscript.regexp")
' Check for slash delim syntax with optional flags, like /pattern/[flags]
Set FRE = CreateObject("vbscript.regexp")
FRE.pattern = "^\/(.+)\/([gmi]*)$"
FRE.IgnoreCase = True
Set flagMatches = FRE.Execute(pattern)