Video uploads: Supported codecs

media
video

#1

For this sample video http://t.co/58WwGRvzp5, the FINALIZE command returns Unsupported video. What codecs (or other format requirements) are to be followed in order for the POST media/upload (chunked) API method to accept it as being a valid video?


#2

Today we added video specifications and recommendations to the Uploading Media guide. However, I am seeing the same unsupported video message for the sample video and have inquired with the media platform as to why this is the case.


#3

Thanks Jon for the docs update. Let’s wait and see what the media platform team says.


#4

Thanks for adding the size recommendations and limitations :slight_smile:

However, I still don’t see anything about which codecs Twitter accepts. The original announcement only said that for MP4 format the H264 video codec was required. What about audio and subtitles? The most common audio codec used with MP4 seems to be AAC. Is that a requirement, or are other codecs acceptable too? Are subtitle tracks allowed at all (seeing as you reencode to WebM format, which doesn’t support subtitle tracks yet)? If they are, should they be in TTXT or SRT format?

For WebM the format specification is a little more restrictive than for MP4. Do you support both VP8 and VP9 video codecs? Both Opus and Vorbis audio codecs?

Are there any other video/audio encoding requirements other than the size restrictions listed on https://dev.twitter.com/rest/public/uploading-media ? Do uploads need to be optimized for streaming (not sure that’s necessary at these small sizes)?

Does Twitter always reencode the original upload? Or only make additional versions (i.e. the original will be available unaltered)?

Sorry to be a bother ^_^; I’d just like to see all the requirements and restrictions made explicit instead of having to figure things out through trial&error.


#5

Media Platform has mentioned that they support mono and stereo audio at this time. The Big Buck Bunny video is unsupported since it has 5.1 audio. I will add this constraint to our documentation.


#6

Well, no reply during the weekend means I experimented a bit myself.

It looks like for MP4 container format the requirements are H264 video codec set to Main or Baseline profile, and AAC audio codec set to LC profile. An upload with H264/High and AAC/HE was rejected, but I didn’t dig deeper to find out if it was one or both settings that caused the rejection. I also haven’t looked into bitrate restrictions.

All media are reencoded on Twitter’s end, even if they match exactly with what Twitter itself produces qua codec/profile/bitrate/resolution. Several video resolutions are produced, 1280×720, 640×360 and 320×180 for 16:9 aspect ratio, and 480×360 and 240×180 for 4:3 aspect ratio (maybe there’s a 960×720 too; didn’t test). It seems that uploaded video resolutions that don’t match these are reduced to the next lower one. REST output always reports the same bitrates, but actual bitrates vary quite a lot. I’d estimate the average to be ~3.33b/px/s for the middle resolutions. The 1280×720 resolution has a H264 Main profile, the middle ones have a Baseline profile (and a level of 2.1, if that’s interesting for anyone).

Since everything is reencoded anyway, it’s probably best to upload in the highest resolution and quality available, and not try to match Twitter’s output. I just tested a small video that ended up larger than the original, but (obviously) looked worse. The reencoding also doesn’t copy any metadata, so it’s pointless to add tags like title, author, cover art, copyright or language :confused:


#7

Am I correct that the audio bit-rate of the video file is also one of the criteria? I tried uploading a bunch of videos with 44.1kbps audio bit-rates and received “Unsupported video.” error, while similar video formats with audio bit-rates higher than 48kbps were accepted.