Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Libraries and executables have been labeled in the list below to help distinguis
#### Qt 5 (libqt5)
* <http://www.qt.io/qt5/> **(Library)**

* Qt5 is used to display video, store image data, composite images,
* Qt5/Qt6 is used to display video, store image data, composite images,
apply image effects, and many other utility functions,
such as file system manipulation, high resolution timers, etc.

Expand Down Expand Up @@ -201,6 +201,7 @@ Following are some of the flags you might need to set when generating your build
* `-DCMAKE_PREFIX_PATH=/extra/path/to/search/for/libraries/`
* `-DUSE_SYSTEM_JSONCPP=0` (default: auto if discovered)
* `-DENABLE_MAGICK=0` (default: auto if discovered)
* `-DUSE_QT6=AUTO|ON|OFF` (default: `AUTO`; prefers Qt6 when available and CMake ≥3.16, `ON` forces Qt6, `OFF` forces Qt5)

#### Options to compile bindings for a specific Python installation
* `-DPYTHON_INCLUDE_DIR=/location/of/python/includes/`
Expand Down
67 changes: 67 additions & 0 deletions bindings/java/openshot.i
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,34 @@
#%template() std::vector<std::pair<std::string, std::string>>;
%template() std::vector<std::vector<float>>;

%inline %{
typedef struct OpenShotByteBuffer {
const unsigned char* data;
int size;
} OpenShotByteBuffer;
%}

%typemap(jni) OpenShotByteBuffer "jbyteArray"
%typemap(jstype) OpenShotByteBuffer "byte[]"
%typemap(jtype) OpenShotByteBuffer "byte[]"
%typemap(javaout) OpenShotByteBuffer {
return $jnicall;
}
%typemap(out) OpenShotByteBuffer {
if ($1.data && $1.size > 0) {
jbyteArray jarr = jenv->NewByteArray($1.size);
if (jarr == NULL) {
SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "Unable to allocate byte array");
return NULL;
}
jenv->SetByteArrayRegion(jarr, 0, $1.size,
reinterpret_cast<const jbyte*>($1.data));
$result = jarr;
} else {
$result = NULL;
}
}

%{
#include "OpenShotVersion.h"
#include "ReaderBase.h"
Expand Down Expand Up @@ -118,6 +146,45 @@
/* Deprecated */
%template(AudioDeviceInfoVector) std::vector<openshot::AudioDeviceInfo>;

%extend openshot::Frame {
OpenShotByteBuffer GetPixelsBytes() {
OpenShotByteBuffer out = {NULL, 0};
std::shared_ptr<QImage> img = $self->GetImage();
if (!img) return out;

const int size = img->bytesPerLine() * img->height();

const unsigned char* p = $self->GetPixels();
if (!p || size <= 0) return out;

out.data = p;
out.size = size;
return out;
}

OpenShotByteBuffer GetPixelsRowBytes(int row) {
OpenShotByteBuffer out = {NULL, 0};
std::shared_ptr<QImage> img = $self->GetImage();
if (!img) return out;

if (row < 0 || row >= img->height()) {
return out;
}

const unsigned char* p = $self->GetPixels(row);
if (!p) return out;

out.data = p;
out.size = img->bytesPerLine();
return out;
}

int GetBytesPerLine() {
std::shared_ptr<QImage> img = $self->GetImage();
return img ? img->bytesPerLine() : 0;
}
}

%include "OpenShotVersion.h"
%include "ReaderBase.h"
%include "WriterBase.h"
Expand Down
68 changes: 68 additions & 0 deletions bindings/python/openshot.i
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,74 @@
}
}

%extend openshot::Frame {
PyObject* GetPixelsBytes() {
PyGILState_STATE gstate = PyGILState_Ensure();
PyObject* result = NULL;

std::shared_ptr<QImage> img = $self->GetImage();
if (!img) {
Py_INCREF(Py_None);
result = Py_None;
PyGILState_Release(gstate);
return result;
}

const Py_ssize_t size =
static_cast<Py_ssize_t>(img->bytesPerLine()) *
static_cast<Py_ssize_t>(img->height());

const unsigned char* p = img->constBits();
if (!p || size <= 0) {
Py_INCREF(Py_None);
result = Py_None;
PyGILState_Release(gstate);
return result;
}

result = PyBytes_FromStringAndSize(reinterpret_cast<const char*>(p), size);
PyGILState_Release(gstate);
return result;
}

PyObject* GetPixelsRowBytes(int row) {
PyGILState_STATE gstate = PyGILState_Ensure();
PyObject* result = NULL;

std::shared_ptr<QImage> img = $self->GetImage();
if (!img) {
Py_INCREF(Py_None);
result = Py_None;
PyGILState_Release(gstate);
return result;
}

if (row < 0 || row >= img->height()) {
PyErr_SetString(PyExc_IndexError, "row out of range");
PyGILState_Release(gstate);
return NULL;
}

const unsigned char* p = img->constScanLine(row);
if (!p) {
Py_INCREF(Py_None);
result = Py_None;
PyGILState_Release(gstate);
return result;
}

const Py_ssize_t row_bytes = static_cast<Py_ssize_t>(img->bytesPerLine());
result = PyBytes_FromStringAndSize(reinterpret_cast<const char*>(p), row_bytes);
PyGILState_Release(gstate);
return result;
}

int GetBytesPerLine() {
std::shared_ptr<QImage> img = $self->GetImage();
return img ? img->bytesPerLine() : 0;
}
}

%include "OpenShotVersion.h"
%include "ReaderBase.h"
%include "WriterBase.h"
Expand Down
54 changes: 54 additions & 0 deletions bindings/ruby/openshot.i
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@
%template() std::vector<std::pair<std::string, std::string>>;
%template() std::vector<std::vector<float>>;

%inline %{
typedef struct OpenShotByteBuffer {
const unsigned char* data;
int size;
} OpenShotByteBuffer;
%}

%typemap(out) OpenShotByteBuffer {
if ($1.data && $1.size > 0) {
$result = rb_str_new(reinterpret_cast<const char*>($1.data), $1.size);
} else {
$result = Qnil;
}
}

%{
/* Ruby and FFmpeg define competing RSHIFT macros,
* so we move Ruby's out of the way for now. We'll
Expand Down Expand Up @@ -136,6 +151,45 @@
/* Deprecated */
%template(AudioDeviceInfoVector) std::vector<openshot::AudioDeviceInfo>;

%extend openshot::Frame {
OpenShotByteBuffer GetPixelsBytes() {
OpenShotByteBuffer out = {NULL, 0};
std::shared_ptr<QImage> img = $self->GetImage();
if (!img) return out;

const int size = img->bytesPerLine() * img->height();

const unsigned char* p = $self->GetPixels();
if (!p || size <= 0) return out;

out.data = p;
out.size = size;
return out;
}

OpenShotByteBuffer GetPixelsRowBytes(int row) {
OpenShotByteBuffer out = {NULL, 0};
std::shared_ptr<QImage> img = $self->GetImage();
if (!img) return out;

if (row < 0 || row >= img->height()) {
rb_raise(rb_eIndexError, "row out of range");
}

const unsigned char* p = $self->GetPixels(row);
if (!p) return out;

out.data = p;
out.size = img->bytesPerLine();
return out;
}

int GetBytesPerLine() {
std::shared_ptr<QImage> img = $self->GetImage();
return img ? img->bytesPerLine() : 0;
}
}

%include "OpenShotVersion.h"
%include "ReaderBase.h"
%include "WriterBase.h"
Expand Down
15 changes: 13 additions & 2 deletions doc/INSTALL-LINUX.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ list below to help distinguish between them.

### Qt 5 (libqt5)
* http://www.qt.io/qt5/ `(Library)`
* Qt5 is used to display video, store image data, composite images, apply image effects, and many other utility functions, such as file system manipulation, high resolution timers, etc...
* Qt5/Qt6 is used to display video, store image data, composite images, apply image effects, and many other utility functions, such as file system manipulation, high resolution timers, etc...
* Use the CMake option `-DUSE_QT6=ON|OFF|AUTO` (default AUTO) to pick a Qt major version; Qt6 builds require CMake 3.16+.

### CMake (cmake)
* http://www.cmake.org/ `(Executable)`
Expand Down Expand Up @@ -163,9 +164,19 @@ software packages available to download and install.
python3-dev \
qtbase5-dev \
qtmultimedia5-dev \
swig
swig \
python3-zmq \
python3-pyqt5.qtwebengine

```

If you want to build against Qt6 on Ubuntu 24.04 or newer, install the Qt6 dev stack instead and configure with the default `USE_QT6=AUTO` (prefers Qt6 when available) or `-DUSE_QT6=ON` to force it:

```
sudo apt install qt6-base-dev qt6-base-dev-tools qt6-tools-dev qt6-svg-dev
```


## Linux Build Instructions (libopenshot-audio)
To compile libopenshot-audio, we need to go through a few additional steps to manually build and
install it. Launch a terminal and enter:
Expand Down
3 changes: 2 additions & 1 deletion doc/INSTALL-MAC.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ list below to help distinguish between them.

### Qt 5 (libqt5)
* http://www.qt.io/qt5/ `(Library)`
* Qt5 is used to display video, store image data, composite images, apply image effects, and many other utility functions, such as file system manipulation, high resolution timers, etc...
* Qt5/Qt6 is used to display video, store image data, composite images, apply image effects, and many other utility functions, such as file system manipulation, high resolution timers, etc...
* Use the CMake option `-DUSE_QT6=ON|OFF|AUTO` (default AUTO) to pick a Qt major version; Qt6 builds require CMake 3.16+.

### CMake (cmake)
* http://www.cmake.org/ `(Executable)`
Expand Down
3 changes: 2 additions & 1 deletion doc/INSTALL-WINDOWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ have been labeled in the list below to help distinguish between them.

### Qt 5 (libqt5)
* http://www.qt.io/qt5/ `(Library)`
* Qt5 is used to display video, store image data, composite images, apply image effects, and many other utility functions, such as file system manipulation, high resolution timers, etc...
* Qt5/Qt6 is used to display video, store image data, composite images, apply image effects, and many other utility functions, such as file system manipulation, high resolution timers, etc...
* Use the CMake option `-DUSE_QT6=ON|OFF|AUTO` (default AUTO) to pick a Qt major version; Qt6 builds require CMake 3.16+.

### CMake (cmake)
* http://www.cmake.org/ `(Executable)`
Expand Down
43 changes: 40 additions & 3 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,45 @@

include(GNUInstallDirs)

# Dependencies
find_package(Qt5 COMPONENTS Gui REQUIRED)
# Qt selection matches the main library (USE_QT6 option, CMake 3.16+ needed for Qt6)
set(_qt6_allowed TRUE)
if(CMAKE_VERSION VERSION_LESS "3.16")
set(_qt6_allowed FALSE)
if(USE_QT6 STREQUAL "ON")
message(FATAL_ERROR "USE_QT6=ON requires CMake 3.16 or newer")
endif()
endif()
if(USE_QT6 STREQUAL "OFF")
set(_qt6_allowed FALSE)
endif()

set(_qt_selection "")
if(USE_QT6 STREQUAL "ON")
if(NOT _qt6_allowed)
message(FATAL_ERROR "Qt6 support disabled by CMake version; set USE_QT6=OFF or upgrade CMake")
endif()
set(_qt_selection "Qt6")
elseif(USE_QT6 STREQUAL "OFF")
set(_qt_selection "Qt5")
else()
if(_qt6_allowed)
find_package(Qt6 COMPONENTS Core QUIET)
if(Qt6_FOUND)
set(_qt_selection "Qt6")
endif()
endif()
if(NOT _qt_selection)
set(_qt_selection "Qt5")
endif()
endif()

if(_qt_selection STREQUAL "Qt6")
set(QT_VERSION_MAJOR 6)
else()
set(QT_VERSION_MAJOR 5)
endif()

find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Gui REQUIRED)

############### CLI EXECUTABLES ################
# Create test executable
Expand All @@ -27,7 +64,7 @@ target_compile_definitions(openshot-example PRIVATE
target_link_libraries(openshot-example openshot)

add_executable(openshot-html-example ExampleHtml.cpp)
target_link_libraries(openshot-html-example openshot Qt5::Gui)
target_link_libraries(openshot-html-example openshot Qt${QT_VERSION_MAJOR}::Gui)

############### PLAYER EXECUTABLE ################
# Create test executable
Expand Down
Loading