Skip to content

Unix



Easily convert (some?) AVIs to QuickTime-compatible files

Here's another entry in my "remind myself without searching the entire internet" series of posts. I often want to convert a non-native video into a QuickTime-compatible format. In one oft-repeated use, I have a time lapse camera that outputs AVI files that QuickTime cannot read. Using Don Melton's Other Video Transcoding tools, converting between the two forms is pretty easy:

other-transcode --hevc --mp4 input_file.m4v

The output file will reside in the same directory, with the same name, but with the mp4 extension. I know there are tons of ways to do this, and many offer much more control over the final quality. For my time lapse camera videos, though, the quality is fine and this is really easy to use.



Merge multiple movies into one while minimizing file size

I had two short video clips I wanted to merge into one, each about 8MB in size. I first did this using QuickTime Player's Clips feature, but the end result was over 100MB in size. For my second try, I switched to ffmpeg, which can be installed via Homebrew, MacPorts, or some other method.

This isn't quite as simple as typing one command, as ffmpeg wants to process a list of files to merge—it can't, without some Unix wizardry, accept a list on the command line. So step one is to create a text file (list.txt in my example) in the same directory as your video files. The file contains a list of each movie to be merged, one entry per row, like this:

file '/full/path/to/movie1.mp4'
file '/full/path/to/movie2.mp4'
file '/full/path/to/movie3.mp4'
etc.

Save the text file, then use this command to merge the movies into one:

ffmpeg -f concat -safe 0 -i list.txt -codec copy merged_movie.mp4

When done, you'll have one new movie with all of the listed movies, in the order in which you listed them. And best of all, the size won't balloon when you do so—using the same movies as I used in QuickTime Player, the finished file was just 28MB in size. This isn't limited to mp4s; you can merge any type of video that ffmpeg can handle.

And yes, this is another entry in my series of "remind myself" posts; I originally found the answer on Stack Overflow.



Reverse a video using ffmpeg

This post is another in an ongoing series where the sole point of the post is to make it easier for me to find this information in the future—instead of searching sites and finding tons of wrong answers, I can just search my blog and find the right answer. If it's useful to anyone else, that's a bonus.

Sometimes, I want to reverse a video, usually for humorous effect—to turn a disassembly time lapse video into an assembly time lapse video, for example. If you have ffmpeg installed (via Homebrew or MacPorts or other method), then it's quite simple to do. Here's the command:

ffmpeg -i original_movie.mp4 -vf reverse -af areverse new_reverse_movie.mp4

It doesn't have to be an mp4, of course—any format that ffmpeg can deal with will work fine.

(I originally found this solution on StackExchange.)



Using NUT to monitor a CyberPower UPS in pfSense

This post is probably of interest only to me, and I'm posting it just because I'm getting tired of remembering where I stored this tidbit on my Mac.

Our home router is a Protectli box running pfSense firewall/router software; the Protectli box is connected to a CyberPower UPS. Within pfSense, you can install the Network UPS Tools package (called NUT in pfSense) to monitor and report on the UPS; here's how it looks in the overview screen:

After recently updating to a newer Protectli box, however, all I saw was a message that read "Cannot communicate with UPS" (or something close to that). I knew I had a fix for this issue somewhere, but I couldn't remember where. Today I found it, so also today, it goes on my blog so I'll always know where it is…

[continue reading…]



Convert epoch time to human-readable time in Terminal

This is a stupid-simple Unix tip, posting more as a reminder to myself than anything truly insightful—I keep forgetting these details, so by doing the work to create a post about it, I'll never forget them again…

I've been using unix time from the unix side of macOS quite a bit lately, as it's an easy way to get timestamps for things. Getting the epoch time is easy:

$ date +%s
1641735529

The thing I always forget is how to convert an epoch time back into a human-readable format of my choosing, despite it being shown in the man page. It's simple; use the -r option, like this:

$ date -r 1641735529
Sun Jan  9 05:38:49 PST 2022

And, of course, you can format it how you like using a strftime formatted format string, i.e.

$ date -r 1641735529 "+Today is %A, %B %e, and it's %I:%M:%S %p"
Today is Sunday, January  9, and it's 05:38:49 AM

Related: Yes, I wake up early; it started with macosxhints.com and needing to update the site before I left for my real job each day, and it persists 20 odd years later.



Archiving and version control for Keyboard Maestro

As much as I rely on our own Many Tricks' apps every day, there's one I rely on more: Keyboard Maestro (KM), the macro app for macOS that can do pretty much anything. How much do I rely on it? The shrunken image at right lists all of my macro groups—not macros, just the groups holding the macros. In terms of actual macros, there are over 425 at present. (These are not all user-facing; many are macros that support other macros.)

I use KM for everything from gathering monthly utility bills to inserting HTML code in blog posts to generating replacement license files for users to controlling iTunes to decrufting URLs when copying (future post coming on that one) to automatically naming and filing documents I scan to storing snippets for insertion into our apps' help files to opening oft-used URLs to adding key functionality to many apps such as Excel, Mail, Messages, Photos, Preview, Safari, etc. In short, it's the single most-used app on any of my Macs.

For as much as I love KM, it has one major shortcoming: All of those macros live in one large XML file. Yes, I back it up to many local and cloud locations, so I'm not worried about losing it. It does mean, though, that if I mangle a single macro while trying to fix something, there's no easy way to get back to the working version (assuming I've gone past the point of multiple undo steps).

But now I can recover from such stupidity, thanks to the amazing Macro Repository Suite from Dan Thomas. This suite consists of two macros: One that updates (and initially creates) the repository, and one that restores a given macro from the repository.

[continue reading…]



See dot files at top of ls output in Linux

In Terminal on macOS, the ls (list directory contents) command sorts the output of its "all files" listing so that hidden files (those that begin with a dot) appear at the top of the list, like this:

$ ls -Alh
total 47640
-rw-r--r--@   1 robg  staff    28K Oct 26 15:00 .DS_Store
drwxrwxrwx@   5 robg  staff   160B Oct 23  2016 .TemporaryItems
... [trimmed for display]
drwxr-xr-x    8 robg  staff   256B Sep 19 08:31 .wine
drwx------   13 robg  staff   416B Apr 13  2019 Applications
drwx------+  20 robg  staff   640B Oct 26 12:36 Desktop
... [trimmed for display]

On the server that hosts my personal sites (as well as Many Tricks), however, ls doesn't sort the invisible files to the top:
[continue reading…]



Two silly solutions for creating numeric passcodes

This morning, I was reading about Henrique Prange's friend's stolen iPhone, and the financial damage the thieves inflicted in only a few hours time—yikes! I've got six-digit codes on all my iOS devices, which suddenly felt like not nearly enough.

I also deleted all my iCloud info from the saved website passwords, as explained in Kirk McElhearn's article for Intego. There are some good recommendations there.

Then I set out to change my iOS passcodes…and me being me, I made it way more complicated than it needed to be. But first, a bit about passcodes on iOS…

[continue reading…]



Another way to open stock charts from mop in Terminal

On Sunday, I posted about my geeky solution to my non-functional Stocks Dashboard widget in Mojave. Then earlier today, I crafted a way to view one of the tracked stock's charts with a mouse click.

A commenter asked if there were any way to view the charts using a built-in tool, as purchasing Keyboard Maestro for just this one task is expensive (and a waste of Keyboard Maestro's capabilities). And in reality, when I first started working on my solution, I started in Automator…but quickly grew frustrated by its inability to do even basic text manipulation.

But then today, I remembered I can use AppleScript in Automator to work with the text, and the solution came together quickly after that: A new Service that appears when you right-click on text in a Terminal window:

[continue reading…]