An open API service indexing awesome lists of open source software.

https://github.com/rhythmusbyte/telegram-video-trimmer-bot


https://github.com/rhythmusbyte/telegram-video-trimmer-bot

Last synced: 8 months ago
JSON representation

Awesome Lists containing this project

README

          

# Telegram-Video-Trimmer-Bot
This is telegram bot script to trim a video and can be hosted on replit.

## Setup Instructions:

### Step 1: Create Telegram Bot
1. Message [@BotFather](https://t.me/botfather) on Telegram
2. Send `/newbot` command
3. Choose a name and username for your bot
4. Copy the bot token (looks like: `1234567890:ABCdefGHIjklMNOpqrsTUVwxyz`)

### Step 2: Setup on Replit
1. Create a new Python project on Replit
2. Replace the contents of `main.py` with the bot code
3. Create `requirements.txt` file with the dependencies listed above
4. Create `.replit` file (optional, for configuration):
```
run = "python main.py"
modules = ["python-3.10"]
```

### Step 3: Configure Environment Variables
1. In Replit, go to "Secrets" (lock icon in sidebar)
2. Add a new secret:
- Key: `BOT_TOKEN`
- Value: Your bot token from Step 1

### Step 4: Install Dependencies and Run
1. Replit should automatically install dependencies from `requirements.txt`
2. If not, run in the Shell: `pip install -r requirements.txt`
3. Click "Run" to start your bot

## Bot Features:

### 🎬 Main Features:
- **Video Trimming**: Removes first 5 seconds from videos
- **Thumbnail Extraction**: Creates PNG thumbnails from videos
- **Interactive Menu**: User-friendly inline keyboard interface
- **File Size Support**: Up to 1.2GB video files
- **Format Support**: MP4, AVI, MOV, MKV, WMV, FLV, etc.

### 📱 How to Use:
1. Start the bot with `/start`
2. Send a video file to the bot
3. Choose "Trim Video" or "Extract Thumbnail"
4. Wait for processing
5. Receive your processed file!

### 🛠️ Commands:
- `/start` - Show main menu
- `/help` - Show help information

## File Structure:
```
your-replit-project/
├── main.py # Main bot code
├── requirements.txt # Python dependencies
├── replit.nix # Replit configuration
└── .replit # Optional run configuration
```

## Troubleshooting:

### Common Issues:
1. **Bot not responding**: Check if BOT_TOKEN is set correctly in Secrets
2. **FFmpeg errors**: Replit includes FFmpeg by default, but ensure `replit.nix` is configured
3. **File too large**: Bot limits files to 1.2GB as requested
4. **Processing timeout**: Large files may take time; the bot shows progress messages

### Performance Notes:
- Processing time depends on video file size
- Replit provides good performance for video processing
- The bot handles temporary files efficiently
- Files are automatically cleaned up after processing

## Security Features:
- Temporary file handling (files deleted after processing)
- File size validation
- Error handling for corrupted files
- User data cleanup after operations

## Customization Options:
- Change trim duration by modifying `start_time` parameter in `trim_video()`
- Adjust thumbnail size by changing scale parameters in `extract_thumbnail()`
- Modify maximum file size by changing `MAX_FILE_SIZE` constant
- Add more video processing features using FFmpeg

# License
The repo is licensed with [MIT License](LICENSE). The sole owner of this project is [@RhythmusByte](github.com/RhythmusByte)