Skip to content

Commit f0e2ed6

Browse files
Initial commit
0 parents  commit f0e2ed6

21 files changed

Lines changed: 680 additions & 0 deletions

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*
2+
!api/*
3+
!cmd/*
4+
!internal/*
5+
!go.mod
6+
!go.sum
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Release Docker Image
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
release-docker:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
packages: write
14+
contents: read
15+
16+
env:
17+
REGISTRY: ghcr.io
18+
IMAGE_NAME: ${{ github.repository }}
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Log in to GitHub Container Registry
25+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
26+
with:
27+
registry: ${{ env.REGISTRY }}
28+
username: ${{ github.actor }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Extract metadata (tags, labels) for Docker
32+
id: meta
33+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
34+
with:
35+
images: ${{ env.REGISTRY }}/${{ github.repository }}
36+
37+
- name: Build and push Docker image
38+
id: push
39+
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
40+
with:
41+
context: .
42+
push: true
43+
tags: ${{ steps.meta.outputs.tags }}
44+
labels: ${{ steps.meta.outputs.labels }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.idea
2+
.DS_Store

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
## [1.0.0] - 2025-12-20
6+
7+
### Added
8+
9+
- Initial commit with FFmpeg HTTP API implementation.

Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM golang:1.25-alpine AS builder
2+
3+
WORKDIR /go/src
4+
5+
COPY go.mod go.sum ./
6+
RUN go mod download
7+
8+
COPY . .
9+
10+
RUN CGO_ENABLED=0 GOOS=linux go build \
11+
-trimpath \
12+
-ldflags="-s -w" \
13+
-o /go/bin/ffmpeg-api \
14+
cmd/main.go
15+
16+
FROM jrottenberg/ffmpeg:8.0-scratch AS ffmpeg
17+
18+
FROM scratch
19+
20+
COPY --from=ffmpeg /bin /bin
21+
COPY --from=ffmpeg /lib /lib
22+
COPY --from=ffmpeg /share /share
23+
COPY --from=ffmpeg /usr/share/fonts /usr/share/fonts
24+
COPY --from=ffmpeg /usr/share/fontconfig /usr/share/fontconfig
25+
26+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
27+
COPY --from=builder /go/bin/ffmpeg-api /usr/local/bin/ffmpeg-api
28+
29+
EXPOSE 8080
30+
31+
ENTRYPOINT ["ffmpeg-api"]

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Aureum Cloud, N-Bit, Niek Berenschot
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Media Processing HTTP API (FFmpeg API)
2+
3+
A **HTTP API** for processing video, audio, and images using **FFmpeg**.
4+
5+
## What it does
6+
7+
* Convert media formats (video ↔ audio, MP4 → GIF, WAV → MP3)
8+
* Resize, trim, or transcode files
9+
* Extract audio or frames from video
10+
* Run media workflows without local file handling
11+
12+
You provide input files and FFmpeg commands; the API returns the results via **S3**, **Base64**, or a **direct HTTP stream**.
13+
14+
## Endpoint
15+
16+
`POST /v1/process`
17+
18+
## Request Structure
19+
20+
```json
21+
{
22+
"s3Config": { ... },
23+
"input": { ... },
24+
"commands": [ ... ],
25+
"output": { ... }
26+
}
27+
```
28+
29+
## Inputs
30+
31+
A map of **filename → source** (used by FFmpeg).
32+
33+
Supported sources:
34+
35+
* `s3`: `s3://bucket/key`
36+
* `http`: public URL
37+
* `base64`: Base64-encoded content
38+
39+
```json
40+
{
41+
"input.mp4": {
42+
"http": "https://example.com/video.mp4"
43+
}
44+
}
45+
```
46+
47+
## FFmpeg Commands
48+
49+
An array of FFmpeg argument lists, executed sequentially.
50+
51+
```json
52+
[
53+
["-i", "input.mp4", "-vn", "output.mp3"]
54+
]
55+
```
56+
57+
Filenames reference input files or outputs from previous commands.
58+
59+
## Output Options
60+
61+
### Upload to S3
62+
63+
```json
64+
{ "s3": "s3://my-bucket/outputs/" }
65+
```
66+
67+
### Return Base64
68+
69+
```json
70+
{ "base64": true }
71+
```
72+
73+
### Stream via HTTP
74+
75+
```json
76+
{ "inlineContentType": "audio/mpeg" }
77+
```
78+
79+
> When streaming, the first output file is returned directly and no JSON is sent.
80+
81+
## JSON Response
82+
83+
```json
84+
{
85+
"results": {
86+
"output.mp3": {
87+
"url": "...",
88+
"base64": "..."
89+
}
90+
}
91+
}
92+
```
93+
94+
## Example
95+
96+
```bash
97+
curl -X POST http://localhost:8080/v1/process \
98+
-H "Content-Type: application/json" \
99+
-d '{
100+
"input": {
101+
"input.mp4": { "http": "https://example.com/video.mp4" }
102+
},
103+
"commands": [
104+
["-i", "input.mp4", "-vn", "output.mp3"]
105+
],
106+
"output": { "base64": true }
107+
}'
108+
```
109+
110+
## Docker
111+
112+
### Image
113+
114+
```
115+
ghcr.io/aureum-cloud/ffmpeg-api:latest
116+
```
117+
118+
### Run
119+
120+
```bash
121+
docker run -d -p 8080:8080 ghcr.io/aureum-cloud/ffmpeg-api:latest
122+
```
123+
124+
API available at:
125+
126+
```
127+
http://localhost:8080
128+
```
129+
130+
## Notes
131+
132+
* FFmpeg is bundled
133+
* No external dependencies
134+
* Temporary files are cleaned automatically
135+
* S3 credentials are supplied per request
136+
* Go binary on scratch image

SECURITY.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
The following table outlines the versions of this project
6+
currently supported with security updates:
7+
8+
| Version | Supported |
9+
|---------| ------------------ |
10+
| 1.0.0 | :white_check_mark: |
11+
12+
## Reporting a Vulnerability
13+
14+
If you discover a security vulnerability, please report it as soon as possible.
15+
16+
### How to Report
17+
18+
- Email us at `cloud@n-bit.nl` with details of the vulnerability.
19+
- Include a detailed description of the issue, steps to reproduce, and potential impact.
20+
21+
### What to Expect
22+
23+
- We will acknowledge your report within 2 business days.
24+
- We will provide regular updates on the status of your report.
25+
- Once the issue is verified, we will work on a fix and update the project accordingly.
26+
27+
Thank you for helping us keep the project secure!

api/input.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package api
2+
3+
type Input struct {
4+
S3 string `json:"s3,omitempty"`
5+
HTTP string `json:"http,omitempty"`
6+
Base64 string `json:"base64,omitempty"`
7+
}

api/output.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package api
2+
3+
type Output struct {
4+
S3 string `json:"s3,omitempty"`
5+
InlineContentType string `json:"inlineContentType,omitempty"`
6+
Base64 bool `json:"base64,omitempty"`
7+
}

0 commit comments

Comments
 (0)