Skip to content

Commit e615053

Browse files
committed
embedded ffmpeg
1 parent f385ddf commit e615053

14 files changed

Lines changed: 550 additions & 113 deletions

File tree

.github/workflows/build.yml

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ on:
1313
default: 'linux,windows,macos'
1414
type: string
1515

16+
permissions:
17+
contents: write
18+
packages: read
19+
1620
jobs:
1721
test:
1822
name: Run Tests
@@ -26,26 +30,27 @@ jobs:
2630
with:
2731
version: 0.15.1
2832

29-
- name: Install FFmpeg
30-
run: |
31-
sudo apt-get update
32-
sudo apt-get install -y ffmpeg
33-
34-
- name: Run tests
33+
- name: Run unit tests
3534
run: zig build test
3635

37-
- name: Build for testing
36+
- name: Build for testing (FFmpeg downloaded automatically)
3837
run: zig build
3938

4039
- name: Run integration tests
40+
run: zig build test-integration
41+
42+
- name: Test CLI functionality
4143
run: |
44+
# Create test-media directory
45+
mkdir -p test-media
46+
4247
# Test video generation
43-
./zig-out/bin/media-gen video --duration 2 --output test_video.mp4
44-
test -f test_video.mp4
48+
./zig-out/bin/media-gen video --duration 2 --output test-media/ci_test_video.mp4
49+
test -f test-media/ci_test_video.mp4
4550
4651
# Test audio generation
47-
./zig-out/bin/media-gen audio --duration 2 --output test_audio.mp3
48-
test -f test_audio.mp3
52+
./zig-out/bin/media-gen audio --duration 2 --output test-media/ci_test_audio.mp3
53+
test -f test-media/ci_test_audio.mp3
4954
5055
# Test help command
5156
./zig-out/bin/media-gen help
@@ -116,12 +121,41 @@ jobs:
116121
path: artifacts
117122

118123
- name: Create release
119-
uses: softprops/action-gh-release@v1
124+
uses: softprops/action-gh-release@v2
120125
with:
121126
tag_name: v${{ github.run_number }}
122-
name: Release v${{ github.run_number }}
127+
name: "Media Generator v${{ github.run_number }} - Embedded FFmpeg Edition"
123128
draft: false
124129
prerelease: false
125130
files: artifacts/**/*
131+
body: |
132+
## Media Generator - Embedded FFmpeg Edition
133+
134+
**No external dependencies required!** FFmpeg is embedded directly into the executable.
135+
136+
### Downloads
137+
- **Linux x86_64**: `media-gen-linux-x86_64`
138+
- **Windows x86_64**: `media-gen-windows-x86_64.exe`
139+
- **macOS Intel**: `media-gen-macos-x86_64`
140+
- **macOS ARM64**: `media-gen-macos-arm64`
141+
142+
### Usage
143+
```bash
144+
# Generate video with countdown
145+
./media-gen video --duration 10 --output countdown.mp4
146+
147+
# Generate audio test tone
148+
./media-gen audio --frequency 440 --duration 5 --output tone.wav
149+
150+
# Show help
151+
./media-gen help
152+
```
153+
154+
### Features
155+
- 🎬 Video generation with animated countdown timer
156+
- 🎵 Audio generation with configurable sine wave test tones
157+
- 🎯 Multiple formats: MP4, AVI, MOV, MKV, MP3, WAV, AAC, FLAC
158+
- 📦 Zero dependencies - FFmpeg embedded
159+
- 🚀 Cross-platform support
126160
env:
127161
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/manual-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ jobs:
7777
with:
7878
version: 0.15.1
7979

80-
- name: Build for ${{ matrix.target }}
80+
- name: Build for ${{ matrix.target }} (FFmpeg embedded automatically)
8181
run: zig build -Dtarget=${{ matrix.target }} -Doptimize=${{ github.event.inputs.optimize }}
8282

8383
- name: Copy artifact (Unix)

.github/workflows/test.yml

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -49,41 +49,28 @@ jobs:
4949
with:
5050
version: 0.15.1
5151

52-
- name: Install FFmpeg (Ubuntu)
53-
if: matrix.os == 'ubuntu-latest'
54-
run: |
55-
sudo apt-get update
56-
sudo apt-get install -y ffmpeg
57-
58-
- name: Install FFmpeg (macOS)
59-
if: matrix.os == 'macos-latest'
60-
run: brew install ffmpeg
61-
62-
- name: Install FFmpeg (Windows)
63-
if: matrix.os == 'windows-latest'
64-
run: |
65-
choco install ffmpeg -y
66-
echo "C:\ProgramData\chocolatey\lib\ffmpeg\tools\ffmpeg\bin" >> $GITHUB_PATH
67-
68-
- name: Build application
52+
- name: Build application (FFmpeg downloaded automatically)
6953
run: zig build
7054

7155
- name: Test video generation
7256
shell: bash
7357
run: |
58+
# Create test-media directory
59+
mkdir -p test-media
60+
7461
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
75-
./zig-out/bin/media-gen.exe video --duration 2 --width 640 --height 480 --output test_video.mp4
62+
./zig-out/bin/media-gen.exe video --duration 2 --width 640 --height 480 --output test-media/test_video.mp4
7663
else
77-
./zig-out/bin/media-gen video --duration 2 --width 640 --height 480 --output test_video.mp4
64+
./zig-out/bin/media-gen video --duration 2 --width 640 --height 480 --output test-media/test_video.mp4
7865
fi
7966
8067
# Check if file exists and has reasonable size
81-
if [[ ! -f test_video.mp4 ]]; then
68+
if [[ ! -f test-media/test_video.mp4 ]]; then
8269
echo "Video file was not created"
8370
exit 1
8471
fi
8572
86-
file_size=$(stat -f%z test_video.mp4 2>/dev/null || stat -c%s test_video.mp4)
73+
file_size=$(stat -f%z test-media/test_video.mp4 2>/dev/null || stat -c%s test-media/test_video.mp4)
8774
if [[ $file_size -lt 1000 ]]; then
8875
echo "Video file is too small: $file_size bytes"
8976
exit 1
@@ -95,18 +82,18 @@ jobs:
9582
shell: bash
9683
run: |
9784
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
98-
./zig-out/bin/media-gen.exe audio --duration 2 --sample-rate 44100 --output test_audio.mp3
85+
./zig-out/bin/media-gen.exe audio --duration 2 --sample-rate 44100 --output test-media/test_audio.mp3
9986
else
100-
./zig-out/bin/media-gen audio --duration 2 --sample-rate 44100 --output test_audio.mp3
87+
./zig-out/bin/media-gen audio --duration 2 --sample-rate 44100 --output test-media/test_audio.mp3
10188
fi
10289
10390
# Check if file exists and has reasonable size
104-
if [[ ! -f test_audio.mp3 ]]; then
91+
if [[ ! -f test-media/test_audio.mp3 ]]; then
10592
echo "Audio file was not created"
10693
exit 1
10794
fi
10895
109-
file_size=$(stat -f%z test_audio.mp3 2>/dev/null || stat -c%s test_audio.mp3)
96+
file_size=$(stat -f%z test-media/test_audio.mp3 2>/dev/null || stat -c%s test-media/test_audio.mp3)
11097
if [[ $file_size -lt 1000 ]]; then
11198
echo "Audio file is too small: $file_size bytes"
11299
exit 1
@@ -151,26 +138,22 @@ jobs:
151138
with:
152139
version: 0.15.1
153140

154-
- name: Install FFmpeg
155-
run: |
156-
sudo apt-get update
157-
sudo apt-get install -y ffmpeg
158-
159-
- name: Build application
141+
- name: Build application (embedded FFmpeg)
160142
run: zig build -Doptimize=ReleaseFast
161143

162144
- name: Performance test - Video generation
163145
run: |
146+
mkdir -p test-media
164147
echo "Testing video generation performance..."
165-
time ./zig-out/bin/media-gen video --duration 10 --output perf_test_video.mp4
148+
time ./zig-out/bin/media-gen video --duration 10 --output test-media/perf_test_video.mp4
166149
167-
file_size=$(stat -c%s perf_test_video.mp4)
150+
file_size=$(stat -c%s test-media/perf_test_video.mp4)
168151
echo "Generated video size: $file_size bytes"
169152
170153
- name: Performance test - Audio generation
171154
run: |
172155
echo "Testing audio generation performance..."
173-
time ./zig-out/bin/media-gen audio --duration 10 --output perf_test_audio.mp3
156+
time ./zig-out/bin/media-gen audio --duration 10 --output test-media/perf_test_audio.mp3
174157
175-
file_size=$(stat -c%s perf_test_audio.mp3)
158+
file_size=$(stat -c%s test-media/perf_test_audio.mp3)
176159
echo "Generated audio size: $file_size bytes"

.gitignore

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,15 @@ Thumbs.db
1818

1919
# Test artifacts
2020
test-media
21-
test_*.mp4
22-
test_*.mp3
23-
test_*.avi
24-
test_*.wav
25-
test_*.flac
26-
*_test.*
27-
ci_test_*
28-
debug_test.*
29-
manual_*.*
30-
perf_test_*
31-
*.yamllint.yml
3221

3322
# Build artifacts from build-all.sh
3423
media-gen-*
3524

25+
# FFmpeg binaries (downloaded during build)
26+
src/vendor/
27+
28+
# Temporary files
29+
temp/
30+
3631
# Keep important files
3732
!LICENSE

CHANGELOG.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [0.1.0] - 2025-10-11
99

1010
### Added
11+
- FFmpeg is embedded directly into the executable
12+
- No external dependencies required - works out of the box
1113
- Video generation with animated countdown timer
12-
- Audio generation with sine wave test tones
14+
- Audio generation with configurable sine wave test tones
1315
- Support for multiple video formats: MP4, AVI, MOV, MKV
1416
- Support for multiple audio formats: MP3, WAV, AAC, FLAC
1517
- Configurable video parameters: resolution, bitrate, FPS, duration, codec
16-
- Configurable audio parameters: sample rate, bitrate, duration, codec
18+
- Configurable audio parameters: sample rate, bitrate, duration, codec, frequency
1719
- Cross-platform support: Windows, macOS (Intel & ARM), Linux
1820
- Command-line interface with comprehensive help system
1921
- Automatic codec selection for different audio formats
20-
- Cross-platform build scripts and CI/CD pipeline
22+
- Comprehensive test suite with unit and integration tests
2123

2224
### Technical
2325
- Built with Zig 0.15+ for optimal performance
24-
- Uses FFmpeg for media processing
25-
- Comprehensive test suite with unit and integration tests
26-
- GitHub Actions workflows for automated building and testing
26+
- FFmpeg binaries embedded using `@embedFile()` for zero-dependency deployment
27+
- Automatic FFmpeg extraction and execution at runtime
28+
- Fallback to system FFmpeg if available for better performance
29+
- Cross-platform binary embedding for Linux, Windows, and macOS
30+
- Comprehensive test coverage including FFmpeg extraction tests

README.md

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22

33
A fast, cross-platform command-line utility for generating test media files with customizable parameters. Perfect for testing applications, creating placeholder content, or generating media samples.
44

5+
**No external dependencies required** - FFmpeg is embedded directly into the executable!
6+
57
[![Build and Test](https://github.com/DimazzzZ/media-gen/actions/workflows/build.yml/badge.svg)](https://github.com/DimazzzZ/media-gen/actions/workflows/build.yml)
68
[![Test Suite](https://github.com/DimazzzZ/media-gen/actions/workflows/test.yml/badge.svg)](https://github.com/DimazzzZ/media-gen/actions/workflows/test.yml)
79

810
## ✨ Features
911

1012
- 🎬 **Video generation** with animated countdown timer
11-
- 🎵 **Audio generation** with customizable test tones
13+
- 🎵 **Audio generation** with customizable sine wave test tones
1214
- 🎯 **Multiple formats** - MP4, AVI, MOV, MKV, MP3, WAV, AAC, FLAC
13-
- ⚙️ **Highly configurable** - resolution, bitrate, duration, codecs
15+
- ⚙️ **Highly configurable** - resolution, bitrate, duration, codecs, frequency
1416
- 🚀 **Cross-platform** - Windows, macOS, Linux (Intel & ARM)
1517
-**Fast** - Built with Zig for optimal performance
18+
- 📦 **Zero dependencies** - FFmpeg embedded, no installation required
1619

1720
## 🚀 Quick Start
1821

@@ -26,10 +29,11 @@ Download the latest release for your platform:
2629

2730
### Requirements
2831

29-
- **FFmpeg** must be installed on your system
30-
- **Ubuntu/Debian**: `sudo apt install ffmpeg`
31-
- **macOS**: `brew install ffmpeg`
32-
- **Windows**: Download from [ffmpeg.org](https://ffmpeg.org/download.html)
32+
**None!** FFmpeg is embedded directly into the executable.
33+
34+
- No external dependencies to install
35+
- No system configuration required
36+
- Works out of the box on all supported platforms
3337

3438
### Basic Usage
3539

@@ -40,6 +44,9 @@ Download the latest release for your platform:
4044
# Generate a 30-second audio test tone
4145
./media-gen audio --duration 30 --output test-tone.mp3
4246

47+
# Generate custom frequency audio
48+
./media-gen audio --frequency 880 --duration 5 --output tone.wav
49+
4350
# Show help
4451
./media-gen help
4552
```
@@ -111,6 +118,18 @@ Create test audio files with sine wave tones:
111118

112119
### Audio Options
113120

121+
| Option | Description | Default | Examples |
122+
|--------|-------------|---------|----------|
123+
| `--duration` | Duration in seconds | 30 | 10, 60, 300 |
124+
| `--sample-rate` | Sample rate in Hz | 44100 | 22050, 48000, 96000 |
125+
| `--frequency` | Sine wave frequency in Hz | 440 | 220, 880, 1000 |
126+
| `--bitrate` | Audio bitrate | 128k | 96k, 192k, 320k |
127+
| `--format` | Output format | mp3 | mp3, wav, aac, flac |
128+
| `--codec` | Audio codec | libmp3lame | pcm_s16le, aac, flac |
129+
| `--output` | Output filename | output.mp3 | my-audio.wav |
130+
131+
### Audio Options
132+
114133
| Option | Description | Default | Examples |
115134
|--------|-------------|---------|----------|
116135
| `--duration` | Duration in seconds | 30 | 10, 60, 300 |
@@ -159,24 +178,27 @@ Create test audio files with sine wave tones:
159178

160179
### Prerequisites
161180
- [Zig 0.15+](https://ziglang.org/download/)
162-
- FFmpeg installed on your system
181+
- Internet connection (for automatic FFmpeg download)
163182

164183
### Build Commands
165184
```bash
166185
# Clone the repository
167186
git clone https://github.com/DimazzzZ/media-gen.git
168187
cd media-gen
169188

170-
# Build for your platform
189+
# Build for your platform (FFmpeg downloaded automatically)
171190
zig build
172191

173192
# Run tests
174193
zig build test
194+
zig build test-integration
175195

176196
# Build for all platforms
177197
./build-all.sh
178198
```
179199

200+
**Note:** FFmpeg binaries are downloaded automatically during the first build. No manual installation required!
201+
180202
### Cross-compilation
181203
```bash
182204
# Windows

0 commit comments

Comments
 (0)