Christian Heilmann

You are currently browsing the archives for the General category.

Archive for the ‘General’ Category

Lossless Cut is my new favourite tool to cut parts from a video without any hassle

Saturday, October 7th, 2023

Lossless cut with a video with defined in and out cutpoints

Lossless Cut is probably the simplest way to cut out parts of a video without having to re-encode it or use an online service. It is open source, free and available for all platforms. It is in essence a frontend for FFMPEG and cuts without re-encoding, so the results are instantaneous.

VideoTap has an amazing feature called Clips, which allows you to highlight parts of the transcript of a video to create shorter videos for social media posts. I got my team on it, but as you pay per minute of converted video it would be wasteful to upload a one hour talk to create a few 15 second videos. So I was looking for simple tools to use and Lossless Cut came up.

Here is how to use it:

  • Download the version you need for your operating system (there are free links to installers, but if you want to support the project, you can also download a $20 version on App Stores)
  • Scrub to the part of the video you want to start cutting a part from
  • Press `I` (for `in`)
  • Scrub to the end part
  • Press `O` (for `out`)
  • Hit the export button

I love that the tool doesn’t re-encode and supports keyboard shortcuts. Another open source alternative for this task that has a lot more features is Openshot which is purely mouse and context-click driven.

I was a guest on the inaugural DevRelShow and chatted about what DevRel is about, my new job at WeAreDevelopers and showed some cool tools

Friday, September 22nd, 2023

Yesterday evening my former colleague Fred Harper invited me to be his first guest on his new DevRelShow. For about 70 minutes we talked about all things Developer Relations, how to get started as a developer advocate and I showed some tools to make it easier for you.

I also covered how I wrote the Developer Advocacy Handbook and how it affected my career.

The tools I talked about were:

  • VideoTap which creates long-form data like blog posts and transcripts from videos as well as automated Tweets and short videos
  • Hemingway a text editor that tells you when your writing is too complex and offers AI generated alternatives
  • FFMPEG to batch convert videos to other formats on the command line

The 10 tools I install on every new Mac I get

Thursday, September 14th, 2023

Picture of tools - a hammer and a spanner

I am currently on a company trip with my brand new MacBook and here are the things I always install first to get started:

  • Homebrew – makes installing of low level stuff a breeze (free)
  • Node/NPM – many things rely on it (free)
  • Dropbox – still be best way to store and share content amongst machines, both Google Drive and Microsoft OneDrive drive me nuts with their file permission nonsense (paid)
  • VLC – plays everything, has excellent keyboard shortcuts and can in a pinch even record screens for you (free)
  • VS Code – coders gotta edit (free)
  • GitHub Desktop – much, much easier than installing and setting up Git yourself (free)
  • ImageOptim – file resizing and optimising images, even on the command line (free)
  • FFMPEG – converts anything to anything on the command line (free)
  • Handbrake – batch conversion of videos made easy (free)
  • Screenflow – my go-to screen recording and video editing tool (paid)

Other essentials are a VPN (I use Mullvad and ProtonVPN), but that’s about it.

Photo by iMattSmart on Unsplash

Podcast: AI solutions need good UX with Chris Heilmann

Wednesday, September 13th, 2023

Logrocket recorded a podcast with me talking about the need for good UX of AI solutions . It is amazing how much opportunities we miss out on by simply trying to copy ChatGPT, not understanding that a faux human chat interaction often only is a flash in the pan success.

I will also cover the same topic at Halfstack Vienna on the 15th of September and you can use my 10% off discount if you still want a ticket.

I will also talk about this in the closing keynote at React Live on the 28-29 of September in Amsterdam. You can use my discount code “chris20” for an additional 20% off there.

Adding sound wave overlays to videos and pictures using FFMPEG

Thursday, August 31st, 2023

In order to fix a broken video where the camera stopped recording, I wanted to replace the part with a video with a sound wave overlay. There are many services for that, and it is also a feature of video editing software. But I am stingy and a geek, so I wanted to use FFMPEG on the command line instead. This also allows for batch processing.

Note: I didn’t embed the videos in this post but GIFs instead. The real videos play the video and audio and the sound wave moves accordingly.

Let’s say this is our original video:

Video of me talking about public speaking

This is what it looked like in the end:

The same video with a sound wave on top of it

Here’s the command I used to create the above version:

ffmpeg -i Understandable.mp4 \
 -filter_complex "[0:a]showwaves=colors=0xff1646@0.3\
 :scale=sqrt:mode=cline,format=yuva420p[v];\
 [v]scale=1280:400[bg];\
 [v][bg]overlay=(W-w)/2:H-h[outv]"\
  -map "[outv]" -map 0:a -c:v libx264 -c:a copy \
  waveform-sqrt-cline.mp4

OK, let’s unwrap this:

  • `Understandable.mp4` is the input file
  • `0xff1646@0.3` is the hexadecimal colour of the waves I want to create. The `@0.3` is the opacity, 30%.
  • The first `scale` is how the bars should be resized to stay in a certain range. I found squareroot to look the best. Other options are available in the documentation
  • `mode` is what soundwave you want. This version, `cline` is a centered, filled line. Other options are `point`, `line` and `p2p`.
  • `scale` is the size of the generated video of the wave, in this case 1280×400 pixels (as the video is 1280×1080)
  • The `overlay` defines where on the background video the wave should appear. In this case centred in the horizontal direction and on the bottom of the video.
  • `waveform-sqrt-cline.mp4` is the name of the final video.

Change location of the sound wave

You can also center the sound wave in both directions using `overlay=(W-w)/2:(H-h)/2`:

ffmpeg -i Understandable.mp4 \
 -filter_complex "[0:a]showwaves=colors=0xff1646@0.3\
 :scale=sqrt:mode=cline,format=yuva420p[v];\
 [v]scale=1280:400[bg];\
 [v][bg]overlay=(W-w)/2:(H-h)/2[outv]"\
  -map "[outv]" -map 0:a -c:v libx264 -c:a copy \
  waveform-sqrt-cline-centered.mp4

And the result looks like this:

Video showing the sound wave in the vertical center

Other sound wave styles

And you can change the output type to line and change the colour:

ffmpeg -i Understandable.mp4 \
 -filter_complex "[0:a]showwaves=colors=0xffffff@0.5\
 :scale=sqrt:mode=line,format=yuva420p[v];\
 [v]scale=1280:400[bg];\
 [v][bg]overlay=(W-w)/2:H-h[outv]"\
  -map "[outv]" -map 0:a -c:v libx264 -c:a copy \
  waveform-sqrt-line.mp4

Video showing the sound wave as lines

This is what the point to point mode looks like:

ffmpeg -i Understandable.mp4 \
 -filter_complex "[0:a]showwaves=colors=0xffffff\    
 :scale=sqrt:mode=p2p,format=yuva420p[v];\ 
 [v]scale=1280:400[bg];\
 [v][bg]overlay=(W-w)/2:H-h[outv]"\
  -map "[outv]" -map 0:a -c:v libx264 -c:a copy \
 waveform-sqrt-p2p.mp4

Video with point to point line

Adding a sound wave to a static image

If you only want the audio from a video and use a background image instead, this is what to use. This creates a 400×400 pixel video with the image as the background and the sound wave on top:

ffmpeg -i Understandable.mp4  -i chris.jpg\
 -filter_complex "[0:a]showwaves=colors=0xff1646@0.3\
 :scale=sqrt:mode=cline,format=yuva420p[v];\
 [1:v]scale=400:400[bg];\
 [bg][v]overlay=(W-w)/2:(H-h)/2[outv]"\
  -map "[outv]" -map 0:a -c:v libx264 -c:a copy \
  static-image.mp4

Soundwave on top of a static image

FFMPEG is amazing

Granted, the syntax of FFMPEG is pretty nuts, but it is also super powerful. Want to know for example how I created the GIFs of this post?

First, I resized all the MP4s in the folder to 1/3 of their size and saved them as small*:

for f in *.mp4 ; \
do ffmpeg -i "$f" -vf scale=w=iw/3:h=ih/3 "small-$f" ;\
done

Then I took those and created gifs

for f in small-*.mp4 ; \
do ffmpeg -i "$f" -sws_dither ed -ss 5 -t 1 "e-$f.gif" ; \
done

In English: Get all small-*.mp4s in the current folder, and create a GIF from second 5 of the video, one second long, using error diffusion.

Automate all the things!

Soundwave from transformers pressing a button