How do I upload videos up to 2 minutes in length?
See original GitHub issueHello! As twitter API documentation says that videos should meet the following criteria in order to be uploaded:
- Duration should be between 0.5 seconds and 30 seconds (sync) / 140 seconds (async)
- File size should not exceed 15 mb (sync) / 512 mb (async)
I am able to upload such videos manually but when I use this code to upload larger videos I get
twython.exceptions.TwythonError: Twitter API returned a 400 (Bad Request), An error occurred processing your request.
I use the following code:
video = open('9.mp4', 'rb')
response = twitter.upload_video(media=video, media_type='video/mp4', check_progress=True)
twitter.update_status(status='check out this video', media_ids=[response['media_id']])
It works fine for uploading videos that are shorter than 30 seconds. Never had any problems with the video size as well, been able to upload videos that are larger than 15 MB. So the only problem I am still having is that I am unable to upload videos longer than 30 seconds using twython (I am able to upload these videos manually via twitter website).
Any advice and suggestions will be greatly appreciated!
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5
Found the answer to this here https://github.com/ryanmcgrath/twython/issues/432 you just have to add
media_category='tweet_video'
to your upload arguments examplevideo = open(video_path, 'rb') response = twitter.upload_video(media=video, media_type='video/mp4', media_category='tweet_video', check_progress=True)
Thank you! I can confirm that using the code you posted I can now post videos of up to 2:20 in length.
I think this is the limit of the Twitter API.