Skip to content

Add disposition-aware audio track matching for audio description flavors#13931

Open
LongingForHome wants to merge 2 commits into
kaltura:Venus-22.17.0from
LongingForHome:feature/audio-disposition-matching
Open

Add disposition-aware audio track matching for audio description flavors#13931
LongingForHome wants to merge 2 commits into
kaltura:Venus-22.17.0from
LongingForHome:feature/audio-disposition-matching

Conversation

@LongingForHome

Copy link
Copy Markdown

Summary

  • KFFMpegMediaParser — parses FFprobe disposition flags (e.g. visual_impaired, default) from each audio stream into a new audioDisposition array property on the per-stream KalturaMediaInfo object stored in contentStreams
  • KDLAudioMultiStreaming — adds a $disposition property to KDLStreamDescriptor and a new selectStreamByDisposition() method that disambiguates same-language audio tracks by disposition when multiple tracks share the same language code; GetSettings() now accepts flavor tags and automatically injects the required disposition for flavors tagged audio_description
  • KDLFlavor — threads $this->_tags through evaluateTargetAudioMultiStream() and GetSettings() so flavor tags are available at stream selection time

Problem

When a source file contains multiple audio tracks with the same language (e.g. a standard eng track and an audio description eng track with visual_impaired disposition), the KDL previously always selected the first matching stream regardless of disposition. This caused:

  • Audio description flavors (tagged audio_description) to transcode the wrong track
  • Standard flavors to potentially pick up an audio description track

Behavior after this change

Scenario Result
Standard English flavor + eng/default source track Selects eng/default
Audio Description flavor (audio_description tag) + eng/visual_impaired source track Selects eng/visual_impaired
Audio Description flavor, language has no AD source track Flavor skipped (returns null) rather than using wrong track ✅
Single-track source, any flavor Existing behaviour preserved ✅
French / Spanish / other language flavors Unaffected ✅

Test plan

A standalone PHP test script is included that exercises all scenarios against the real sample file stream layout (eng/default, eng/visual_impaired, fra, spa) without requiring a full Kaltura platform:

php tests/test_audio_disposition_matching.php

All 13 assertions pass.

Notes

  • No schema changes required — disposition matching is driven entirely by the existing tags field on flavorParams (presence of audio_description tag)
  • Backward compatible — single-stream sources and sources without disposition tags follow the existing code path unchanged
  • The disposition property on KDLStreamDescriptor can also be set directly via the new-format multiStream JSON ({"audio":{"streams":[{"lang":"eng","disposition":["visual_impaired"]}]}}) for future use cases

🤖 Generated with Claude Code

LongingForHome and others added 2 commits April 9, 2026 07:55
Parses FFprobe disposition flags from mediaInfo output and uses them
to disambiguate same-language audio tracks during flavor matching.

- KFFMpegMediaParser: captures active disposition flags (e.g.
  visual_impaired, default) from FFprobe stream data into
  audioDisposition on each contentStreams audio entry

- KDLAudioMultiStreaming: adds $disposition property to
  KDLStreamDescriptor; new selectStreamByDisposition() selects the
  correct stream when multiple tracks share the same language —
  audio_description flavors (tagged 'audio_description') target
  visual_impaired/visual_impaired_audio streams; standard flavors
  skip those tracks and prefer the default stream

- KDLFlavor: threads $this->_tags through evaluateTargetAudioMultiStream()
  and GetSettings() so flavor tags are available at stream selection time

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
selectStreamByDisposition() was short-circuiting on single-stream
language groups before checking the requested disposition, allowing
an AD flavor to match a non-AD track when it was the only stream for
that language. Disposition check now always runs when $this->disposition
is set, regardless of stream count.

Also adds tests/test_audio_disposition_matching.php — a standalone PHP
test covering all 6 matching scenarios against the real sample file
stream layout (eng/default, eng/visual_impaired, fra, spa).

Run: php tests/test_audio_disposition_matching.php

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant