Skip to content

Commit 4212ce6

Browse files
committed
better error handling
1 parent 13b55df commit 4212ce6

File tree

8 files changed

+215
-220
lines changed

8 files changed

+215
-220
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ project(ffmpeg-api VERSION 1.0.0)
1414
add_library(${PROJECT_NAME} SHARED
1515
src/recorder.cpp
1616
src/audio_mixer.cpp
17+
src/utils.cpp
1718
# Add any extra C++ source files here
1819
)
1920

include/audio_mixer.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include "export.hpp"
44

5+
#include <Geode/Result.hpp>
6+
57
#include <filesystem>
68

79
namespace ffmpeg {
@@ -21,7 +23,7 @@ class FFMPEG_API_DLL AudioMixer {
2123
* @warning The audio file is expected to contain stereo (dual-channel) audio. Using other formats might lead to unexpected results.
2224
* @warning The video file is expected to contain a single video stream. Only the first video stream will be copied.
2325
*/
24-
void mixVideoAudio(std::filesystem::path videoFile, std::filesystem::path audioFile, std::filesystem::path outputMp4File);
26+
geode::Result<void> mixVideoAudio(std::filesystem::path videoFile, std::filesystem::path audioFile, std::filesystem::path outputMp4File);
2527

2628
/**
2729
* @deprecated sampleRate parameter is no longer used. Use the other overload of this function instead.
@@ -54,7 +56,7 @@ class FFMPEG_API_DLL AudioMixer {
5456
* @warning The raw audio data is expected to be stereo (dual-channel). Using mono or multi-channel audio might lead to issues.
5557
* @warning The video file is expected to contain a single video stream. Only the first video stream will be copied.
5658
*/
57-
void mixVideoRaw(const std::filesystem::path& videoFile, const std::vector<float>& raw, const std::filesystem::path &outputMp4File);
59+
geode::Result<void> mixVideoRaw(const std::filesystem::path& videoFile, const std::vector<float>& raw, const std::filesystem::path &outputMp4File);
5860
};
5961

6062
}

include/recorder.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include "render_settings.hpp"
44
#include "export.hpp"
55

6+
#include <Geode/Result.hpp>
7+
68
#include <vector>
79
#include <string>
810
#include <memory>
@@ -35,7 +37,7 @@ class FFMPEG_API_DLL Recorder {
3537
*
3638
* @return true if initialization is successful, false otherwise.
3739
*/
38-
bool init(const RenderSettings& settings);
40+
geode::Result<void> init(const RenderSettings& settings);
3941
/**
4042
* @brief Stops the recording process and finalizes the output file.
4143
*
@@ -57,7 +59,7 @@ class FFMPEG_API_DLL Recorder {
5759
*
5860
* @warning Ensure that the frameData size matches the expected dimensions of the frame.
5961
*/
60-
bool writeFrame(const std::vector<uint8_t>& frameData);
62+
geode::Result<void> writeFrame(const std::vector<uint8_t>& frameData);
6163

6264
/**
6365
* @brief Retrieves a list of available codecs for video encoding.
@@ -70,7 +72,7 @@ class FFMPEG_API_DLL Recorder {
7072
std::vector<std::string> getAvailableCodecs();
7173

7274
private:
73-
void filterFrame(AVFrame* inputFrame, AVFrame* outputFrame);
75+
geode::Result<void> filterFrame(AVFrame* inputFrame, AVFrame* outputFrame);
7476

7577
private:
7678
AVFormatContext* m_formatContext = nullptr;

mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"id": "eclipse.ffmpeg-api",
1515
"name": "FFmpeg API",
16-
"version": "v1.1.2",
16+
"version": "v1.1.3",
1717
"developers": ["Eclipse Team", "maxnu"],
1818
"description": "Interaction with FFmpeg made easy",
1919
"tags": ["utility", "offline", "developer"],

0 commit comments

Comments
 (0)