Merge branch 'clip-refactor-keyframes' into opencv

This commit is contained in:
Brenno
2020-10-19 22:29:48 -03:00
195 changed files with 2323 additions and 1542 deletions

View File

@@ -0,0 +1,124 @@
####################### CMakeLists.txt (libopenshot) #########################
# @brief CMake build file for libopenshot (used to generate Python SWIG bindings)
# @author Jonathan Thomas <jonathan@openshot.org>
#
# @section LICENSE
#
# Copyright (c) 2008-2019 OpenShot Studios, LLC
# <http://www.openshotstudios.com/>. This file is part of
# OpenShot Library (libopenshot), an open-source project dedicated to
# delivering high quality video editing and animation solutions to the
# world. For more information visit <http://www.openshot.org/>.
#
# OpenShot Library (libopenshot) is free software: you can redistribute it
# and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# OpenShot Library (libopenshot) is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
################################################################################
############### SWIG PYTHON BINDINGS ################
find_package(SWIG 3.0 REQUIRED)
include(${SWIG_USE_FILE})
### Enable some legacy SWIG behaviors, in newer CMAKEs
if (POLICY CMP0078)
cmake_policy(SET CMP0078 OLD)
endif()
if (POLICY CMP0086)
cmake_policy(SET CMP0086 OLD)
endif()
find_package(PythonInterp 3)
find_package(PythonLibs 3)
if (NOT PYTHONLIBS_FOUND OR NOT PYTHONINTERP_FOUND)
return()
endif()
### Include Python header files
include_directories(${PYTHON_INCLUDE_PATH})
if (CMAKE_VERSION VERSION_LESS 3.12)
### Include project headers
include_directories(
"${PROJECT_SOURCE_DIR}/src"
"${PROJECT_BINARY_DIR}/src")
endif()
### Enable C++ in SWIG
set_property(SOURCE openshot.i PROPERTY CPLUSPLUS ON)
set_property(SOURCE openshot.i PROPERTY SWIG_MODULE_NAME openshot)
### Suppress a ton of warnings in the generated SWIG C++ code
set(SWIG_CXX_FLAGS "-Wno-unused-variable -Wno-unused-function \
-Wno-deprecated-copy -Wno-class-memaccess -Wno-cast-function-type \
-Wno-unused-parameter -Wno-catch-value -Wno-sign-compare -Wno-ignored-qualifiers")
separate_arguments(sw_flags UNIX_COMMAND ${SWIG_CXX_FLAGS})
set_property(SOURCE openshot.i PROPERTY GENERATED_COMPILE_OPTIONS ${sw_flags})
### Take include dirs from target, automatically if possible
if (CMAKE_VERSION VERSION_GREATER 3.13)
set_property(SOURCE openshot.i PROPERTY USE_TARGET_INCLUDE_DIRECTORIES True)
elseif (CMAKE_VERSION VERSION_GREATER 3.12)
set_property(SOURCE openshot.i PROPERTY
INCLUDE_DIRECTORIES $<TARGET_PROPERTY:openshot,INCLUDE_DIRECTORIES>)
endif ()
### Add the SWIG interface file (which defines all the SWIG methods)
if (CMAKE_VERSION VERSION_LESS 3.8.0)
swig_add_module(pyopenshot python openshot.i)
else()
swig_add_library(pyopenshot LANGUAGE python SOURCES openshot.i)
endif()
### Set output name of target
set_target_properties(${SWIG_MODULE_pyopenshot_REAL_NAME} PROPERTIES
PREFIX "_" OUTPUT_NAME "openshot")
### Link the new python wrapper library with libopenshot
target_link_libraries(${SWIG_MODULE_pyopenshot_REAL_NAME} PUBLIC
${PYTHON_LIBRARIES} openshot)
######### INSTALL PATH ########
if (NOT DEFINED PYTHON_MODULE_PATH AND DEFINED $ENV{PYTHON_MODULE_PATH})
set(PYTHON_MODULE_PATH $ENV{PYTHON_MODULE_PATH})
endif()
if (NOT DEFINED PYTHON_MODULE_PATH)
if (WIN32 OR APPLE)
set (PYTHON_MODULE_PATH "python")
endif()
if (UNIX AND NOT APPLE)
### Check if the following Debian-friendly python module path exists
set(PYTHON_MODULE_PATH
"lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/dist-packages")
if (NOT EXISTS "${CMAKE_INSTALL_PREFIX}/${PYTHON_MODULE_PATH}")
### Calculate the python module path (using distutils)
execute_process ( COMMAND ${PYTHON_EXECUTABLE} -c "\
from distutils.sysconfig import get_python_lib; \
print( get_python_lib( plat_specific=True, prefix='' ) )"
OUTPUT_VARIABLE PYTHON_MODULE_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE )
endif()
endif()
endif()
message(STATUS "PYTHON_MODULE_PATH: ${CMAKE_INSTALL_PREFIX}/${PYTHON_MODULE_PATH}")
############### INSTALL HEADERS & LIBRARY ################
### Install Python bindings
install(TARGETS ${SWIG_MODULE_pyopenshot_REAL_NAME}
DESTINATION ${PYTHON_MODULE_PATH} )
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/openshot.py
DESTINATION ${PYTHON_MODULE_PATH} )

261
bindings/python/openshot.i Normal file
View File

@@ -0,0 +1,261 @@
/* ####################### src/openshot.i (libopenshot) ########################
# @brief SWIG configuration for libopenshot (to generate Python SWIG bindings)
# @author Jonathan Thomas <jonathan@openshot.org>
#
# @section LICENSE
#
# Copyright (c) 2008-2019 OpenShot Studios, LLC
# <http://www.openshotstudios.com/>. This file is part of
# OpenShot Library (libopenshot), an open-source project dedicated to
# delivering high quality video editing and animation solutions to the
# world. For more information visit <http://www.openshot.org/>.
#
# OpenShot Library (libopenshot) is free software: you can redistribute it
# and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# OpenShot Library (libopenshot) is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
################################################################################ */
%module openshot
/* Suppress warnings about ignored operator= */
%warnfilter(362);
/* Don't generate multiple wrappers for functions with default args */
%feature("compactdefaultargs", "1");
/* Enable inline documentation */
%feature("autodoc", "1");
/* Include various SWIG helpers */
%include "typemaps.i"
%include "std_string.i"
%include "std_list.i"
%include "std_vector.i"
%include "std_map.i"
%include <stdint.i>
/* Unhandled STL Exception Handling */
%include <std_except.i>
/* Include shared pointer code */
%include <std_shared_ptr.i>
/* Mark these classes as shared_ptr classes */
#ifdef USE_IMAGEMAGICK
%shared_ptr(Magick::Image)
#endif
%shared_ptr(juce::AudioSampleBuffer)
%shared_ptr(openshot::Frame)
%{
#include "OpenShotVersion.h"
#include "ReaderBase.h"
#include "WriterBase.h"
#include "CacheBase.h"
#include "CacheDisk.h"
#include "CacheMemory.h"
#include "ChannelLayouts.h"
#include "ChunkReader.h"
#include "ChunkWriter.h"
#include "ClipBase.h"
#include "Clip.h"
#include "Coordinate.h"
#include "Color.h"
#include "DummyReader.h"
#include "EffectBase.h"
#include "Effects.h"
#include "EffectInfo.h"
#include "Enums.h"
#include "Exceptions.h"
#include "FFmpegReader.h"
#include "FFmpegWriter.h"
#include "Fraction.h"
#include "Frame.h"
#include "FrameMapper.h"
#include "PlayerBase.h"
#include "Point.h"
#include "Profiles.h"
#include "QtHtmlReader.h"
#include "QtImageReader.h"
#include "QtPlayer.h"
#include "QtTextReader.h"
#include "KeyFrame.h"
#include "RendererBase.h"
#include "Settings.h"
#include "TimelineBase.h"
#include "Timeline.h"
#include "ZmqLogger.h"
#include "AudioDeviceInfo.h"
%}
#ifdef USE_BLACKMAGIC
%{
#include "DecklinkReader.h"
#include "DecklinkWriter.h"
%}
#endif
#ifdef USE_IMAGEMAGICK
%{
#include "ImageReader.h"
#include "ImageWriter.h"
#include "TextReader.h"
%}
#endif
#ifdef USE_OPENCV
%{
#include "ClipProcessingJobs.h"
#include "effects/Stabilizer.h"
#include "effects/Tracker.h"
#include "effects/ObjectDetection.h"
%}
#endif
/* Generic language independent exception handler. */
%include "exception.i"
%exception {
try {
$action
}
catch (std::exception &e) {
SWIG_exception_fail(SWIG_RuntimeError, e.what());
}
}
/* Instantiate the required template specializations */
%template() std::map<std::string, int>;
/* Make openshot.Fraction more Pythonic */
%extend openshot::Fraction {
%{
#include <sstream>
#include <map>
%}
double __float__() {
return $self->ToDouble();
}
int __int__() {
return $self->ToInt();
}
std::map<std::string, int> GetMap() {
std::map<std::string, int> map1;
map1.insert({"num", $self->num});
map1.insert({"den", $self->den});
return map1;
}
std::string __repr__() {
std::ostringstream result;
result << $self->num << ":" << $self->den;
return result.str();
}
}
%extend openshot::OpenShotVersion {
// Give the struct a string representation
const std::string __str__() {
return std::string(OPENSHOT_VERSION_FULL);
}
// And a repr for interactive use
const std::string __repr__() {
std::ostringstream result;
result << "OpenShotVersion('" << OPENSHOT_VERSION_FULL << "')";
return result.str();
}
}
%include "OpenShotVersion.h"
%include "ReaderBase.h"
%include "WriterBase.h"
%include "CacheBase.h"
%include "CacheDisk.h"
%include "CacheMemory.h"
%include "ChannelLayouts.h"
%include "ChunkReader.h"
%include "ChunkWriter.h"
%include "ClipBase.h"
%include "Clip.h"
%include "Coordinate.h"
%include "Color.h"
#ifdef USE_BLACKMAGIC
%include "DecklinkReader.h"
%include "DecklinkWriter.h"
#endif
%include "DummyReader.h"
%include "EffectBase.h"
%include "Effects.h"
%include "EffectInfo.h"
%include "Enums.h"
%include "Exceptions.h"
%include "FFmpegReader.h"
%include "FFmpegWriter.h"
%include "Fraction.h"
%include "Frame.h"
%include "FrameMapper.h"
%include "PlayerBase.h"
%include "Point.h"
%include "Profiles.h"
%include "QtHtmlReader.h"
%include "QtImageReader.h"
%include "QtPlayer.h"
%include "QtTextReader.h"
%include "KeyFrame.h"
%include "RendererBase.h"
%include "Settings.h"
%include "TimelineBase.h"
%include "Timeline.h"
%include "ZmqLogger.h"
%include "AudioDeviceInfo.h"
#ifdef USE_OPENCV
%include "ClipProcessingJobs.h"
#endif
#ifdef USE_IMAGEMAGICK
%include "ImageReader.h"
%include "ImageWriter.h"
%include "TextReader.h"
#endif
/* Effects */
%include "effects/Bars.h"
%include "effects/Blur.h"
%include "effects/Brightness.h"
%include "effects/ChromaKey.h"
%include "effects/ColorShift.h"
%include "effects/Crop.h"
%include "effects/Deinterlace.h"
%include "effects/Hue.h"
%include "effects/Mask.h"
%include "effects/Negate.h"
%include "effects/Pixelate.h"
%include "effects/Saturation.h"
%include "effects/Shift.h"
%include "effects/Wave.h"
#ifdef USE_OPENCV
%include "effects/Stabilizer.h"
%include "effects/Tracker.h"
%include "effects/ObjectDetection.h"
#endif
/* Wrap std templates (list, vector, etc...) */
%template(ClipList) std::list<openshot::Clip *>;
%template(EffectBaseList) std::list<openshot::EffectBase *>;
%template(CoordinateVector) std::vector<openshot::Coordinate>;
%template(PointsVector) std::vector<openshot::Point>;
%template(FieldVector) std::vector<openshot::Field>;
%template(MappedFrameVector) std::vector<openshot::MappedFrame>;
%template(MetadataMap) std::map<std::string, std::string>;
%template(AudioDeviceInfoVector) std::vector<openshot::AudioDeviceInfo>;