Skip to content

File Conversions

Images

For converting images I use ImageMagick on Linux.
I allows converting in batches.
I chose the WebP format because as of 2026, the format is understood by the majority of browsers and programs and is unencumbered by patents and other sorts of legal matters.
Is also supports transparency like PNGs and animations like GIFs.

After some experimentation, I realized that quality setting of 75 is a good compromise, regardless of image size, but for screenshots, where you’d like better readability, the resolution needs to be higher than regular photos. Increasing the quality while keeping the resolution low, did not work as well.

Formats

Here’s what I use:

jpeg

magick mogrify -path ./webp/ -format webp -resize "1024x>" -quality 75 -auto-orient -strip  *.jpg

png ( or generally screenshots)

magick mogrify -path ./webp/ -format webp -resize "1920x>" -quality 75 -auto-orient -strip  *.png

animations:

magick -delay 100 -loop 0 input_frame_*.webp output.webp

Embedding

For the first few weeks I would take screenshots and past them directly into an obsidian document, and then rename them with

for f in "Pasted image "*; do mv -i -- "$f" "${f#Pasted image }"; done

and update the links in the document.

Then I realized I could skip some work and just ask AI (opencode-cli) to do it for me:

🤖 AI prompt

in the md files in this dir, update all image references in wiki style to markdown style, change the extenstion from png to webp and remove “Pasted image” from the file name if they have that prefix

Later I found out that I could also use a convenient obsidian extension to accomplish the same in one go.

Video

Why WebM and not mp4

To be precise, MP4 (.mp4) is a proprietary container format defined by the ISO (International Organization for Standardization). While the specification is public, the technologies inside it (like the H.264/AVC or H.265/HEVC codecs) are heavily patented

WebM was created specifically to provide a high-quality video format that is royalty-free for everyone.
- It is based on the Matroska (.mkv) container.
- It uses the VP8/VP9 or AV1 codecs.
- It is designed to bypass the legal and financial hurdles of MPEG patents.

As of 2026 the support for webM is pretty good, and that’s why I went for it in general.

Conversions

If I really need to use mp4:

ffmpeg -y -i input.mp4 -vf "scale=1024:-2" -an -c:v libx264 -crf 23 -preset medium output.mp4

WebM

ffmpeg -y -i input.mp4 -vf "scale=1024:-2" -an -c:v libvpx-vp9 -crf 35 -b:v 0 output.webm

Smaller WebM

ffmpeg -y -i input.mp4 -vf "scale=1024:-2" -an -c:v libvpx-vp9 -crf 45 -b:v 0 VID_20260214_214214_small.webm

For cropping the video add to the command line (as an example):

-ss 00:00:10 -to 00:00:25

All the snippets include the -an flag to remove the sound, which is not needed most of the times.

Test comparison (all 640x360):
- MP4 (H.264 CRF 23): ~789KB
- WebM (VP9 CRF 35): ~593KB
- WebM (VP9 CRF 45): ~252KB

Embedding

While in obsidian a standard markdown link makes the video playable, when exporting to mkdocs, it doesn’t quite work without extra plugins. Since one can embed HTML inside the markdown file, I found that the following snippet works for both obsidian and mkdocs.

<video width="100%" height="auto" controls muted loop playsinline style="max-width: 800px; border-radius: 8px; border: 1px solid #ddd;">
    <source src="video.webm" type="video/webm">
    Your browser does not support the video tag.
</video>

I created a template for this so that I don’t have to search around every time I want to embed a video.