question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How do I upload videos up to 2 minutes in length?

See original GitHub issue

Hello! 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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

3reactions
princelySidcommented, May 15, 2019

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 example video = open(video_path, 'rb') response = twitter.upload_video(media=video, media_type='video/mp4', media_category='tweet_video', check_progress=True)

0reactions
TariqMKcommented, Aug 21, 2019

Found the answer to this here #432 you just have to add media_category='tweet_video' to your upload arguments example video = 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upload videos longer than 15 minutes - Android - YouTube Help
Increase your video length limit · Open the YouTube mobile app. · Tap Create addition sign and then · Select a video longer...
Read more >
Send Long Videos Without a Video Compressor - Dropbox.com
You can send videos of any length with Dropbox—send a 20 minute video, an hour long video, it doesn't matter. You can create...
Read more >
How to Upload Longer Videos on YouTube 2021
Learn how to upload videos longer than 15 minutes. YouTube Creators can enable their channels for uploading of videos longer than the ...
Read more >
How to Upload Full-Length Videos on Facebook
Video Length Longer Than 20 Minutes · 1. Open your Web browser navigate to YouTube. · 2. Click on the "Increase your limit"...
Read more >
How to Post a Long Video on Instagram: Reels, Stories, Feed
Learn how to share up to 10 minutes of video in one post. ... Option 2: Upload to your Feed with Instagram Video...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found