Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
c2095b9
Added method to set all Keyframes with unnormalised vales at once
ffAudio Mar 12, 2021
3a68c4d
Pull silence instead of garbage if FIFO is empty
ffAudio Mar 12, 2021
f110f13
Fixed warning
ffAudio Mar 12, 2021
7e9f479
Optimised CPU spin on read ahead, and when clip is exhausted
ffAudio Mar 24, 2021
7c6231a
Write header even when aborting writing
ffAudio Apr 26, 2021
e68979d
Merge branch 'develop' of https://github.com/ffAudio/foleys_video_eng…
ffAudio Apr 26, 2021
106f5d3
Fixed some warnings
ffAudio Apr 26, 2021
ca53f74
Added AVFormat interface to allow different reading backends
ffAudio Apr 30, 2021
9bfbd60
Merge branch 'avformat' into develop
ffAudio Apr 30, 2021
d16a08e
Fixed wrong FFmpegFormat include
ffAudio Apr 30, 2021
7fb18b1
Fixed FFmpeg setup
ffAudio Apr 30, 2021
641c1ce
Sound dev (#12)
ffAudio May 18, 2021
110f186
initial commit to cmake branch
benthevining Feb 23, 2022
aeb0938
fixing issue with directory structure; refactoring cmake
benthevining Mar 1, 2022
5b0fe54
refactoring cmake
benthevining Mar 1, 2022
1c60780
cmake refactor: universal binary build of ffmpeg
benthevining Mar 3, 2022
8f179b5
disabled assembly to fix ffmpeg compile error
benthevining Mar 3, 2022
465b99a
refactor: various cmake refactors
benthevining Mar 15, 2022
5f8b392
fixied audio stream init
andorxornot Apr 7, 2022
f2a441c
removed avresample
andorxornot Apr 7, 2022
070ef72
fixed gl namespace for last JUCE
andorxornot Apr 7, 2022
0eafa66
fixed another gl namespace
andorxornot Apr 7, 2022
8d8d5d4
added relative ffmpeg header path
andorxornot Apr 7, 2022
8462010
fixed linking for ffmpeg libs to expected juce library paths, include…
himwho Apr 8, 2022
46f4fe3
removed unnecessary ffmpeg libs for windows
andorxornot Apr 8, 2022
55c34e7
removed some unused libs
himwho Apr 8, 2022
478810c
updated macos ffmpeg setup script to use homebrew entirely on stable …
himwho Apr 8, 2022
14cbbbe
remove explicit error handling
himwho Apr 8, 2022
bde013c
Added getNumChannels method
andorxornot Apr 22, 2022
805906d
Removed inner nested directory; configured CMake package file exporting
benthevining Jun 17, 2022
7bb7994
small improvements to script for safer usage
himwho Jul 11, 2022
015bf1d
fix: updating JUCE hash to latest JUCE6 commit
benthevining Jul 13, 2022
90152cd
refactor: updating fetch logic for ffmpeg
benthevining Jul 14, 2022
0721018
fix: renaming ffmpeg find module
benthevining Jul 14, 2022
61972a6
pathing error
himwho Aug 30, 2022
eab357f
Merge pull request #1 from Mach1Studios/feature/cmake
himwho Mar 16, 2023
f4a58f5
Merge branch 'mach1/develop'
himwho Mar 16, 2023
c3a181c
changed cmake behavior to not require juce if included as a module
himwho Mar 16, 2023
e8f8d92
more protections for usage as module, pointed the ffmpeg cmake to custom
himwho Mar 21, 2023
faea1e3
remove some dead files
himwho Mar 21, 2023
5b4b1d9
removed conflicting linking declarations
himwho Mar 22, 2023
d2593cf
fix: JUCE7, last ffmpeg
andorxornot May 18, 2023
b78bf26
revert libs path
andorxornot May 18, 2023
a2299b8
fixed for linking with submodules
himwho May 19, 2023
16e7f0d
added a check for find_package
himwho May 25, 2023
aa55cd5
Merge branch 'ffAudio:master' into master
himwho Oct 24, 2023
cd24a2d
added to ffmpeg cmake process to make it work crossplatform
himwho Oct 24, 2023
9095a34
Merge branch 'master' of github.com:Mach1Studios/foleys_video_engine
himwho Oct 24, 2023
a0165de
fixed windows compile issue with syntax
himwho Oct 26, 2023
3f27ec8
remove preset file
himwho Oct 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
**/.DS*
**/Builds/
**/Cache/
**/JuceLibraryCode/
**/!JuceLibraryCode/AppConfig.h

# ingore ffmpeg lib folder contents
libs/
ffmpeg/
# except for the .gitkeep(s)
!.gitkeep
2 changes: 1 addition & 1 deletion Basics/foleys_AudioFifo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void AudioFifo::pushSamples (const juce::AudioBuffer<float>& samples)
void AudioFifo::setNumSamples (int samples)
{
audioFifo.setTotalSize (samples);
audioBuffer.setSize (2, samples);
audioBuffer.setSize (audioBuffer.getNumChannels(), samples);
}

void AudioFifo::pullSamples (const juce::AudioSourceChannelInfo& info)
Expand Down
2 changes: 1 addition & 1 deletion Basics/foleys_VideoEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class VideoEngine : private juce::Timer

juce::OptionalScopedPointer<juce::UndoManager> undoManager { new juce::UndoManager(), true };

juce::ThreadPool jobThreads { std::max (4, juce::SystemStats::getNumCpus()) };
juce::ThreadPool jobThreads{ (std::max)(4, juce::SystemStats::getNumCpus()) };
std::vector<std::unique_ptr<juce::TimeSliceThread>> readingThreads;

std::vector<std::shared_ptr<AVClip>> releasePool;
Expand Down
77 changes: 77 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
cmake_minimum_required (VERSION 3.15 FATAL_ERROR)

if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
project (FoleysVideoEngine
VERSION 0.2.0
LANGUAGES CXX OBJC C
DESCRIPTION "A video engine module for JUCE"
HOMEPAGE_URL "https://foleysfinest.com/foleys_video_engine/")
else()
project (FoleysVideoEngine
VERSION 0.2.0
LANGUAGES CXX C
DESCRIPTION "A video engine module for JUCE"
HOMEPAGE_URL "https://foleysfinest.com/foleys_video_engine/")
endif()

list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

if(NOT ffmpeg_FOUND)
find_package (ffmpeg REQUIRED)
endif()

if(PROJECT_IS_TOP_LEVEL)
message(STATUS "No parent project found, requiring JUCE")
find_package (JUCE 6 REQUIRED)
endif()

juce_add_module ("${CMAKE_CURRENT_LIST_DIR}" ALIAS_NAMESPACE Foleys)

target_compile_definitions (foleys_video_engine INTERFACE
JUCE_MODAL_LOOPS_PERMITTED=1
JUCE_STRICT_REFCOUNTEDPOINTER=1
JUCE_PLUGINHOST_AU=1
JUCE_PLUGINHOST_VST3=1
JUCE_PLUGINHOST_LADSPA=1)

target_link_libraries (foleys_video_engine INTERFACE FFmpeg::FFmpeg)

#

set (FVE_INSTALL_DEST "${CMAKE_INSTALL_LIBDIR}/cmake/foleys_video_engine"
CACHE STRING
"Directory below INSTALL_PREFIX where the foleys_video_engine CMake package files will be installed to")

install (DIRECTORY "${CMAKE_CURRENT_LIST_DIR}"
DESTINATION "${FVE_INSTALL_DEST}/.."
COMPONENT foleys_video_engine
PATTERN *.md EXCLUDE
PATTERN .git/* EXCLUDE
PATTERN .github/* EXCLUDE
PATTERN *.json EXCLUDE
PATTERN CMakeLists.txt EXCLUDE
PATTERN "${CMAKE_CURRENT_BINARY_DIR}/" EXCLUDE)

include (CPackComponent)

cpack_add_component (foleys_video_engine
GROUP Foleys
INSTALL_TYPES Developer)

include (CMakePackageConfigHelpers)

write_basic_package_version_file (foleys_video_engine-config-version.cmake
VERSION "${PROJECT_VERSION}"
COMPATIBILITY SameMajorVersion
ARCH_INDEPENDENT)

configure_package_config_file (cmake/config.cmake foleys_video_engine-config.cmake
INSTALL_DESTINATION "${FVE_INSTALL_DEST}"
NO_SET_AND_CHECK_MACRO)

install (FILES "${CMAKE_CURRENT_BINARY_DIR}/foleys_video_engine-config-version.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/foleys_video_engine-config.cmake"
DESTINATION "${FVE_INSTALL_DEST}"
COMPONENT foleys_video_engine)

export (PACKAGE foleys_video_engine)
2 changes: 2 additions & 0 deletions Clips/foleys_AVClip.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ class AVClip : public juce::PositionableAudioSource,
/** Returns true, if this clip will produce audio */
virtual bool hasAudio() const = 0;

virtual int getNumChannels() const = 0;

/**
This is the samplerate supplied from prepareToPlay and the sample rate
this clip will produce audio and use as clock source. */
Expand Down
2 changes: 2 additions & 0 deletions Clips/foleys_AudioClip.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ class AudioClip : public AVClip

std::shared_ptr<AVClip> createCopy (StreamTypes types) override;

int getNumChannels() const override { return reader.get() ? reader->numChannels : 0; }

double getSampleRate() const override { return sampleRate; }

private:
Expand Down
5 changes: 5 additions & 0 deletions Clips/foleys_ComposedClip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,11 @@ std::shared_ptr<AVClip> ComposedClip::createCopy (StreamTypes)
return clipCopy;
}

int ComposedClip::getNumChannels() const
{
return audioSettings.numChannels;
}

double ComposedClip::getSampleRate() const
{
return audioSettings.timebase;
Expand Down
2 changes: 2 additions & 0 deletions Clips/foleys_ComposedClip.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ class ComposedClip : public AVClip,

std::shared_ptr<AVClip> createCopy (StreamTypes types) override;

int getNumChannels() const override;

double getSampleRate() const override;

/** When rendering non realtime (bounce), use this to wait for background
Expand Down
6 changes: 6 additions & 0 deletions Clips/foleys_ImageClip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ std::shared_ptr<AVClip> ImageClip::createCopy (StreamTypes types)
return engine->createClipFromFile (getMediaFile(), types);
}


int ImageClip::getNumChannels() const
{
return 0;
}

double ImageClip::getSampleRate() const
{
return sampleRate;
Expand Down
2 changes: 2 additions & 0 deletions Clips/foleys_ImageClip.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class ImageClip : public AVClip

std::shared_ptr<AVClip> createCopy (StreamTypes types) override;

int getNumChannels() const override;

double getSampleRate() const override;

private:
Expand Down
5 changes: 5 additions & 0 deletions Clips/foleys_MovieClip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ double MovieClip::getSampleRate() const
return sampleRate;
}

int MovieClip::getNumChannels() const
{
return movieReader ? movieReader->numChannels : 0;
}

void MovieClip::handleAsyncUpdate()
{
if (sampleRate > 0 && hasVideo())
Expand Down
2 changes: 2 additions & 0 deletions Clips/foleys_MovieClip.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class MovieClip : public AVClip,

std::shared_ptr<AVClip> createCopy (StreamTypes types) override;

int getNumChannels() const override;

double getSampleRate() const override;

/** When rendering non realtime (bounce), use this to wait for background
Expand Down
13 changes: 12 additions & 1 deletion Processing/foleys_ProcessorController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,24 @@ struct AudioProcessorAdapter : public ProcessorController::ProcessorAdapter
public:
PlayHead() = default;

bool getCurrentPosition (juce::AudioPlayHead::CurrentPositionInfo &result) override
#if JUCE_VERSION > 0x70000
juce::Optional<PositionInfo> getPosition() const override
{
PositionInfo result;
result.setTimeInSamples(timeInSamples);
result.setTimeInSeconds(timeInSeconds);
result.setFrameRate(frameRate);
return juce::Optional<PositionInfo>(result);
}
#else
bool getCurrentPosition (juce::AudioPlayHead::CurrentPositionInfo &result) override
{
result.timeInSamples = timeInSamples;
result.timeInSeconds = timeInSeconds;
result.frameRate = frameRate;
return true;
}
#endif

bool canControlTransport() override
{
Expand Down
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,35 @@ Foleys Finest Audio Ltd.
With the module foleys_video_engine we offer a simple way to implement reading,
writing, displaying and editing of videos using the audio framework JUCE (https://juce.com)

Setup
--------

To use the video engine, add this module via Projucer or CMake to your JUCE project.

In CMake, this module can be added like this:
```cmake
add_subdirectory (foleys_video_engine)
```
or like this:
```cmake
find_package (foleys_video_engine)
```
This repo's CMake scripts add JUCE by calling `find_package()`. Foleys video engine requires JUCE version 6, and may
be incompatible with JUCE version 7.

You can override the path to JUCE on the command line like so:
```shell
cmake -B Builds -D FETCHCONTENT_SOURCE_DIR_JUCE=<your_juce_path>
```

If you are using CMake and the CPM.cmake package manager to add this repository, be aware that:
- JUCE's module system expects the root folder of a module to have the same name as the module
- By default, CPM.cmake will download the source code into a nested folder named with the version, for example `foleys_video_engine/<version>/<sourcesHere>`
This can cause the JUCE module system to get confused. If you are using CPM.cmake, we recommend you set the `CPM_USE_NAMED_CACHE_DIRECTORIES` CMake or environment variable to `ON` to prevent this issue.

foleys_video_engine requires [ffmpeg](https://www.ffmpeg.org/), which is built in CMake using [this repository](https://github.com/ffAudio/FFmpegBuild). The CMake configuration should "just work" out of the box, you don't need
to download or install anything.

Features
--------

Expand Down
9 changes: 1 addition & 8 deletions ReadWrite/FFmpeg/foleys_FFmpegHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,12 @@
#pragma clang diagnostic ignored "-Wfloat-conversion"
#endif

#if JUCE_MSVC
#pragma comment (lib, "avformat.lib")
#pragma comment (lib, "avutil.lib")
#pragma comment (lib, "avcodec.lib")
#pragma comment (lib, "swscale.lib")
#pragma comment (lib, "swresample.lib")
#pragma comment (lib, "avresample.lib")
#endif

#ifdef __cplusplus
extern "C" {
#endif

#include <libavcodec/avcodec.h>
#include <libavutil/pixdesc.h>
#include <libavutil/imgutils.h>
#include <libavutil/opt.h>
Expand Down
4 changes: 2 additions & 2 deletions ReadWrite/FFmpeg/foleys_FFmpegReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#if FOLEYS_USE_FFMPEG

#include "foleys_FFmpegHelpers.h"

#include <libavcodec/avcodec.h>

namespace foleys
{
Expand Down Expand Up @@ -353,7 +353,7 @@ class FFmpegReader::Pimpl
enum AVMediaType type,
bool refCounted)
{
AVCodec *decoder = nullptr;
const AVCodec *decoder = nullptr;
AVDictionary *opts = nullptr;

int id = av_find_best_stream (formatContext, type, -1, -1, nullptr, 0);
Expand Down
Loading