# shortcap
Add automatic captions to YouTube & TikTok Shorts (and other videos) using Whisper and MoviePy.
## Demo

## Quick Start
Install shortcap:
```bash
pip install shortcap
```
Set required environment variables for OpenAI API:
```bash
export OPENAI_BASE_URL="your_openai_base_url"
export OPENAI_API_KEY="your_openai_api_key"
```
Use the command-line interface:
```bash
shortcap <video_file> <output_file>
```
## Features
- Automatic speech recognition using OpenAI's Whisper
- Customizable caption styling
- Support for local Whisper model or OpenAI API
- Command-line interface and programmatic usage
## Example
```bash
shortcap input.mp4 output.mp4 --font-size 80 --font-color white --stroke-width 2 --stroke-color black --highlight-current-word --word-highlight-color yellow --line-count 2 --verbose
```
## Programmatic Usage
```python
import shortcap
shortcap.add_captions(
video_file="my_short.mp4",
output_file="my_short_with_captions.mp4",
)
```
## Custom Configuration
You can customize various aspects of the captions:
```python
import shortcap
shortcap.add_captions(
video_file="my_short.mp4",
output_file="my_short_with_captions.mp4",
font = "/path/to/your/font.ttf",
font_size = 130,
font_color = "yellow",
stroke_width = 3,
stroke_color = "black",
shadow_strength = 1.0,
shadow_blur = 0.1,
highlight_current_word = True,
word_highlight_color = "red",
line_count=1,
padding = 50,
position = "center"
)
```
The `position` parameter allows you to control where the captions appear on the video.
Vertical position: "top", "center", "bottom", or an integer value
For example:
- `position = "top"`: Centers the text horizontally and places it at the top of the video
- `position = "center"`: Centers the text horizontally and places it at the center of the video
- `position = "bottom"`: Centers the text horizontally and places it at the bottom of the video
- `position = 100`: Centers the text horizontally and places it 100 pixels from the top of the video
The default value is `"center"`, which centers the text both horizontally and vertically.
## Using Whisper Locally
By default, OpenAI Whisper is used locally if the `openai-whisper` package is installed. Otherwise, the OpenAI Whisper API is used. To force the use of the API:
```python
shortcap.add_captions(
video_file="my_short.mp4",
output_file="my_short_with_captions.mp4",
use_local_whisper=False,
)
```
Install shortcap with local Whisper support:
```bash
pip install shortcap[local_whisper]
```
## Command-line Options
For a full list of command-line options, run:
```bash
shortcap --help
```
## Changelog
For a detailed list of changes and version updates, please refer to the [CHANGELOG.md](CHANGELOG.md) file.
## License
This project is licensed under the MIT License.
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## Support
If you encounter any problems or have any questions, please open an issue on the GitHub repository.
---
For more detailed information on usage and configuration, please refer to the documentation.
Raw data
{
"_id": null,
"home_page": "https://github.com/SmartClipAI/shortcap",
"name": "shortcap",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "SmartClipAI",
"author_email": "jacky.xbb@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/3b/4b/669913ce1496fd35e400700c3b5aa5537d0d4deb43efe094a67d77342147/shortcap-1.0.6.tar.gz",
"platform": null,
"description": "# shortcap\n\nAdd automatic captions to YouTube & TikTok Shorts (and other videos) using Whisper and MoviePy.\n\n## Demo\n\n\n\n## Quick Start\n\nInstall shortcap:\n\n```bash\npip install shortcap\n```\n\nSet required environment variables for OpenAI API:\n\n```bash\nexport OPENAI_BASE_URL=\"your_openai_base_url\"\nexport OPENAI_API_KEY=\"your_openai_api_key\"\n```\n\nUse the command-line interface:\n\n```bash\nshortcap <video_file> <output_file>\n```\n\n## Features\n\n- Automatic speech recognition using OpenAI's Whisper\n- Customizable caption styling\n- Support for local Whisper model or OpenAI API\n- Command-line interface and programmatic usage\n\n## Example\n\n```bash\nshortcap input.mp4 output.mp4 --font-size 80 --font-color white --stroke-width 2 --stroke-color black --highlight-current-word --word-highlight-color yellow --line-count 2 --verbose\n```\n\n## Programmatic Usage\n\n```python\nimport shortcap\nshortcap.add_captions(\n video_file=\"my_short.mp4\",\n output_file=\"my_short_with_captions.mp4\",\n)\n```\n\n## Custom Configuration\n\nYou can customize various aspects of the captions:\n\n```python\nimport shortcap\nshortcap.add_captions(\n video_file=\"my_short.mp4\",\n output_file=\"my_short_with_captions.mp4\",\n font = \"/path/to/your/font.ttf\",\n font_size = 130,\n font_color = \"yellow\",\n stroke_width = 3,\n stroke_color = \"black\",\n shadow_strength = 1.0,\n shadow_blur = 0.1,\n highlight_current_word = True,\n word_highlight_color = \"red\",\n line_count=1,\n padding = 50,\n position = \"center\"\n)\n```\n\nThe `position` parameter allows you to control where the captions appear on the video.\n\nVertical position: \"top\", \"center\", \"bottom\", or an integer value\n\nFor example:\n- `position = \"top\"`: Centers the text horizontally and places it at the top of the video\n- `position = \"center\"`: Centers the text horizontally and places it at the center of the video\n- `position = \"bottom\"`: Centers the text horizontally and places it at the bottom of the video\n- `position = 100`: Centers the text horizontally and places it 100 pixels from the top of the video\n\nThe default value is `\"center\"`, which centers the text both horizontally and vertically.\n\n## Using Whisper Locally\n\nBy default, OpenAI Whisper is used locally if the `openai-whisper` package is installed. Otherwise, the OpenAI Whisper API is used. To force the use of the API:\n\n```python\nshortcap.add_captions(\nvideo_file=\"my_short.mp4\",\noutput_file=\"my_short_with_captions.mp4\",\nuse_local_whisper=False,\n)\n```\n\n\nInstall shortcap with local Whisper support:\n\n```bash\npip install shortcap[local_whisper]\n```\n\n## Command-line Options\n\nFor a full list of command-line options, run:\n\n```bash\nshortcap --help\n```\n\n\n## Changelog\n\nFor a detailed list of changes and version updates, please refer to the [CHANGELOG.md](CHANGELOG.md) file.\n\n## License\n\nThis project is licensed under the MIT License.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## Support\n\nIf you encounter any problems or have any questions, please open an issue on the GitHub repository.\n\n---\n\nFor more detailed information on usage and configuration, please refer to the documentation.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Add Automatic Captions to Short Videos with AI",
"version": "1.0.6",
"project_urls": {
"Homepage": "https://github.com/SmartClipAI/shortcap"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "48211adcb29e1c1457049eea444683b38d2ed2c2ecbc150e1177c5ca50b6a9c7",
"md5": "6891966c674918c0046e7d99bc4ab204",
"sha256": "4a67e333be0e385b014d177765054d559971b38f7f6cbe1691535c0be5436154"
},
"downloads": -1,
"filename": "shortcap-1.0.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6891966c674918c0046e7d99bc4ab204",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 38906,
"upload_time": "2025-02-10T11:03:09",
"upload_time_iso_8601": "2025-02-10T11:03:09.850916Z",
"url": "https://files.pythonhosted.org/packages/48/21/1adcb29e1c1457049eea444683b38d2ed2c2ecbc150e1177c5ca50b6a9c7/shortcap-1.0.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "3b4b669913ce1496fd35e400700c3b5aa5537d0d4deb43efe094a67d77342147",
"md5": "be0348d64292038bf7079352433ae56d",
"sha256": "8db784eed62ec4d7c98b9514f1de39307e9a022dbb1b90cca7d197e10914e38a"
},
"downloads": -1,
"filename": "shortcap-1.0.6.tar.gz",
"has_sig": false,
"md5_digest": "be0348d64292038bf7079352433ae56d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 39174,
"upload_time": "2025-02-10T11:03:12",
"upload_time_iso_8601": "2025-02-10T11:03:12.390604Z",
"url": "https://files.pythonhosted.org/packages/3b/4b/669913ce1496fd35e400700c3b5aa5537d0d4deb43efe094a67d77342147/shortcap-1.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-10 11:03:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "SmartClipAI",
"github_project": "shortcap",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "moviepy",
"specs": [
[
"==",
"1.0.3"
]
]
},
{
"name": "pillow",
"specs": [
[
"==",
"10.4.0"
]
]
},
{
"name": "openai",
"specs": [
[
"==",
"1.61.1"
]
]
},
{
"name": "python-dotenv",
"specs": [
[
"==",
"1.0.1"
]
]
},
{
"name": "numpy",
"specs": [
[
"==",
"1.26.4"
]
]
}
],
"lcname": "shortcap"
}