This FFmpeg command reads images named frame_[4 char digit].png and converts it to an mp4 using the h264 encoding which Twitter accepts. The bitrate is set to 5M to reduce blocking as much as possible while keeping the size small.
ffmpeg -framerate 10 -i frame_%04d.png -c:v h264_qsv -b:v 5M video.mp4
ffmpeg -i input.mp4 -c:v h264_qsv -vf: scale=1080:-1 -b:v 5M output.mp4
ffmpeg -i input.gif -c:v h264_qsv -filter_complex loop=loop=<NrOfLoops>:size=<TotalFrames>:start=<FramesToSkip> -b:v 5M output.mp4
ffmpeg -i input.mp4 -vf "select=eq(n\,65)" -vframes 1 output.png
if it complains about MFX error, remove _qsv from h264
twitter still wont accept it though, i think bframes need sanitized somehow especially if converting from webm