Skip to main content

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