Skip to content

Commit 59ce1de

Browse files
committed
First implementation
1 parent 23ef7b4 commit 59ce1de

File tree

14 files changed

+1353
-7
lines changed

14 files changed

+1353
-7
lines changed

.github/FUNDING.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github: igolaizola
2+
custom: ["https://ko-fi.com/igolaizola", "https://buymeacoffee.com/igolaizola", "https://paypal.me/igolaizola"]

.github/workflows/ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
ci:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
- name: Setup go
18+
uses: actions/setup-go@v4
19+
with:
20+
go-version-file: 'go.mod'
21+
- name: Build
22+
run: go build -v ./...
23+
- name: Lint
24+
uses: golangci/golangci-lint-action@v3
25+
- name: Test
26+
run: go test -v ./...

.github/workflows/release.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: goreleaser
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
goreleaser:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
18+
- run: git fetch --force --tags
19+
- uses: actions/setup-go@v3
20+
with:
21+
go-version-file: 'go.mod'
22+
cache: true
23+
- uses: goreleaser/goreleaser-action@v4
24+
with:
25+
distribution: goreleaser
26+
version: latest
27+
args: release --clean
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
# If you prefer the allow list template instead of the deny list, see community template:
2-
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
3-
#
41
# Binaries for programs and plugins
52
*.exe
63
*.exe~
74
*.dll
85
*.so
96
*.dylib
7+
bin
108

119
# Test binary, built with `go test -c`
1210
*.test
@@ -17,5 +15,8 @@
1715
# Dependency directories (remove the comment below to include it)
1816
# vendor/
1917

20-
# Go workspace file
21-
go.work
18+
# Other
19+
.history
20+
.vscode
21+
*.conf
22+
logs/

.goreleaser.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
builds:
2+
- id: vidai
3+
binary: vidai
4+
main: ./cmd/vidai
5+
goarch:
6+
- amd64
7+
- arm64
8+
- arm
9+
archives:
10+
- id: vidai
11+
builds:
12+
- vidai
13+
format: zip
14+
name_template: 'vidai_{{ .Version }}_{{- if eq .Os "darwin" }}macos{{- else }}{{ .Os }}{{ end }}_{{ .Arch }}'

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# builder image
2+
FROM golang:alpine as builder
3+
ARG TARGETPLATFORM
4+
COPY . /src
5+
WORKDIR /src
6+
RUN apk add --no-cache make bash git
7+
RUN make app-build PLATFORMS=$TARGETPLATFORM
8+
9+
# running image
10+
FROM alpine
11+
WORKDIR /home
12+
COPY --from=builder /src/bin/vidai-* /bin/vidai
13+
14+
# executable
15+
ENTRYPOINT [ "/bin/vidai" ]

Makefile

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash
2+
3+
SHELL = /bin/bash
4+
PLATFORMS ?= linux/amd64 darwin/amd64 windows/amd64
5+
IMAGE_PREFIX ?= igolaizola
6+
REPO_NAME ?= vidai
7+
COMMIT_SHORT ?= $(shell git rev-parse --verify --short HEAD)
8+
VERSION ?= $(COMMIT_SHORT)
9+
VERSION_NOPREFIX ?= $(shell echo $(VERSION) | sed -e 's/^[[v]]*//')
10+
11+
# Build the binaries for the current platform
12+
.PHONY: build
13+
build:
14+
os=$$(go env GOOS); \
15+
arch=$$(go env GOARCH); \
16+
PLATFORMS="$$os/$$arch" make app-build
17+
18+
# Build the binaries
19+
# Example: PLATFORMS=linux/amd64 make app-build
20+
.PHONY: app-build
21+
app-build:
22+
@for platform in $(PLATFORMS) ; do \
23+
os=$$(echo $$platform | cut -f1 -d/); \
24+
arch=$$(echo $$platform | cut -f2 -d/); \
25+
arm=$$(echo $$platform | cut -f3 -d/); \
26+
arm=$${arm#v}; \
27+
ext=""; \
28+
if [ "$$os" == "windows" ]; then \
29+
ext=".exe"; \
30+
fi; \
31+
file=./bin/$(REPO_NAME)-$(VERSION_NOPREFIX)-$$(echo $$platform | tr / -)$$ext; \
32+
GOOS=$$os GOARCH=$$arch GOARM=$$arm CGO_ENABLED=0 \
33+
go build \
34+
-a -x -tags netgo,timetzdata -installsuffix cgo -installsuffix netgo \
35+
-ldflags " \
36+
-X main.Version=$(VERSION_NOPREFIX) \
37+
-X main.GitRev=$(COMMIT_SHORT) \
38+
" \
39+
-o $$file \
40+
./cmd/$(REPO_NAME); \
41+
if [ $$? -ne 0 ]; then \
42+
exit 1; \
43+
fi; \
44+
chmod +x $$file; \
45+
done
46+
47+
# Build the docker image
48+
# Example: PLATFORMS=linux/amd64 make docker-build
49+
.PHONY: docker-build
50+
docker-build:
51+
rm -rf bin; \
52+
@platforms=($(PLATFORMS)); \
53+
platform=$${platforms[0]}; \
54+
if [[ $${#platforms[@]} -ne 1 ]]; then \
55+
echo "Multi-arch build not supported"; \
56+
exit 1; \
57+
fi; \
58+
docker build --platform $$platform -t $(IMAGE_PREFIX)/$(REPO_NAME):$(VERSION) .; \
59+
if [ $$? -ne 0 ]; then \
60+
exit 1; \
61+
fi
62+
63+
# Build the docker images using buildx
64+
# Example: PLATFORMS="linux/amd64 darwin/amd64 windows/amd64" make docker-buildx
65+
.PHONY: docker-buildx
66+
docker-buildx:
67+
@platforms=($(PLATFORMS)); \
68+
platform=$$(IFS=, ; echo "$${platforms[*]}"); \
69+
docker buildx build --platform $$platform -t $(IMAGE_PREFIX)/$(REPO_NAME):$(VERSION) .
70+
71+
# Clean binaries
72+
.PHONY: clean
73+
clean:
74+
rm -rf bin

README.md

Lines changed: 141 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,141 @@
1-
# vidai
2-
Video generation using AI
1+
# vidai 📹🤖
2+
3+
**vidai** generates videos using AI.
4+
5+
This is a CLI tool for [RunwayML Gen-2](https://runwayml.com/) that adds some extra features on top of it.
6+
7+
## 🚀 Features
8+
9+
- Generate videos directly from the command line using a text or image prompt.
10+
- Create or extend videos longer than 4 seconds by reusing the last frame of the video as the input for the next generation.
11+
- Other handy tools to edit videos, like generating loops or resizing videos.
12+
13+
## 📦 Installation
14+
15+
You can use the Golang binary to install **vidai**:
16+
17+
```bash
18+
go install github.com/igolaizola/vidai/cmd/vidai@latest
19+
```
20+
21+
Or you can download the binary from the [releases](https://github.com/igolaizola/vidai/releases)
22+
23+
## 📋 Requirements
24+
25+
You need to have a [RunwayML](https://runwayml.com/) account and extract the token from the request authorization header using your browser's developer tools.
26+
27+
To create extended videos, you need to have [ffmpeg](https://ffmpeg.org/) installed.
28+
29+
## 🕹️ Usage
30+
31+
### Some examples
32+
33+
Generate a video from an image prompt:
34+
35+
```bash
36+
vidai generate --token RUNWAYML_TOKEN --image car.jpg --output car.mp4
37+
```
38+
39+
Generate a video from a text prompt:
40+
41+
```bash
42+
vidai generate --token RUNWAYML_TOKEN --text "a car in the middle of the road" --output car.mp4
43+
```
44+
45+
Extend a video by reusing the last frame twice:
46+
47+
```bash
48+
vidai extend --input car.mp4 --output car-extended.mp4 --n 2
49+
```
50+
51+
Convert a video to a loop:
52+
53+
```bash
54+
vidai loop --input car.mp4 --output car-loop.mp4
55+
```
56+
57+
### Help
58+
59+
Launch `vidai` with the `--help` flag to see all available commands and options:
60+
61+
```bash
62+
vidai --help
63+
```
64+
65+
You can use the `--help` flag with any command to view available options:
66+
67+
```bash
68+
vidai generate --help
69+
```
70+
71+
### How to launch commands
72+
73+
Launch commands using a configuration file:
74+
75+
```bash
76+
vidai generate --config vidai.conf
77+
```
78+
79+
```bash
80+
# vidai.conf
81+
token RUNWAYML_TOKEN
82+
image car.jpg
83+
output car.mp4
84+
extend 2
85+
```
86+
87+
Using environment variables (`VIDAI` prefix, uppercase and underscores):
88+
89+
```bash
90+
export VIDAI_TOKEN=RUNWAYML_TOKEN
91+
export VIDAI_IMAGE="car.jpg"
92+
export VIDAI_OUTPUT="car.mp4"
93+
export VIDAI_EXTEND=2
94+
vidai generate
95+
```
96+
97+
Using command line arguments:
98+
99+
```bash
100+
vidai generate --token RUNWAYML_TOKEN --image car.jpg --video car.mp4 --extend 2
101+
```
102+
103+
## ⚠️ Disclaimer
104+
105+
The automation of RunwayML accounts is a violation of their Terms of Service and will result in your account(s) being terminated.
106+
107+
Read about RunwayML Terms of Service and Community Guidelines.
108+
109+
vidai was written as a proof of concept and the code has been released for educational purposes only. The authors are released of any liabilities which your usage may entail.
110+
111+
## 💖 Support
112+
113+
If you have found my code helpful, please give the repository a star ⭐
114+
115+
Additionally, if you would like to support my late-night coding efforts and the coffee that keeps me going, I would greatly appreciate a donation.
116+
117+
You can invite me for a coffee at ko-fi (0% fees):
118+
119+
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/igolaizola)
120+
121+
Or at buymeacoffee:
122+
123+
[![buymeacoffee](https://user-images.githubusercontent.com/11333576/223217083-123c2c53-6ab8-4ea8-a2c8-c6cb5d08e8d2.png)](https://buymeacoffee.com/igolaizola)
124+
125+
Donate to my PayPal:
126+
127+
[paypal.me/igolaizola](https://www.paypal.me/igolaizola)
128+
129+
Sponsor me on GitHub:
130+
131+
[github.com/sponsors/igolaizola](https://github.com/sponsors/igolaizola)
132+
133+
Or donate to any of my crypto addresses:
134+
135+
- BTC `bc1qvuyrqwhml65adlu0j6l59mpfeez8ahdmm6t3ge`
136+
- ETH `0x960a7a9cdba245c106F729170693C0BaE8b2fdeD`
137+
- USDT (TRC20) `TD35PTZhsvWmR5gB12cVLtJwZtTv1nroDU`
138+
- USDC (BEP20) / BUSD (BEP20) `0x960a7a9cdba245c106F729170693C0BaE8b2fdeD`
139+
- Monero `41yc4R9d9iZMePe47VbfameDWASYrVcjoZJhJHFaK7DM3F2F41HmcygCrnLptS4hkiJARCwQcWbkW9k1z1xQtGSCAu3A7V4`
140+
141+
Thanks for your support!

0 commit comments

Comments
 (0)