Skip to content

Commit 6483ab1

Browse files
committed
improve recorder and mixer. also readme
1 parent 052fbae commit 6483ab1

12 files changed

Lines changed: 851 additions & 69 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Build Geode Mod
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- "**"
8+
9+
jobs:
10+
build:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
config:
15+
- name: Windows
16+
os: windows-latest
17+
18+
- name: macOS
19+
os: macos-latest
20+
21+
- name: Android32
22+
os: ubuntu-latest
23+
target: Android32
24+
25+
- name: Android64
26+
os: ubuntu-latest
27+
target: Android64
28+
29+
name: ${{ matrix.config.name }}
30+
runs-on: ${{ matrix.config.os }}
31+
32+
steps:
33+
- uses: actions/checkout@v4
34+
35+
- name: Build the mod
36+
uses: geode-sdk/build-geode-mod@main
37+
with:
38+
bindings: geode-sdk/bindings
39+
bindings-ref: main
40+
combine: true
41+
target: ${{ matrix.config.target }}
42+
43+
package:
44+
name: Package builds
45+
runs-on: ubuntu-latest
46+
needs: ['build']
47+
48+
steps:
49+
- uses: geode-sdk/build-geode-mod/combine@main
50+
id: build
51+
52+
- uses: actions/upload-artifact@v4
53+
with:
54+
name: Build Output
55+
path: ${{ steps.build.outputs.build-output }}

README.md

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,62 @@
1-
# ffmpeg-api
1+
# ffmpeg-api
2+
A mod that lets developers easily interact with ffmpeg to record raw videos, and mix video and audio files.
3+
4+
## Usage
5+
6+
### Record videos
7+
8+
```cpp
9+
#include <eclipse.ffmpeg-api/include/recorder.hpp>
10+
11+
void video() {
12+
ffmpeg::Recorder recorder;
13+
14+
RenderSettings settings;
15+
16+
//ffmpeg-api will automatically handle conversion between the input pixel
17+
//format and the codec's pixel format
18+
settings.m_pixelFormat = PixelFormat::RGB0;
19+
settings.m_codec = "h264_nvenc";
20+
settings.m_bitrate = 30000000;
21+
settings.m_width = 1920;
22+
settings.m_height = 1080;
23+
settings.m_fps = 60;
24+
settings.m_outputFile = "output_video.mp4";
25+
26+
//insert your raw data here
27+
std::vector<uint8_t> frame;
28+
29+
recorder.init(settings);
30+
31+
for(int i = 0; i < 60; i++)
32+
recorder.writeFrame(frame);
33+
34+
recorder.stop();
35+
}
36+
```
37+
38+
### Mix audio
39+
40+
```cpp
41+
#include <eclipse.ffmpeg-api/include/audio_mixer.hpp>
42+
43+
void audioFile() {
44+
ffmpeg::AudioMixer mixer;
45+
mixer.mixVideoAudio("video.mp4", "audio.mp3", "output_mp3.mp4");
46+
mixer.mixVideoAudio("video.mp4", "audio.wav", "output_wav.mp4");
47+
}
48+
49+
void audioRaw() {
50+
ffmpeg::AudioMixer mixer;
51+
52+
//insert your raw data here
53+
std::vector<float> raw;
54+
mixer.mixVideoRaw("video.mp4", raw, "output_raw.mp4", 44100);
55+
}
56+
```
57+
58+
## Build instructions
59+
### Windows
60+
To get the needed libraries on Windows, you can use vcpkg
61+
```sh
62+
vcpkg install ffmpeg[core,avcodec,avformat,avutil,swscale,swresample,amf,x264,x265,nvcodec]:x64-windows-static --recurse

about.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# Template Mod
1+
# ffmpeg-api
22

3-
Edit about.md to change this
3+
A mod that lets developers easily interact with ffmpeg to record raw videos, and mix video and audio files.

include/audio_mixer.hpp

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,36 @@ namespace ffmpeg {
88

99
class FFMPEG_API_DLL AudioMixer {
1010
public:
11-
void mixMp4Wav(std::filesystem::path mp4File, std::filesystem::path wavFile, std::filesystem::path outputMp4File);
11+
/**
12+
* @brief Mixes a video file and an audio file into a single MP4 output.
13+
*
14+
* This function takes an input video file and an audio file, and merges them into a single MP4 output file.
15+
* The output MP4 file will have both the video and audio streams synchronized.
16+
*
17+
* @param videoFile The path to the input video file.
18+
* @param audioFile The path to the input audio file.
19+
* @param outputMp4File The path where the output MP4 file will be saved.
20+
*
21+
* @warning The audio file is expected to contain stereo (dual-channel) audio. Using other formats might lead to unexpected results.
22+
* @warning The video file is expected to contain a single video stream. Only the first video stream will be copied.
23+
*/
24+
void mixVideoAudio(std::filesystem::path videoFile, std::filesystem::path audioFile, std::filesystem::path outputMp4File);
25+
26+
/**
27+
* @brief Mixes a video file and raw audio data into a single MP4 output.
28+
*
29+
* This function takes an input video file and raw audio data (in the form of a vector of floating-point samples),
30+
* and merges them into a single MP4 output file. The audio codec parameters must also be provided to describe the format of the raw audio.
31+
*
32+
* @param videoFile The path to the input video file.
33+
* @param raw A vector containing the raw audio data (floating-point samples).
34+
* @param outputMp4File The path where the output MP4 file will be saved.
35+
* @param sampleRate The sample rate of the raw audio data.
36+
*
37+
* @warning The raw audio data is expected to be stereo (dual-channel). Using mono or multi-channel audio might lead to issues.
38+
* @warning The video file is expected to contain a single video stream. Only the first video stream will be copied.
39+
*/
40+
void mixVideoRaw(std::filesystem::path videoFile, const std::vector<float>& raw, std::filesystem::path outputMp4File, uint32_t sampleRate);
1241
};
1342

1443
}

0 commit comments

Comments
 (0)