Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hongjungwan/ffmpeg-video-modules

FFπš–πš™πšŽπš Vπš’πšπšŽπš˜ Mπš˜πšπšžπš•πšŽπšœ 🎞
https://github.com/hongjungwan/ffmpeg-video-modules

docker ffmpeg gin go go-clean-architecture golang gorm mariadb

Last synced: 2 months ago
JSON representation

FFπš–πš™πšŽπš Vπš’πšπšŽπš˜ Mπš˜πšπšžπš•πšŽπšœ 🎞

Awesome Lists containing this project

README

        

# ffmpeg-video-modules


### 핡심 문제 ν•΄κ²° μ „λž΅ 및 뢄석 🧐

* πŸ“Œ [FFmpeg 라이브러리둜 κ΅¬ν˜„ν•˜λŠ” λ™μ˜μƒ 처리 λͺ¨λ“ˆ: 문제 ν•΄κ²° μ „λž΅ 및 뢄석](https://day-t.tistory.com/11)



### FFmpeg 및 FFprobe μ„€μΉ˜ κ°€μ΄λ“œ (Windows 10)

```
# πŸ“Œ FFmpeg 및 FFprobe μ„€μΉ˜
- [FFmpeg λ‹€μš΄λ‘œλ“œ νŽ˜μ΄μ§€](https://ffmpeg.org/download.html)둜 이동
- Windows λΉŒλ“œ 선택 (ꢌμž₯: [gyan.dev](https://www.gyan.dev/ffmpeg/builds/))
- "Release builds"μ—μ„œ `ffmpeg-release-essentials.zip` λ‹€μš΄λ‘œλ“œ
- ZIP νŒŒμΌμ„ `C:\ffmpeg`에 μ••μΆ• ν•΄μ œ

# πŸ“Œ PATH ν™˜κ²½ λ³€μˆ˜ μΆ”κ°€
- `C:\ffmpeg\bin` 경둜 볡사
- λ‚΄ PC β†’ 속성 β†’ κ³ κΈ‰ μ‹œμŠ€ν…œ μ„€μ • β†’ ν™˜κ²½ λ³€μˆ˜ 클릭
- μ‹œμŠ€ν…œ λ³€μˆ˜μ—μ„œ `Path` νŽΈμ§‘ β†’ μƒˆ κ²½λ‘œμ— `C:\ffmpeg\bin` μΆ”κ°€
- λͺ¨λ“  μ°½ λ‹«κΈ°

# πŸ“Œ μ„€μΉ˜ 확인
- Win + R β†’ "cmd" μž…λ ₯ ν›„ μ‹€ν–‰
- `ffmpeg -version` 및 `ffprobe -version` μž…λ ₯ν•΄ μ„€μΉ˜ 확인
```

* μœ„ 과정을 진행해야 Local ν™˜κ²½μ—μ„œ ffmpeg 라이브러리λ₯Ό μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.



### MariaDB μ»¨ν…Œμ΄λ„ˆ μ‹€ν–‰ (Windows Powershell)

```
docker network create --driver bridge mynetwork

docker network ls

docker run -d --name mariadb -p 3310:3306 -v mysql_db:/var/lib/mysql --network mynetwork -e MYSQL_DATABASE=ffmpeg-video-database -e MYSQL_ROOT_PASSWORD=password mariadb:latest
```



### μ‹€ν–‰

```
# πŸ“Œ GoLand IDEμ—μ„œ ν”„λ‘œκ·Έλž¨ μ‹€ν–‰ μ‹œ μ„€μ •ν•˜λŠ” 방법

- Program arguments: Go ν”„λ‘œκ·Έλž¨μ„ μ‹€ν–‰ν•  λ•Œ 전달할 λͺ…령쀄 인수.
- μ—¬κΈ°μ„œλŠ” `-c deploy/dev/config.toml`을 μ „λ‹¬ν•˜μ—¬ `config.toml` νŒŒμΌμ„ μ„€μ • 파일둜 μ‚¬μš©ν•©λ‹ˆλ‹€.

- μ„€μ • 방법
1. GoLandμ—μ„œ Run/Debug Configurationsλ₯Ό μ—½λ‹ˆλ‹€.
2. Program arguments ν•„λ“œμ— `-c deploy/dev/config.toml`을 μž…λ ₯ν•©λ‹ˆλ‹€.
3. 이 섀정은 ν”„λ‘œκ·Έλž¨μ΄ `config.toml` νŒŒμΌμ„ 읽어듀이도둝 ν•˜μ—¬, μ§€μ •λœ ν™˜κ²½ 섀정을 λ‘œλ“œν•˜κ²Œ ν•©λ‹ˆλ‹€.
4. 섀정을 μ €μž₯ν•˜κ³ , Run λ²„νŠΌμ„ ν΄λ¦­ν•˜μ—¬ ν”„λ‘œκ·Έλž¨μ„ μ‹€ν–‰ν•©λ‹ˆλ‹€.

```



### ν…ŒμŠ€νŠΈ μ½”λ“œ μ‹€ν–‰ μ‹œν‚€κΈ° (Git Bash)

```
# πŸ“Œ λͺ¨λ“  ν…ŒμŠ€νŠΈ μ½”λ“œ μ‹€ν–‰
go test ./internal/...

# πŸ“Œ 컀버리지 ν”„λ‘œνŒŒμΌ 생성 ν›„, HTML λ³΄κ³ μ„œ 생성
go test -v -coverprofile=coverage.out ./internal/...
go tool cover -html=coverage.out
```



### ν—¬μŠ€ 체크 API ν…ŒμŠ€νŠΈ (Git Bash)

```git bash
$ curl --http1.1 http://localhost:3031/api/health
```



### ν…ŒμŠ€νŠΈ λΉ„λ””μ˜€ 생성 ffmpeg λͺ…λ Ήμ–΄ (Windows Powershell)

```
ffmpeg -f lavfi -i color=c=blue:s=320x240:d=5 -vf "drawtext=fontfile='C\\Windows\\Fonts\\arial.ttf': text='Test Video 1': fontcolor=white: fontsize=24: x=(w-text_w)/2: y=(h-text_h)/2" -c:v libx264 -t 5 -pix_fmt yuv420p "C:\test_video_1.mp4"

ffmpeg -f lavfi -i color=c=red:s=320x240:d=6 -vf "drawtext=fontfile='C\\Windows\\Fonts\\arial.ttf': text='Test Video 2': fontcolor=white: fontsize=24: x=(w-text_w)/2: y=(h-text_h)/2" -c:v libx264 -t 6 -pix_fmt yuv420p "C:\test_video_2.mp4"

ffmpeg -f lavfi -i color=c=green:s=320x240:d=7 -vf "drawtext=fontfile='C\\Windows\\Fonts\\arial.ttf': text='Test Video 3': fontcolor=white: fontsize=24: x=(w-text_w)/2: y=(h-text_h)/2" -c:v libx264 -t 7 -pix_fmt yuv420p "C:\test_video_3.mp4"

ffmpeg -f lavfi -i color=c=yellow:s=320x240:d=5 -vf "drawtext=fontfile='C\\Windows\\Fonts\\arial.ttf': text='Test Video 4': fontcolor=black: fontsize=24: x=(w-text_w)/2: y=(h-text_h)/2" -c:v libx264 -t 5 -pix_fmt yuv420p "C:\test_video_4.mp4"

ffmpeg -f lavfi -i color=c=purple:s=320x240:d=6 -vf "drawtext=fontfile='C\\Windows\\Fonts\\arial.ttf': text='Test Video 5': fontcolor=white: fontsize=24: x=(w-text_w)/2: y=(h-text_h)/2" -c:v libx264 -t 6 -pix_fmt yuv420p "C:\test_video_5.mp4"
```
* μœ„ λͺ…λ Ήμ–΄λ₯Ό μ‹€ν–‰ν•˜λ©΄, ν…ŒμŠ€νŠΈ λΉ„λ””μ˜€ νŒŒμΌλ“€μ€ `C λ“œλΌμ΄λΈŒ`의 λ£¨νŠΈμ— μƒμ„±λ©λ‹ˆλ‹€.



### Swagger ν…ŒμŠ€νŠΈ (Windows)

```
cd internal
swag init

ffmpeg-video-modules API Server μ‹€ν–‰ ν›„, `http://localhost:3031/docs/index.html` μ ‘κ·Ό
```



### Swagger ν…ŒμŠ€νŠΈ μˆœμ„œ (πŸ“Œ ꢌμž₯)

* `[GET] /health` -> `[POST] /videos` -> `[POST] /videos/{id}/trim` -> `[POST] /videos/concat` -> `[POST] /jobs/execute` -> `[GET] /Videos` -> `[GET] /videos/{fid}/download`



### ν—¬μŠ€ 체크 API

| μ‹€ν–‰ μ „ UI | μ‹€ν–‰ ν›„ UI |
|-------------------------------------------------------|-------------------------------------------------------|
| | |



### λ™μ˜μƒ μ—…λ‘œλ“œ API

| μ‹€ν–‰ μ „ UI | μ‹€ν–‰ ν›„ UI |
|-------|---------------|
| | |

* Swagger UIμ—μ„œλŠ” 기본적으둜 μ—¬λŸ¬ 개의 νŒŒμΌμ„ ν•œ λ²ˆμ— μ—…λ‘œλ“œν•  수 μžˆλŠ” κΈ°λŠ₯을 직접 μ œκ³΅ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

* μ—¬λŸ¬ 개의 νŒŒμΌμ„ ν•œ λ²ˆμ— μ—…λ‘œλ“œν•˜λŠ” κΈ°λŠ₯은 μ•„λž˜μ˜ 이미지λ₯Ό μ°Έκ³ ν•˜μ—¬ Postman으둜 μˆ˜ν–‰ν•˜κΈΈ λ°”λžλ‹ˆλ‹€.



### λ™μ˜μƒ μ»· νŽΈμ§‘ (Trim) API

| μ‹€ν–‰ μ „ UI | μ‹€ν–‰ ν›„ UI |
|-------|---------------|
| | |

* πŸ“Œ μ–ΈκΈ‰λœ μš”κ΅¬μ‚¬ν•­μ€ μ‚¬μš©μžκ°€ 이전에 μš”μ²­ν•œ λͺ¨λ“  트림 및 이어뢙이기 μž‘μ—…μ„ ν•œ λ²ˆμ— μˆ˜ν–‰ν•  수 μžˆλ„λ‘ ν•˜λŠ” 것이닀.

* πŸ“Œ 제곡된 μš”κ΅¬μ‚¬ν•­ λ²”μœ„ λ‚΄μ—μ„œλŠ” 트림과 이어 뢙이기 μž‘μ—…μ΄ 순차적으둜(ν•œ λ²ˆμ—) μ²˜λ¦¬λ˜λŠ” λ°©μ‹μœΌλ‘œ κ΅¬ν˜„ν•˜λ©΄ μΆ©λΆ„ν•  κ²ƒμœΌλ‘œ νŒλ‹¨.



### λ™μ˜μƒ 이어 뢙이기 (Concat) API

| μ‹€ν–‰ μ „ UI | μ‹€ν–‰ ν›„ UI |
|-------|---------------|
| | |

* πŸ“Œ μ–ΈκΈ‰λœ μš”κ΅¬μ‚¬ν•­μ€ μ‚¬μš©μžκ°€ 이전에 μš”μ²­ν•œ λͺ¨λ“  트림 및 이어뢙이기 μž‘μ—…μ„ ν•œ λ²ˆμ— μˆ˜ν–‰ν•  수 μžˆλ„λ‘ ν•˜λŠ” 것이닀.

* πŸ“Œ 제곡된 μš”κ΅¬μ‚¬ν•­ λ²”μœ„ λ‚΄μ—μ„œλŠ” 트림과 이어 뢙이기 μž‘μ—…μ΄ 순차적으둜(ν•œ λ²ˆμ—) μ²˜λ¦¬λ˜λŠ” λ°©μ‹μœΌλ‘œ κ΅¬ν˜„ν•˜λ©΄ μΆ©λΆ„ν•  κ²ƒμœΌλ‘œ νŒλ‹¨.



### μž‘μ—… μˆ˜ν–‰ API

| μ‹€ν–‰ μ „ UI | μ‹€ν–‰ ν›„ UI |
|-------|------------------------------------------------------|
| | |



### μ΅œμ’… λ™μ˜μƒ λ‹€μš΄λ‘œλ“œ API

| μ‹€ν–‰ μ „ UI | μ‹€ν–‰ ν›„ UI |
|----------------------------------------------------------------|---------------|
| | |



### Application Server Architecture

Application Server Architecture

πŸ“Œ [μ°Έκ³  Link](https://github.com/bxcodec/go-clean-arch)



### Go Clean Architecture 기반 폴더 ꡬ쑰

Folder Structure



### ERD(Entity Relationship Diagram)

ERD Diagram



### API Endpoint

| HTTP Method | URI | Description |
|-------------|---------------------------|--------------------------|
| `POST` | `/api/videos` | λ™μ˜μƒ μ—…λ‘œλ“œ |
| `POST` | `/api/videos/{id}/trim` | `λͺ…λ Ή` λ™μ˜μƒ μ»· νŽΈμ§‘ (Trim) |
| `POST` | `/api/videos/concat` | `λͺ…λ Ή` λ™μ˜μƒ 이어 뢙이기 (Concat) |
| `POST` | `/api/jobs/execute` | `λͺ…λ Ή` μž‘μ—… μˆ˜ν–‰ |
| `GET` | `/api/videos/{id}/download` | μ΅œμ’… λ™μ˜μƒ λ‹€μš΄λ‘œλ“œ |
| `GET` | `/api/videos` | λ™μ˜μƒ 및 μž‘μ—… 쑰회 |



### Git 컀밋 λ©”μ‹œμ§€ κ·œμΉ™

| Tag | Description |
|------------|-----------------------------------------------------|
| `feat` | μƒˆλ‘œμš΄ κΈ°λŠ₯을 μΆ”κ°€ν•œ 경우 μ‚¬μš©ν•©λ‹ˆλ‹€. |
| `fix` | 버그λ₯Ό μˆ˜μ •ν•œ 경우 μ‚¬μš©ν•©λ‹ˆλ‹€. |
| `refactor` | μ½”λ“œ λ¦¬νŒ©ν† λ§ν•œ 경우 μ‚¬μš©ν•©λ‹ˆλ‹€. |
| `style` | μ½”λ“œ ν˜•μ‹, μ •λ ¬, 주석 λ“±μ˜ λ³€κ²½(λ™μž‘μ— 영ν–₯을 μ£ΌλŠ” μ½”λ“œ λ³€κ²½ μ—†μŒ)ν•œ 경우 μ‚¬μš©ν•©λ‹ˆλ‹€. |
| `test` | ν…ŒμŠ€νŠΈ μΆ”κ°€, ν…ŒμŠ€νŠΈ λ¦¬νŒ©ν† λ§(μ œν’ˆ μ½”λ“œ μˆ˜μ • μ—†μŒ, ν…ŒμŠ€νŠΈ μ½”λ“œμ— κ΄€λ ¨λœ λͺ¨λ“  변경에 ν•΄λ‹Ή)ν•œ 경우 μ‚¬μš©ν•©λ‹ˆλ‹€. |
| `docs` | λ¬Έμ„œλ₯Ό μˆ˜μ •(μ œν’ˆ μ½”λ“œ μˆ˜μ • μ—†μŒ)ν•œ 경우 μ‚¬μš©ν•©λ‹ˆλ‹€. |
| `chore` | λΉŒλ“œ 업무 μˆ˜μ •, νŒ¨ν‚€μ§€ λ§€λ‹ˆμ € μ„€μ • λ“± μœ„μ— ν•΄λ‹Ήλ˜μ§€ μ•ŠλŠ” λͺ¨λ“  λ³€κ²½(μ œν’ˆ μ½”λ“œ μˆ˜μ • μ—†μŒ)일 경우 μ‚¬μš©ν•©λ‹ˆλ‹€. |