I tried adding a video to a tweet. A video I encoded myself with ffmpeg. I chose what I thought were sane and common parameters (mainly ffmpeg defaults), also sane aspect ratio and resolution and so on.
Yet, no matter what I tried, I got the following error message when trying to send the tweet :
“Your video file could not be processed. Please see tips for upload videos.”
The error message linked to a rather unspecific help page showing constraints with respect to resolution, frame rate, aspect ratio — but the video I was trying to upload seemed to meet all those listed criteria.
I found other people’s ramblings about the above error message, but all these resources were not really offering a precise understanding:
I looked for further documentation and then found https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/uploading-media/media-best-practices which has a section “Video specifications and recommendations”. I double-checked things like pixel aspect ratio etc, and then I found two more rather rather specific criteria:
- “Only YUV 4:2:0 pixel format is supported”
- “H264 High Profile” (emphasis mine)
I was indeed using the “high” profile (see this for learning more about these profiles). However, I noticed that all files I tried to upload used the yuv444p pixel format, as shown by this line of output of
Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444p, 1280x720 [SAR 1:1 DAR 16:9], 271 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
So, I followed this lovely resource and added the following command line flags to
ffmpeg to explicitly set the profile
High, level 4.0, and to set the pixel format to yuv420p:
-profile:v high -level:v 4.0 -pix_fmt yuv420p
With these choices,
Video: h264 (High) (avc1 / 0x31637661), yuv420p
and Twitter accepted my H.264 video. Hope this helps!
By the way, the following resources help understanding the role of the pixel format and also the differences between yuv444 and yuv420: