Skip to content

Commit

Permalink
better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnut committed Nov 28, 2024
1 parent 13b55df commit 4212ce6
Show file tree
Hide file tree
Showing 8 changed files with 215 additions and 220 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ project(ffmpeg-api VERSION 1.0.0)
add_library(${PROJECT_NAME} SHARED
src/recorder.cpp
src/audio_mixer.cpp
src/utils.cpp
# Add any extra C++ source files here
)

Expand Down
6 changes: 4 additions & 2 deletions include/audio_mixer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "export.hpp"

#include <Geode/Result.hpp>

#include <filesystem>

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

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

}
8 changes: 5 additions & 3 deletions include/recorder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "render_settings.hpp"
#include "export.hpp"

#include <Geode/Result.hpp>

#include <vector>
#include <string>
#include <memory>
Expand Down Expand Up @@ -35,7 +37,7 @@ class FFMPEG_API_DLL Recorder {
*
* @return true if initialization is successful, false otherwise.
*/
bool init(const RenderSettings& settings);
geode::Result<void> init(const RenderSettings& settings);
/**
* @brief Stops the recording process and finalizes the output file.
*
Expand All @@ -57,7 +59,7 @@ class FFMPEG_API_DLL Recorder {
*
* @warning Ensure that the frameData size matches the expected dimensions of the frame.
*/
bool writeFrame(const std::vector<uint8_t>& frameData);
geode::Result<void> writeFrame(const std::vector<uint8_t>& frameData);

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

private:
void filterFrame(AVFrame* inputFrame, AVFrame* outputFrame);
geode::Result<void> filterFrame(AVFrame* inputFrame, AVFrame* outputFrame);

private:
AVFormatContext* m_formatContext = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"id": "eclipse.ffmpeg-api",
"name": "FFmpeg API",
"version": "v1.1.2",
"version": "v1.1.3",
"developers": ["Eclipse Team", "maxnu"],
"description": "Interaction with FFmpeg made easy",
"tags": ["utility", "offline", "developer"],
Expand Down
Loading

0 comments on commit 4212ce6

Please sign in to comment.