diff --git a/orx-jvm/orx-video-profiles/README.md b/orx-jvm/orx-video-profiles/README.md index 6143ed3f..fbde196a 100644 --- a/orx-jvm/orx-video-profiles/README.md +++ b/orx-jvm/orx-video-profiles/README.md @@ -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 { diff --git a/orx-jvm/orx-video-profiles/src/main/kotlin/GIFProfile.kt b/orx-jvm/orx-video-profiles/src/main/kotlin/GIFProfile.kt index 8414a7ea..2e8816c8 100644 --- a/orx-jvm/orx-video-profiles/src/main/kotlin/GIFProfile.kt +++ b/orx-jvm/orx-video-profiles/src/main/kotlin/GIFProfile.kt @@ -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) +} \ No newline at end of file diff --git a/orx-jvm/orx-video-profiles/src/main/kotlin/X265Profile.kt b/orx-jvm/orx-video-profiles/src/main/kotlin/H265Profile.kt similarity index 84% rename from orx-jvm/orx-video-profiles/src/main/kotlin/X265Profile.kt rename to orx-jvm/orx-video-profiles/src/main/kotlin/H265Profile.kt index 3ac9e2b2..52039803 100644 --- a/orx-jvm/orx-video-profiles/src/main/kotlin/X265Profile.kt +++ b/orx-jvm/orx-video-profiles/src/main/kotlin/H265Profile.kt @@ -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() { } } } -} \ No newline at end of file +} + +/** + * Configure a h265 video profile + */ +fun ScreenRecorder.h265(configure : H265Profile.() -> Unit = {}) { + profile = H265Profile().apply(configure) +} diff --git a/orx-jvm/orx-video-profiles/src/main/kotlin/PNGProfile.kt b/orx-jvm/orx-video-profiles/src/main/kotlin/PNGProfile.kt index 0654cdc4..b44e7bd8 100644 --- a/orx-jvm/orx-video-profiles/src/main/kotlin/PNGProfile.kt +++ b/orx-jvm/orx-video-profiles/src/main/kotlin/PNGProfile.kt @@ -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 { return arrayOf("-vf", "vflip") } +} + +/** + * Configure a png sequence profile + */ +fun ScreenRecorder.pngSequence(configure : PNGProfile.() -> Unit = {}) { + profile = PNGProfile().apply(configure) } \ No newline at end of file diff --git a/orx-jvm/orx-video-profiles/src/main/kotlin/ProresProfile.kt b/orx-jvm/orx-video-profiles/src/main/kotlin/ProresProfile.kt index 5bce24b4..c232093e 100644 --- a/orx-jvm/orx-video-profiles/src/main/kotlin/ProresProfile.kt +++ b/orx-jvm/orx-video-profiles/src/main/kotlin/ProresProfile.kt @@ -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) } \ No newline at end of file diff --git a/orx-jvm/orx-video-profiles/src/main/kotlin/TIFFProfile.kt b/orx-jvm/orx-video-profiles/src/main/kotlin/TIFFProfile.kt index 50cb377e..60a604b9 100644 --- a/orx-jvm/orx-video-profiles/src/main/kotlin/TIFFProfile.kt +++ b/orx-jvm/orx-video-profiles/src/main/kotlin/TIFFProfile.kt @@ -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) +} \ No newline at end of file diff --git a/orx-jvm/orx-video-profiles/src/main/kotlin/WebpProfile.kt b/orx-jvm/orx-video-profiles/src/main/kotlin/WebpProfile.kt index d3d941c2..6b25d8a5 100644 --- a/orx-jvm/orx-video-profiles/src/main/kotlin/WebpProfile.kt +++ b/orx-jvm/orx-video-profiles/src/main/kotlin/WebpProfile.kt @@ -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) +} +