Post has video

Smol bash script for finding oversize media files

Friday, September 2, 2022 

Sometimes you want to know if you have media files that are taking up more than their fair share of space.  You compressed the file some time ago in an old, inefficient format, or you just need to archive the oversize stuff, this can help you find em.  It’s different from file size detection in that it uses mediainfo to determine the media file length and wc -c to get the size, and from that computes the total effective data rate. All math is done with bc, which is usually installed. Files are found recursively from the starting point (passed as first argument) using find.

basic usage would be:

./ /search/path/tostart/ [min rate] [min size]

The script will then report media with a rate higher than minimum and size larger than minimum as a tab delimited list of filenames, calculated rate, and calculated size. Piping the output to a file, output.csv, makes it easy to sort and otherwise manipulate in LibreOffice Calc.

Save the file as a name you like (such as and # chmod  +x and off you go.

The code (also available here):


# check arguments passed and set defaults if needed
# No argument given?
if [ -z "$1" ]; then
  printf "\nUsage:\n\n  pass a starting point and min data rate in kbps and min size like /media/gessel/datas/Downloads/ 100 10 \n\n" 
  exit 1

if [ -z "$2" ]; then
  printf "\nUsage:\n\n  returning files with data rate greater than default max of 100 kbps  \n\n" 
        echo -e "\n\n  returning files with dara rate greater than " $maxr " kbps  \n\n" 

if [ -z "$3" ]; then
  printf "\nUsage:\n\n  returning files with file size greater than default max of 100 MB  \n\n" 
        echo -e "\n\n  returning files with dara rate greater than " $maxs " MB  \n\n" 

# multipliers to get to human readable values

echo -e "file path \t rate kbps \t size MB"

# search for files with the extensions enumerated below
# edit this list to your needs (e.g. -iname \*.mp3 or whatever
# the -o means "or", -iname (vs -name) means case independent so
# it will find .MKV and .mkv.
# then pass each file found to check if the data rate is 
# above the min rate of concern and then if the files size is 
# above the min size of concern, and if so, print the result
find "$1" -type f \( -iname \*.avi -o -iname \*.mkv -o -iname \*.mp4 -o -iname \*.wmv \) -print0 | while read -rd $'\0' file
    size="$(wc -c  "$file" |  awk '{print $1}')"
    duration="$(mediainfo --Inform="Video;%Duration%" "$file")"
    seconds=$(bc -l <<<"${duration}/${msec}")
    sizek=$(bc -l <<<"scale=1; ${size}/${kilo}")
    sizem=$(bc -l <<<"scale=1; ${sizek}/${kilo}")
    rate=$(bc -l <<<"scale=1; ${sizek}/${seconds}")
    if (( $(bc  <<<"$rate > $maxr") )); then
        if (( $(bc  <<<"$sizem > $maxs") )); then
            echo -e $file "\t" $rate "\t" $sizem

Results might look like

file path 	 rate kbps 	 size MB
/media/my kitties playing.mkv 	 1166.0 	 5802.6
/media/cats jumping.mkv 	 460.1 	 2858.9
/media/fuzzy kitties.AVI 	 1092.7 	 7422.0

Another common task is renaming video files with some key stats on the contents so they’re easier to find and compare. Linux has limited integration with media information (dolphin is somewhat capable, but thunar not so much). This little script also leans on mediainfo command line to append the following to the file name of media files recursively found below a starting directory path:

  • WidthxHeight in pixels (1920×1080)
  • Runtime in HH-MM-SS.msec (02-38-15.111) (colons aren’t a good thing in filenames, yah, it is confusingly like a date)
  • CODEC name (AVC)
  • Datarate (1323kbps)

For example

kittyplay.mp4 -> kittyplay_1280x682_02-38-15.111_AVC_154.3kbps.mp4

The code is also available here.


############################# USE #######################################################
# /starting/path/ (quote path names with spaces)

# No argument given?
if [ -z "$1" ]; then
  printf "\nUsage:\n  pass a starting point like \"/Downloads/Media files/\" \n" 
  exit 1


find "$1" -type f \( -iname \*.avi -o -iname \*.mkv -o -iname \*.mp4 -o -iname \*.wmv \) -print0 | while read -rd $'\0' file
  if [[ -f "$file" ]]; then
    size="$(wc -c  "$file" |  awk '{print $1}')"
    duration="$(mediainfo --Inform="Video;%Duration%" "$file")"
    seconds=$(bc -l <<<"${duration}/${msec}")
    sizek=$(bc -l <<<"scale=1; ${size}/${kilo}")
    sizem=$(bc -l <<<"scale=1; ${sizek}/${kilo}")
    rate=$(bc -l <<<"scale=1; ${sizek}/${seconds}")
    codec="$(mediainfo --Inform="Video;%Format%" "$file")"
    framerate="$(mediainfo --Inform="General;%FrameRate%" "$file")"
    rtime="$(mediainfo --Inform="General;%Duration/String3%" "$file")"
    width="$(mediainfo --Inform="Video;%Width%" "$file")"
    height="$(mediainfo --Inform="Video;%Height%" "$file")"
    $(mv "$file" "$fname$s$width$x$height$s$runtime$s$codec$s$rate$kbps$dot$ext")

If you don’t have mediainfo installed,

sudo apt update
sudo apt install mediainfo
Posted at 10:18:58 GMT-0700

Category: AudioHowToLinuxvideo

South Lake Tahoe Caldor Fire Timelapse

Friday, September 3, 2021 

Sentinalhub Playground is an excellent resource for near real time, albeit not quite google earth 1m resolution, satellite images.  One of the cool features is being able to adjust the mapping of the satellite bands to RGB outputs.  For example, using Sentinel-2 L2A image data of South Lake Tahoe between 2021-08-17 and 2021-09-01 and remapping the 2190nm (SWIR2) to red, which tends to highlight fires though isn’t thermal, 783nm to green, a vegetation band (though it is NIR to humans) to make vegetation cover more obvious, and 443nm to blue instead of 490nm as shorter wavelengths tend to be scattered more by aerosols and smoke the fire line (bright red) and smoke (obvs) is very visible while vegetation is (false) green. Burnt earth shows as dark red, compared to bare ground, which tends to show tan in this mapping, thus revealing the current line of fire, the recently burned areas, and the wind direction carrying smoke, which tends to correlate with the advancing line, and fuel (vegetation) still standing.

Sentinel-2 L2A image on 2021-09-01 if South Lake Tahoe Caldor Fire


Then using the history controller to generate and save a sequence of stills, we can animate the progress of the fire with a simple FFMPEG command:

ffmpeg -framerate 1 -pattern_type glob -i '*.jpg' -vf crop=1754:1146 -c:v libx264 -r 30 -pix_fmt yuv420p fire.mp4

and you get:


Posted at 08:17:00 GMT-0700

Category: EventsGeopostmaptechnologyvideoweather

Kitty Poop

Tuesday, June 27, 2017 

Many years ago (21 years, 9 months as of this post), I used some as-of-then only slightly out of date equipment to record a one week time lapse of the cats’ litter box.

I found the video on a CD-ROM (remember those?) and thought I’d see if it was still usable. It wasn’t – Quicktime had abandoned support for most of the 1990’s era codecs, and as it was pre-internet, there just wasn’t any support any more. I had to fire up my old Mac 9500, which booted just fine after years of sitting, even if most of the rubber feet on the peripherals had long since turned to goo. The OS9 version of QT let me resave as uncompressed, which of course was way too big for the massive dual 9GB drives in that machine. Youtube would eat the uncompressed format and this critical archival record is preserved for a little longer.

Posted at 15:16:46 GMT-0700

Category: catsfilmsfunnyoddself-publishingvanity sitesvideo

Visiting the Burj Khalifa

Saturday, February 2, 2013 

Dubai is an interesting contrast to Iraq. The first time I went through DXB from BSR it was more than a little culture shock. Getting out of the airport only amplifies the experience.

Dubai DSC03683.jpg

Jared and I had dinner at the Mall of Dubai and before eating had a little walk around the fountains – the largest dancing fountains in the world at the foot of the tallest man-made structure in the world.

Dubai DSC03693.jpg

Dubai is an good place to spot cars. Obviously the gold accented rolls is more pose-worthy than the $450k GTO. Then again they were probably posing with the license plate number which I think was 1, and therefore cost as much as 20 Ferrari GTOs.

Dubai DSC03695.jpg
The fire fountains:
[quicktime width=”560″ height=”331″][/quicktime]

Dubai DSC03692.jpg

Posted at 17:58:15 GMT-0700

Category: mapphotoplacestravelvideo

A Very Energetic Band at Borgo a Mozzano’s Halloween

Thursday, November 3, 2011 

This band was playing a small stage along Via Roma at Borgo a Mozzano’s Halloween festival.   I haven’t been able to figure out their name yet (will update when I do).  The singer managed to put out an amazing amount of vocal power from such a small frame.


(on youtube)

Posted at 07:13:14 GMT-0700

Category: Eventsplacestravelvideo

Fantomatik Orchestra at Borgo a Mozzano

Thursday, November 3, 2011 

The Fantomatik Orchestra performing at Halloween at Borgo a Mozzano


That’s our local butcher dancing with the cow’s head and eyeball.

(on youtube the video is available in 1080)

Posted at 04:03:03 GMT-0700

Category: GeopostplacesPositivereviewstravelvideo


Thursday, October 20, 2011 

I went to see Scrapper, the documentary by Stephen Wassmann, that was showing as part of the SF Documentary Film Festival.   It is the story of the people who live between the Salton Sea and the Chocolate Mountain Bombing Range and make a living gathering scrap metal off the range between bombing runs.

It’s quite a frank and intimate portrayal of some extremely eccentric characters.  They spend their time divided between driving around the range gently prying the aluminum tail fins off unexploded ordinance, heating the booty over open fires to loosen the scrap-value-reducing steel rivets, and doing crystal meth and drinking, though the last activity isn’t so much divided from the former two.

The most entertaining character is an old guy who set up camp on the isolated East side of the range, far from humanity, and cruises around the range in a highly modified VW bug living a life pretty much straight out of the Road Warrior.

It is definitely a movie where every moment seems to balance precariously on the edge of a ravine or on a delicate trip wire on a 2,000# bomb that failed to release when it buried itself fins-deep in the desert sand.


Posted at 04:18:18 GMT-0700

Category: filmsGeopostPositivereviewsvideo

Superconducter B-Field Locking

Wednesday, October 19, 2011 


This is super cool.  It is very tempting to imagine magnetic field lines as being  physical wires, the superconductor being a semi-permeable substance through which the mathematical wires can be forced, but not so heavy as to drag itself through them, even flying around the track.

Posted at 03:02:03 GMT-0700

Category: technologyvideo


Friday, May 27, 2011 

Bad video of good guitar at graduation

VID 00010-20110527-2020.3GP

Posted at 20:21:55 GMT-0700

Category: video

Radioactive Mudworms

Monday, May 23, 2011 

[quicktime width=”250″ height=”126″][/quicktime]

I animated Radioactive Mudworms in 1991 with a program called Infini-D.  The soundtrack was courtesy of David Lenat. It was first published on the QuickTime Beta CD to Apple Developers and then in 1992 re-rendered on a Mac IIfx 40mhz 68040 with a massive 16MB of RAM in this version for the FigTime commercial CD. As I remember it, this took about a week to render on that massive machine.  I’m pretty sure I ray-traced it, but I output to “thousands” of colors as required by the CODEC and so it is hard to see some of the details.

The file is so old that the “animation” CODEC used is no longer supported.  I had to boot my old Mac 8600 to read the CD and convert the file to uncompressed, so I could re-compress it with a modern version of QuickTime.  I was greeted with an alert that my last backup was in 2003.  Time flies, but the mac still runs and that OS 9 operating system is still a nostalgic pleasure.  I used it regularly from 1987-ish to 2003-ish, and it is still the OS I’ve spent the most hours in front of.

Digital obsolescence is starting to consume my work history as the past has already eaten the DECstation streaming tapes my MIT work was “archived” on.  Of course, I can still read my preschool notebooks and I’m sure I could still read my parents notebooks.

Infini-D was my favorite 3D program of the time, though it was supplanted by StrataStudio 3D, Turbo-3D, and finally ProEngineer. It had a nice combination of modelling, rendering, and animation tools and was part of a brief “golden era” of 3D most remarkable for VPL and the existential excitement around Virtual Reality.

I was reminded of Radioactive Mudworms as I spent the weekend trying to teach the basics of video compression remotely to some coworkers who may not have been born when I made this.

The video was encoded at Valley Green 6, in the cube farm for the Advanced Technology Group at Apple.

Posted at 04:21:18 GMT-0700

Category: technologyvanity sitesvideo