Skip to content

Commit

Permalink
Merge branch 'channel-layouts' into 'master'
Browse files Browse the repository at this point in the history
Improved audio handling

See merge request videocore/encore!144
  • Loading branch information
fhermansson committed Dec 16, 2022
2 parents fd97fae + 4689201 commit c41787d
Show file tree
Hide file tree
Showing 53 changed files with 974 additions and 292 deletions.
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ LABEL org.opencontainers.image.url="https://github.com/svt/encore"
LABEL org.opencontainers.image.source="https://github.com/svt/encore"

COPY build/libs/encore*.jar /app/encore.jar
COPY bin/start.sh /app/start.sh

WORKDIR /app

ENV JAVA_OPTS "-XX:MaxRAMPercentage=10"

CMD ["/app/start.sh"]
CMD ["java", "-jar", "encore.jar"]
18 changes: 0 additions & 18 deletions bin/start.sh

This file was deleted.

56 changes: 32 additions & 24 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
idea
jacoco
id("org.springframework.boot") version "2.6.6"
id("se.ascp.gradle.gradle-versions-filter") version "0.1.10"
kotlin("jvm") version "1.6.20"
kotlin("plugin.spring") version "1.6.20"
id("org.springframework.boot") version "2.7.6"
id("se.ascp.gradle.gradle-versions-filter") version "0.1.16"
kotlin("jvm") version "1.7.21"
kotlin("plugin.spring") version "1.7.21"
id("com.github.fhermansson.assertj-generator") version "1.1.4"
id("org.jmailen.kotlinter") version "3.9.0"
id("io.spring.dependency-management") version "1.0.11.RELEASE"
id("pl.allegro.tech.build.axion-release") version "1.13.3"
id("org.jmailen.kotlinter") version "3.12.0"
id("io.spring.dependency-management") version "1.1.0"
id("pl.allegro.tech.build.axion-release") version "1.14.2"

//openapi generation
id("com.github.johnrengelman.processes") version "0.5.0"
Expand All @@ -33,7 +33,15 @@ assertjGenerator {
}

kotlinter {
disabledRules = arrayOf("import-ordering")
disabledRules = arrayOf(
"import-ordering",
"trailing-comma-on-declaration-site",
"trailing-comma-on-call-site"
)
}

tasks.lintKotlinTest {
source = (source - fileTree("src/test/generated-java")).asFileTree
}

tasks.test {
Expand Down Expand Up @@ -69,14 +77,14 @@ configurations {

dependencyManagement {
imports {
mavenBom("org.springframework.cloud:spring-cloud-dependencies:2021.0.1")
mavenBom("org.springframework.cloud:spring-cloud-dependencies:2021.0.5")
}
}

val redissonVersion = "3.18.0"
val redissonVersion = "3.18.1"

dependencies {
implementation("se.svt.oss:media-analyzer:1.0.3")
implementation("se.svt.oss:media-analyzer:2.0.1")
implementation(kotlin("reflect"))

implementation("org.springframework.boot:spring-boot-starter-web")
Expand All @@ -89,32 +97,32 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-security")

implementation("org.redisson:redisson-spring-boot-starter:$redissonVersion")
implementation("org.redisson:redisson-spring-data-26:$redissonVersion") // match boot version
implementation("io.github.microutils:kotlin-logging:2.1.21")
implementation("org.redisson:redisson-spring-data-27:$redissonVersion") // match boot version
implementation("io.github.microutils:kotlin-logging:3.0.2")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.6.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:1.6.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.6.4")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:1.6.4")

implementation("org.springframework.cloud:spring-cloud-starter-openfeign")
implementation("io.github.openfeign:feign-okhttp")
implementation("org.springframework.retry:spring-retry")
implementation("org.springframework.boot:spring-boot-starter-aop")

//openapi generation
implementation("org.springdoc:springdoc-openapi-ui:1.5.10")
implementation("org.springdoc:springdoc-openapi-kotlin:1.5.10")
implementation("org.springdoc:springdoc-openapi-data-rest:1.5.10")
implementation("org.springdoc:springdoc-openapi-hateoas:1.5.10")
implementation("org.springdoc:springdoc-openapi-ui:1.6.12")
implementation("org.springdoc:springdoc-openapi-kotlin:1.6.12")
implementation("org.springdoc:springdoc-openapi-data-rest:1.6.12")
implementation("org.springdoc:springdoc-openapi-hateoas:1.6.12")

testImplementation("se.svt.oss:junit5-redis-extension:3.0.0")
testImplementation("se.svt.oss:random-port-initializer:1.0.5")
testImplementation("org.awaitility:awaitility:4.1.1")
testImplementation("org.awaitility:awaitility")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.springframework.security:spring-security-test")
testImplementation("org.assertj:assertj-core:3.20.2") // Can be bumped with future kotlin 1.7 release, https://github.com/assertj/assertj-core/issues/2357
testImplementation("io.mockk:mockk:1.12.3")
testImplementation("com.squareup.okhttp3:mockwebserver:3.14.9")//shall match with okhttp version used
testImplementation("org.assertj:assertj-core")
testImplementation("io.mockk:mockk:1.13.2")
testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.0")
testImplementation("com.ninja-squad:springmockk:3.1.1")
testImplementation("org.junit.jupiter:junit-jupiter-api")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
6 changes: 5 additions & 1 deletion src/main/kotlin/se/svt/oss/encore/RedisConfiguration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import org.springframework.context.annotation.Configuration
import org.springframework.data.redis.core.RedisKeyValueAdapter
import org.springframework.data.redis.core.convert.RedisCustomConversions
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories
import se.svt.oss.encore.repository.ByteArrayToChannelLayoutConverter
import se.svt.oss.encore.repository.ByteArrayToOffsetDateTimeConverter
import se.svt.oss.encore.repository.ByteArrayToURIConverter
import se.svt.oss.encore.repository.ByteArrayToUUIDConverter
import se.svt.oss.encore.repository.ChannelLayoutToByteArrayConverter
import se.svt.oss.encore.repository.OffsetDateTimeToByteArrayConverter
import se.svt.oss.encore.repository.URIToByteArrayConverter
import se.svt.oss.encore.repository.UUIDToByteArrayConverter
Expand All @@ -31,7 +33,9 @@ class RedisConfiguration {
UUIDToByteArrayConverter(),
ByteArrayToUUIDConverter(),
URIToByteArrayConverter(),
ByteArrayToURIConverter()
ByteArrayToURIConverter(),
ChannelLayoutToByteArrayConverter(),
ByteArrayToChannelLayoutConverter()
)
)

Expand Down
6 changes: 4 additions & 2 deletions src/main/kotlin/se/svt/oss/encore/config/AudioMixPreset.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
// SPDX-License-Identifier: EUPL-1.2
package se.svt.oss.encore.config

import se.svt.oss.encore.model.profile.ChannelLayout

data class AudioMixPreset(
val fallbackToAuto: Boolean = true,
val defaultPan: Map<Int, String> = emptyMap(),
val panMapping: Map<Int, Map<Int, String>> = emptyMap()
val defaultPan: Map<ChannelLayout, String> = emptyMap(),
val panMapping: Map<ChannelLayout, Map<ChannelLayout, String>> = emptyMap(),
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package se.svt.oss.encore.config

import se.svt.oss.encore.model.profile.ChannelLayout

data class EncodingProperties(
val audioMixPresets: Map<String, AudioMixPreset> = mapOf("default" to AudioMixPreset()),
val defaultChannelLayouts: Map<Int, ChannelLayout> = emptyMap(),
val flipWidthHeightIfPortrait: Boolean = true
)
4 changes: 2 additions & 2 deletions src/main/kotlin/se/svt/oss/encore/config/EncoreProperties.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import java.time.Duration
@ConstructorBinding
data class EncoreProperties(
val localTemporaryEncode: Boolean = false,
val audioMixPresets: Map<String, AudioMixPreset> = mapOf("default" to AudioMixPreset()),
val concurrency: Int = 2,
val pollInitialDelay: Duration = Duration.ofSeconds(10),
val pollDelay: Duration = Duration.ofSeconds(5),
val redisKeyPrefix: String = "encore",
val security: Security = Security(),
val openApi: OpenApi = OpenApi()
val openApi: OpenApi = OpenApi(),
val encoding: EncodingProperties = EncodingProperties()
) {
data class Security(
val enabled: Boolean = false,
Expand Down
59 changes: 41 additions & 18 deletions src/main/kotlin/se/svt/oss/encore/model/EncoreJob.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,87 +28,109 @@ import javax.validation.constraints.Positive
data class EncoreJob(

@Schema(
description = "The Encore Internal EncoreJob Identity", example = "fb2baa17-8972-451b-bb1e-1bc773283476",
accessMode = Schema.AccessMode.READ_ONLY, hidden = false, defaultValue = "A random UUID"
description = "The Encore Internal EncoreJob Identity",
example = "fb2baa17-8972-451b-bb1e-1bc773283476",
accessMode = Schema.AccessMode.READ_ONLY,
hidden = false,
defaultValue = "A random UUID"
)
@Id val id: UUID = UUID.randomUUID(),
@Id
val id: UUID = UUID.randomUUID(),

@Schema(
description = "External id - for external backreference", example = "any-string",
description = "External id - for external backreference",
example = "any-string",
nullable = true
)
val externalId: String? = null,

@Schema(
description = "The name of the encoding profile to use",
example = "x264-animated", required = true
example = "x264-animated",
required = true
)
@NotBlank
val profile: String,

@Schema(
description = "A directory path to where the output should be written",
example = "/an/output/path/dir", required = true
example = "/an/output/path/dir",
required = true
)
@NotBlank
val outputFolder: String,

@Schema(
description = "Base filename of output files",
example = "any_file", required = true
example = "any_file",
required = true
)
@NotBlank
val baseName: String,

@Schema(
description = "The Creation date for the EncoreJob",
example = "2021-04-22T03:00:48.759168+02:00", accessMode = Schema.AccessMode.READ_ONLY,
example = "2021-04-22T03:00:48.759168+02:00",
accessMode = Schema.AccessMode.READ_ONLY,
defaultValue = "now()"
)
@Indexed
val createdDate: OffsetDateTime = OffsetDateTime.now(),

@Schema(
description = "An url to which the progress status callback should be directed",
example = "http://projectx/encorecallback", nullable = true
example = "http://projectx/encorecallback",
nullable = true
)
val progressCallbackUri: URI? = null,

@Schema(
description = "The queue priority of the EncoreJob",
defaultValue = "0", minimum = "0", maximum = "100"
defaultValue = "0",
minimum = "0",
maximum = "100"
)
@Min(0)
@Max(100)
val priority: Int = 0,

@Schema(
description = "The exception message, if the EncoreJob failed",
example = "input/output error", accessMode = Schema.AccessMode.READ_ONLY, nullable = true
example = "input/output error",
accessMode = Schema.AccessMode.READ_ONLY,
nullable = true
)
var message: String? = null,

@Schema(
description = "The EncoreJob progress",
example = "57", accessMode = Schema.AccessMode.READ_ONLY, defaultValue = "0"
example = "57",
accessMode = Schema.AccessMode.READ_ONLY,
defaultValue = "0"
)
var progress: Int = 0,

@Schema(
description = "The Encoding speed of the job (compared to it's play speed/input duration)",
example = "0.334", accessMode = Schema.AccessMode.READ_ONLY, nullable = true
example = "0.334",
accessMode = Schema.AccessMode.READ_ONLY,
nullable = true
)
var speed: Double? = null,

@Schema(
description = "The time for when the EncoreJob was picked from the queue)",
example = "2021-04-19T07:20:43.819141+02:00", accessMode = Schema.AccessMode.READ_ONLY, nullable = true
example = "2021-04-19T07:20:43.819141+02:00",
accessMode = Schema.AccessMode.READ_ONLY,
nullable = true
)
var startedDate: OffsetDateTime? = null,

@Schema(
description = "The time for when the EncoreJob was completed (fail or success)",
example = "2021-04-19T07:20:43.819141+02:00", accessMode = Schema.AccessMode.READ_ONLY, nullable = true
example = "2021-04-19T07:20:43.819141+02:00",
accessMode = Schema.AccessMode.READ_ONLY,
nullable = true
)
var completedDate: OffsetDateTime? = null,

Expand All @@ -119,7 +141,8 @@ data class EncoreJob(
val debugOverlay: Boolean = false,

@Schema(
description = "Key/Values to append to the MDC log context", defaultValue = "{}"
description = "Key/Values to append to the MDC log context",
defaultValue = "{}"
)
val logContext: Map<String, String> = emptyMap(),

Expand All @@ -131,7 +154,8 @@ data class EncoreJob(

@Schema(
description = "Time in seconds for when the thumbnail should be picked. Overrides profile configuration for thumbnails",
example = "1800.5", nullable = true
example = "1800.5",
nullable = true
)
@Positive
val thumbnailTime: Double? = null,
Expand All @@ -150,7 +174,6 @@ data class EncoreJob(
description = "The Job Status",
accessMode = Schema.AccessMode.READ_ONLY
)

@Indexed
var status = Status.NEW
set(value) {
Expand Down
Loading

0 comments on commit c41787d

Please sign in to comment.