Wednesday, January 10, 2018

How can I get a bigger Twitter Video size from the API?

Leave a Comment

When doing a search via the Twitter API, I get URLs to only small videos, for example:

u'video_info': {u'aspect_ratio': [1, 1],                 u'duration_millis': 98615,                 u'variants': [{u'bitrate': 320000,                 u'content_type': u'video/mp4', u'url': u'https://video.twimg.com/ext_tw_video/944064088308510720/pu/vid/240x240/Dbol1j YzSdt5A9Pi.mp4'},                {u'content_type': u'application/x-mpegURL', u'url': u'https://video.twimg.com/ext_tw_video/944064088308510720/pu/pl/6iSBw8vIHgtISD_ 1.m3u8'}]}}]} 

The video is only 240x240

How can I get a bigger version for resizing?

2 Answers

Answers 1

I think you're looking for the Media Size Objects

All Tweets with native media (photos, video, and GIFs) will include a set of ‘thumb’, ‘small’, ‘medium’, and ‘large’ sizes with height and width pixel sizes.

Also look at the overall Media Objects:

The entities section will contain a media array containing a single media object if any media object has been ‘attached’ to the Tweet. If no native media has been attached, there will be no media array in the entities. The has:media Operator will match if this array is populated.

Ideally your code should check which media sizes exist and use whichever suits your site the best, since you can't rely on all of the sizes being there all the time.

Answers 2

Are you able to provide any more information about the specific Tweet ID you're trying to retrieve? maybe it does not have any larger video size available?

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment