Skip to content

Commit

Permalink
Merge pull request #116 from vitrivr/feature/ffmpeg
Browse files Browse the repository at this point in the history
Video Decoder using external ffmpeg process
  • Loading branch information
ppanopticon authored Nov 8, 2024
2 parents c27e605 + 4f95eac commit 1f5eb7a
Show file tree
Hide file tree
Showing 15 changed files with 478 additions and 78 deletions.
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ version_caffeine=3.1.8
version_clikt=4.2.2
version_commonsmath3=3.6.1
version_cottontaildb=0.16.7
version_jaffree=2024.08.29
version_javacv=1.5.10
version_javalin=6.3.0
version_jdbc_postgres=42.7.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ interface Resolver {
* Attempts to resolve the provided [RetrievableId] to a [Resolvable] using this [Resolver].
*
* @param id The [RetrievableId] to resolve.
* @param suffix The suffix of the filename.
* @return [Resolvable] or null, if [RetrievableId] could not be resolved.
*/
fun resolve(id: RetrievableId) : Resolvable?
fun resolve(id: RetrievableId, suffix: String) : Resolvable?

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ class DiskResolver : ResolverFactory {
*/
override fun newResolver(schema: Schema, parameters: Map<String, String>): Resolver {
val location = Paths.get(parameters["location"] ?: "./thumbnails/${schema.name}")
val mimeType = MimeType.valueOf(parameters["mimeType"] ?: "JPG")
return Instance(location, mimeType)
return Instance(location)
}

/**
* The [Resolver] generated by this [DiskResolver].
*/
private class Instance(private val location: Path, private val mimeType: MimeType) : Resolver {
private class Instance(private val location: Path) : Resolver {
init {
/* Make sure, directory exists. */
if (!Files.exists(this.location)) {
Expand All @@ -47,20 +46,19 @@ class DiskResolver : ResolverFactory {
* Resolves the provided [RetrievableId] to a [Resolvable] using this [Resolver].
*
* @param id The [RetrievableId] to resolve.
* @param suffix The suffix of the filename.
* @return [Resolvable] or null, if [RetrievableId] could not be resolved.
*/
override fun resolve(id: RetrievableId): Resolvable = DiskResolvable(id)

override fun resolve(id: RetrievableId, suffix: String): Resolvable = DiskResolvable(id, suffix)

/**
* A [Resolvable] generated by this [DiskResolver].
*/
inner class DiskResolvable(override val retrievableId: RetrievableId) : Resolvable {
val path: Path
get() = this@Instance.location.resolve("$retrievableId.${this@Instance.mimeType.fileExtension}")
override val mimeType: MimeType
get() = this@Instance.mimeType

inner class DiskResolvable(override val retrievableId: RetrievableId, suffix: String) : Resolvable {
val path: Path = this@Instance.location.resolve("${retrievableId}.$suffix")
override val mimeType: MimeType by lazy {
MimeType.getMimeType(this.path) ?: MimeType.UNKNOWN
}
override fun exists(): Boolean = Files.exists(this.path)
override fun openInputStream(): InputStream = Files.newInputStream(this.path, StandardOpenOption.READ)
override fun openOutputStream(): OutputStream = Files.newOutputStream(this.path, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,8 @@ enum class MimeType(val fileExtension: String, val mimeType: String, val mediaTy
OFF("off", "application/3d-off", MediaType.MESH),
GLTF("gltf", "model/gltf+json", MediaType.MESH),




//Unknown type
UNKNOWN("", "", MediaType.NONE)
;
UNKNOWN("", "", MediaType.NONE);

companion object {
fun getMimeType(fileName: String): MimeType? = try {
Expand All @@ -80,6 +76,6 @@ enum class MimeType(val fileExtension: String, val mimeType: String, val mediaTy
null
}

val allValid = MimeType.values().filter { it != UNKNOWN }.toSet()
val allValid = entries.filter { it != UNKNOWN }.toSet()
}
}
3 changes: 3 additions & 0 deletions vitrivr-engine-index/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ dependencies {
implementation group: 'org.bytedeco', name: 'javacv', version: version_javacv
implementation group: 'org.bytedeco', name: 'ffmpeg', version: version_ffmpeg, classifier: project.ext.javacppPlatform

/** Jaffree for external ffmpeg*/
implementation group: 'com.github.kokorin.jaffree', name: 'jaffree', version: version_jaffree

/** ScrImage (used for image resizing). */
implementation group: 'com.sksamuel.scrimage', name: 'scrimage-core', version: version_scrimage

Expand Down
Loading

0 comments on commit 1f5eb7a

Please sign in to comment.