{"record":{"id":"dd91c7cb5866c849","repo":"stride3d/stride","slug":"no-mediatype-track-found-in-inputfile-absolutepath","errorCode":null,"errorMessage":"No {MediaType} track found in: {inputFile.AbsolutePath}","messagePattern":"No (.+?) track found in: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Video/Android/MediaCodecExtractorBase.cs","lineNumber":121,"sourceCode":"            {\n                inputFile = new Java.IO.File(url);\n                if (!inputFile.CanRead())\n                    throw new Exception(string.Format(\"Unable to read: {0} \", inputFile.AbsolutePath));\n\n                inputFileDescriptor = new Java.IO.FileInputStream(inputFile);\n\n                // ===================================================================================================\n                // Initialize the audio media extractor\n                mediaExtractor = new MediaExtractor();\n                mediaExtractor.SetDataSource(inputFileDescriptor.FD, startPosition, length);\n\n                var videoTrackIndex = FindTrack(mediaExtractor, MediaType.Video);\n                var audioTrackIndex = FindTrack(mediaExtractor, MediaType.Audio);\n                HasAudioTrack = audioTrackIndex >= 0;\n\n                mediaTrackIndex = MediaType == MediaType.Audio ? audioTrackIndex : videoTrackIndex;\n                if (mediaTrackIndex < 0)\n                    throw new Exception(string.Format($\"No {MediaType} track found in: {inputFile.AbsolutePath}\"));\n\n                mediaExtractor.SelectTrack(mediaTrackIndex);\n\n                var trackFormat = mediaExtractor.GetTrackFormat(mediaTrackIndex);\n                MediaDuration = TimeSpanExtensions.FromMicroSeconds(trackFormat.GetLong(MediaFormat.KeyDuration));\n\n                ExtractMediaMetadata(trackFormat);\n\n                // Create a MediaCodec mediadecoder, and configure it with the MediaFormat from the mediaExtractor\n                // 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.\n                var mime = trackFormat.GetString(MediaFormat.KeyMime);\n                MediaDecoder = MediaCodec.CreateDecoderByType(mime);\n                MediaDecoder.Configure(trackFormat, decoderOutputSurface, null, 0);\n\n                isInitialized = true;\n\n                StartWorker();\n            }","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Video/Android/MediaCodecExtractorBase.cs#L103-L139","documentation":"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>'.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Pass the MediaType that actually matches the file's content (use Audio for audio files).","Check HasAudioTrack after Initialize when the audio track is optional instead of failing.","Probe the file's tracks (e.g. MediaMetadataRetriever or ffprobe offline) to confirm a compatible track exists.","Re-encode the media into a widely supported container/codec (MP4 with H.264/AAC)."],"exampleFix":"// before\nextractor.Initialize(\"music.mp3\", MediaType.Video); // throws\n// after\nextractor.Initialize(\"music.mp3\", MediaType.Audio);","handlingStrategy":"validation","validationCode":"// pick MediaType based on extension/content before init\nvar mediaType = Path.GetExtension(url) is \".mp3\" or \".m4a\" or \".ogg\" or \".wav\"\n    ? MediaType.Audio : MediaType.Video;\nextractor.Initialize(url, mediaType);","typeGuard":null,"tryCatchPattern":"try { extractor.Initialize(url, mediaType); }\ncatch (Exception ex) when (ex.Message.Contains(\"track found\")) { /* treat file as incompatible / try other MediaType */ }","preventionTips":["Match MediaType to the file's actual content","Handle audio-less videos by checking HasAudioTrack after init","Re-encode assets to MP4/H.264/AAC for maximum Android compatibility"],"tags":["android","video","media","track-not-found"],"backgroundTag":"resource-not-found","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}