Skip to content

Commit

Permalink
Merge pull request #13 from svt/more-props
Browse files Browse the repository at this point in the history
Added property "extra" to media info tracks.
  • Loading branch information
mikaela-garde authored Sep 5, 2024
2 parents db2df5d + bf3ef2c commit 2ff495b
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
@JsonIgnoreProperties(ignoreUnknown = true)
data class AudioTrack(
override val format: String,
override val extra: Map<String, Any> = emptyMap(),
@JsonProperty("Duration")
val duration: Double,
@JsonProperty("BitRate")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Any> = emptyMap(),
@JsonProperty("FileSize")
val fileSize: Long,
@JsonProperty("Duration")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
@JsonIgnoreProperties(ignoreUnknown = true)
data class ImageTrack(
override val format: String,
override val extra: Map<String, Any> = emptyMap(),
@JsonProperty("Width")
val width: Int,
@JsonProperty("Height")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Any> = emptyMap()
) : Track
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Any> = emptyMap()
) : Track
2 changes: 2 additions & 0 deletions src/main/kotlin/se/svt/oss/mediaanalyzer/mediainfo/Track.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo
interface Track {
@get:JsonProperty("Format")
val format: String
@get:JsonProperty("extra")
val extra: Map<String, Any>
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
@JsonIgnoreProperties(ignoreUnknown = true)
data class VideoTrack(
override val format: String,
override val extra: Map<String, Any> = emptyMap(),
@JsonProperty("Duration")
val duration: Double,
@JsonProperty("BitRate")
Expand All @@ -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")
Expand Down Expand Up @@ -73,9 +78,7 @@ data class VideoTrack(
@JsonProperty("MasteringDisplay_Luminance")
val masteringDisplayLuminance: String?,
@JsonProperty("MasteringDisplay_Luminance_Source")
val masteringDisplayLuminanceSource: String?,
val extra: Map<String, String> = emptyMap()

val masteringDisplayLuminanceSource: String?
) : Track {
val isInterlaced: Boolean?
get() = scanType?.let { it != "Progressive" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ class MediaAnalyzerIntegrationTest {
file,
ffprobeInputParams = linkedMapOf(
"f" to "s16le",
"ac" to "1",
"ar" to "22050",
)
)
Expand Down
9 changes: 9 additions & 0 deletions src/test/kotlin/se/svt/oss/mediaanalyzer/MediaAnalyzerTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 2ff495b

Please sign in to comment.