Skip to content

Commit 0817d62

Browse files
migrate to gem coop (#45)
* [video_convert] migrate to gem.coop * [video_convert] fix failing test * [video_convert] add basic readme
1 parent df02c4c commit 0817d62

4 files changed

Lines changed: 157 additions & 3 deletions

File tree

commands/video-converter/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
source "https://rubygems.org"
3+
source "https://gem.coop"
44

55
gemspec
66

commands/video-converter/Gemfile.lock

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ PATH
44
video_convert (0.0.1)
55

66
GEM
7-
remote: https://rubygems.org/
7+
remote: https://gem.coop/
88
specs:
99
ansi (1.5.0)
1010
ast (2.4.2)
@@ -83,6 +83,7 @@ GEM
8383

8484
PLATFORMS
8585
arm64-darwin-22
86+
arm64-darwin-24
8687

8788
DEPENDENCIES
8889
guard

commands/video-converter/README.md

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
# Video Converter
2+
3+
A Ruby gem for converting video files using FFmpeg. This project is designed to work as a Raycast script and automatically converts videos from an `input` directory to an `output` directory.
4+
5+
## Features
6+
7+
- Automatically converts video files using FFmpeg
8+
- Scales videos to 1920px width while maintaining aspect ratio
9+
- Only converts files created today (skips older files)
10+
- Skips files that have already been converted
11+
- Supports both Raycast script and standalone Ruby execution
12+
- Uses high-quality encoding settings (CRF 18, slow preset)
13+
14+
## Prerequisites
15+
16+
- Ruby 2.6.0 or higher
17+
- FFmpeg installed on your system
18+
- Bundler gem
19+
20+
## Installation
21+
22+
1. Clone or download this project
23+
2. Navigate to the project directory:
24+
```bash
25+
cd commands/video-converter
26+
```
27+
28+
3. Install dependencies:
29+
```bash
30+
bundle install
31+
```
32+
33+
4. Ensure FFmpeg is installed:
34+
```bash
35+
# On macOS with Homebrew
36+
brew install ffmpeg
37+
38+
# On Ubuntu/Debian
39+
sudo apt update && sudo apt install ffmpeg
40+
41+
# On Windows
42+
# Download from https://ffmpeg.org/download.html
43+
```
44+
45+
## Usage
46+
47+
### As a Raycast Script
48+
49+
1. Place video files in the `input/` directory
50+
2. Run the Raycast command: `video:convert`
51+
3. Converted videos will appear in the `output/` directory
52+
53+
### As a Standalone Ruby Script
54+
55+
1. Place video files in the `input/` directory
56+
2. Run the converter:
57+
```bash
58+
ruby convertio.rb
59+
# or
60+
ruby plg.rb
61+
```
62+
63+
### Programmatic Usage
64+
65+
```ruby
66+
require_relative "lib/video_convert"
67+
68+
converter = VideoConvert::Converter.new("./input", "./output")
69+
converter.convert_all
70+
```
71+
72+
## Configuration
73+
74+
The converter uses the following FFmpeg parameters:
75+
- **Scale**: 1920px width, height auto-calculated to maintain aspect ratio
76+
- **Preset**: slow (for better compression)
77+
- **CRF**: 18 (high quality)
78+
- **Log Level**: error (minimal output)
79+
80+
## Development
81+
82+
### Running Tests
83+
84+
```bash
85+
# Run all tests
86+
bundle exec rake test
87+
88+
# Run specific test file
89+
bundle exec ruby spec/utils_spec.rb
90+
```
91+
92+
### Code Quality
93+
94+
```bash
95+
# Run RuboCop linting
96+
bundle exec rake rubocop
97+
98+
# Run both tests and linting
99+
bundle exec rake
100+
```
101+
102+
### Development Dependencies
103+
104+
- **Guard**: File watching for automatic test running
105+
- **Minitest**: Testing framework
106+
- **RuboCop**: Code style and quality checker
107+
- **Rake**: Task runner
108+
109+
## How It Works
110+
111+
1. **File Discovery**: Scans the `input/` directory for video files
112+
2. **Filtering**: Only processes files that:
113+
- Were created today
114+
- Haven't been converted yet (not in `output/` directory)
115+
- Are actual files (not directories)
116+
3. **Conversion**: Uses FFmpeg to convert each file with optimized settings
117+
4. **Async Processing**: Each conversion runs in a separate process
118+
119+
## Requirements
120+
121+
- Ruby 2.6.0+
122+
- FFmpeg
123+
- Input videos in supported formats (MP4, MOV, AVI, etc.)
124+
125+
## License
126+
127+
MIT License - see LICENSE file for details
128+
129+
## Contributing
130+
131+
1. Fork the repository
132+
2. Create a feature branch
133+
3. Make your changes
134+
4. Add tests for new functionality
135+
5. Ensure all tests pass and code follows style guidelines
136+
6. Submit a pull request
137+
138+
## Troubleshooting
139+
140+
### FFmpeg Not Found
141+
Make sure FFmpeg is installed and available in your PATH:
142+
```bash
143+
ffmpeg -version
144+
```
145+
146+
### Permission Issues
147+
Ensure the script has write permissions to the `output/` directory:
148+
```bash
149+
chmod 755 output/
150+
```
151+
152+
### No Files to Convert
153+
The converter only processes files created today. If you need to convert older files, modify the `created_today?` check in the converter logic.

commands/video-converter/lib/video_convert/utils.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module Utils # :nodoc:
44
def self.created_today?(date)
55
today = Time.now
6-
date.day == today.day && date.month == today.month
6+
date.day == today.day && date.month == today.month && date.year == today.year
77
end
88

99
def self.get_file_paths(dirs, filename)

0 commit comments

Comments
 (0)