Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnut committed Dec 20, 2024
1 parent 1effc2a commit a9d771e
Showing 1 changed file with 69 additions and 1 deletion.
70 changes: 69 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ A mod that lets developers easily interact with ffmpeg to record raw videos, and

### Record videos

<details>
<summary>Normal API</summary>

```cpp
#include <eclipse.ffmpeg-api/include/recorder.hpp>

Expand Down Expand Up @@ -35,8 +38,48 @@ void video() {
}
```

</details>

<details>
<summary>Event-based API</summary>

```cpp
#include <events.hpp>

void video() {
ffmpeg::events::Recorder recorder;

ffmpeg::RenderSettings settings;

//ffmpeg-api will automatically handle conversion between the input pixel
//format and the codec's pixel format
settings.m_pixelFormat = PixelFormat::RGB0;
settings.m_codec = "h264_nvenc"; //fetch codecs using recorder.getAvailableCodecs()
settings.m_bitrate = 30000000;
settings.m_width = 1920;
settings.m_height = 1080;
settings.m_fps = 60;
settings.m_outputFile = "output_video.mp4";

//insert your raw data here
std::vector<uint8_t> frame;

recorder.init(settings);

for(int i = 0; i < 60; i++)
recorder.writeFrame(frame);

recorder.stop();
}
```

</details>

### Mix audio

<details>
<summary>Normal API</summary>

```cpp
#include <eclipse.ffmpeg-api/include/audio_mixer.hpp>

Expand All @@ -51,10 +94,35 @@ void audioRaw() {

//insert your raw data here
std::vector<float> raw;
mixer.mixVideoRaw("video.mp4", raw, "output_raw.mp4", 44100);
mixer.mixVideoRaw("video.mp4", raw, "output_raw.mp4");
}
```

</details>

<details>
<summary>Event-based API</summary>

```cpp
#include <events.hpp>

void audioFile() {
ffmpeg::events::AudioMixer mixer;
mixer.mixVideoAudio("video.mp4", "audio.mp3", "output_mp3.mp4");
mixer.mixVideoAudio("video.mp4", "audio.wav", "output_wav.mp4");
}

void audioRaw() {
ffmpeg::events::AudioMixer mixer;

//insert your raw data here
std::vector<float> raw;
mixer.mixVideoRaw("video.mp4", raw, "output_raw.mp4");
}
```

</details>

## Build instructions
### Windows
To get the needed libraries on Windows, you can use vcpkg:
Expand Down

0 comments on commit a9d771e

Please sign in to comment.