From 6a729d9fa3d70049ff12dec9dd5c98b0b6d508c1 Mon Sep 17 00:00:00 2001 From: Finn Hermansson Date: Wed, 4 Sep 2024 16:16:14 +0200 Subject: [PATCH 1/2] Added property "extra" to media info tracks. Signed-off-by: Finn Hermansson --- .../se/svt/oss/mediaanalyzer/mediainfo/AudioTrack.kt | 1 + .../se/svt/oss/mediaanalyzer/mediainfo/GeneralTrack.kt | 1 + .../se/svt/oss/mediaanalyzer/mediainfo/ImageTrack.kt | 1 + .../se/svt/oss/mediaanalyzer/mediainfo/OtherTrack.kt | 5 ++++- .../se/svt/oss/mediaanalyzer/mediainfo/TextTrack.kt | 5 ++++- .../kotlin/se/svt/oss/mediaanalyzer/mediainfo/Track.kt | 2 ++ .../se/svt/oss/mediaanalyzer/mediainfo/VideoTrack.kt | 9 ++++++--- .../oss/mediaanalyzer/MediaAnalyzerIntegrationTest.kt | 1 - 8 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/AudioTrack.kt b/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/AudioTrack.kt index 8831e71..fba6d5d 100644 --- a/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/AudioTrack.kt +++ b/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/AudioTrack.kt @@ -10,6 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty @JsonIgnoreProperties(ignoreUnknown = true) data class AudioTrack( override val format: String, + override val extra: Map = emptyMap(), @JsonProperty("Duration") val duration: Double, @JsonProperty("BitRate") diff --git a/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/GeneralTrack.kt b/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/GeneralTrack.kt index bb19208..adccb21 100644 --- a/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/GeneralTrack.kt +++ b/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/GeneralTrack.kt @@ -10,6 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty @JsonIgnoreProperties(ignoreUnknown = true) data class GeneralTrack( override val format: String = "UNKNOWN", + override val extra: Map = emptyMap(), @JsonProperty("FileSize") val fileSize: Long, @JsonProperty("Duration") diff --git a/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/ImageTrack.kt b/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/ImageTrack.kt index 0a76960..ea46bff 100644 --- a/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/ImageTrack.kt +++ b/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/ImageTrack.kt @@ -10,6 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty @JsonIgnoreProperties(ignoreUnknown = true) data class ImageTrack( override val format: String, + override val extra: Map = emptyMap(), @JsonProperty("Width") val width: Int, @JsonProperty("Height") diff --git a/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/OtherTrack.kt b/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/OtherTrack.kt index 65e2b97..7530c84 100644 --- a/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/OtherTrack.kt +++ b/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/OtherTrack.kt @@ -7,4 +7,7 @@ package se.svt.oss.mediaanalyzer.mediainfo import com.fasterxml.jackson.annotation.JsonIgnoreProperties @JsonIgnoreProperties(ignoreUnknown = true) -data class OtherTrack(override val format: String) : Track +data class OtherTrack( + override val format: String, + override val extra: Map = emptyMap() +) : Track diff --git a/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/TextTrack.kt b/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/TextTrack.kt index f52d01f..522d4cc 100644 --- a/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/TextTrack.kt +++ b/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/TextTrack.kt @@ -7,4 +7,7 @@ package se.svt.oss.mediaanalyzer.mediainfo import com.fasterxml.jackson.annotation.JsonIgnoreProperties @JsonIgnoreProperties(ignoreUnknown = true) -data class TextTrack(override val format: String) : Track +data class TextTrack( + override val format: String, + override val extra: Map = emptyMap() +) : Track diff --git a/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/Track.kt b/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/Track.kt index 087298d..7893512 100644 --- a/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/Track.kt +++ b/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/Track.kt @@ -45,4 +45,6 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo interface Track { @get:JsonProperty("Format") val format: String + @get:JsonProperty("extra") + val extra: Map } diff --git a/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/VideoTrack.kt b/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/VideoTrack.kt index 4d2422b..b7b908f 100644 --- a/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/VideoTrack.kt +++ b/src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/VideoTrack.kt @@ -10,6 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty @JsonIgnoreProperties(ignoreUnknown = true) data class VideoTrack( override val format: String, + override val extra: Map = emptyMap(), @JsonProperty("Duration") val duration: Double, @JsonProperty("BitRate") @@ -24,6 +25,10 @@ data class VideoTrack( val displayAspectRatio: Double, @JsonProperty("FrameRate") val frameRate: Double, + @JsonProperty("FrameRate_Num") + val frameRateNum: Int?, + @JsonProperty("FrameRate_Den") + val frameRateDen: Int?, @JsonProperty("FrameCount") val frameCount: Int, @JsonProperty("ColorSpace") @@ -73,9 +78,7 @@ data class VideoTrack( @JsonProperty("MasteringDisplay_Luminance") val masteringDisplayLuminance: String?, @JsonProperty("MasteringDisplay_Luminance_Source") - val masteringDisplayLuminanceSource: String?, - val extra: Map = emptyMap() - + val masteringDisplayLuminanceSource: String? ) : Track { val isInterlaced: Boolean? get() = scanType?.let { it != "Progressive" } diff --git a/src/test/kotlin/se/svt/oss/mediaanalyzer/MediaAnalyzerIntegrationTest.kt b/src/test/kotlin/se/svt/oss/mediaanalyzer/MediaAnalyzerIntegrationTest.kt index b42e318..9ef0670 100644 --- a/src/test/kotlin/se/svt/oss/mediaanalyzer/MediaAnalyzerIntegrationTest.kt +++ b/src/test/kotlin/se/svt/oss/mediaanalyzer/MediaAnalyzerIntegrationTest.kt @@ -125,7 +125,6 @@ class MediaAnalyzerIntegrationTest { file, ffprobeInputParams = linkedMapOf( "f" to "s16le", - "ac" to "1", "ar" to "22050", ) ) From bf3ef2cf6bd072bd8e4b590578b062f19bbf67c5 Mon Sep 17 00:00:00 2001 From: Finn Hermansson Date: Thu, 5 Sep 2024 12:07:15 +0200 Subject: [PATCH 2/2] added test Signed-off-by: Finn Hermansson --- .../kotlin/se/svt/oss/mediaanalyzer/MediaAnalyzerTest.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/test/kotlin/se/svt/oss/mediaanalyzer/MediaAnalyzerTest.kt b/src/test/kotlin/se/svt/oss/mediaanalyzer/MediaAnalyzerTest.kt index 3bc850b..1e327e0 100644 --- a/src/test/kotlin/se/svt/oss/mediaanalyzer/MediaAnalyzerTest.kt +++ b/src/test/kotlin/se/svt/oss/mediaanalyzer/MediaAnalyzerTest.kt @@ -106,6 +106,15 @@ internal class MediaAnalyzerTest { ) } + @Test + fun testMediaInfoSource() { + mockMediaInfo("/mediainfo-hls.json") + val videoTrack = MediaInfoAnalyzer().analyze(file, true).videoTracks.firstOrNull() + assertThat(videoTrack?.extra?.get("Source") as? String) + .describedAs("extra.Source") + .isEqualTo("hls-video1/hls-video1.m3u8") + } + @Test fun testMediaInfoNoAudio() { mockMediaInfo("/mediainfo-audio-corrupt.json")