Skip to content

Commit 2a7f837

Browse files
committed
[orx-video-profiles] Add orx-video-profiles
1 parent b050c52 commit 2a7f837

File tree

9 files changed

+157
-2
lines changed

9 files changed

+157
-2
lines changed

build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ buildscript {
1414
apply plugin: 'org.jetbrains.dokka'
1515

1616
project.ext {
17-
openrndrVersion = "0.3.43-rc.15"
17+
openrndrVersion = "0.3.44-rc.1"
1818
kotlinVersion = "1.3.72"
1919
spekVersion = "2.0.10"
2020
libfreenectVersion = "0.5.7-1.5.3"
@@ -181,6 +181,9 @@ task collectScreenshots {
181181
continue
182182
if (sub.name == "orx-chataigne")
183183
continue
184+
if (sub.name == "orx-video-profiles")
185+
continue
186+
184187
def set = sub.sourceSets.demo
185188
def ucl = new URLClassLoader(set.runtimeClasspath.collect { it.toURI().toURL() } as URL[])
186189

orx-video-profiles/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# orx-video-profiles
2+
3+
A collection of `VideoWriterProfile` implementations that can be used with `ScreenRecorder` and `VideoWriter`
4+
5+
## Usage
6+

orx-video-profiles/build.gradle

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
sourceSets {
2+
demo {
3+
java {
4+
srcDirs = ["src/demo/kotlin"]
5+
compileClasspath += main.getCompileClasspath()
6+
runtimeClasspath += main.getRuntimeClasspath()
7+
}
8+
}
9+
}
10+
11+
dependencies {
12+
demoImplementation("org.openrndr:openrndr-core:$openrndrVersion")
13+
demoImplementation("org.openrndr:openrndr-extensions:$openrndrVersion")
14+
demoImplementation("org.openrndr:openrndr-ffmpeg:$openrndrVersion")
15+
demoRuntimeOnly("org.openrndr:openrndr-gl3:$openrndrVersion")
16+
demoRuntimeOnly("org.openrndr:openrndr-gl3-natives-$openrndrOS:$openrndrVersion")
17+
implementation("org.openrndr:openrndr-ffmpeg:$openrndrVersion")
18+
demoImplementation(sourceSets.getByName("main").output)
19+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import org.openrndr.application
2+
import org.openrndr.color.ColorRGBa
3+
import org.openrndr.extra.videoprofiles.GIFProfile
4+
import org.openrndr.extra.videoprofiles.ProresProfile
5+
import org.openrndr.ffmpeg.ScreenRecorder
6+
7+
fun main() = application {
8+
program {
9+
extend(ScreenRecorder()) {
10+
profile = GIFProfile()
11+
}
12+
extend {
13+
drawer.clear(ColorRGBa.GREEN)
14+
}
15+
}
16+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import org.openrndr.application
2+
import org.openrndr.color.ColorRGBa
3+
import org.openrndr.extra.videoprofiles.ProresProfile
4+
import org.openrndr.ffmpeg.ScreenRecorder
5+
6+
fun main() = application {
7+
program {
8+
extend(ScreenRecorder()) {
9+
profile = ProresProfile()
10+
}
11+
extend {
12+
drawer.clear(ColorRGBa.GREEN)
13+
}
14+
}
15+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package org.openrndr.extra.videoprofiles
2+
import org.openrndr.ffmpeg.VideoWriterProfile
3+
4+
class GIFProfile : VideoWriterProfile() {
5+
override val fileExtension = "gif"
6+
7+
override fun arguments(): Array<String> {
8+
return arrayOf("-vf", "split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse=dither=none:diff_mode=rectangle")
9+
}
10+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.openrndr.extra.videoprofiles
2+
3+
import org.openrndr.ffmpeg.VideoWriterProfile
4+
5+
class ProresProfile : VideoWriterProfile() {
6+
enum class Profile(val argument:String) {
7+
PROXY("0"),
8+
LT("1"),
9+
SQ("2"),
10+
HQ("3"),
11+
HQ4444("4444")
12+
}
13+
14+
override val fileExtension: String = "mov"
15+
var profile = Profile.SQ
16+
var codec = "prores_ks"
17+
18+
override fun arguments(): Array<String> {
19+
val vcodec = arrayOf("-vcodec", codec)
20+
val profile = arrayOf("-profile:v", profile.argument)
21+
val filters = arrayOf("-vf", "vflip")
22+
val audio = arrayOf("-an")
23+
return vcodec + profile + filters + audio
24+
}
25+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package org.openrndr.extra.videoprofiles
2+
import org.openrndr.ffmpeg.VideoWriterProfile
3+
4+
class X265Profile : VideoWriterProfile() {
5+
internal var mode = WriterMode.Normal
6+
internal var constantRateFactor = 28
7+
var hlg = false
8+
9+
enum class WriterMode {
10+
Normal,
11+
Lossless
12+
}
13+
14+
fun mode(mode: WriterMode): X265Profile {
15+
this.mode = mode
16+
return this
17+
}
18+
19+
/**
20+
* Sets the constant rate factor
21+
* @param constantRateFactor the constant rate factor (default is 28)
22+
* @return
23+
*/
24+
fun constantRateFactor(constantRateFactor: Int): X265Profile {
25+
this.constantRateFactor = constantRateFactor
26+
return this
27+
}
28+
29+
override val fileExtension = "mp4"
30+
31+
32+
override fun arguments(): Array<String> {
33+
when (mode) {
34+
WriterMode.Normal -> {
35+
return if (!hlg) {
36+
arrayOf("-pix_fmt", "yuv420p", // this will produce videos that are playable by quicktime
37+
"-vf", "vflip",
38+
"-an", "-vcodec", "libx265", "-crf", "" + constantRateFactor)
39+
} else {
40+
arrayOf( // this will produce videos that are playable by quicktime
41+
"-an", "" +
42+
"-vcodec", "libx265",
43+
"-pix_fmt", "yuv420p10le",
44+
"-color_primaries", "bt2020",
45+
"-colorspace", "bt2020_ncl",
46+
"-color_trc", "arib-std-b67",
47+
"-crf", "" + constantRateFactor)
48+
// transfer=arib-std-b67
49+
}
50+
}
51+
WriterMode.Lossless -> {
52+
return arrayOf("-pix_fmt", "yuv420p10", // this will produce videos that are playable by quicktime
53+
"-an", "-vcodec", "libx265", "-preset", "ultrafast")
54+
}
55+
else -> {
56+
throw RuntimeException("unsupported write mode")
57+
}
58+
}
59+
}
60+
}

settings.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ rootProject.name = 'orx'
33
include 'openrndr-demos',
44
'orx-boofcv',
55
'orx-camera',
6+
'orx-chataigne',
67
'orx-compositor',
78
'orx-dnk3',
89
'orx-easing',
@@ -46,5 +47,5 @@ include 'openrndr-demos',
4647
'orx-kinect-v1-natives-macos',
4748
'orx-kinect-v1-natives-windows',
4849
'orx-kinect-v1-demo',
49-
'orx-chataigne'
50+
'orx-video-profiles'
5051

0 commit comments

Comments
 (0)