Skip to main content

Kdenlive for video

I used Kdenlive to make a new Numbas demo video.

I was pleased with how easy it was.

  • Wrote a script, using the old video and the text from the Numbas front page.

  • Did some screen recordings to cover each of the bits.

  • Made 1920×1080 images using the drawings from the front page.

  • Recorded the script in gnome-sound-recorder.

  • Dragged all the files into kdenlive.

  • Cut out just the bits I wanted from the videos and the sound by making zones: play a clip, press I to set the start point, and O to set the end point, then Ctrl-I to save that as a zone.

  • Eventually realised V inserts the selected zone into the timeline.

  • Dragging things around on the timeline is easy. The move tool with M shifts a contiguous block of things around to make space.

  • Worked out that you can trim bits by dragging their sides in the timeline, and add fades or wipes by clicking the dots that appear in the corners of a clip.

Uploading an Ubuntu screen recording to Mastodon or Twitter

I used the new screen recorder in ubuntu 22.04 (I think it's really the Gnome 3 built-in recorder) to record my screen, then wanted to share it on twitter and mastodon.

It produces a webM file with a lot of missing metadata, so I had to convert it. A lot of searching finally got me something that worked.

First, make an mp4 with a fixed frame rate:

ffmpeg -i recording.webm -c:v libvpx-vp9 -minrate 2M -maxrate 2M -b:v 2M -pix_fmt yuv420p -r 16 recording.mp4

This makes something that mastodon will accept. Twitter won't, so you need to convert that. I also had the problem that my video was an odd number of pixels wide, so I did this:

ffmpeg -i recording.mp4 -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" recording.twitter.mp4

Since I'm probably going to do this a few times, I've put these steps in a script in ~/bin/convert-screencast, which finds the most recent recording and converts it to mp4:

#!/bin/bash

LATEST=`ls -tr ~/Videos/Screencasts/Screencast*.webm | tail -1`
OUT=${LATEST%.webm}.mp4

ffmpeg -i "$LATEST" -c:v libvpx-vp9 -minrate 2M -maxrate 2M -b:v 2M -pix_fmt yuv420p -r 16 -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" "${LATEST%.webm}.mp4"
echo $OUT

This site is now sort of static

checkmyworking.com has always been powered by WordPress, but every now and then it’s fallen victim to annoying hacks that manage to write some spam nonsense at the top of all my PHP files. From what I can tell, WordPress and the few plugins I use are such a labyrinthine mess of code that going through and closing security vulnerabilities would be a sisyphean task.

So, I’ve taken the nuclear option – this site, as served to the wider web, is now entirely made up of static files. Hopefully, that’ll stop the hacks – there’s no PHP to abuse, leaving only any vulnerabillities in Apache or Media Temple’s account management as potential ways of getting in.

The static files are generated by Spress, which seems to be one of the least opinionated static site generators I’ve come across. It was very easy to make it produce pretty much exactly the same pages WordPress does.

I still wanted the nice editing interface WordPress provides, so I’ve made a plugin which exports posts from WordPress to the Spress source directory whenever I update them. I’ve got the WordPress installation hidden somewhere private, behind a very simple login script which stands in the way to make sure that nobody else can run WordPress code. This way, I can write posts in WordPress, and the plugin automatically rebuilds the site for me. The one compromise is that I can’t do comments any more – my current line of thought is that I’ll write a script to add comments to the WordPress database which would be simple enough to satisfy myself that it’s more secure than going through WordPress itself.

For the moment I’ve kept the layout of the site as it was, but it’s looking very old now so I’d like to redo it at some point. I don’t really post here any more, so it’s entirely possible that this’ll still be the top post in a few years’ time.

Next job is to do the same thing to The Aperiodical, which will take a lot more work!

Pattern-matching syntax trees

I’m doing some very fun things with pattern-matching syntax trees today.

For context: I write a computer-based assessment system called Numbas, and it’s focused on assessing mathematics. A big part of that assessment involves asking the student to enter an algebraic expression as the answer to a question. How do you decide whether to mark the student’s answer as correct or not? Historically, there have been two approaches, given a representative “correct” expression written by the teacher:

  • Put the student’s answer and the correct answer into a canonical form. If their syntax trees are exactly the same, then the student’s answer is the same as the teacher’s. This is the model used by, for example, STACK.
  • Identify the variables used in the student’s answer and the teacher’s. Pick a few random numbers as values for those variables, and evaluate both expressions. If they come out to the same number, then the student’s answer is the same as the teacher’s. This is the model used by systems in the CALM line.

Read more…