Sample Python code for uploading video up to 140 seconds and/or up to 512Mb.
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 2 commits ahead, 2 commits behind twitterdev:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
LICENSE
README.md
async-upload.py
icon.jpg
requirements.txt
screenshot.png

README.md

Large Video Upload

This Python sample demonstrates the following process of uploading large video files asynchronously with the Twitter API.

  1. INIT media upload.
  2. APPEND chunked data.
  3. FINALIZE media uploaded.
  4. Check STATUS of video processing.
  5. Tweet with attached video.

Large video files are longer than 30 seconds up to 140 seconds, and/or a file size larger than 15 megabytes up to 512 megabytes.

Learn more about the Twitter Media APIs. Pay attention to the other requirements such as encoding, frame size and video formats supported.

Running the sample

  1. Install requirements:

    $ pip install -r requirements.txt
    
  2. Fill in your consumer keys and access tokens in async-upload.py:

    CONSUMER_KEY = 'your-consumer-key'
    CONSUMER_SECRET = 'your-consumer-secret'
    ACCESS_TOKEN = 'your-access-token'
    ACCESS_TOKEN_SECRET = 'your-access-secret'
    
  3. Edit path to your video file in async-upload.py:

VIDEO_FILENAME = 'path/to/video/file'
  1. Run script:

    $ python async-upload.py
    

Questions? Check our developer discussion forums.