After my deep focus writing sessions in Obsidian, I record what I want to share with the world of my slightly funny life (with ShareX or Snipping Tool).
Once I’m done with that, I paste the video into the note. This embeds it as:
![[note-title_video_1.mp4]]
(The video file is automatically renamed to the syntax above via the Attachment Name Formatting plugin and is moved to my images folder)
Next, I run a shell command to compress the video because you don’t want to download 150MB of me yabbing about some random stuff.
Below is the compression command:
# change current directory to image folder
cd "{{vault_path}}/40-Assets/images/"
# compress {{title}}_video_1.mp4 to {{title}}-compressed_video_1.mp4 via ffmpeg
ffmpeg -i "{{title}}_video_1.mp4" -vcodec libx264 -crf 23 -acodec aac -b:a 128k -map_metadata 0 "{{title}}-compressed_video_1.mp4"
# delete {{title}}_video_1.mp4`
Remove-Item -Path "{{title}}_video_1.mp4"
({{vault_path}}
and{{title}}
are variables automatically populated at runtime.)
Then I add a custom shortcode to where I’d place the video.
For example, this:
{{< html-video src="add-videos-to-post-compressed_video_1.mp4" type="video/mp4" >}}
Renders:
And there we have it!
Granted, this isn’t some mind-blowing workaround. It’s just something I was excited to try.
Wanna know what makes this even better? With a single command, I can delete the compressed video, and other attachments from the vault, keeping it nice and tidy.
Pretty cool.
Reply by Email