[orx-video-profiles] Expose filters in video profiles
This commit is contained in:
@@ -5,8 +5,10 @@ import org.openrndr.ffmpeg.VideoWriterProfile
|
|||||||
class GIFProfile : VideoWriterProfile() {
|
class GIFProfile : VideoWriterProfile() {
|
||||||
override val fileExtension = "gif"
|
override val fileExtension = "gif"
|
||||||
|
|
||||||
|
val filters = mutableListOf("split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse=dither=none:diff_mode=rectangle", "vflip")
|
||||||
|
|
||||||
override fun arguments(): Array<String> {
|
override fun arguments(): Array<String> {
|
||||||
return arrayOf("-vf", "split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse=dither=none:diff_mode=rectangle,vflip")
|
return arrayOf("-vf", filters.joinToString(","))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,61 +5,64 @@ import org.openrndr.ffmpeg.VideoWriterProfile
|
|||||||
@Deprecated("use h265 profile", replaceWith = ReplaceWith("H265Profile"))
|
@Deprecated("use h265 profile", replaceWith = ReplaceWith("H265Profile"))
|
||||||
typealias X265Profile = H265Profile
|
typealias X265Profile = H265Profile
|
||||||
|
|
||||||
|
|
||||||
class H265Profile : VideoWriterProfile() {
|
class H265Profile : VideoWriterProfile() {
|
||||||
internal var mode = WriterMode.Normal
|
|
||||||
internal var constantRateFactor = 28
|
|
||||||
var hlg = false
|
|
||||||
|
|
||||||
enum class WriterMode {
|
|
||||||
Normal,
|
|
||||||
Lossless
|
|
||||||
}
|
|
||||||
|
|
||||||
fun mode(mode: WriterMode): X265Profile {
|
|
||||||
this.mode = mode
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the constant rate factor
|
* constant rate factor (default is 23)
|
||||||
* @param constantRateFactor the constant rate factor (default is 28)
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
fun constantRateFactor(constantRateFactor: Int): X265Profile {
|
var constantRateFactor = null as Int?
|
||||||
this.constantRateFactor = constantRateFactor
|
|
||||||
return this
|
@Deprecated("Use constantRateFactor property")
|
||||||
|
fun constantRateFactor(factor: Int) {
|
||||||
|
constantRateFactor = factor
|
||||||
}
|
}
|
||||||
|
|
||||||
override val fileExtension = "mp4"
|
override var fileExtension = "mp4"
|
||||||
|
|
||||||
|
var highPrecisionChroma = true
|
||||||
|
|
||||||
|
val CODEC_LIBX265 = "libx265"
|
||||||
|
|
||||||
|
|
||||||
|
var videoCodec = CODEC_LIBX265 as String?
|
||||||
|
var hwaccel = null as String?
|
||||||
|
var preset = null as String?
|
||||||
|
|
||||||
|
|
||||||
|
var pixelFormat = "yuv420p" as String?
|
||||||
|
var userArguments = emptyArray<String>()
|
||||||
|
|
||||||
|
val filters = mutableListOf("vflip")
|
||||||
|
|
||||||
override fun arguments(): Array<String> {
|
override fun arguments(): Array<String> {
|
||||||
when (mode) {
|
val chromaArguments = if (highPrecisionChroma) {
|
||||||
WriterMode.Normal -> {
|
arrayOf(
|
||||||
return if (!hlg) {
|
"-sws_flags", "spline+accurate_rnd+full_chroma_int",
|
||||||
arrayOf("-pix_fmt", "yuv420p", // this will produce videos that are playable by quicktime
|
"-color_range", "1",
|
||||||
"-vf", "vflip",
|
"-colorspace", "1",
|
||||||
"-an", "-vcodec", "libx265", "-crf", "" + constantRateFactor)
|
"-color_primaries","1",
|
||||||
} else {
|
"-color_trc", "1"
|
||||||
arrayOf( // this will produce videos that are playable by quicktime
|
)
|
||||||
"-an", "" +
|
} else {
|
||||||
"-vcodec", "libx265",
|
emptyArray()
|
||||||
"-pix_fmt", "yuv420p10le",
|
|
||||||
"-color_primaries", "bt2020",
|
|
||||||
"-colorspace", "bt2020_ncl",
|
|
||||||
"-color_trc", "arib-std-b67",
|
|
||||||
"-crf", "" + constantRateFactor)
|
|
||||||
// transfer=arib-std-b67
|
|
||||||
}
|
|
||||||
}
|
|
||||||
WriterMode.Lossless -> {
|
|
||||||
return arrayOf("-pix_fmt", "yuv420p10", // this will produce videos that are playable by quicktime
|
|
||||||
"-an", "-vcodec", "libx265", "-preset", "ultrafast")
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
throw RuntimeException("unsupported write mode")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (highPrecisionChroma) {
|
||||||
|
filters.add("colorspace=bt709:iall=bt601-6-625:fast=1")
|
||||||
|
}
|
||||||
|
|
||||||
|
val hwaccelArguments = hwaccel?.let { arrayOf("-hwaccel", it) } ?: emptyArray()
|
||||||
|
val pixelFormatArguments = pixelFormat?.let { arrayOf("-pix_fmt", it) } ?: emptyArray()
|
||||||
|
val constantRateArguments = constantRateFactor?.let { arrayOf("-crf", it.toString()) } ?: emptyArray()
|
||||||
|
val presetArguments = preset?.let { arrayOf("-preset", it) } ?: emptyArray()
|
||||||
|
val videoCodecArguments = videoCodec?.let { arrayOf("-vcodec", it) } ?: emptyArray()
|
||||||
|
val filterArguments = arrayOf("-vf", filters.joinToString(","))
|
||||||
|
|
||||||
|
val arguments =
|
||||||
|
hwaccelArguments + pixelFormatArguments + chromaArguments + filterArguments + videoCodecArguments + constantRateArguments + presetArguments + userArguments
|
||||||
|
|
||||||
|
return arguments
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,10 @@ import org.openrndr.ffmpeg.VideoWriterProfile
|
|||||||
class PNGProfile : VideoWriterProfile() {
|
class PNGProfile : VideoWriterProfile() {
|
||||||
override val fileExtension = "png"
|
override val fileExtension = "png"
|
||||||
|
|
||||||
|
val filters = mutableListOf("vflip")
|
||||||
|
|
||||||
override fun arguments(): Array<String> {
|
override fun arguments(): Array<String> {
|
||||||
return arrayOf("-vf", "vflip")
|
return arrayOf("-vf", filters.joinToString(","))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,10 +16,12 @@ class ProresProfile : VideoWriterProfile() {
|
|||||||
var profile = Profile.SQ
|
var profile = Profile.SQ
|
||||||
var codec = "prores_ks"
|
var codec = "prores_ks"
|
||||||
|
|
||||||
|
val filters = mutableListOf("vflip")
|
||||||
|
|
||||||
override fun arguments(): Array<String> {
|
override fun arguments(): Array<String> {
|
||||||
val vcodec = arrayOf("-vcodec", codec)
|
val vcodec = arrayOf("-vcodec", codec)
|
||||||
val profile = arrayOf("-profile:v", profile.argument)
|
val profile = arrayOf("-profile:v", profile.argument)
|
||||||
val filters = arrayOf("-vf", "vflip")
|
val filters = arrayOf("-vf", filters.joinToString(","))
|
||||||
val audio = arrayOf("-an")
|
val audio = arrayOf("-an")
|
||||||
return vcodec + profile + filters + audio
|
return vcodec + profile + filters + audio
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,9 @@ import org.openrndr.ffmpeg.VideoWriterProfile
|
|||||||
class TIFFProfile : VideoWriterProfile() {
|
class TIFFProfile : VideoWriterProfile() {
|
||||||
override val fileExtension = "tif"
|
override val fileExtension = "tif"
|
||||||
|
|
||||||
|
val filters = mutableListOf("vflip")
|
||||||
override fun arguments(): Array<String> {
|
override fun arguments(): Array<String> {
|
||||||
return arrayOf("-vf", "vflip")
|
return arrayOf("-vf", filters.joinToString(","))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,11 @@ import org.openrndr.ffmpeg.VideoWriterProfile
|
|||||||
class WebpProfile : VideoWriterProfile() {
|
class WebpProfile : VideoWriterProfile() {
|
||||||
override val fileExtension = "webp"
|
override val fileExtension = "webp"
|
||||||
|
|
||||||
|
|
||||||
|
val filters = mutableListOf("vflip")
|
||||||
|
|
||||||
override fun arguments(): Array<String> {
|
override fun arguments(): Array<String> {
|
||||||
return arrayOf("-vf", "vflip")
|
return arrayOf("-vf", filters.joinToString(","))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user