Skip to content

Commit

Permalink
support old abi, refactor few things
Browse files Browse the repository at this point in the history
  • Loading branch information
Prevter committed Dec 29, 2024
1 parent a9d771e commit 46e68fc
Show file tree
Hide file tree
Showing 9 changed files with 237 additions and 250 deletions.
8 changes: 2 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ endif()

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
)
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS src/*.cpp)
add_library(${PROJECT_NAME} SHARED ${SOURCES})

set_property(TARGET ${PROJECT_NAME} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Final>:Final>")
set_property(TARGET ${PROJECT_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
Expand Down
30 changes: 8 additions & 22 deletions include/audio_mixer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@

#include <filesystem>

namespace ffmpeg {
BEGIN_FFMPEG_NAMESPACE_V

class FFMPEG_API_DLL AudioMixer {
public:
AudioMixer() = delete;
AudioMixer(const AudioMixer&) = delete;
AudioMixer(AudioMixer&&) = delete;

/**
* @brief Mixes a video file and an audio file into a single MP4 output.
*
Expand All @@ -23,25 +27,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.
*/
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.
*
* @brief Mixes a video file and raw audio data into a single MP4 output.
*
* This function takes an input video file and raw audio data (in the form of a vector of floating-point samples),
* and merges them into a single MP4 output file.
*
* @param videoFile The path to the input video file.
* @param raw A vector containing the raw audio data (floating-point samples).
* @param outputMp4File The path where the output MP4 file will be saved.
* @param sampleRate The sample rate of the raw audio data.
*
* @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.
*/
[[deprecated]] void mixVideoRaw(std::filesystem::path videoFile, const std::vector<float>& raw, std::filesystem::path outputMp4File, uint32_t sampleRate);
static geode::Result<> mixVideoAudio(std::filesystem::path videoFile, std::filesystem::path audioFile, std::filesystem::path outputMp4File);

/**
* @brief Mixes a video file and raw audio data into a single MP4 output.
Expand All @@ -56,7 +42,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.
*/
geode::Result<void> mixVideoRaw(const std::filesystem::path& videoFile, const std::vector<float>& raw, const std::filesystem::path &outputMp4File);
static geode::Result<> mixVideoRaw(const std::filesystem::path& videoFile, const std::vector<float>& raw, const std::filesystem::path &outputMp4File);
};

}
END_FFMPEG_NAMESPACE_V
Loading

0 comments on commit 46e68fc

Please sign in to comment.