Skip to content

Commit 13c2306

Browse files
authored
✨ use ffmpeg to encode raw pcm (#69)
* ✨ use ffmpeg to encode raw pcm * 🚨 lint * 💚 install ffmpeg in ci * 👷 update ci setup-ffmpeg action * 👷 nvm, install ffmpeg myself * 🐛 use old way to get supported formats since the new `avcodec_get_supported_config` is too new * 💡 comment out the new function
1 parent 440ff15 commit 13c2306

File tree

23 files changed

+850
-198
lines changed

23 files changed

+850
-198
lines changed

.cargo/config-windows.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[target.'cfg(target_env = "msvc")']
2+
rustflags = ["-C", "target-feature=+crt-static"]
3+
4+
[env]
5+
LIBCLANG_PATH = ""
6+
FFMPEG_DIR = ""

.cargo/config.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
[target.'cfg(target_env = "msvc")']
2-
rustflags = ["-C", "target-feature=+crt-static"]
1+
[alias]
2+
build-windows = "build --config .cargo/config-windows.toml"

.github/workflows/build.yaml

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build
22

33
on:
44
push:
5-
branches: ["main"]
5+
branches: [main]
66
tags: ["*"]
77

88
env:
@@ -27,34 +27,39 @@ jobs:
2727
- name: Install Rust
2828
uses: dtolnay/rust-toolchain@stable
2929

30-
- name: Install nasm
31-
uses: ilammy/setup-nasm@v1
30+
- name: Install FFmpeg
31+
run: |
32+
if [ "${{ runner.os }}" = "Linux" ]; then
33+
sudo apt-get update
34+
sudo apt-get install libavformat-dev libavcodec-dev libavutil-dev libswresample-dev
35+
elif [ "${{ runner.os }}" = "macOS" ]; then
36+
sudo brew install ffmpeg
37+
elif [ "${{ runner.os }}" = "Windows" ]; then
38+
curl --location https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-n7.1-latest-win64-lgpl-shared-7.1.zip --output ffmpeg.zip
39+
unzip ffmpeg.zip
40+
fi
41+
shell: bash
3242

3343
- uses: Swatinem/rust-cache@v2
3444

3545
- name: Build
36-
run: cargo build --release
46+
run: |
47+
export name=mltd-git-$(git describe --tags --dirty)-${{ runner.os }}
3748
38-
- name: Get version (Windows)
39-
if: ${{ contains('Windows', runner.os) }}
40-
id: version_windows
41-
run: echo "version=$(git describe --tags --dirty)" >> $env:GITHUB_OUTPUT
49+
if [ "${{ runner.os }}" = "Windows" ]; then
50+
export FFMPEG_DIR=$PWD/ffmpeg-n7.1-latest-win64-lgpl-shared-7.1
51+
cargo build-windows --release
52+
export name=$name.exe
53+
else
54+
cargo build --release
55+
fi
4256
43-
- name: Get version
44-
if: ${{ !contains('Windows', runner.os) }}
45-
id: version
46-
run: echo "version=$(git describe --tags --dirty)" >> $GITHUB_OUTPUT
57+
echo "name=$name" >> $GITHUB_OUTPUT
4758
48-
- name: Publish artifact (Windows)
49-
if: ${{ contains('Windows', runner.os) }}
50-
uses: actions/upload-artifact@v4
51-
with:
52-
name: mltd-git-${{ steps.version_windows.outputs.version }}-Windows.exe
53-
path: target/release/mltd.exe
59+
shell: bash
5460

5561
- name: Publish artifact
56-
if: ${{ !contains('Windows', runner.os) }}
5762
uses: actions/upload-artifact@v4
5863
with:
59-
name: mltd-git-${{ steps.version.outputs.version }}-${{ runner.os }}
60-
path: target/release/mltd
64+
name: ${{ steps.version.outputs.name }}
65+
path: target/release/mltd-git-*

.github/workflows/check.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ jobs:
1717
with:
1818
submodules: true
1919

20+
- name: Install FFmpeg
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install libavformat-dev libavcodec-dev libavutil-dev libswresample-dev
24+
2025
- name: Install Rust
2126
uses: dtolnay/rust-toolchain@nightly
2227

23-
- name: Install nasm
24-
uses: ilammy/setup-nasm@v1
25-
2628
- uses: Swatinem/rust-cache@v2
2729

2830
- name: Install cargo-binstall

.github/workflows/fmt.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ jobs:
2222
with:
2323
components: rustfmt
2424

25-
- name: Install nasm
26-
uses: ilammy/setup-nasm@v1
27-
2825
- uses: Swatinem/rust-cache@v2
2926

3027
- name: Fmt

.github/workflows/lint.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ jobs:
1717
with:
1818
submodules: true
1919

20+
- name: Install FFmpeg
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install libavformat-dev libavcodec-dev libavutil-dev libswresample-dev
24+
2025
- name: Install Rust
2126
uses: dtolnay/rust-toolchain@stable
2227
with:
2328
components: clippy
2429

25-
- name: Install nasm
26-
uses: ilammy/setup-nasm@v1
27-
2830
- uses: Swatinem/rust-cache@v2
2931

3032
- name: Lint

.github/workflows/test.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ jobs:
1717
with:
1818
submodules: true
1919

20+
- name: Install FFmpeg
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install libavformat-dev libavcodec-dev libavutil-dev libswresample-dev
24+
2025
- name: Install Rust
2126
uses: dtolnay/rust-toolchain@stable
2227

23-
- name: Install nasm
24-
uses: ilammy/setup-nasm@v1
25-
2628
- uses: Swatinem/rust-cache@v2
2729

2830
- name: Test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ output/
44
build/
55

66
.vscode/
7+
8+
.cargo/config-windows.toml

0 commit comments

Comments
 (0)