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)
|
- FFmpeg 7.0+ (with subtitle support)
|
||||||
- `pipx` for installation (recommended)
|
- `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
|
## Installation
|
||||||
|
|
||||||
### Using pipx (Recommended)
|
### Using pipx (Recommended)
|
||||||
|
|
@ -30,7 +41,13 @@ This creates an isolated environment and installs the `video-subtitle-gif` comma
|
||||||
### Manual Installation
|
### Manual Installation
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# Install required dependencies
|
||||||
pip install srt webvtt-py
|
pip install srt webvtt-py
|
||||||
|
|
||||||
|
# Install optional dependencies for better experience
|
||||||
|
pip install colorama
|
||||||
|
|
||||||
|
# Run the script
|
||||||
python video_subtitle_gif.py [options]
|
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)
|
- `video_path`: Path to the video file (required)
|
||||||
- `search_text`: Text to search for in subtitles (required)
|
- `search_text`: Text to search for in subtitles (required)
|
||||||
- `--output-prefix PREFIX`: Prefix for output files (default: `output`)
|
- `--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`)
|
- `--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-before SECONDS`: Extra seconds before subtitle start (default: `0`, can be negative to trim)
|
||||||
- `--context-after SECONDS`: Tweak the end time of the output GIF (default: `0`)
|
- `--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
|
## Examples
|
||||||
|
|
||||||
|
|
@ -155,6 +173,7 @@ Any format supported by FFmpeg (MP4, MKV, AVI, WebM, etc.)
|
||||||
### "Library not installed" errors
|
### "Library not installed" errors
|
||||||
|
|
||||||
- Install missing dependencies: `pip install srt webvtt-py`
|
- Install missing dependencies: `pip install srt webvtt-py`
|
||||||
|
- For colored output: `pip install colorama`
|
||||||
- Or reinstall with pipx: `pipx reinstall video-subtitle-gif`
|
- Or reinstall with pipx: `pipx reinstall video-subtitle-gif`
|
||||||
|
|
||||||
### Poor GIF quality
|
### Poor GIF quality
|
||||||
|
|
|
||||||
|
|
@ -56,21 +56,6 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
webvtt = None
|
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):
|
class SubtitleError(Exception):
|
||||||
"""Base exception for subtitle-related errors"""
|
"""Base exception for subtitle-related errors"""
|
||||||
|
|
@ -114,14 +99,14 @@ def parse_arguments() -> argparse.Namespace:
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--context-before",
|
"--context-before",
|
||||||
type=float,
|
type=float,
|
||||||
default=0.5,
|
default=0,
|
||||||
help="Extra seconds before subtitle (default: 0.5, can be negative to trim)"
|
help="Extra seconds before subtitle (default: 0, can be negative to trim)"
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--context-after",
|
"--context-after",
|
||||||
type=float,
|
type=float,
|
||||||
default=0.5,
|
default=0,
|
||||||
help="Extra seconds after subtitle (default: 0.5, can be negative to trim)"
|
help="Extra seconds after subtitle (default: 0, can be negative to trim)"
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--include-surrounding-subtitles",
|
"--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
|
# Keep original extension for ASS/VTT
|
||||||
output_path = temp_output
|
output_path = temp_output
|
||||||
else:
|
else:
|
||||||
# Image-based subtitle format detected
|
# Unsupported subtitle format detected
|
||||||
print(f"{Fore.YELLOW} ⚠️ Detected image-based subtitle format: {selected_codec}{Style.RESET_ALL}")
|
print(f"{Fore.YELLOW} ⚠️ Detected unsupported 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}")
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
print(f"{Fore.GREEN}✅ Extracted embedded subtitles to: {output_path}{Style.RESET_ALL}")
|
print(f"{Fore.GREEN}✅ Extracted embedded subtitles to: {output_path}{Style.RESET_ALL}")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue