Convert video for Twitter
Published on Oct 11, 2022If you want to post a video on Twitter there's a few rules that are important for the video to be accepted.
Unfortunately the interface will only show "The video file is not compatible" while only the actual API request in the background will tell you exactly what is wrong. If you know where to look, that is.
On of the rules is a max frame rate of 60fps. If your video has more you have to change that.
First, extract the raw bit stream
ffmpeg -i your-high-framerate-video.mp4 -c copy -f h264 raw-stream.h264
Remux that back into a new mp4 container
With the -r
flag we can set frame rate (Hz value, fraction or abbreviation)
according to the documentation.
ffmpeg -r 60 -i raw-stream.h264 -c copy your-60-fps-video.mp4
Upload
Now we can upload the video to Twitter. If you want to know what's the real reason your video doesn't work you can check that in the network inspector. Look for the request hitting the upload.json
endpoint.
This is one of these posts I'm writing for myself so future-me can copy paste from here.