Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added property "extra" to media info tracks. #13

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading