stride3d/stride · error · Exception

No track found in

Error message

No {MediaType} track found in: {inputFile.AbsolutePath}

What it means

After extracting track indices, Initialize requires a track matching the configured MediaType (Video or Audio). If FindTrack returns -1 for the requested type, it throws 'No <type> track found in: <path>'.

Solutions

  1. Pass the MediaType that actually matches the file's content (use Audio for audio files).
  2. Check HasAudioTrack after Initialize when the audio track is optional instead of failing.
  3. Probe the file's tracks (e.g. MediaMetadataRetriever or ffprobe offline) to confirm a compatible track exists.
  4. Re-encode the media into a widely supported container/codec (MP4 with H.264/AAC).

Example fix

// before
extractor.Initialize("music.mp3", MediaType.Video); // throws
// after
extractor.Initialize("music.mp3", MediaType.Audio);
Defensive patterns

Strategy: validation

Validate before calling

// pick MediaType based on extension/content before init
var mediaType = Path.GetExtension(url) is ".mp3" or ".m4a" or ".ogg" or ".wav"
    ? MediaType.Audio : MediaType.Video;
extractor.Initialize(url, mediaType);

Try / catch

try { extractor.Initialize(url, mediaType); }
catch (Exception ex) when (ex.Message.Contains("track found")) { /* treat file as incompatible / try other MediaType */ }

Prevention

When it happens

Trigger: Initializing with MediaType.Video on an audio-only file (e.g. MP3), MediaType.Audio on a silent video, or on a container the Android MediaExtractor cannot demux (unsupported codec/container).

Common situations: Wrong MediaType passed for the asset; videos without an audio stream where code assumed audio exists; exotic containers (MKV with unsupported codecs) on a given Android device.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/dd91c7cb5866c849. Report an issue: GitHub.

Appendix: source

Thrown at sources/engine/Stride.Video/Android/MediaCodecExtractorBase.cs:121

            {
                inputFile = new Java.IO.File(url);
                if (!inputFile.CanRead())
                    throw new Exception(string.Format("Unable to read: {0} ", inputFile.AbsolutePath));

                inputFileDescriptor = new Java.IO.FileInputStream(inputFile);

                // ===================================================================================================
                // Initialize the audio media extractor
                mediaExtractor = new MediaExtractor();
                mediaExtractor.SetDataSource(inputFileDescriptor.FD, startPosition, length);

                var videoTrackIndex = FindTrack(mediaExtractor, MediaType.Video);
                var audioTrackIndex = FindTrack(mediaExtractor, MediaType.Audio);
                HasAudioTrack = audioTrackIndex >= 0;

                mediaTrackIndex = MediaType == MediaType.Audio ? audioTrackIndex : videoTrackIndex;
                if (mediaTrackIndex < 0)
                    throw new Exception(string.Format($"No {MediaType} track found in: {inputFile.AbsolutePath}"));

                mediaExtractor.SelectTrack(mediaTrackIndex);

                var trackFormat = mediaExtractor.GetTrackFormat(mediaTrackIndex);
                MediaDuration = TimeSpanExtensions.FromMicroSeconds(trackFormat.GetLong(MediaFormat.KeyDuration));

                ExtractMediaMetadata(trackFormat);

                // Create a MediaCodec mediadecoder, and configure it with the MediaFormat from the mediaExtractor
                // It's very important to use the format from the mediaExtractor because it contains a copy of the CSD-0/CSD-1 codec-specific data chunks.
                var mime = trackFormat.GetString(MediaFormat.KeyMime);
                MediaDecoder = MediaCodec.CreateDecoderByType(mime);
                MediaDecoder.Configure(trackFormat, decoderOutputSurface, null, 0);

                isInitialized = true;

                StartWorker();
            }

View on GitHub (pinned to 96fad776d2)