Shrinking Media With The Help Of Emacs
Often I find myself refining my collection of photos and family videos, usually with the following process:
- removing media clutter
- removing any duplicates
- tagging as necessary
- compressing where reasonable
- renaming to a more
denoteformat
Emacs and the associated muscle memory greatly helps with this process.
Firstly though I leverage other applications, for example, duplicate removal and tagging takes place through digikam, media clutter through thunar and gthumb
My emacs process is then:
-
open media directory in
dired -
sort by size using
C-u s S- the big S is setting the ls format by size -
M-<(beginning-of-buffer)- so I can see the largest files -
if I want to squish a video I will probably want to preview it first in mpv, so I do this asynchronously using
&(dired-do-async-shell-command)and relying on my defineddired-guess-shell-alist-usersetup and then selectingi(mpv shortcut) to have a quick peek at the original dimensions. Typically if the video is 1920x1080 then I like to halve the dimensions which when running throughffmpegsaves about 80-90% on disk space.I have my own
ffmpegbash scripts which I call throughdwim-shell-commandso a command search for something like dw shmy/dwim-video-shrinkwill dired execute the file under cursor or over a list of marked files. -
for images I again use
dwim-shell-commandwith a quick command search for something like dw crmy/dwim-picture-crushwhich isn’t always as brutal as it might suggest but a script that I regularly modify when compressing images, setting the compression parameters appropriately.If I need to quickly inspect the image then I could open it in emacs but I prefer again to open in gthumb using
& -
Possibly at the end of a directory compress I might check the directory size by
?indiredwhich I have mapped to an elispmy/get-file-sizefunction that runs theasync-shell-commanddu - -
and of course my files can be easily renamed through
wdired
As I am using a tiling window manager all of this can be accomplished keyboard only and on a single screen!