[orx-video-profiles] Add video profile extension functions

This commit is contained in:
Edwin Jakobs
2022-07-14 12:54:37 +02:00
parent 5b7327eda1
commit a6de46d71c
7 changed files with 64 additions and 17 deletions

View File

@@ -15,7 +15,7 @@ import org.openrndr.ffmpeg.ScreenRecorder
fun main() = application {
program {
extend(ScreenRecorder()) {
profile = GIFProfile()
gif()
}
extend {
drawer.clear(ColorRGBa.GREEN)
@@ -38,7 +38,7 @@ This profile requires specifying a file name: `outputFile = "frame-%05d.png"`,
where `%05d` means "zero-padded five-digit frame number".
The frame number format is not optional.
```
```kotlin
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.extra.videoprofiles.*
@@ -47,7 +47,7 @@ import org.openrndr.ffmpeg.ScreenRecorder
fun main() = application {
program {
extend(ScreenRecorder()) {
profile = PNGProfile()
pngSequence()
outputFile = "frame-%05d.png"
}
extend {
@@ -59,7 +59,7 @@ fun main() = application {
### Animated Webp
```
```kotlin
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.extra.videoprofiles.*
@@ -68,7 +68,7 @@ import org.openrndr.ffmpeg.ScreenRecorder
fun main() = application {
program {
extend(ScreenRecorder()) {
profile = WebpProfile()
webp()
}
extend {
drawer.clear(ColorRGBa.GREEN)
@@ -80,7 +80,7 @@ fun main() = application {
### Prores (large file, high quality video)
```
```kotlin
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.extra.videoprofiles.*
@@ -89,10 +89,8 @@ import org.openrndr.ffmpeg.ScreenRecorder
fun main() = application {
program {
extend(ScreenRecorder()) {
// .apply is optional, for further configuration
profile = ProresProfile().apply {
prores {
profile = ProresProfile.Profile.HQ4444
codec = "prores_ks"
}
}
extend {
@@ -102,9 +100,9 @@ fun main() = application {
}
```
### X265
### H265
```
```kotlin
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.extra.videoprofiles.*
@@ -113,11 +111,8 @@ import org.openrndr.ffmpeg.ScreenRecorder
fun main() = application {
program {
extend(ScreenRecorder()) {
// .apply is optional, for further configuration
profile = X265Profile().apply {
mode(X265Profile.WriterMode.Lossless)
h265 {
constantRateFactor(23)
hlg = true
}
}
extend {

View File

@@ -1,4 +1,5 @@
package org.openrndr.extra.videoprofiles
import org.openrndr.ffmpeg.ScreenRecorder
import org.openrndr.ffmpeg.VideoWriterProfile
class GIFProfile : VideoWriterProfile() {
@@ -8,3 +9,10 @@ class GIFProfile : VideoWriterProfile() {
return arrayOf("-vf", "split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse=dither=none:diff_mode=rectangle,vflip")
}
}
/**
* Configure an animated GIF video profile
*/
fun ScreenRecorder.gif(configure : GIFProfile.() -> Unit = {}) {
profile = GIFProfile().apply(configure)
}

View File

@@ -1,7 +1,11 @@
package org.openrndr.extra.videoprofiles
import org.openrndr.ffmpeg.ScreenRecorder
import org.openrndr.ffmpeg.VideoWriterProfile
class X265Profile : VideoWriterProfile() {
@Deprecated("use h265 profile", replaceWith = ReplaceWith("H265Profile"))
typealias X265Profile = H265Profile
class H265Profile : VideoWriterProfile() {
internal var mode = WriterMode.Normal
internal var constantRateFactor = 28
var hlg = false
@@ -57,4 +61,11 @@ class X265Profile : VideoWriterProfile() {
}
}
}
}
}
/**
* Configure a h265 video profile
*/
fun ScreenRecorder.h265(configure : H265Profile.() -> Unit = {}) {
profile = H265Profile().apply(configure)
}

View File

@@ -1,4 +1,5 @@
package org.openrndr.extra.videoprofiles
import org.openrndr.ffmpeg.ScreenRecorder
import org.openrndr.ffmpeg.VideoWriterProfile
/**
@@ -13,4 +14,11 @@ class PNGProfile : VideoWriterProfile() {
override fun arguments(): Array<String> {
return arrayOf("-vf", "vflip")
}
}
/**
* Configure a png sequence profile
*/
fun ScreenRecorder.pngSequence(configure : PNGProfile.() -> Unit = {}) {
profile = PNGProfile().apply(configure)
}

View File

@@ -1,5 +1,6 @@
package org.openrndr.extra.videoprofiles
import org.openrndr.ffmpeg.ScreenRecorder
import org.openrndr.ffmpeg.VideoWriterProfile
class ProresProfile : VideoWriterProfile() {
@@ -22,4 +23,11 @@ class ProresProfile : VideoWriterProfile() {
val audio = arrayOf("-an")
return vcodec + profile + filters + audio
}
}
/**
* Configure a Prores video profile
*/
fun ScreenRecorder.prores(configure : ProresProfile.() -> Unit = {}) {
profile = ProresProfile().apply(configure)
}

View File

@@ -1,4 +1,5 @@
package org.openrndr.extra.videoprofiles
import org.openrndr.ffmpeg.ScreenRecorder
import org.openrndr.ffmpeg.VideoWriterProfile
/**
@@ -14,3 +15,10 @@ class TIFFProfile : VideoWriterProfile() {
return arrayOf("-vf", "vflip")
}
}
/**
* Configure a tiff sequence profile
*/
fun ScreenRecorder.tiffSequence(configure : TIFFProfile.() -> Unit = {}) {
profile = TIFFProfile().apply(configure)
}

View File

@@ -1,4 +1,5 @@
package org.openrndr.extra.videoprofiles
import org.openrndr.ffmpeg.ScreenRecorder
import org.openrndr.ffmpeg.VideoWriterProfile
class WebpProfile : VideoWriterProfile() {
@@ -8,3 +9,11 @@ class WebpProfile : VideoWriterProfile() {
return arrayOf("-vf", "vflip")
}
}
/**
* Configure a webp video profile
*/
fun ScreenRecorder.webp(configure : WebpProfile.() -> Unit) {
profile = WebpProfile().apply(configure)
}