-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support transforming video (pan, zoom, rotate)
- Loading branch information
1 parent
2b5cec4
commit f597f1c
Showing
9 changed files
with
156 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (C) 2024 Andrew Wason | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
import QtQuick | ||
|
||
/*! | ||
\qmltype Transformer | ||
\inqmlmodule MediaFX | ||
\inherits QtObject | ||
\brief Computes pan, zoom, rotate transformation | ||
*/ | ||
QtObject { | ||
/*! Scale factor. */ | ||
property real scale: 1 | ||
/*! Rotation in degrees. */ | ||
property real rotate: 0 | ||
/*! Translation, normalized to -1..0..1. */ | ||
property point translate: Qt.point(0, 0) | ||
/*! Width of item being transformed. */ | ||
property real width | ||
/*! Height of item being transformed. */ | ||
property real height | ||
/*! The transformation matrix. */ | ||
readonly property Matrix4x4 transform: Matrix4x4 { | ||
matrix: computeTransform(width, height, scale, rotate, translate) | ||
} | ||
|
||
function computeTransform(width: real, height: real, scale: real, rotate: real, translate: point): matrix4x4 { | ||
const matrix = Qt.matrix4x4(); | ||
if (scale === 1 && rotate === 0 && translate.x === 0 && translate.y === 0) | ||
return matrix; | ||
matrix.translate(Qt.vector3d(width / 2, height / 2, 0)); | ||
if (translate.x !== 0 || translate.y !== 0) | ||
matrix.translate(Qt.vector3d(-translate.x * width, -translate.y * height, 0)); | ||
if (scale !== 1) | ||
matrix.scale(scale); | ||
if (rotate !== 0) | ||
matrix.rotate(rotate, Qt.vector3d(0, 0, 1)); | ||
matrix.translate(Qt.vector3d(-width / 2, -height / 2, 0)); | ||
return matrix; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule fixtures
updated
6 files
+ − | gl-transitions.nut | |
+933 −882 | gl-transitions.nut.framehash | |
+ − | sequence.nut | |
+287 −277 | sequence.nut.framehash | |
+ − | transformer.nut | |
+119 −0 | transformer.nut.framehash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (C) 2024 Andrew Wason | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
import QtQuick | ||
import QtMultimedia | ||
import MediaFX | ||
import MediaFX.Transition.GL | ||
|
||
Item { | ||
MediaSequence { | ||
id: sequence | ||
|
||
anchors.fill: parent | ||
|
||
Component.onCompleted: { | ||
sequence.mediaSequenceEnded.connect(sequence.RenderSession.session.endSession); | ||
} | ||
|
||
Component { | ||
MediaSequenceClip { | ||
id: clip1 | ||
endTime: 3500 | ||
source: Qt.resolvedUrl("../fixtures/assets/road.jpg") | ||
endTransition: Bounce { | ||
objectName: "Bounce" | ||
duration: 1000 | ||
} | ||
transformer: Transformer { | ||
NumberAnimation on scale { | ||
to: 2 | ||
duration: clip1.duration | ||
} | ||
PropertyAnimation on translate { | ||
to: Qt.point(0.5, 0.5) | ||
duration: clip1.duration | ||
} | ||
} | ||
} | ||
} | ||
Component { | ||
MediaSequenceClip { | ||
id: clip2 | ||
endTime: 3500 | ||
source: Qt.resolvedUrl("../fixtures/assets/lake.jpg") | ||
transformer: Transformer { | ||
NumberAnimation on scale { | ||
to: 2 | ||
duration: clip2.duration | ||
} | ||
RotationAnimation on rotate { | ||
to: 45 | ||
easing.type: Easing.InQuart | ||
duration: clip2.duration | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |