Upload iOS screen recording to Mastodon

1 Terminal command to showcase your recordings from Simulator

·

3 min read

Error 422 NxN videos are not supported

You've made the move to Mastodon, and now you want to share a video of your new iOS feature. But Mastodon refuses to attach your uploaded video!

Before I explain why, I want to rant a bit to the Mastodon devs.

This error message is hard to find. It's buried in the bottom left corner and in dark mode, it blends in with everything around it, so it's easy for users to miss.

Why is this happening? Mastodon has a resolution limit on videos and the recording from Simulator is too big in terms of pixels.

What's more frustrating is that this resolution is undocumented. The official Mastodon documentation only mentions the accepted file formats, encodings, and file sizes.

Videos (MP4, M4V, MOV, WebM) up to 40MB. Video will be transcoded to H.264 MP4 with a maximum bitrate of 1300kbps and framerate of 60fps.

Thanks to some helpful blog posts, we know this resolution to be 1920 x 1200.

At the time of this writing, the resolution of the video that Simulator 14.3 recorded from an iPhone 14 Pro was 1178 x 2556. Way too tall!

Terminal to the rescue

ffmpeg -i input.mp4 -vf scale=-2:1200 -vcodec libx264 -crf 31 -b:v 1300k output.mp4

scale=-2:1200 is the key part in this command.

  • -2 tells FFmpeg that we don't care what the width is; just make sure it's a multiple of 2 (explanation below) and keep the resolution proportional to the original.

  • 1200 says we want the maximum height of the video to be 1200 pixels

When all goes well, your output.mp4 will have a resolution somewhere around 554 x 1200.

Installing FFmpeg

FFmpeg is a 3rd party package and doesn't come standard on Mac, so you'll need to install it.

I like using homebrew, so all I ran was...

brew doctor
brew install ffmpeg

Why a multiple of 2?

In my own search for a solution, I found and ran Jacob Tender's terminal command. FFmpeg threw an error that said something like "width not divisible by 2." A helpful StackOverflow answer said to try -2 for one of the scale dimensions.

Sure enough, a check of the FFmpeg docs confirms this:

Some codecs require the size of width and height to be a multiple of n. You can achieve this by setting the width or height to -n:

Maybe it's time for an app?

Interesting we find ourselves here.

Twit-hurt refugees flocking to Mastodon, a haven for techies.

Undocumented video dimensions and baffling error messages from this supposedly tech-friendly space.

Sure we can get a subscription to a 3rd party Mastodon client, but at the same time, who knows when Mastodon will get around to providing free downscaling of videos. I can imagine video crunching is not something they want their servers to handle.

Could a Safari extension do this for us?