Removing old code, updating readme
This commit is contained in:
parent
6f332d46aa
commit
e4aff104b2
2 changed files with 28 additions and 29 deletions
25
README.md
25
README.md
|
|
@ -17,6 +17,17 @@ A Python tool that searches video subtitles for text matches and generates GIF c
|
|||
- FFmpeg 7.0+ (with subtitle support)
|
||||
- `pipx` for installation (recommended)
|
||||
|
||||
### Python Dependencies
|
||||
|
||||
**Required:**
|
||||
|
||||
- `srt` - For SRT subtitle parsing
|
||||
- `webvtt-py` - For WebVTT subtitle parsing
|
||||
|
||||
**Optional:**
|
||||
|
||||
- `colorama` - For colored terminal output (enhances readability and looks pretty)
|
||||
|
||||
## Installation
|
||||
|
||||
### Using pipx (Recommended)
|
||||
|
|
@ -30,7 +41,13 @@ This creates an isolated environment and installs the `video-subtitle-gif` comma
|
|||
### Manual Installation
|
||||
|
||||
```bash
|
||||
# Install required dependencies
|
||||
pip install srt webvtt-py
|
||||
|
||||
# Install optional dependencies for better experience
|
||||
pip install colorama
|
||||
|
||||
# Run the script
|
||||
python video_subtitle_gif.py [options]
|
||||
```
|
||||
|
||||
|
|
@ -63,10 +80,11 @@ video-subtitle-gif video.mp4 "search text" \
|
|||
- `video_path`: Path to the video file (required)
|
||||
- `search_text`: Text to search for in subtitles (required)
|
||||
- `--output-prefix PREFIX`: Prefix for output files (default: `output`)
|
||||
- `--fps FPS`: GIF framerate in frames per second (default: `10`)
|
||||
- `--fps FPS`: GIF framerate in frames per second (default: `10`, range: 1-60)
|
||||
- `--width WIDTH`: GIF width in pixels, height auto-calculated (default: `480`)
|
||||
- `--context-before SECONDS`: Tweak the start time of the output GIF (default: `0`)
|
||||
- `--context-after SECONDS`: Tweak the end time of the output GIF (default: `0`)
|
||||
- `--context-before SECONDS`: Extra seconds before subtitle start (default: `0`, can be negative to trim)
|
||||
- `--context-after SECONDS`: Extra seconds after subtitle end (default: `0`, can be negative to trim)
|
||||
- `--include-surrounding-subtitles`: Include subtitles from surrounding lines in the output (optional flag)
|
||||
|
||||
## Examples
|
||||
|
||||
|
|
@ -155,6 +173,7 @@ Any format supported by FFmpeg (MP4, MKV, AVI, WebM, etc.)
|
|||
### "Library not installed" errors
|
||||
|
||||
- Install missing dependencies: `pip install srt webvtt-py`
|
||||
- For colored output: `pip install colorama`
|
||||
- Or reinstall with pipx: `pipx reinstall video-subtitle-gif`
|
||||
|
||||
### Poor GIF quality
|
||||
|
|
|
|||
|
|
@ -56,21 +56,6 @@ try:
|
|||
except ImportError:
|
||||
webvtt = None
|
||||
|
||||
try:
|
||||
import pgsrip
|
||||
except ImportError:
|
||||
pgsrip = None
|
||||
|
||||
try:
|
||||
import pytesseract
|
||||
except ImportError:
|
||||
pytesseract = None
|
||||
|
||||
try:
|
||||
from PIL import Image
|
||||
except ImportError:
|
||||
Image = None
|
||||
|
||||
|
||||
class SubtitleError(Exception):
|
||||
"""Base exception for subtitle-related errors"""
|
||||
|
|
@ -114,14 +99,14 @@ def parse_arguments() -> argparse.Namespace:
|
|||
parser.add_argument(
|
||||
"--context-before",
|
||||
type=float,
|
||||
default=0.5,
|
||||
help="Extra seconds before subtitle (default: 0.5, can be negative to trim)"
|
||||
default=0,
|
||||
help="Extra seconds before subtitle (default: 0, can be negative to trim)"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--context-after",
|
||||
type=float,
|
||||
default=0.5,
|
||||
help="Extra seconds after subtitle (default: 0.5, can be negative to trim)"
|
||||
default=0,
|
||||
help="Extra seconds after subtitle (default: 0, can be negative to trim)"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--include-surrounding-subtitles",
|
||||
|
|
@ -323,13 +308,8 @@ def extract_embedded_subtitles(video_path: str, output_dir: str, base_name: str)
|
|||
# Keep original extension for ASS/VTT
|
||||
output_path = temp_output
|
||||
else:
|
||||
# Image-based subtitle format detected
|
||||
print(f"{Fore.YELLOW} ⚠️ Detected image-based subtitle format: {selected_codec}{Style.RESET_ALL}")
|
||||
return None
|
||||
else:
|
||||
# Check if the codec is image-based
|
||||
if selected_codec in ['hdmv_pgs_subtitle', 'dvd_subtitle', 'dvdsub', 'pgssub']:
|
||||
print(f"{Fore.YELLOW} ⚠️ Found image-based subtitles ({selected_codec}){Style.RESET_ALL}")
|
||||
# Unsupported subtitle format detected
|
||||
print(f"{Fore.YELLOW} ⚠️ Detected unsupported subtitle format: {selected_codec}{Style.RESET_ALL}")
|
||||
return None
|
||||
|
||||
print(f"{Fore.GREEN}✅ Extracted embedded subtitles to: {output_path}{Style.RESET_ALL}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue