https://github.com/xdevplatform/large-video-upload-python
Sample Python code for uploading video up to 140 seconds and/or up to 512Mb.
https://github.com/xdevplatform/large-video-upload-python
media python twitter-api video video-upload
Last synced: 9 months ago
JSON representation
Sample Python code for uploading video up to 140 seconds and/or up to 512Mb.
- Host: GitHub
- URL: https://github.com/xdevplatform/large-video-upload-python
- Owner: xdevplatform
- License: mit
- Created: 2016-07-06T23:05:55.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-03-29T14:34:18.000Z (almost 5 years ago)
- Last Synced: 2025-02-22T22:51:20.413Z (11 months ago)
- Topics: media, python, twitter-api, video, video-upload
- Language: Python
- Homepage:
- Size: 385 KB
- Stars: 127
- Watchers: 19
- Forks: 50
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Large Media Upload
This Python sample demonstrates the following process of uploading large media (video / GIF / image) files asynchronously with the Twitter API, via the "chunked upload" method.
1. **INIT** media upload.
2. **APPEND** chunked data.
3. **FINALIZE** media uploaded.
4. Check **STATUS** of media processing.
5. Tweet with attached media.
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](https://developer.twitter.com/en/docs/media/upload-media/overview) about the Twitter Media APIs. Pay attention to the other requirements such as encoding, frame size and video formats supported, as these may be reasons for uploads failing at the processing stage.
## Running the sample
1. Install requirements:
```
$ pipenv shell
$ pipenv install
```
2. Fill in your [consumer keys and access tokens](https://developer.twitter.com/en/apps) 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 media file in `async-upload.py`:
```
VIDEO_FILENAME = 'path/to/video/file'
```
4. Run script:
```
$ python async-upload.py
```
Questions? Check our [developer discussion forums](https://twittercommunity.com/c/media-apis).