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
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
My emacs process is then:
open media directory in
sort by size using
C-u s S- the big S is setting the ls format by size
(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 defined
dired-guess-shell-alist-usersetup and then selecting
i(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 through
ffmpegsaves about 80-90% on disk space.
I have my own
ffmpegbash scripts which I call through
dwim-shell-commandso a command search for something like dw sh
my/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 cr
my/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
diredwhich I have mapped to an elisp
my/get-file-sizefunction that runs the
and of course my files can be easily renamed through
As I am using a tiling window manager all of this can be accomplished keyboard only and on a single screen!